调整平昌的党组织选择
This commit is contained in:
@@ -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
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 封装提示框
|
* 封装提示框
|
||||||
@@ -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.valueType) {
|
|
||||||
this.selected = res.data.filter(e => (this.valueType == "string" && e.id == this.value) || this.value?.includes(e.id))
|
|
||||||
if (this.selected) {
|
if (this.selected) {
|
||||||
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)
|
||||||
}
|
}
|
||||||
}
|
this.treeData = this.$arr2tree(res.data, {root: this.topOrgId})
|
||||||
this.treeData = res.data.filter(e => !e.parentId || e.id === 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.valueType = typeof this.value
|
|
||||||
this.searchSysAll();
|
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