fix(order): 统一文件排序字段类型为字符串

- 将 contractTableData 中的 fileSort 字段统一改为字符串类型
- 修改上传文件时的 fileSort 赋值逻辑,确保类型一致性
- 更新文件查找逻辑,使用 == 进行比较以兼容字符串和数字类型
- 修复上传输入框点击事件中的 sortNum 类型处理
- 确保所有版本 tab 初始化时 fileSort 使用字符串值
master
chenhao 2025-12-03 10:36:41 +08:00
parent 357010e7ee
commit 65fc038b7c
1 changed files with 10 additions and 10 deletions

View File

@ -372,12 +372,12 @@ export default {
const files = this.form.contractTableData[currentVersion]; const files = this.form.contractTableData[currentVersion];
const existingSorts = new Set(files.map(f => String(f.fileSort))); const existingSorts = new Set(files.map(f => String(f.fileSort)));
if (this.canUpdate) { if (this.canUpdate) {
if (!existingSorts.has('0')) files.push({id: -1, fileSort: 0}); if (!existingSorts.has('0')) files.push({id: -1, fileSort: "0"});
if (!existingSorts.has('1')) files.push({id: -1, fileSort: 1}); if (!existingSorts.has('1')) files.push({id: -1, fileSort: "1"});
if (!existingSorts.has('2')) files.push({id: -1, fileSort: 2}); if (!existingSorts.has('2')) files.push({id: -1, fileSort: "2"});
} }
if (this.uploadFinalFile) { if (this.uploadFinalFile) {
if (!existingSorts.has('3')) files.push({id: -1, fileSort: 3}); if (!existingSorts.has('3')) files.push({id: -1, fileSort: "3"});
} }
if (this.uniqueVersions.length > 0) this.activeVersionTab = String(this.uniqueVersions[0]); if (this.uniqueVersions.length > 0) this.activeVersionTab = String(this.uniqueVersions[0]);
@ -393,9 +393,9 @@ export default {
const currentVersion = String(this.form.versionCode); const currentVersion = String(this.form.versionCode);
this.$set(this.form, 'contractTableData', { this.$set(this.form, 'contractTableData', {
[currentVersion]: [ [currentVersion]: [
{ id: -1, fileSort: 0 }, { id: -1, fileSort: "0" },
{ id: -1, fileSort: 1 }, { id: -1, fileSort: "1" },
{ id: -1, fileSort: 2 } { id: -1, fileSort: "2" }
] ]
}); });
this.activeContractVersionTab = currentVersion; this.activeContractVersionTab = currentVersion;
@ -565,12 +565,12 @@ export default {
this.$modal.alertWarning("请先保存订单,再上传合同信息"); this.$modal.alertWarning("请先保存订单,再上传合同信息");
return; return;
} }
this.fileSort = sortNum; this.fileSort = String(sortNum);
document.getElementById(`uploadInput${sortNum > 1 ? 2 : sortNum}`).click(); document.getElementById(`uploadInput${sortNum > 1 ? 2 : sortNum}`).click();
}, },
addFile(data) { addFile(data) {
const currentVersionFiles = this.groupedContractFiles[String(this.form.versionCode)].files; const currentVersionFiles = this.groupedContractFiles[String(this.form.versionCode)].files;
const fileIndex = currentVersionFiles.findIndex(file => file.fileSort === data.fileSort); const fileIndex = currentVersionFiles.findIndex(file => file.fileSort == data.fileSort);
if (fileIndex !== -1) this.$set(currentVersionFiles, fileIndex, data); if (fileIndex !== -1) this.$set(currentVersionFiles, fileIndex, data);
else currentVersionFiles.push(data); else currentVersionFiles.push(data);
}, },
@ -581,7 +581,7 @@ export default {
const currentVersionFiles = this.groupedContractFiles[String(this.activeContractVersionTab)].files; const currentVersionFiles = this.groupedContractFiles[String(this.activeContractVersionTab)].files;
const fileIndex = currentVersionFiles.findIndex(file => file.id === id); const fileIndex = currentVersionFiles.findIndex(file => file.id === id);
if (fileIndex !== -1) { if (fileIndex !== -1) {
this.$set(currentVersionFiles, fileIndex, { id: -1, fileSort: sortNum }); this.$set(currentVersionFiles, fileIndex, { id: -1, fileSort: String(sortNum) });
} }
}); });
}); });