Commit cd81a8f2 authored by renjintao's avatar renjintao

getArry

parent cfdf172e
......@@ -43,12 +43,12 @@ henq.isArray = u => {
return Object.prototype.toString.call(u) == '[object Array]';
}
henq.toIntArray = u => {
if(henq.isNull(u)){
if (henq.isNull(u)) {
return [];
}
var arrs=u.split(',')
var result=[];
arrs.map(p=>{
var arrs = u.split(',')
var result = [];
arrs.map(p => {
result.push(parseInt(p));
})
return result;
......@@ -96,7 +96,7 @@ henq.getDate = (strDate) => {
}).match(/\d+/g) + ')');
return date;
}
henq.group=(array, f)=> {
henq.group = (array, f) => {
const groups = {};
array.forEach(function (o) {
const group = JSON.stringify(f(o));
......@@ -122,7 +122,7 @@ henq.toTree = (list, rootId, format, parentFiledName) => {
if (format) {
format(u)
}
u.children = toTree(data, u.id, level)
u.children = toTree(data, u.id, level)
})
}
return parents;
......@@ -130,19 +130,20 @@ henq.toTree = (list, rootId, format, parentFiledName) => {
return toTree(list, rootId, i)
}
henq.treeToList = (tree) => {
let list=[];
let list = [];
function treeToList(data) {
data.map(u=>{
if(u.children){
treeToList(u.children,u)
data.map(u => {
if (u.children) {
treeToList(u.children, u)
}
let copy=henq.clone(u);
let copy = henq.clone(u);
delete copy.delete;
copy.parent=u;
copy.parent = u;
list.push(copy);
})
}
treeToList(tree,null)
treeToList(tree, null)
return list;
}
//导出pdf
......@@ -169,4 +170,15 @@ henq.outPdf = (ele, fileName) => {
window.open("/static/pdf.html", '_blank');
}, 1000)
}
export default henq;
\ No newline at end of file
henq.getArry = (arryList) => {//得到数据字典对应的label和value,用于table排序
let arry = [];
arryList.forEach(data => {
var that = this;
let arryObj = {};
arryObj["label"] = data.name;
arryObj["value"] = data.code;
arry.push(arryObj);
});
return arry;
}
export default henq;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment