diff --git a/src/components/noTemplateComponents/switchBtn.js b/src/components/noTemplateComponents/switchBtn.js index 5ac0f3c..19be899 100644 --- a/src/components/noTemplateComponents/switchBtn.js +++ b/src/components/noTemplateComponents/switchBtn.js @@ -10,9 +10,12 @@ export default { }, }, data() { - const elSwitchModel = this.injectData.enabled ? true : false + const propName = this.injectData.head.prop + let elSwitchModel = this.injectData[propName] ? true : false + return { - elSwitchModel + elSwitchModel, + propName }; }, mounted() { @@ -32,11 +35,11 @@ export default { // 发射事件 emit(booleanValue) { const { id, code } = this.injectData - this.$emit('emit-data', { type: 'status', data: { id, code, enabled: booleanValue ? '1' : '0' } }) + this.$emit('emit-data', { type: 'status', data: { id, code, [this.propName]: booleanValue ? '1' : '0' } }) }, }, render: function (h) { - var self = this + var self = this return h( "el-switch", { diff --git a/src/views/atomViews/ListViewWithHead.vue b/src/views/atomViews/ListViewWithHead.vue index 81e2643..c6f3f8e 100644 --- a/src/views/atomViews/ListViewWithHead.vue +++ b/src/views/atomViews/ListViewWithHead.vue @@ -222,20 +222,18 @@ export default { break; } case "status": { + console.log('status', data) // TODO: 类似于这种字符串,可以统一集中到一个文件里 - const { id, code, enabled } = data; + const { id, code } = data; + const queryCondition = { id, code }; + if ("enabled" in data) queryCondition.enabled = data['enabled']; + if ("status" in data) queryCondition.status = data['status']; // 更改状态,更改状态需要 id 和 code 然后是 状态 enabled - this.$http - .put(this.urls.base, { - id, - code, - enabled, - }) - .then(({ data: res }) => { - if (res.code === 0) { - // do nothing - } - }); + this.$http.put(this.urls.base, queryCondition).then(({ data: res }) => { + if (res.code === 0) { + // do nothing + } + }); break; } } diff --git a/src/views/modules/pms/material/components/ListViewWithHead.vue b/src/views/modules/pms/material/components/ListViewWithHead.vue index 8fbdbbd..427480a 100644 --- a/src/views/modules/pms/material/components/ListViewWithHead.vue +++ b/src/views/modules/pms/material/components/ListViewWithHead.vue @@ -56,6 +56,10 @@ import DialogJustForm from "@/components/DialogJustForm.vue"; const DIALOG_WITH_MENU = "DialogWithMenu"; const DIALOG_JUST_FORM = "DialogJustForm"; +function constructToTree(list) { + return list; +} + export default { name: "ListViewWithHead", components: { BaseSearchForm, BaseListTable, DialogWithMenu, DialogJustForm }, @@ -146,10 +150,12 @@ export default { // page 场景: if ("list" in res.data) { // real env: - this.dataList = res.data.list.map((item) => ({ - ...item, - id: item._id ?? item.id, - })); + this.dataList = constructToTree( + res.data.list.map((item) => ({ + ...item, + id: item._id ?? item.id, + })) + ); // this.dataList = res.data.records; this.totalPage = res.data.total; } else if ("records" in res.data) { @@ -214,6 +220,21 @@ export default { this.openDialog(data, true); break; } + case "status": { + console.log('status', data) + // TODO: 类似于这种字符串,可以统一集中到一个文件里 + const { id, code } = data; + const queryCondition = { id, code }; + if ("enabled" in data) queryCondition.enabled = data['enabled']; + if ("status" in data) queryCondition.status = data['status']; + // 更改状态,更改状态需要 id 和 code 然后是 状态 enabled + this.$http.put(this.urls.base, queryCondition).then(({ data: res }) => { + if (res.code === 0) { + // do nothing + } + }); + break; + } } }, diff --git a/src/views/modules/pms/material/config.js b/src/views/modules/pms/material/config.js index b9fb077..3eb0262 100644 --- a/src/views/modules/pms/material/config.js +++ b/src/views/modules/pms/material/config.js @@ -61,7 +61,7 @@ export default function () { menu: [ { name: "物料信息", key: "info" }, { name: "物料属性信息", key: "attr", onlyEditMode: true }, - { name: "子类", key: "add-sub", onlyEditMode: true }, + { name: "添加子类", key: "add-sub", onlyEditMode: true }, ], form: { rows: [ diff --git a/src/views/modules/pms/productionLine/config.js b/src/views/modules/pms/productionLine/config.js index edb6125..c3740e0 100644 --- a/src/views/modules/pms/productionLine/config.js +++ b/src/views/modules/pms/productionLine/config.js @@ -1,5 +1,5 @@ import TableOperaionComponent from "@/components/noTemplateComponents/operationComponent"; -import StatusComponent from "@/components/noTemplateComponents/statusComponent"; +import switchBtn from "@/components/noTemplateComponents/switchBtn"; import request from "@/utils/request"; export default function () { @@ -7,7 +7,8 @@ export default function () { { prop: "name", label: "产线名称" }, { prop: "code", label: "产线编码" }, { prop: "factory", label: "所属工厂" }, - { prop: "status", label: "产线状态", subcomponent: StatusComponent }, // subcomponent + { prop: "status", label: "产线状态", subcomponent: switchBtn }, // subcomponent + // TODO: 2023.2.3 产线状态切换功能不生效 { prop: "tvalue", label: "每小时下片数量" }, { prop: "description", label: "描述" }, { prop: "remark", label: "备注" },