This commit is contained in:
lb 2023-02-01 17:02:14 +08:00
vanhempi 65ee2fe0d7
commit c705b591b1
2 muutettua tiedostoa jossa 32 lisäystä ja 6 poistoa

Näytä tiedosto

@ -46,7 +46,7 @@
:key="'component_' + col.prop"
@update:modelValue="handleComponentModelUpdate(col.prop, $event)"
:modelValue="dataForm[col.prop]"
:mode="detailMode ? 'detail' : dataForm.id ? 'edit' : 'create' "
:mode="detailMode ? 'detail' : dataForm.id ? 'edit' : 'create'"
/>
</div>
<!-- add more... -->
@ -71,7 +71,32 @@
import { pick as __pick } from "@/utils/filters";
function reConstructTreeData(listObj) {
Object.keys(listObj).forEach((id) => {});
// O(2n)
//
Object.keys(listObj).map((key) => {
const currentNode = listObj[key];
if (currentNode.parentId === "0") 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);
});
//
function recursive(list) {
// TODO: 2023.2.2
list.forEach(item => {
if (item.children) recursive(item.children)
})
}
return Object.keys(listObj).map(key => {
const currentNode = listObj[key];
if (currentNode.children) recursive(currentNode.children)
})
}
export default {
@ -108,15 +133,16 @@ export default {
// dataForm[col.prop] = col.default ?? null; // not perfect!
});
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) {
//
//
const obj = {};
res.data.list.map((item) => {
obj[item.id] = item;
});
//
//
let filteredList = reConstructTreeData(obj);
// options
this.$set(col, "options", filteredList);

Näytä tiedosto

@ -82,9 +82,9 @@ export default function () {
// fetchData() 获取普通列表数据
// fetchTreeData() 获取需要展示层级结构的数据
fetchTreeData: () => {
// TODO前提是工厂里总的设备类型数不会超过 999
return this.$http.get('/pms/equipmentType/page', {
// TODO前提是工厂里总的设备类型数不会超过 999
limit: 999, page: 1, key: ""
params: { limit: 999, page: 1, key: "" }
})
},
label: "父类",