update 基本完成物料表

This commit is contained in:
lb
2023-02-06 16:39:00 +08:00
parent e8798c66c2
commit 72043ed63f
2 changed files with 51 additions and 9 deletions

View File

@@ -57,6 +57,13 @@
<el-col v-for="(col, colIndex) in row" :key="colIndex" :span="24 / row.length">
<el-form-item :label="col.label" :prop="col.prop" :rules="col.rules || null">
<el-input v-if="col.input" v-model="dataForm[col.prop]" clearable :disabled="disableCondition(col.prop)" v-bind="col.elparams" />
<el-cascader
v-if="col.cascader"
v-model="dataForm[col.prop]"
:options="col.options"
:disabled="detailMode"
v-bind="col.elparams"
></el-cascader>
<el-select
v-if="col.select"
v-model="dataForm[col.prop]"
@@ -124,6 +131,25 @@ import { pick as __pick } from "@/utils/filters";
import SmallDialog from "@/components/SmallDialog.vue";
import BaseListTable from "@/components/BaseListTable.vue";
function reConstructTreeData(listObj) {
const entry = [];
Object.keys(listObj).map((key) => {
const currentNode = listObj[key];
currentNode.label = currentNode.name;
currentNode.value = currentNode.id;
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);
});
return entry;
}
export default {
name: "DialogWithMenu",
components: { SmallDialog, BaseListTable },
@@ -175,13 +201,20 @@ export default {
else if (col.fetchTreeData) {
// 获取设备类型时触发的用于前端构建属性结构约定parentId 为0时是顶级节点
col.fetchTreeData().then(({ data: res }) => {
console.log("[Fetch Tree Data]", res.data.list);
if (res.code === 0 && res.data.list) {
console.log("[Fetch Tree Data]", res.data);
if (res.code === 0) {
// 先把数据先重构成一个对象
const obj = {};
res.data.list.map((item) => {
obj[item.id] = item;
});
if ("list" in res.data) {
res.data.list.map((item) => {
obj[item.id] = item;
});
} else if (Array.isArray(res.data)) {
res.data.map((item) => {
obj[item.id] = item;
});
}
// 再过滤这个对象
let filteredList = reConstructTreeData(obj);
console.log("** filteredList **", filteredList);
@@ -189,6 +222,7 @@ export default {
this.$set(col, "options", filteredList);
} else {
col.options.splice(0);
this.$message.error(res.msg);
}
});
}
@@ -514,7 +548,8 @@ export default {
padding-bottom: 0 !important;
}
.el-select {
.el-select,
.el-cascader {
width: 100% !important;
}