Browse Source

字典管理

master
xuhuajiao 2 years ago
parent
commit
e4acd5f6fd
  1. 123
      src/views/system/dict/index.vue

123
src/views/system/dict/index.vue

@ -35,14 +35,18 @@
controls-position="right"
/>
</el-form-item>
<el-form-item v-if="form.isTop === '0'" label="上级节点" prop="dicPid">
<treeselect
v-model="form.dicPid"
:load-options="loadDicts"
:options="dicts"
placeholder="选择上级节点"
/>
</el-form-item>
<el-row>
<el-form-item v-if="form.isTop === '0'" label="上级节点" prop="dicPid">
<treeselect
v-model="form.dicPid"
style="width: 584px;"
:load-options="loadDicts"
:options="dicts"
:normalizer="normalizer"
placeholder="选择上级节点"
/>
</el-form-item>
</el-row>
<el-form-item label="内容说明" prop="dicExplain">
<el-input v-model="form.dicExplain" type="textarea" :rows="4" style="width: 584px;" />
</el-form-item>
@ -53,7 +57,7 @@
</div>
</div>
</el-dialog>
<el-dialog title="删除字典内容" :visible.sync="deleteVisible" :before-close="handleClose">
<!-- <el-dialog title="删除字典内容" :visible.sync="deleteVisible" :before-close="handleClose">
<span class="dialog-right-top" />
<span class="dialog-left-bottom" />
<div class="setting-dialog">
@ -64,7 +68,7 @@
<el-button type="primary" @click.native="handleConfirm">确定</el-button>
</div>
</div>
</el-dialog>
</el-dialog> -->
<div class="container-wrap">
<span class="right-top-line" />
<span class="left-bottom-line" />
@ -75,7 +79,7 @@
ref="table"
v-loading="crud.loading"
lazy
:load="getDicts"
:load="getDictsDatas"
:data="crud.data"
:tree-props="{children: 'childMenus', hasChildren: 'hasChildren'}"
highlight-current-row
@ -174,6 +178,15 @@ export default {
[CRUD.HOOK.afterDelete]() {
this.needRefreshTree = true
},
//
[CRUD.HOOK.afterToCU](crud, form) {
if (form.dicPid !== null) {
form.isTop = '0'
} else if (form.id !== null) {
form.isTop = '1'
}
this.getDicts()
},
//
[CRUD.HOOK.beforeRefresh]() {
this.crud.query.id = this.dicPid
@ -184,7 +197,7 @@ export default {
this.$emit('treeRefresh', crud.data)
}
},
getDicts(tree, treeNode, resolve) {
getDictsDatas(tree, treeNode, resolve) {
const params = { pid: tree.id }
setTimeout(() => {
crudDict.getDicts(params).then(res => {
@ -192,13 +205,23 @@ export default {
})
}, 100)
},
//
getDicts() {
crudDict.getDicts().then(res => {
this.dicts = res.map(function(obj) {
if (!obj.childMenus) {
obj.childMenus = null
}
return obj
})
})
},
//
loadDicts({ action, parentNode, callback }) {
if (action === LOAD_CHILDREN_OPTIONS) {
crudDict.getDicts({ enabled: true, pid: parentNode.id }).then(res => {
parentNode.childMenus = res.content.map(function(obj) {
if (obj.hasChildren) {
obj.children = null
crudDict.getDicts().then(res => {
parentNode.children = res.map(function(obj) {
if (obj.children) {
obj.childMenus = null
}
return obj
})
@ -208,35 +231,45 @@ export default {
})
}
},
clickRowHandler(row) {
this.$refs.table.clearSelection()
this.$refs.table.toggleRowSelection(row)
},
selectionChangeHandler(val) {
if (val.length > 1) {
// val
const finalVal = val.pop()
//
this.$refs.table.clearSelection()
//
this.$refs.table.toggleRowSelection(finalVal)
this.crud.selectionChangeHandler([finalVal])
} else {
this.crud.selectionChangeHandler(val)
// clickRowHandler(row) {
// this.$refs.table.clearSelection()
// this.$refs.table.toggleRowSelection(row)
// },
// selectionChangeHandler(val) {
// if (val.length > 1) {
// // val
// const finalVal = val.pop()
// //
// this.$refs.table.clearSelection()
// //
// this.$refs.table.toggleRowSelection(finalVal)
// this.crud.selectionChangeHandler([finalVal])
// } else {
// this.crud.selectionChangeHandler(val)
// }
// },
// toDelete(data) {
// this.deleteData = data
// this.deleteVisible = true
// },
// handleConfirm() {
// this.deleteVisible = false
// this.crud.delAllLoading = true
// this.crud.doDelete(this.deleteData)
// },
// handleClose(done) {
// this.deleteData = {}
// done()
// },
normalizer(node) {
if (node.childMenus == null || node.childMenus === 'null') {
delete node.childMenus
}
return {
id: node.id,
label: node.dicName,
children: node.childMenus
}
},
toDelete(data) {
this.deleteData = data
this.deleteVisible = true
},
handleConfirm() {
this.deleteVisible = false
this.crud.delAllLoading = true
this.crud.doDelete(this.deleteData)
},
handleClose(done) {
this.deleteData = {}
done()
}
}
}

Loading…
Cancel
Save