+
@@ -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()
}
}
}