From f568f2056a994f24b202110145489c7f08a792c4 Mon Sep 17 00:00:00 2001 From: lb Date: Mon, 6 Feb 2023 14:24:12 +0800 Subject: [PATCH] =?UTF-8?q?update=20=E7=89=A9=E6=96=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/DialogWithMenu.vue | 66 +++++++-- .../pms/material/components/BaseListTable.vue | 138 ++++++++++++++++++ .../material/components/ListViewWithHead.vue | 68 +++++---- src/views/modules/pms/material/config.js | 77 +++++----- 4 files changed, 267 insertions(+), 82 deletions(-) create mode 100644 src/views/modules/pms/material/components/BaseListTable.vue diff --git a/src/components/DialogWithMenu.vue b/src/components/DialogWithMenu.vue index 3db8de0..f4031ab 100644 --- a/src/components/DialogWithMenu.vue +++ b/src/components/DialogWithMenu.vue @@ -46,8 +46,8 @@ 'el-icon-s-data': tab.key === 'attr', 'el-icon-folder-opened': tab.key === 'attachment', }" - > {{ tab.name }} + > + {{ tab.name }}
@@ -56,12 +56,12 @@ - + @@ -73,9 +73,15 @@ :active-value="1" :inactive-value="0" @change="handleSwitchChange" - :disabled="detailMode" + :disabled="disableCondition(col.prop)" + /> + - @@ -134,22 +140,33 @@ export default { inject: ["urls"], data() { const dataForm = {}; - + const autoDisabledList = []; this.configs.form.rows.forEach((row) => { row.forEach((col) => { if (col.upload) dataForm[col.prop] = col.default ?? []; else dataForm[col.prop] = col.default ?? null; + if (col.autoDisabled) autoDisabledList.push(col.prop); + if (col.fetchData) col.fetchData().then(({ data: res }) => { console.log("[Fetch Data]", res.data.list); if (res.code === 0 && res.data.list) { - this.$set( - col, - "options", - res.data.list.map((i) => ({ label: i.name, value: i.id })) - ); + if (!col.options || !col.options.length) + this.$set( + col, + "options", + res.data.list.map((i) => ({ label: i.name, value: i.id })) + ); // col.options = res.data.list; + else if (col.options.length) { + res.data.list.unshift(...col.options); + this.$set( + col, + "options", + res.data.list.map((i) => ({ label: i.name, value: i.id })) + ); + } } else { col.options.splice(0); } @@ -184,11 +201,12 @@ export default { activeMenu: this.configs.menu[0].name, dataForm, detailMode: false, - + autoDisabledList, showBaseDialog: false, baseDialogConfig: null, subList: [], showSubDialog: false, + disableXXX: false, }; }, computed: { @@ -204,7 +222,29 @@ export default { return this.detailMode ? this.configs.table.props.filter((v) => v.prop !== "operations") : this.configs.table.props; }, }, + watch: { + // "dataForm.parentId": function (val, old) { + // if (val && val !== "0") { + // // 如果不是 '无' 选项,就锁定 typeDictValue(物料类别),和 typeId(物料类型) + // this.$http.get(`/pms/material/${val}`).then(({ data: res }) => { + // if (res.code === 0) { + // const { typeDictValue, typeId } = res.data; + // this.dataForm.typeDictValue = typeDictValue; + // this.dataForm.typeId = typeId; + // this.disableXXX = true; + // } + // }); + // } else { + // this.dataForm.typeDictValue = null; + // this.dataForm.typeId = null; + // this.disableXXX = false; + // } + // }, + }, methods: { + disableCondition(prop) { + return this.detailMode || (this.disableXXX && this.autoDisabledList.indexOf(prop) !== -1); + }, /** utitilities */ showButton(operate) { const notDetailMode = !this.detailMode; diff --git a/src/views/modules/pms/material/components/BaseListTable.vue b/src/views/modules/pms/material/components/BaseListTable.vue new file mode 100644 index 0000000..b9238df --- /dev/null +++ b/src/views/modules/pms/material/components/BaseListTable.vue @@ -0,0 +1,138 @@ + + + + + + diff --git a/src/views/modules/pms/material/components/ListViewWithHead.vue b/src/views/modules/pms/material/components/ListViewWithHead.vue index 427480a..c8b2250 100644 --- a/src/views/modules/pms/material/components/ListViewWithHead.vue +++ b/src/views/modules/pms/material/components/ListViewWithHead.vue @@ -15,6 +15,7 @@ :column-config="tableConfig.column" :table-data="dataList" @operate-event="handleOperate" + @load-sub="handleLoadSub" />