update ---

This commit is contained in:
lb
2023-04-03 10:58:58 +08:00
parent 8ef8d32e19
commit 13753f0c6c
2 changed files with 21 additions and 6 deletions

View File

@@ -142,6 +142,7 @@ export default {
const savedDatalist = {};
const cachedList = {};
const watchList = [];
const promiseChain = {};
this.configs.form.rows.forEach((row) => {
row.forEach((col) => {
@@ -152,8 +153,8 @@ export default {
savedDatalist[col.prop] = [];
}
if (col.fetchData && typeof col.fetchData === "function") {
col.fetchData().then(({ data: res }) => {
if (col.fetchData && typeof col.fetchData === "function" && !col.fetchDataWait) {
const ps = col.fetchData().then(({ data: res }) => {
if (res.code === 0) {
if ("list" in res.data) {
if ("injectTo" in col) {
@@ -196,6 +197,8 @@ export default {
}
// dataForm[col.prop] = col.default ?? null; // not perfect!
});
promiseChain[col.prop] = ps;
} else if (col.fetchTreeData && typeof col.fetchTreeData === "function") {
// 获取设备类型时触发的用于前端构建属性结构约定parentId 为0时是顶级节点
col.fetchTreeData().then(({ data: res }) => {
@@ -220,6 +223,7 @@ export default {
savedDatalist,
cachedList,
watchList,
promiseChain,
detailMode: false,
baseDialogConfig: null,
defaultQuillConfig: {
@@ -278,8 +282,14 @@ export default {
if ("toggleFetchData" in col) {
const unwatch = this.$watch(
() => this.dataForm[col.toggleFetchData],
(carId) => {
col.fetchData(carId).then(({ data: res }) => {
(val) => {
const { search, get } = col.fetchDataParam; // 伴随着 toggleFetchData 出现的
const chosenObject = this.cachedList[col.toggleFetchData]?.find((i) => i[search] === val);
const paramValue = chosenObject ? chosenObject[get] : "";
console.log("((( chosenObject )))", chosenObject);
col.fetchData(paramValue).then(({ data: res }) => {
console.log("((( col.fetchData )))", paramValue, data);
if (res.code === 0) {
if ("list" in res.data) {
if ("injectTo" in col) this.$set(this.cachedList, col.prop, res.data.list);