Commit cd81a8f2 authored by renjintao's avatar renjintao

getArry

parent cfdf172e
...@@ -43,12 +43,12 @@ henq.isArray = u => { ...@@ -43,12 +43,12 @@ henq.isArray = u => {
return Object.prototype.toString.call(u) == '[object Array]'; return Object.prototype.toString.call(u) == '[object Array]';
} }
henq.toIntArray = u => { henq.toIntArray = u => {
if(henq.isNull(u)){ if (henq.isNull(u)) {
return []; return [];
} }
var arrs=u.split(',') var arrs = u.split(',')
var result=[]; var result = [];
arrs.map(p=>{ arrs.map(p => {
result.push(parseInt(p)); result.push(parseInt(p));
}) })
return result; return result;
...@@ -96,7 +96,7 @@ henq.getDate = (strDate) => { ...@@ -96,7 +96,7 @@ henq.getDate = (strDate) => {
}).match(/\d+/g) + ')'); }).match(/\d+/g) + ')');
return date; return date;
} }
henq.group=(array, f)=> { henq.group = (array, f) => {
const groups = {}; const groups = {};
array.forEach(function (o) { array.forEach(function (o) {
const group = JSON.stringify(f(o)); const group = JSON.stringify(f(o));
...@@ -130,19 +130,20 @@ henq.toTree = (list, rootId, format, parentFiledName) => { ...@@ -130,19 +130,20 @@ henq.toTree = (list, rootId, format, parentFiledName) => {
return toTree(list, rootId, i) return toTree(list, rootId, i)
} }
henq.treeToList = (tree) => { henq.treeToList = (tree) => {
let list=[]; let list = [];
function treeToList(data) { function treeToList(data) {
data.map(u=>{ data.map(u => {
if(u.children){ if (u.children) {
treeToList(u.children,u) treeToList(u.children, u)
} }
let copy=henq.clone(u); let copy = henq.clone(u);
delete copy.delete; delete copy.delete;
copy.parent=u; copy.parent = u;
list.push(copy); list.push(copy);
}) })
} }
treeToList(tree,null) treeToList(tree, null)
return list; return list;
} }
//导出pdf //导出pdf
...@@ -169,4 +170,15 @@ henq.outPdf = (ele, fileName) => { ...@@ -169,4 +170,15 @@ henq.outPdf = (ele, fileName) => {
window.open("/static/pdf.html", '_blank'); window.open("/static/pdf.html", '_blank');
}, 1000) }, 1000)
} }
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; 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