修复崩溃问题

This commit is contained in:
wangchengming 2025-11-21 15:52:04 +08:00
parent f81e56e167
commit 7a7d550a77

View File

@ -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);
} }