update ---
This commit is contained in:
parent
8ef8d32e19
commit
13753f0c6c
@ -142,6 +142,7 @@ export default {
|
|||||||
const savedDatalist = {};
|
const savedDatalist = {};
|
||||||
const cachedList = {};
|
const cachedList = {};
|
||||||
const watchList = [];
|
const watchList = [];
|
||||||
|
const promiseChain = {};
|
||||||
|
|
||||||
this.configs.form.rows.forEach((row) => {
|
this.configs.form.rows.forEach((row) => {
|
||||||
row.forEach((col) => {
|
row.forEach((col) => {
|
||||||
@ -152,8 +153,8 @@ export default {
|
|||||||
savedDatalist[col.prop] = [];
|
savedDatalist[col.prop] = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (col.fetchData && typeof col.fetchData === "function") {
|
if (col.fetchData && typeof col.fetchData === "function" && !col.fetchDataWait) {
|
||||||
col.fetchData().then(({ data: res }) => {
|
const ps = col.fetchData().then(({ data: res }) => {
|
||||||
if (res.code === 0) {
|
if (res.code === 0) {
|
||||||
if ("list" in res.data) {
|
if ("list" in res.data) {
|
||||||
if ("injectTo" in col) {
|
if ("injectTo" in col) {
|
||||||
@ -196,6 +197,8 @@ export default {
|
|||||||
}
|
}
|
||||||
// dataForm[col.prop] = col.default ?? null; // not perfect!
|
// dataForm[col.prop] = col.default ?? null; // not perfect!
|
||||||
});
|
});
|
||||||
|
|
||||||
|
promiseChain[col.prop] = ps;
|
||||||
} else if (col.fetchTreeData && typeof col.fetchTreeData === "function") {
|
} else if (col.fetchTreeData && typeof col.fetchTreeData === "function") {
|
||||||
// 获取设备类型时触发的,用于前端构建属性结构,约定,parentId 为0时是顶级节点
|
// 获取设备类型时触发的,用于前端构建属性结构,约定,parentId 为0时是顶级节点
|
||||||
col.fetchTreeData().then(({ data: res }) => {
|
col.fetchTreeData().then(({ data: res }) => {
|
||||||
@ -220,6 +223,7 @@ export default {
|
|||||||
savedDatalist,
|
savedDatalist,
|
||||||
cachedList,
|
cachedList,
|
||||||
watchList,
|
watchList,
|
||||||
|
promiseChain,
|
||||||
detailMode: false,
|
detailMode: false,
|
||||||
baseDialogConfig: null,
|
baseDialogConfig: null,
|
||||||
defaultQuillConfig: {
|
defaultQuillConfig: {
|
||||||
@ -278,8 +282,14 @@ export default {
|
|||||||
if ("toggleFetchData" in col) {
|
if ("toggleFetchData" in col) {
|
||||||
const unwatch = this.$watch(
|
const unwatch = this.$watch(
|
||||||
() => this.dataForm[col.toggleFetchData],
|
() => this.dataForm[col.toggleFetchData],
|
||||||
(carId) => {
|
(val) => {
|
||||||
col.fetchData(carId).then(({ data: res }) => {
|
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 (res.code === 0) {
|
||||||
if ("list" in res.data) {
|
if ("list" in res.data) {
|
||||||
if ("injectTo" in col) this.$set(this.cachedList, col.prop, res.data.list);
|
if ("injectTo" in col) this.$set(this.cachedList, col.prop, res.data.list);
|
||||||
|
@ -102,9 +102,10 @@ export default function () {
|
|||||||
options: [],
|
options: [],
|
||||||
optionLabel: 'code',
|
optionLabel: 'code',
|
||||||
optionValue: 'carId',
|
optionValue: 'carId',
|
||||||
|
needCache: true,
|
||||||
fetchData: () => this.$http.post("/pms/carHandle/pageView", { page: 1, limit: 999 }),
|
fetchData: () => this.$http.post("/pms/carHandle/pageView", { page: 1, limit: 999 }),
|
||||||
rules: { required: true, message: "必填项不能为空", trigger: "blur" },
|
rules: { required: true, message: "必填项不能为空", trigger: "blur" },
|
||||||
elparams: { placeholder: "请输入批次编码", filterable: true },
|
elparams: { placeholder: "请输入窑车号", filterable: true },
|
||||||
injectTo: [
|
injectTo: [
|
||||||
['posCode', 'posCode'], // TODO
|
['posCode', 'posCode'], // TODO
|
||||||
['carState', 'stateDictValue']
|
['carState', 'stateDictValue']
|
||||||
@ -150,7 +151,11 @@ export default function () {
|
|||||||
options: [],
|
options: [],
|
||||||
optionLabel: 'orderCode',
|
optionLabel: 'orderCode',
|
||||||
toggleFetchData: 'carId', // 当 carId 改变的时候,也会 fetchData
|
toggleFetchData: 'carId', // 当 carId 改变的时候,也会 fetchData
|
||||||
fetchData: (carId) => this.$http.post("/pms/carHandle/getCurrent", { id: carId ?? null, page: 1, limit: 999 }),
|
// 需要保存当前状态
|
||||||
|
needCache: true,
|
||||||
|
fetchDataParam: { search: 'carId', get: 'id' }, // 伴随着 toggleFetchData 出现
|
||||||
|
fetchData: (hisId) => this.$http.get(`/pms/carHandle/${hisId}`),
|
||||||
|
fetchDataWait: true,
|
||||||
rules: { required: true, message: "必选项不能为空", trigger: "blur" },
|
rules: { required: true, message: "必选项不能为空", trigger: "blur" },
|
||||||
elparams: { placeholder: "请选择订单" },
|
elparams: { placeholder: "请选择订单" },
|
||||||
injectTo: [
|
injectTo: [
|
||||||
|
Loading…
Reference in New Issue
Block a user