调整平昌的党组织选择
This commit is contained in:
		| @@ -15,12 +15,12 @@ import $reg from "./regular" | ||||
|  */ | ||||
| const addChild = (parent, pending, config) => { | ||||
|   let conf = { | ||||
|       key: 'id', | ||||
|       parent: 'parentId', | ||||
|       children: 'children', | ||||
|       ...config | ||||
|     }, | ||||
|     doBeforeCount = pending.length | ||||
|         key: 'id', | ||||
|         parent: 'parentId', | ||||
|         children: 'children', | ||||
|         ...config | ||||
|       }, | ||||
|       doBeforeCount = pending.length | ||||
|   for (let i = pending.length - 1; i >= 0; i--) { | ||||
|     let e = pending[i] | ||||
|     if (e[conf.parent] == parent[conf.key]) { | ||||
| @@ -34,35 +34,6 @@ const addChild = (parent, pending, config) => { | ||||
|     parent[conf.children].map(c => addChild(c, pending, conf)) | ||||
|   } | ||||
| } | ||||
| /** | ||||
|  * 数组转tree | ||||
|  * @param list 待转化的数组 | ||||
|  * @param config 配置 | ||||
|  */ | ||||
| const $arr2tree = (list, config = {}) => { | ||||
|   const {key = 'id', parent = 'parentId', children = 'children'} = config, result = [], itemMap = {}, | ||||
|     ids = list?.map(e => `#${e[key]}#`)?.toString() | ||||
|   for (const e of list) { | ||||
|     const id = e[key], pid = e[parent] | ||||
|     itemMap[id] = {...e, [children]: [itemMap[id]?.[children]].flat().filter(Boolean)} | ||||
|     const treeItem = itemMap[id] | ||||
|     if (!!pid && ids.indexOf(`#${pid}#`) > -1) { | ||||
|       if (!itemMap[pid]) { | ||||
|         itemMap[pid] = { | ||||
|           children: [] | ||||
|         } | ||||
|       } | ||||
|       itemMap[pid].children.push(treeItem) | ||||
|     } else result.push(treeItem) | ||||
|   } | ||||
|   const removeNullChildren = node => { | ||||
|     if (node[children] && node[children].length > 0) { | ||||
|       node[children].map(c => removeNullChildren(c)) | ||||
|     } else delete node[children] | ||||
|   } | ||||
|   result.forEach(removeNullChildren) | ||||
|   return result | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * 封装提示框 | ||||
| @@ -87,7 +58,7 @@ const $decimalCalc = (...arr) => { | ||||
|     return ('' + e).length - index | ||||
|   }) | ||||
|   let maxDecimal = Math.max(...decimalLengthes), | ||||
|     precision = Math.pow(10, maxDecimal) | ||||
|       precision = Math.pow(10, maxDecimal) | ||||
|   // 计算 | ||||
|   let intArr = arr.map(e => (Number(e) || 0) * precision) | ||||
|   // 返回计算值 | ||||
| @@ -115,10 +86,10 @@ const $colorUtils = { | ||||
|       if (color.length == 4) { | ||||
|         // 检测诸如#FFF简写格式 | ||||
|         color = | ||||
|           '#' + | ||||
|           color.charAt(1).repeat(2) + | ||||
|           color.charAt(2).repeat(2) + | ||||
|           color.charAt(3).repeat(2) | ||||
|             '#' + | ||||
|             color.charAt(1).repeat(2) + | ||||
|             color.charAt(2).repeat(2) + | ||||
|             color.charAt(3).repeat(2) | ||||
|       } | ||||
|       hex = parseInt(color.slice(1), 16) | ||||
|     } | ||||
| @@ -199,8 +170,8 @@ export default { | ||||
|   }, | ||||
|   $dateFormat: (time, format) => { | ||||
|     return $moment(time) | ||||
|       .format(format || 'YYYY-MM-DD') | ||||
|       .replace('Invalid Date', '') | ||||
|         .format(format || 'YYYY-MM-DD') | ||||
|         .replace('Invalid Date', '') | ||||
|   }, | ||||
|   $copy, | ||||
|   $download: (url, name) => { | ||||
| @@ -216,7 +187,34 @@ export default { | ||||
|   }, | ||||
|   $debounce, | ||||
|   $checkJson, | ||||
|   $arr2tree, | ||||
|   $arr2tree: (list, config = {}) => { | ||||
|     let result = [] | ||||
|     const {key = 'id', parent = 'parentId', children = 'children'} = config, itemMap = {}, | ||||
|         ids = list?.map(e => `#${e[key]}#`)?.toString() | ||||
|     for (const e of list) { | ||||
|       const id = e[key], pid = e[parent] | ||||
|       itemMap[id] = {...e, [children]: [itemMap[id]?.[children]].flat().filter(Boolean)} | ||||
|       const treeItem = itemMap[id] | ||||
|       if (!!pid && ids.indexOf(`#${pid}#`) > -1) { | ||||
|         if (!itemMap[pid]) { | ||||
|           itemMap[pid] = { | ||||
|             children: [] | ||||
|           } | ||||
|         } | ||||
|         itemMap[pid].children.push(treeItem) | ||||
|       } else result.push(treeItem) | ||||
|     } | ||||
|     const removeNullChildren = node => { | ||||
|       if (node[children] && node[children].length > 0) { | ||||
|         node[children].map(c => removeNullChildren(c)) | ||||
|       } else delete node[children] | ||||
|     } | ||||
|     if (!!config.root) { | ||||
|       result = itemMap[config.root] | ||||
|     } | ||||
|     result.forEach(removeNullChildren) | ||||
|     return result | ||||
|   }, | ||||
|   $load, | ||||
|   $reg, | ||||
|   Area, | ||||
|   | ||||
		Reference in New Issue
	
	Block a user