From cd4366f7806de9ee2637c23a8dc89d3246537b09 Mon Sep 17 00:00:00 2001 From: lb Date: Thu, 23 Feb 2023 11:29:31 +0800 Subject: [PATCH] =?UTF-8?q?add=20=E7=83=A7=E5=88=B6=E5=B7=A5=E8=89=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/DialogWithMenu.vue | 47 ++++- src/views/modules/pms/blenderStep/config.js | 10 +- src/views/modules/pms/bom/config.js | 2 +- src/views/modules/pms/firingStep/config.js | 211 ++++++++++++++++++++ src/views/modules/pms/firingStep/index.vue | 51 +++++ 5 files changed, 308 insertions(+), 13 deletions(-) create mode 100644 src/views/modules/pms/firingStep/config.js create mode 100644 src/views/modules/pms/firingStep/index.vue diff --git a/src/components/DialogWithMenu.vue b/src/components/DialogWithMenu.vue index ebc9b1c..2d26966 100644 --- a/src/components/DialogWithMenu.vue +++ b/src/components/DialogWithMenu.vue @@ -253,14 +253,16 @@ export default { inject: ["urls"], data() { const dataForm = {}; - const autoDisabledList = []; + const autoDisabledQueue = []; + const watingToRefreshQueue = []; + 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.autoDisabled) autoDisabledQueue.push(col.prop); + if (!!col.refreshOptionsAfterConfirm) watingToRefreshQueue.push(col); if (col.fetchData) col.fetchData().then(({ data: res }) => { console.log("[Fetch Data]", "list" in res.data, res.data, res.data.list); @@ -275,7 +277,7 @@ export default { ); // col.options = res.data.list; else if (col.options.length) { - res.data.list.unshift(...col.options); + "list" in res.data ? res.data.list.unshift(...col.options) : res.data.unshift(...col.options); this.$set( col, "options", @@ -326,7 +328,8 @@ export default { activeMenu: this.configs.menu[0].name, dataForm, detailMode: false, - autoDisabledList, + autoDisabledQueue, + watingToRefreshQueue, showBaseDialog: false, baseDialogConfig: null, subList: [], @@ -387,7 +390,7 @@ export default { methods: { disableCondition(prop) { - return this.detailMode || (this.disableXXX && this.autoDisabledList.indexOf(prop) !== -1); + return this.detailMode || (this.disableXXX && this.autoDisabledQueue.indexOf(prop) !== -1); }, /** utitilities */ showButton(operate) { @@ -654,12 +657,12 @@ export default { } // 加载额外需要的 id - let extraIds = {} - if (this.configs.extraIds && typeof this.configs.extraIds === 'object') { + let extraIds = {}; + if (this.configs.extraIds && typeof this.configs.extraIds === "object") { // 如果配置里,有 extraIds 选项 Object.entries(this.configs.extraIds).forEach(([key, value]) => { - extraIds[key] = value - }) + extraIds[key] = value; + }); } // 实际发送请求 @@ -669,7 +672,7 @@ export default { data: { ...extraIds, ...this.dataForm, - } + }, }) .then(({ data: res }) => { console.log("[add&update] res is: ", res); @@ -677,6 +680,28 @@ export default { this.$message.success(payload.name === "add" ? "添加成功" : "更新成功"); this.$emit("refreshDataList"); this.loadingStatus = false; + + // 如果 watingToRefreshQueue 队列里有数据 + if (this.watingToRefreshQueue.length) { + // 刷新队列 + this.watingToRefreshQueue.forEach((opt) => { + console.log('[刷新数据, ', opt, ']') + if ("fetchData" in opt) { + opt.fetchData().then(({ data: res }) => { + if (res.code === 0) { + this.$set( + opt, + "options", + "list" in res.data + ? res.data.list.map((i) => ({ label: i.name, value: i.id })) + : res.data.map((i) => ({ label: i.name, value: i.id })) + ); + } + }); + } + }); + } + this.handleClose(); } else { this.$message({ diff --git a/src/views/modules/pms/blenderStep/config.js b/src/views/modules/pms/blenderStep/config.js index 6537a94..83a5df3 100644 --- a/src/views/modules/pms/blenderStep/config.js +++ b/src/views/modules/pms/blenderStep/config.js @@ -90,11 +90,19 @@ export default function () { rules: { required: true, message: "必填项不能为空", trigger: "blur" }, elparams: { placeholder: "请输入混料程序编码" }, }, + ], + [ + { + forceDisabled: true, + prop: 'bomCode', + label: '当前配方' + }, { select: true, - label: "配方", + label: "选择新配方", prop: "bomId", options: [], + refreshOptionsAfterConfirm: true, elparams: { clearable: true, filterable: true, placeholder: "请选择配方" }, fetchData: () => this.$http.get("/pms/bom/listUnR", { params: { wsId: 1, externalCode: '', key: '' } }), }, diff --git a/src/views/modules/pms/bom/config.js b/src/views/modules/pms/bom/config.js index b386d71..0be276a 100644 --- a/src/views/modules/pms/bom/config.js +++ b/src/views/modules/pms/bom/config.js @@ -119,7 +119,7 @@ export default function () { prop: "sync", key: 'sync', // rules: { required: true, message: "必填项不能为空", trigger: "blur" }, - elparams: { placeholder: "请输入同步状态" }, + // elparams: { placeholder: "请输入同步状态" }, }, ], [{ textarea: true, label: "备注", prop: "remark", elparams: { placeholder: "备注" } }], diff --git a/src/views/modules/pms/firingStep/config.js b/src/views/modules/pms/firingStep/config.js new file mode 100644 index 0000000..b2dbcd5 --- /dev/null +++ b/src/views/modules/pms/firingStep/config.js @@ -0,0 +1,211 @@ +import TableOperaionComponent from "@/components/noTemplateComponents/operationComponent"; +import TableTextComponent from "@/components/noTemplateComponents/detailComponent"; +import StatusComponent from "@/components/noTemplateComponents/statusComponent"; +import { timeFilter } from "@/utils/filters"; + +export default function () { + const tableProps = [ + { type: "index", label: "序号" }, + { prop: "createTime", label: "添加时间", filter: timeFilter }, + { prop: "name", label: "工艺名称" }, + { prop: "code", label: "工艺编码" }, + // { prop: 'version', label: '配方号' }, + { prop: "bomCode", label: "配方号" }, + // { prop: 'status', label: '状态', subcomponent: StatusComponent }, // subcomponent + { prop: "description", label: "详情", subcomponent: TableTextComponent }, + { prop: "remark", label: "备注" }, + { + prop: "operations", + name: "操作", + fixed: "right", + width: 120, + subcomponent: TableOperaionComponent, + options: ["edit", { name: "delete", emitFull: true, permission: "pms:blenderStep:delete" }], + }, + ]; + + const headFormFields = [ + { + prop: "key", + label: "工艺名称/编码", + input: true, + default: { value: "" }, + bind: { + placeholder: "请输入工艺名称或编码", + }, + }, + { + prop: "bom", + label: "配方号", + input: true, + default: { value: "" }, + bind: { + placeholder: "请输入配方号", + }, + }, + // { + // prop: 'bom', + // label: '配方号', + // input: true, + // default: { value: '' }, + // bind: { + // placeholder: '请输入配方号' + // } + // }, + { + button: { + type: "primary", + name: "查询", + }, + }, + { + button: { + type: "plain", + name: "新增", + permission: "pms:blenderStep:save", + }, + }, + ]; + + const dialogConfigs = { + extraIds: { wsId: 3 }, // 工艺管理里面的相关模块的 dialogWithMenu 需要额外的工序 id + menu: [ + { name: "烧制工艺", key: "info" }, + { name: "工艺参数", key: "attr", onlyEditMode: true }, + ], + form: { + rows: [ + [ + { + input: true, + label: "工艺名称", + prop: "name", + rules: { required: true, message: "必填项不能为空", trigger: "blur" }, + elparams: { placeholder: "请输入烧制工艺名称" }, + }, + { + input: true, + label: "工艺编码", + prop: "code", + rules: { required: true, message: "必填项不能为空", trigger: "blur" }, + elparams: { placeholder: "请输入烧制工艺编码" }, + }, + ], + [ + { + forceDisabled: true, + prop: 'bomCode', + label: '当前配方' + }, + { + select: true, + label: "选择新配方", + prop: "bomId", + options: [], + refreshOptionsAfterConfirm: true, + elparams: { clearable: true, filterable: true, placeholder: "请选择配方" }, + fetchData: () => this.$http.get("/pms/bom/listUnR", { params: { wsId: 3, externalCode: '', key: '' } }), + }, + ], + [{ textarea: true, label: "备注", prop: "remark", elparams: { placeholder: "备注" } }], + ], + operations: [ + { name: "add", label: "保存", type: "primary", permission: "pms:firingStep:save", showOnEdit: false }, + { name: "update", label: "更新", type: "primary", permission: "pms:firingStep:update", showOnEdit: true }, + { name: "reset", label: "重置", type: "warning", showAlways: true }, + // { name: 'cancel', label: '取消', showAlways: true }, + ], + }, + table: { + extraParams: ["techId", "key"], + props: [ + // { type: 'index', label: '序号' }, + // { prop: "createTime", label: "添加时间", filter: timeFilter }, + { prop: "name", label: "参数名称", isEditField: true }, + { prop: "code", label: "参数编码", isEditField: true }, + // { prop: "specifications", label: "规格", isEditField: true }, + { prop: "value", label: "设定值", isEditField: true }, + { prop: "valueFloor", label: "值下限", isEditField: true }, + { prop: "valueTop", label: "值上限", isEditField: true }, + { prop: "description", label: "描述", isEditField: true }, + { + prop: "operations", + name: "操作", + fixed: "right", + width: 120, + subcomponent: TableOperaionComponent, + options: [ + { name: "edit", permission: "pms:blenderStepParam:update" }, + { name: "delete", emitFull: true, permission: "pms:blenderStepParam:delete" }, + ], + }, + ], + data: [ + // TOOD 暂时用不到,但获取可以考虑把拉取接口数据的函数迁移到此文件(没有太大必要) + ], + }, + + subDialog: { + extraParam: "techId", + rows: [ + [ + { + input: true, + label: "参数名称", + prop: "name", + rules: { required: true, message: "必填项不能为空", trigger: "blur" }, + elparams: { placeholder: "请输入参数名称" }, + }, + { + input: true, + label: "参数编码", + prop: "code", + rules: { required: true, message: "必填项不能为空", trigger: "blur" }, + elparams: { placeholder: "请输入描述" }, + }, + ], + [ + { input: true, label: "参数值上限", prop: "valueTop", elparams: { placeholder: "请输入参数值上限" } }, + { input: true, label: "参数值下限", prop: "valueFloor", elparams: { placeholder: "请输入参数值下限" } }, + ], + [ + { input: true, label: "参数值", prop: "value", elparams: { placeholder: "请输入参数值" } }, + { + input: true, + label: "描述", + prop: "description", + // rules: { required: true, message: "必填项不能为空", trigger: "blur" }, + elparams: { placeholder: "请输入描述" }, + }, + ], + ], + operations: [ + { name: "add", label: "保存", type: "primary", showOnEdit: false }, + { name: "update", label: "更新", type: "primary", showOnEdit: true }, + // { name: "update", label: "更新", type: "primary", permission: "pms:blenderStepParam:update", showOnEdit: true }, + // { name: 'reset', label: '重置', type: 'warning', showAlways: true }, + // { name: 'cancel', label: '取消', showAlways: true }, + ], + }, + }; + + return { + dialogConfigs, + tableConfig: { + table: null, // 此处可省略,el-table 上的配置项 + column: tableProps, // el-column-item 上的配置项 + }, + headFormConfigs: { + rules: null, // 名称是由 BaseSearchForm.vue 组件固定的 + fields: headFormFields, // 名称是由 BaseSearchForm.vue 组件固定的 + }, + urls: { + base: "/pms/equipmentTech", + page: "/pms/equipmentTech/pageView", + pageIsPostApi: true, // 使用post接口来获取page数据,极少用,目前基本上只有工艺管理模块里在用 + subase: "/pms/equipmentTechParam", + subpage: "/pms/equipmentTechParam/page", + // more... + }, + }; +} diff --git a/src/views/modules/pms/firingStep/index.vue b/src/views/modules/pms/firingStep/index.vue new file mode 100644 index 0000000..8ee2344 --- /dev/null +++ b/src/views/modules/pms/firingStep/index.vue @@ -0,0 +1,51 @@ + + + + +