fix 0720
This commit is contained in:
@@ -270,6 +270,7 @@ export default {
|
||||
inject: ["urls"],
|
||||
data() {
|
||||
const dataForm = {};
|
||||
let dataForm__duplicate = null;
|
||||
const autoDisabledQueue = [];
|
||||
const watingToRefreshQueue = [];
|
||||
const cached = {};
|
||||
@@ -373,12 +374,15 @@ export default {
|
||||
});
|
||||
});
|
||||
|
||||
if (this.configs.form.duplicate) dataForm__duplicate = JSON.parse(JSON.stringify(dataForm));
|
||||
|
||||
return {
|
||||
// configs,
|
||||
btnLoading: false,
|
||||
loadingStatus: false,
|
||||
activeMenu: this.configs.menu[0].name,
|
||||
dataForm,
|
||||
dataForm__duplicate,
|
||||
detailMode: false,
|
||||
autoDisabledQueue,
|
||||
watingToRefreshQueue,
|
||||
@@ -419,44 +423,44 @@ export default {
|
||||
};
|
||||
},
|
||||
mounted() {
|
||||
this.configs.form.rows.forEach((row) => {
|
||||
row.forEach((col) => {
|
||||
if (
|
||||
col.changeReflects &&
|
||||
typeof col.changeReflects === "object" &&
|
||||
"fromKey" in col.changeReflects &&
|
||||
"toProp" in col.changeReflects
|
||||
) {
|
||||
this.$watch(
|
||||
() => this.dataForm[col.prop],
|
||||
(val) => {
|
||||
if (val && col.prop in this.cached) {
|
||||
console.log("here changeReflects", col.prop, col.changeReflects.toProp, this.cached[col.prop]);
|
||||
if (typeof col.changeReflects.fromKey === "string") {
|
||||
this.dataForm[col.changeReflects.toProp] = this.cached[col.prop].find((item) => item.id === val)?.[
|
||||
col.changeReflects.fromKey
|
||||
];
|
||||
} else if (Array.isArray(col.changeReflects.fromKey) && col.changeReflects.delimiter) {
|
||||
const foundItem = (this.dataForm[col.changeReflects.toProp] = this.cached[col.prop].find(
|
||||
(item) => item.id === val
|
||||
));
|
||||
if (foundItem) {
|
||||
const values = col.changeReflects.fromKey.map((key) => foundItem[key]);
|
||||
this.dataForm[col.changeReflects.toProp] = values.join(col.changeReflects.delimiter);
|
||||
} else {
|
||||
this.dataForm[col.changeReflects.toProp] = col.changeReflects.delimiter;
|
||||
console.log("[DialogWithMenu] mounted() 没找到对应数据");
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
immediate: false,
|
||||
}
|
||||
);
|
||||
}
|
||||
});
|
||||
});
|
||||
// this.configs.form.rows.forEach((row) => {
|
||||
// row.forEach((col) => {
|
||||
// if (
|
||||
// col.changeReflects &&
|
||||
// typeof col.changeReflects === "object" &&
|
||||
// "fromKey" in col.changeReflects &&
|
||||
// "toProp" in col.changeReflects
|
||||
// ) {
|
||||
// this.$watch(
|
||||
// () => this.dataForm[col.prop],
|
||||
// (val) => {
|
||||
// if (val && col.prop in this.cached) {
|
||||
// console.log("here changeReflects", col.prop, col.changeReflects.toProp, this.cached[col.prop]);
|
||||
// if (typeof col.changeReflects.fromKey === "string") {
|
||||
// this.dataForm[col.changeReflects.toProp] = this.cached[col.prop].find((item) => item.id === val)?.[
|
||||
// col.changeReflects.fromKey
|
||||
// ];
|
||||
// } else if (Array.isArray(col.changeReflects.fromKey) && col.changeReflects.delimiter) {
|
||||
// const foundItem = (this.dataForm[col.changeReflects.toProp] = this.cached[col.prop].find(
|
||||
// (item) => item.id === val
|
||||
// ));
|
||||
// if (foundItem) {
|
||||
// const values = col.changeReflects.fromKey.map((key) => foundItem[key]);
|
||||
// this.dataForm[col.changeReflects.toProp] = values.join(col.changeReflects.delimiter);
|
||||
// } else {
|
||||
// this.dataForm[col.changeReflects.toProp] = col.changeReflects.delimiter;
|
||||
// console.log("[DialogWithMenu] mounted() 没找到对应数据");
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// },
|
||||
// {
|
||||
// immediate: false,
|
||||
// }
|
||||
// );
|
||||
// }
|
||||
// });
|
||||
// });
|
||||
},
|
||||
|
||||
watch: {
|
||||
@@ -583,7 +587,7 @@ export default {
|
||||
this.$http.get(this.urls.base + `/${this.dataForm.id}`).then(({ data: res }) => {
|
||||
if (res && res.code === 0) {
|
||||
const dataFormKeys = Object.keys(this.dataForm);
|
||||
console.log('[DialogWithMenu] dataFormKeys -------->', dataFormKeys)
|
||||
console.log("[DialogWithMenu] dataFormKeys -------->", dataFormKeys);
|
||||
|
||||
this.dataForm = __pick(res.data, dataFormKeys);
|
||||
if ("files" in res.data) {
|
||||
@@ -778,7 +782,17 @@ export default {
|
||||
console.log("[DialogJustForm] handleComponentModelUpdate", this.dataForm[propName]);
|
||||
},
|
||||
handleSelectChange(col, eventValue) {
|
||||
console.log("[dialog] select change: ", col, eventValue);
|
||||
console.log("[dialog] select change: ", col, eventValue, this.dataForm__duplicate);
|
||||
if (this.dataForm__duplicate !== null) {
|
||||
console.log("before B--------->", this.dataForm__duplicate);
|
||||
const shape = this.cached[col.prop].find((item) => item.id === eventValue);
|
||||
this.$set(
|
||||
this.dataForm__duplicate,
|
||||
col.changeReflects.toProp,
|
||||
shape && col.changeReflects.toProp in shape ? shape[col.changeReflects.toProp] : null
|
||||
);
|
||||
console.log("B--------->", shape, this.dataForm__duplicate);
|
||||
}
|
||||
},
|
||||
handleSwitchChange(val) {
|
||||
console.log("[dialog] switch change: ", val, this.dataForm);
|
||||
@@ -798,6 +812,8 @@ export default {
|
||||
case "update": {
|
||||
this.$refs.dataForm[0].validate((passed, result) => {
|
||||
if (passed) {
|
||||
// 判断dataForm类型
|
||||
let dataForm = this.dataForm__duplicate !== null ? this.dataForm__duplicate : this.dataForm;
|
||||
// 如果通过验证
|
||||
this.btnLoading = true;
|
||||
this.loadingStatus = true;
|
||||
@@ -807,7 +823,8 @@ export default {
|
||||
const hasAttachment = !!this.configs.menu.find((item) => item.key === "attachment");
|
||||
if (hasAttachment) {
|
||||
const fileIds = this.fileList.map((item) => item.id);
|
||||
this.$set(this.dataForm, "fileIds", fileIds);
|
||||
// this.$set(this.dataForm, "fileIds", fileIds);
|
||||
dataForm.fileIds = fileIds;
|
||||
}
|
||||
|
||||
// 加载额外需要的 id
|
||||
@@ -828,6 +845,8 @@ export default {
|
||||
// console.log('actualPayload', actualPayload);
|
||||
// }
|
||||
|
||||
console.log("before update:", dataForm);
|
||||
|
||||
// 实际发送请求
|
||||
this.btnLoading = true;
|
||||
this.$http({
|
||||
@@ -835,7 +854,8 @@ export default {
|
||||
method,
|
||||
data: {
|
||||
...extraIds,
|
||||
...this.dataForm,
|
||||
// ...this.dataForm,
|
||||
...dataForm,
|
||||
},
|
||||
})
|
||||
.then(({ data: res }) => {
|
||||
|
||||
Reference in New Issue
Block a user