From 3c7954b8ec2fd060944724c976861e4f402328c3 Mon Sep 17 00:00:00 2001 From: smallchill Date: Thu, 23 Apr 2020 20:54:24 +0800 Subject: [PATCH] =?UTF-8?q?:zap:=20=E4=BC=98=E5=8C=96=E5=AD=97=E5=85=B8?= =?UTF-8?q?=E6=A8=A1=E5=9D=97=EF=BC=8C=E5=A2=9E=E5=8A=A0=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E4=B8=8B=E7=BA=A7=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/const/system/dict.js | 3 +-- src/const/system/dictbiz.js | 3 +-- src/views/system/dict.vue | 45 ++++++++++++++++++++++++++++++++---- src/views/system/dictbiz.vue | 45 ++++++++++++++++++++++++++++++++---- 4 files changed, 82 insertions(+), 14 deletions(-) diff --git a/src/const/system/dict.js b/src/const/system/dict.js index 2b79988..0b7261e 100644 --- a/src/const/system/dict.js +++ b/src/const/system/dict.js @@ -99,7 +99,7 @@ export const optionChild = { index: true, selection: true, viewBtn: true, - menuWidth: 150, + menuWidth: 220, dialogWidth: 880, dialogClickModal: false, column: [ @@ -107,7 +107,6 @@ export const optionChild = { label: "字典编号", prop: "code", addDisabled: true, - editDisabled: true, search: true, span: 24, rules: [ diff --git a/src/const/system/dictbiz.js b/src/const/system/dictbiz.js index 2b79988..0b7261e 100644 --- a/src/const/system/dictbiz.js +++ b/src/const/system/dictbiz.js @@ -99,7 +99,7 @@ export const optionChild = { index: true, selection: true, viewBtn: true, - menuWidth: 150, + menuWidth: 220, dialogWidth: 880, dialogClickModal: false, column: [ @@ -107,7 +107,6 @@ export const optionChild = { label: "字典编号", prop: "code", addDisabled: true, - editDisabled: true, search: true, span: 24, rules: [ diff --git a/src/views/system/dict.vue b/src/views/system/dict.vue index dc49a30..e5cbfe3 100644 --- a/src/views/system/dict.vue +++ b/src/views/system/dict.vue @@ -63,6 +63,7 @@ v-model="formChild" :permission="permissionList" :before-open="beforeOpenChild" + :before-close="beforeCloseChild" @row-del="rowDelChild" @row-update="rowUpdateChild" @row-save="rowSaveChild" @@ -85,6 +86,16 @@ >删 除 + @@ -139,7 +150,7 @@ }; }, computed: { - ...mapGetters(["permission"]), + ...mapGetters(["userInfo", "permission"]), permissionList() { return { addBtn: this.vaildData(this.permission.dict_add, false), @@ -157,12 +168,24 @@ } }, mounted() { - getDictTree().then(res => { - const column = this.findObject(this.optionChild.column, "parentId"); - column.dicData = res.data.data; - }); + this.initData(); }, methods: { + initData() { + getDictTree().then(res => { + const column = this.findObject(this.optionChild.column, "parentId"); + column.dicData = res.data.data; + }); + }, + handleAdd(row) { + this.$refs.crudChild.value.parentId = row.id; + this.$refs.crudChild.option.column.filter(item => { + if (item.prop === "parentId") { + item.value = row.id; + } + }); + this.$refs.crudChild.rowAdd(); + }, rowSave(row, done, loading) { const form = { ...row, @@ -365,6 +388,9 @@ }); }, beforeOpenChild(done, type) { + if (["add", "edit"].includes(type)) { + this.initData(); + } if (["edit", "view"].includes(type)) { getDict(this.formChild.id).then(res => { this.formChild = res.data.data; @@ -372,6 +398,15 @@ } done(); }, + beforeCloseChild(done) { + this.$refs.crudChild.value.parentId = this.parentId; + this.$refs.crudChild.option.column.filter(item => { + if (item.prop === "parentId") { + item.value = this.parentId; + } + }); + done(); + }, currentChangeChild(currentPage) { this.pageChild.currentPage = currentPage; }, diff --git a/src/views/system/dictbiz.vue b/src/views/system/dictbiz.vue index 7ab8bff..6faca68 100644 --- a/src/views/system/dictbiz.vue +++ b/src/views/system/dictbiz.vue @@ -63,6 +63,7 @@ v-model="formChild" :permission="permissionList" :before-open="beforeOpenChild" + :before-close="beforeCloseChild" @row-del="rowDelChild" @row-update="rowUpdateChild" @row-save="rowSaveChild" @@ -85,6 +86,16 @@ >删 除 + @@ -139,7 +150,7 @@ }; }, computed: { - ...mapGetters(["permission"]), + ...mapGetters(["userInfo", "permission"]), permissionList() { return { addBtn: this.vaildData(this.permission.dictbiz_add, false), @@ -157,12 +168,24 @@ } }, mounted() { - getDictTree().then(res => { - const column = this.findObject(this.optionChild.column, "parentId"); - column.dicData = res.data.data; - }); + this.initData(); }, methods: { + initData() { + getDictTree().then(res => { + const column = this.findObject(this.optionChild.column, "parentId"); + column.dicData = res.data.data; + }); + }, + handleAdd(row) { + this.$refs.crudChild.value.parentId = row.id; + this.$refs.crudChild.option.column.filter(item => { + if (item.prop === "parentId") { + item.value = row.id; + } + }); + this.$refs.crudChild.rowAdd(); + }, rowSave(row, done, loading) { const form = { ...row, @@ -365,6 +388,9 @@ }); }, beforeOpenChild(done, type) { + if (["add", "edit"].includes(type)) { + this.initData(); + } if (["edit", "view"].includes(type)) { getDict(this.formChild.id).then(res => { this.formChild = res.data.data; @@ -372,6 +398,15 @@ } done(); }, + beforeCloseChild(done) { + this.$refs.crudChild.value.parentId = this.parentId; + this.$refs.crudChild.option.column.filter(item => { + if (item.prop === "parentId") { + item.value = this.parentId; + } + }); + done(); + }, currentChangeChild(currentPage) { this.pageChild.currentPage = currentPage; },