|
|
|
@ -171,7 +171,7 @@ export default {
|
|
|
|
|
form: {
|
|
|
|
|
...this.qyrzInfo
|
|
|
|
|
},
|
|
|
|
|
tableData: [], // 初始化为空数组
|
|
|
|
|
tableData: [],
|
|
|
|
|
pagination: {
|
|
|
|
|
currentPage: 1,
|
|
|
|
|
pageSize: 10,
|
|
|
|
@ -192,7 +192,7 @@ export default {
|
|
|
|
|
};
|
|
|
|
|
},
|
|
|
|
|
created() {
|
|
|
|
|
this.fetchTableData(); // 仅加载数据,不主动保存
|
|
|
|
|
this.fetchTableData();
|
|
|
|
|
},
|
|
|
|
|
methods: {
|
|
|
|
|
async fetchTableData() {
|
|
|
|
@ -202,21 +202,19 @@ export default {
|
|
|
|
|
this.tableData = response.data.records.map(item => ({ ...item, isEditing: false }));
|
|
|
|
|
this.pagination.total = response.data.total;
|
|
|
|
|
|
|
|
|
|
// 数据加载完成后,更新 form.rzqys 并通知父组件
|
|
|
|
|
// 更新 form.rzqys
|
|
|
|
|
this.form.rzqys = this.tableData.length;
|
|
|
|
|
this.$emit('update-data', { ...this.form }); // 确保传递完整数据
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error('获取数据失败:', error);
|
|
|
|
|
}
|
|
|
|
|
this.$emit('update-data', { ...this.form });
|
|
|
|
|
} catch (error) {}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
watch: {
|
|
|
|
|
qyrzInfo: {
|
|
|
|
|
handler(newVal) {
|
|
|
|
|
// 仅合并父组件传入的字段,保留子组件自己的状态(如 tableData 生成的 rzqys)
|
|
|
|
|
//(如 tableData 生成的 rzqys)
|
|
|
|
|
this.form = {
|
|
|
|
|
...newVal,
|
|
|
|
|
rzqys: this.tableData.length // 优先使用本地计算的 rzqys
|
|
|
|
|
rzqys: this.tableData.length //rzqys
|
|
|
|
|
};
|
|
|
|
|
},
|
|
|
|
|
immediate: true,
|
|
|
|
@ -232,12 +230,10 @@ export default {
|
|
|
|
|
size: this.pagination.pageSize
|
|
|
|
|
};
|
|
|
|
|
return getqyBasicInformationPage(params).then(response => {
|
|
|
|
|
// console.log('Fetched Data:', response.data.records);
|
|
|
|
|
this.tableData = response.data.records.map(item => ({
|
|
|
|
|
...item,
|
|
|
|
|
isEditing: false
|
|
|
|
|
}));
|
|
|
|
|
// console.log('Table Data:', this.tableData);
|
|
|
|
|
this.pagination.total = response.data.total;
|
|
|
|
|
}).catch();
|
|
|
|
|
},
|
|
|
|
@ -270,7 +266,6 @@ export default {
|
|
|
|
|
updateqyBasicInformation(row).then(response => {
|
|
|
|
|
this.$modal.msgSuccess('保存成功');
|
|
|
|
|
}).catch(error => {
|
|
|
|
|
console.error('保存失败:', error);
|
|
|
|
|
this.$modal.msgError('保存失败');
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
@ -279,15 +274,11 @@ export default {
|
|
|
|
|
deleteqyBasicInformation([id]).then(response => {
|
|
|
|
|
this.$modal.msgSuccess('删除成功');
|
|
|
|
|
this.tableData.splice(index, 1);
|
|
|
|
|
// 重新获取表格数据以确保分页正确
|
|
|
|
|
this.fetchTableData().then(() => {
|
|
|
|
|
// 更新 form 数据
|
|
|
|
|
this.form.rzqys = this.tableData.length;
|
|
|
|
|
// 调用 save 方法发送最新的数据
|
|
|
|
|
this.save();
|
|
|
|
|
});
|
|
|
|
|
}).catch(error => {
|
|
|
|
|
console.error('删除失败:', error);
|
|
|
|
|
this.$modal.msgError('删除失败');
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
@ -331,7 +322,7 @@ export default {
|
|
|
|
|
this.$modal.msgWarning("请先选择文件");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
// 将 xmId 添加到请求参数中
|
|
|
|
|
// xmId 请求参数
|
|
|
|
|
const formData = new FormData();
|
|
|
|
|
formData.append('file', this.$refs.upload.uploadFiles[0].raw);
|
|
|
|
|
formData.append('xmId', this.upload.data.xmId);
|
|
|
|
|