From 6b0d5f0bc1a6739257ea38aa7927463600b62854 Mon Sep 17 00:00:00 2001 From: lb Date: Tue, 14 Feb 2023 09:56:52 +0800 Subject: [PATCH] =?UTF-8?q?update=20=E8=AE=BE=E5=A4=87=E7=B1=BB=E5=9E=8Btr?= =?UTF-8?q?ee=E6=95=B0=E6=8D=AE=E2=80=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/DialogJustForm.vue | 57 +++---------------- src/views/modules/pms/equipmentType/config.js | 5 +- 2 files changed, 8 insertions(+), 54 deletions(-) diff --git a/src/components/DialogJustForm.vue b/src/components/DialogJustForm.vue index 5ececf6..35bafa8 100644 --- a/src/components/DialogJustForm.vue +++ b/src/components/DialogJustForm.vue @@ -105,27 +105,6 @@ import "quill/dist/quill.bubble.css"; import { quillEditor } from "vue-quill-editor"; - -// TODO: 这个函数不需要了(该函数有逻辑也有问题),让后端直接给 tree 接口 -function reConstructTreeData(listObj) { - const entry = []; - Object.keys(listObj).map((key) => { - const currentNode = listObj[key]; - - if (currentNode.parentId === "0") { - entry.push(listObj[key]); - return; // return { label: currentNode.name, value: currentNode.id, children: currentNode.children ?? [] }; - } - const parentNode = listObj[currentNode.parentId]; - if (!parentNode.children) { - parentNode.children = []; - } - parentNode.children.push(currentNode); - }); - console.log("[reConstructTreeData]", entry); - return entry; -} - export default { name: "DialogJustForm", components: { uploadBtn, quillEditor }, @@ -168,18 +147,13 @@ export default { else if (col.fetchTreeData) { // 获取设备类型时触发的,用于前端构建属性结构,约定,parentId 为0时是顶级节点 col.fetchTreeData().then(({ data: res }) => { - console.log("[DialogJustForm fetchTreeData -->]", res.data.list); - if (res.code === 0 && res.data.list) { - // 先把数据先重构成一个对象 - const obj = {}; - res.data.list.map((item) => { - obj[item.id] = item; - }); - // 再过滤这个对象 - let filteredList = reConstructTreeData(obj); - // 最后设置 options - console.log("[DialogJustForm fetchTreeData 2 -->]", filteredList); - this.$set(col, "options", filteredList); + console.log("[DialogJustForm fetchTreeData -->]", res.data); + if (res.code === 0 && res.data) { + if ("list" in res.data) { + this.$set(col, "options", res.data.list); + } else if (Array.isArray(res.data)) { + this.$set(col, "options", res.data); + } } else { col.options.splice(0); } @@ -295,21 +269,6 @@ export default { } this.loadingStatus = false; }); - - // // 获取文件信息 - // this.uploadComponentsList.forEach((col) => { - // this.$http - // .get(col.fetchUrl, { - // params: { - // limit: 999, - // page: 1, - // [col.paramName]: this.dataForm.id, - // }, - // }) - // .then(({ data: res }) => { - // console.log("fetch filelist:", res); - // }); - // }); } else { // 如果不是编辑 } @@ -385,8 +344,6 @@ export default { if (this.loadingStatus) this.loadingStatus = false; }); } else { - // 没有通过验证 - // this.$message.error(JSON.stringify(result)); this.$message.error("请核查字段信息"); } }); diff --git a/src/views/modules/pms/equipmentType/config.js b/src/views/modules/pms/equipmentType/config.js index 369c8b5..c2148a8 100644 --- a/src/views/modules/pms/equipmentType/config.js +++ b/src/views/modules/pms/equipmentType/config.js @@ -83,10 +83,7 @@ export default function () { // fetchData() 获取普通列表数据 // fetchTreeData() 获取需要展示层级结构的数据 fetchTreeData: () => { - // TODO:前提是工厂里总的设备类型数不会超过 999 - return this.$http.get('/pms/equipmentType/page', { - params: { limit: 999, page: 1, key: "" } - }) + return this.$http.get('/pms/equipmentType/getTree') }, label: "父类", rules: { required: false, message: "not empty", trigger: "change" },