update ---
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user