修复崩溃问题
This commit is contained in:
parent
f81e56e167
commit
7a7d550a77
|
|
@ -215,6 +215,8 @@ export default {
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
// 当前编辑的ID
|
||||||
|
currentEditId: null,
|
||||||
formGroup,
|
formGroup,
|
||||||
AEform: {
|
AEform: {
|
||||||
formModel: {
|
formModel: {
|
||||||
|
|
@ -242,12 +244,26 @@ export default {
|
||||||
this.getMediaType();
|
this.getMediaType();
|
||||||
const rawData = await cityDataCache.getCityData();
|
const rawData = await cityDataCache.getCityData();
|
||||||
this.cityList = Object.freeze(rawData);
|
this.cityList = Object.freeze(rawData);
|
||||||
|
|
||||||
|
if (this.$route.query.id) {
|
||||||
|
this.getDetailData()
|
||||||
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
if (this.$route.query.id) {
|
if (this.$route.query.id) {
|
||||||
this.getDetailData()
|
this.getDetailData()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
watch: {
|
||||||
|
'$route.query.id': {
|
||||||
|
immediate: true,
|
||||||
|
handler(newId) {
|
||||||
|
if (newId !== this.currentEditId) {
|
||||||
|
this.getDetailData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
computed: {
|
computed: {
|
||||||
contractMoney() {
|
contractMoney() {
|
||||||
// 使用非响应式方式计算
|
// 使用非响应式方式计算
|
||||||
|
|
@ -263,8 +279,37 @@ export default {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
resetFormData() {
|
||||||
|
this.AEform.formModel = {};
|
||||||
|
this.mediaTableData = [];
|
||||||
|
this.paymentTableData = [];
|
||||||
|
|
||||||
|
// 更新key强制重新渲染组件
|
||||||
|
this.mediaTableKey = Date.now();
|
||||||
|
this.paymentTableKey = Date.now();
|
||||||
|
this.formKey = Date.now();
|
||||||
|
|
||||||
|
// 重置文件上传组件
|
||||||
|
this.$nextTick(() => {
|
||||||
|
const resetFileUpload = (ref) => {
|
||||||
|
if (ref && ref.setFileList) {
|
||||||
|
ref.setFileList([]);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
resetFileUpload(this.$refs.contractAccess);
|
||||||
|
resetFileUpload(this.$refs.detectPicAttr);
|
||||||
|
resetFileUpload(this.$refs.upPrint);
|
||||||
|
resetFileUpload(this.$refs.nextPrint);
|
||||||
|
resetFileUpload(this.$refs.exchangePrint);
|
||||||
|
resetFileUpload(this.$refs.mediaLink);
|
||||||
|
});
|
||||||
|
},
|
||||||
async getDetailData() {
|
async getDetailData() {
|
||||||
try {
|
try {
|
||||||
|
if (this.$route.query.id) {
|
||||||
|
this.resetFormData()
|
||||||
|
this.currentEditId = this.$route.query.id;
|
||||||
const res = await getAction(`/system/purchase/${this.$route.query.id}`);
|
const res = await getAction(`/system/purchase/${this.$route.query.id}`);
|
||||||
|
|
||||||
// 使用浅拷贝避免深层响应式
|
// 使用浅拷贝避免深层响应式
|
||||||
|
|
@ -309,7 +354,7 @@ export default {
|
||||||
setFileList(this.$refs.exchangePrint, res.data.exchangePrintList);
|
setFileList(this.$refs.exchangePrint, res.data.exchangePrintList);
|
||||||
setFileList(this.$refs.mediaLink, res.data.mediaLinkList);
|
setFileList(this.$refs.mediaLink, res.data.mediaLinkList);
|
||||||
});
|
});
|
||||||
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('获取详情失败:', error);
|
console.error('获取详情失败:', error);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user