修复崩溃问题
This commit is contained in:
parent
f81e56e167
commit
7a7d550a77
|
|
@ -215,6 +215,8 @@ export default {
|
|||
},
|
||||
data() {
|
||||
return {
|
||||
// 当前编辑的ID
|
||||
currentEditId: null,
|
||||
formGroup,
|
||||
AEform: {
|
||||
formModel: {
|
||||
|
|
@ -242,12 +244,26 @@ export default {
|
|||
this.getMediaType();
|
||||
const rawData = await cityDataCache.getCityData();
|
||||
this.cityList = Object.freeze(rawData);
|
||||
|
||||
if (this.$route.query.id) {
|
||||
this.getDetailData()
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
if (this.$route.query.id) {
|
||||
this.getDetailData()
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
'$route.query.id': {
|
||||
immediate: true,
|
||||
handler(newId) {
|
||||
if (newId !== this.currentEditId) {
|
||||
this.getDetailData();
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
contractMoney() {
|
||||
// 使用非响应式方式计算
|
||||
|
|
@ -263,8 +279,37 @@ export default {
|
|||
},
|
||||
},
|
||||
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() {
|
||||
try {
|
||||
if (this.$route.query.id) {
|
||||
this.resetFormData()
|
||||
this.currentEditId = 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.mediaLink, res.data.mediaLinkList);
|
||||
});
|
||||
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取详情失败:', error);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user