|
|
@@ -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("请核查字段信息"); |
|
|
|
} |
|
|
|
}); |
|
|
|