调整平昌的党组织选择
This commit is contained in:
		| @@ -15,12 +15,12 @@ import $reg from "./regular" | |||||||
|  */ |  */ | ||||||
| const addChild = (parent, pending, config) => { | const addChild = (parent, pending, config) => { | ||||||
|   let conf = { |   let conf = { | ||||||
|       key: 'id', |         key: 'id', | ||||||
|       parent: 'parentId', |         parent: 'parentId', | ||||||
|       children: 'children', |         children: 'children', | ||||||
|       ...config |         ...config | ||||||
|     }, |       }, | ||||||
|     doBeforeCount = pending.length |       doBeforeCount = pending.length | ||||||
|   for (let i = pending.length - 1; i >= 0; i--) { |   for (let i = pending.length - 1; i >= 0; i--) { | ||||||
|     let e = pending[i] |     let e = pending[i] | ||||||
|     if (e[conf.parent] == parent[conf.key]) { |     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)) |     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 |     return ('' + e).length - index | ||||||
|   }) |   }) | ||||||
|   let maxDecimal = Math.max(...decimalLengthes), |   let maxDecimal = Math.max(...decimalLengthes), | ||||||
|     precision = Math.pow(10, maxDecimal) |       precision = Math.pow(10, maxDecimal) | ||||||
|   // 计算 |   // 计算 | ||||||
|   let intArr = arr.map(e => (Number(e) || 0) * precision) |   let intArr = arr.map(e => (Number(e) || 0) * precision) | ||||||
|   // 返回计算值 |   // 返回计算值 | ||||||
| @@ -115,10 +86,10 @@ const $colorUtils = { | |||||||
|       if (color.length == 4) { |       if (color.length == 4) { | ||||||
|         // 检测诸如#FFF简写格式 |         // 检测诸如#FFF简写格式 | ||||||
|         color = |         color = | ||||||
|           '#' + |             '#' + | ||||||
|           color.charAt(1).repeat(2) + |             color.charAt(1).repeat(2) + | ||||||
|           color.charAt(2).repeat(2) + |             color.charAt(2).repeat(2) + | ||||||
|           color.charAt(3).repeat(2) |             color.charAt(3).repeat(2) | ||||||
|       } |       } | ||||||
|       hex = parseInt(color.slice(1), 16) |       hex = parseInt(color.slice(1), 16) | ||||||
|     } |     } | ||||||
| @@ -199,8 +170,8 @@ export default { | |||||||
|   }, |   }, | ||||||
|   $dateFormat: (time, format) => { |   $dateFormat: (time, format) => { | ||||||
|     return $moment(time) |     return $moment(time) | ||||||
|       .format(format || 'YYYY-MM-DD') |         .format(format || 'YYYY-MM-DD') | ||||||
|       .replace('Invalid Date', '') |         .replace('Invalid Date', '') | ||||||
|   }, |   }, | ||||||
|   $copy, |   $copy, | ||||||
|   $download: (url, name) => { |   $download: (url, name) => { | ||||||
| @@ -216,7 +187,34 @@ export default { | |||||||
|   }, |   }, | ||||||
|   $debounce, |   $debounce, | ||||||
|   $checkJson, |   $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, |   $load, | ||||||
|   $reg, |   $reg, | ||||||
|   Area, |   Area, | ||||||
|   | |||||||
| @@ -113,7 +113,6 @@ export default { | |||||||
|       selected: [], |       selected: [], | ||||||
|       selectedTemp: [], |       selectedTemp: [], | ||||||
|       selectParty: [], |       selectParty: [], | ||||||
|       valueType: "", |  | ||||||
|       defaultChecked: [], |       defaultChecked: [], | ||||||
|       defaultExpanded: [], |       defaultExpanded: [], | ||||||
|       childCount: 0 |       childCount: 0 | ||||||
| @@ -164,18 +163,12 @@ export default { | |||||||
|           if (this.type === '2') { |           if (this.type === '2') { | ||||||
|             this.treeData = res.data |             this.treeData = res.data | ||||||
|           } else { |           } else { | ||||||
|             res.data = res.data.map(a => { |             this.selected = res.data.filter(e => [this.value].flat().includes(e.id)) | ||||||
|               return {...a, name: a.name} |             if (this.selected) { | ||||||
|             }); |               this.$emit('name', this.selected.map(e => e.name)) | ||||||
|             if (this.valueType) { |               this.$emit('origin', this.selected) | ||||||
|               this.selected = res.data.filter(e => (this.valueType == "string" && e.id == this.value) || this.value?.includes(e.id)) |  | ||||||
|               if (this.selected) { |  | ||||||
|                 this.$emit('name', this.selected.map(e => e.name)) |  | ||||||
|                 this.$emit('origin', this.selected) |  | ||||||
|               } |  | ||||||
|             } |             } | ||||||
|             this.treeData = res.data.filter(e => !e.parentId || e.id === this.topOrgId); |             this.treeData = this.$arr2tree(res.data, {root: this.topOrgId}) | ||||||
|             this.treeData.map(t => this.addChild(t, res.data)); |  | ||||||
|           } |           } | ||||||
|         } else { |         } else { | ||||||
|           this.treeData = [res.data] |           this.treeData = [res.data] | ||||||
| @@ -187,14 +180,13 @@ export default { | |||||||
|       if (!this.selectedTemp.length && !this.isEmpty) { |       if (!this.selectedTemp.length && !this.isEmpty) { | ||||||
|         return this.$message.error(this.type === '0' ? '党组织不能为空' : '小区不能为空') |         return this.$message.error(this.type === '0' ? '党组织不能为空' : '小区不能为空') | ||||||
|       } |       } | ||||||
|  |  | ||||||
|       this.selected = this.selectedTemp; |       this.selected = this.selectedTemp; | ||||||
|       this.selectParty.length && (this.selected = JSON.parse(JSON.stringify(this.selectParty))) |       this.selectParty.length && (this.selected = JSON.parse(JSON.stringify(this.selectParty))) | ||||||
|       if (this.type === '1' && this.selected[0].isVan === '0') { |       if (this.type === '1' && this.selected[0].isVan === '0') { | ||||||
|         return this.$message.error('请选择小区') |         return this.$message.error('请选择小区') | ||||||
|       } |       } | ||||||
|       this.dialog = false |       this.dialog = false | ||||||
|       this.$emit('change', this.valueType == "string" ? this.selected.map(e => e.id)[0] : this.selected.map(e => e.id)) |       this.$emit('change', typeof this.value == "string" ? this.selected.map(e => e.id)[0] : this.selected.map(e => e.id)) | ||||||
|       this.$emit('name', this.selected.map(e => e.name)) |       this.$emit('name', this.selected.map(e => e.name)) | ||||||
|       this.$emit('origin', this.selected) |       this.$emit('origin', this.selected) | ||||||
|     }, |     }, | ||||||
| @@ -205,11 +197,8 @@ export default { | |||||||
|       } |       } | ||||||
|     } |     } | ||||||
|   }, |   }, | ||||||
|   mounted() { |   created() { | ||||||
|     this.$nextTick(() => { |     this.searchSysAll(); | ||||||
|       this.valueType = typeof this.value |  | ||||||
|       this.searchSysAll(); |  | ||||||
|     }) |  | ||||||
|   } |   } | ||||||
| } | } | ||||||
| </script> | </script> | ||||||
| @@ -220,46 +209,46 @@ export default { | |||||||
|   overflow-y: hidden; |   overflow-y: hidden; | ||||||
| } | } | ||||||
|  |  | ||||||
| :deep(.el-dialog__header ){ | :deep(.el-dialog__header ) { | ||||||
|   line-height: 1; |   line-height: 1; | ||||||
|   // padding: 13px 16px; |   // padding: 13px 16px; | ||||||
|   // border-bottom: 1px solid #eee; |   // border-bottom: 1px solid #eee; | ||||||
| } | } | ||||||
|  |  | ||||||
| :deep( .el-tree--highlight-current .el-tree-node.is-current > .el-tree-node__content ){ | :deep( .el-tree--highlight-current .el-tree-node.is-current > .el-tree-node__content ) { | ||||||
|   background: #eaf5ff !important; |   background: #eaf5ff !important; | ||||||
|   color: #257fff !important; |   color: #257fff !important; | ||||||
| } | } | ||||||
|  |  | ||||||
| :deep(.el-dialog__body ){ | :deep(.el-dialog__body ) { | ||||||
|   padding: 16px 16px 0; |   padding: 16px 16px 0; | ||||||
| } | } | ||||||
|  |  | ||||||
| :deep( .ai-dialog__content--wrapper ){ | :deep( .ai-dialog__content--wrapper ) { | ||||||
|   padding-right: 0 !important; |   padding-right: 0 !important; | ||||||
| } | } | ||||||
|  |  | ||||||
| :deep(.left_cont ){ | :deep(.left_cont ) { | ||||||
|   height: calc(100% - 40px); |   height: calc(100% - 40px); | ||||||
|   padding-top: 8px; |   padding-top: 8px; | ||||||
|   box-sizing: border-box; |   box-sizing: border-box; | ||||||
|   overflow: auto; |   overflow: auto; | ||||||
| } | } | ||||||
|  |  | ||||||
| :deep(.el-tree ){ | :deep(.el-tree ) { | ||||||
|   background: #fcfcfc; |   background: #fcfcfc; | ||||||
| } | } | ||||||
|  |  | ||||||
| :deep( .el-dialog__body ){ | :deep( .el-dialog__body ) { | ||||||
|   background: #fcfcfc; |   background: #fcfcfc; | ||||||
| } | } | ||||||
|  |  | ||||||
| :deep(.el-tree-node:focus > .el-tree-node__content ){ | :deep(.el-tree-node:focus > .el-tree-node__content ) { | ||||||
|   background: #eaf5ff !important; |   background: #eaf5ff !important; | ||||||
|   color: #257fff !important; |   color: #257fff !important; | ||||||
| } | } | ||||||
|  |  | ||||||
| :deep(.el-tree-node__content:hover ){ | :deep(.el-tree-node__content:hover ) { | ||||||
|   background: #eaf5ff !important; |   background: #eaf5ff !important; | ||||||
|   color: #257fff !important; |   color: #257fff !important; | ||||||
| } | } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user