|
@@ -244,8 +244,8 @@ export default {
|
|
|
|
|
|
|
|
],
|
|
],
|
|
|
uniqueId: "",
|
|
uniqueId: "",
|
|
|
- allFiles: []
|
|
|
|
|
-
|
|
|
|
|
|
|
+ allFiles: [],
|
|
|
|
|
+ invoiceNoSet: new Set(), // 已存在的发票号
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
watch: {
|
|
watch: {
|
|
@@ -328,7 +328,7 @@ export default {
|
|
|
} else {
|
|
} else {
|
|
|
const tempFiles = fileList.filter(item => item.remarks == uniqueId);
|
|
const tempFiles = fileList.filter(item => item.remarks == uniqueId);
|
|
|
this.dataListLength = tempFiles.length
|
|
this.dataListLength = tempFiles.length
|
|
|
- this.allFiles = fileList
|
|
|
|
|
|
|
+ // this.allFiles = fileList
|
|
|
}
|
|
}
|
|
|
if (this.commonJS.isEmpty(dividerName)) {
|
|
if (this.commonJS.isEmpty(dividerName)) {
|
|
|
this.dividerName = '数电发票信息'
|
|
this.dividerName = '数电发票信息'
|
|
@@ -461,28 +461,35 @@ export default {
|
|
|
this.$message.error('只能上传 XML 文件');
|
|
this.$message.error('只能上传 XML 文件');
|
|
|
return false; // 取消上传
|
|
return false; // 取消上传
|
|
|
}
|
|
}
|
|
|
- // else {
|
|
|
|
|
- // try {
|
|
|
|
|
- //对上传的xml文件信息进行处理并通过后端接口进行解析返回到父页面进行调整
|
|
|
|
|
- // const formBody = new FormData()
|
|
|
|
|
- // formBody.append('file', file)
|
|
|
|
|
- // await this.ossService.disposeXmlFile(formBody).then((data) => {
|
|
|
|
|
- // if (JSON.stringify(data) === "{}") {
|
|
|
|
|
- // this.$message.warning('数电发票:' + file.name + '格式错误');
|
|
|
|
|
- // this.loading = false;
|
|
|
|
|
- // // 在验证失败时删除已经添加的行
|
|
|
|
|
- // const index = this.fileList.findIndex(item => item.name === file.name);
|
|
|
|
|
- // if (index !== -1) {
|
|
|
|
|
- // this.deleteFileById(this.fileList[index], index, this.fileList);
|
|
|
|
|
- // }
|
|
|
|
|
- // }
|
|
|
|
|
- // })
|
|
|
|
|
- // } catch (error) {
|
|
|
|
|
- // console.error(error);
|
|
|
|
|
- // }
|
|
|
|
|
- // }
|
|
|
|
|
- // 其他判定逻辑...
|
|
|
|
|
- return true; // 允许上传
|
|
|
|
|
|
|
+
|
|
|
|
|
+ const formBody = new FormData()
|
|
|
|
|
+ formBody.append('file', file)
|
|
|
|
|
+ let res
|
|
|
|
|
+ try {
|
|
|
|
|
+ // 后端解析
|
|
|
|
|
+ res = await this.ossService.disposeXmlFile(formBody)
|
|
|
|
|
+ } catch (e) {
|
|
|
|
|
+ this.$message.error('发票文件解析失败')
|
|
|
|
|
+ return false
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 取发票号
|
|
|
|
|
+ const invoiceNo = res?.InvoiceNumber
|
|
|
|
|
+ if (!invoiceNo) {
|
|
|
|
|
+ this.$message.warning('发票文件解析失败')
|
|
|
|
|
+ return false
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 去重
|
|
|
|
|
+ if (this.invoiceNoSet.has(invoiceNo)) {
|
|
|
|
|
+ this.$message.warning({ message: `数电发票:${file.name + "<br/>发票号:" + invoiceNo}<br/>已经上传,请勿重复上传`, dangerouslyUseHTMLString: true });
|
|
|
|
|
+
|
|
|
|
|
+ return false
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 记录发票号
|
|
|
|
|
+ this.invoiceNoSet.add(invoiceNo)
|
|
|
|
|
+ return true
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
uploadVideoProcess(event, file, fileList) {
|
|
uploadVideoProcess(event, file, fileList) {
|
|
@@ -599,7 +606,6 @@ export default {
|
|
|
},
|
|
},
|
|
|
async changes(file, fileList) {
|
|
async changes(file, fileList) {
|
|
|
if (file.status == 'ready') return //阻止上传多次触发changes
|
|
if (file.status == 'ready') return //阻止上传多次触发changes
|
|
|
-
|
|
|
|
|
try {
|
|
try {
|
|
|
this.uploadKey = Math.random();
|
|
this.uploadKey = Math.random();
|
|
|
// 2. 文件大小检查
|
|
// 2. 文件大小检查
|
|
@@ -612,23 +618,24 @@ export default {
|
|
|
const fileBody = new FormData();
|
|
const fileBody = new FormData();
|
|
|
fileBody.append('file', file.raw);
|
|
fileBody.append('file', file.raw);
|
|
|
const fileData = await this.ossService.disposeXmlFile(fileBody);
|
|
const fileData = await this.ossService.disposeXmlFile(fileBody);
|
|
|
|
|
+
|
|
|
//判断文件是否重复
|
|
//判断文件是否重复
|
|
|
let fileIndex = this.dataList.findIndex(fileItem => {
|
|
let fileIndex = this.dataList.findIndex(fileItem => {
|
|
|
return fileItem.number == fileData.InvoiceNumber
|
|
return fileItem.number == fileData.InvoiceNumber
|
|
|
})
|
|
})
|
|
|
if (fileIndex != -1) {
|
|
if (fileIndex != -1) {
|
|
|
- // 记录重复文件名
|
|
|
|
|
- const formBody = new FormData();
|
|
|
|
|
- formBody.append('file', file.raw);
|
|
|
|
|
- const data1 = await this.ossService.disposeXmlFile(formBody);
|
|
|
|
|
|
|
+ // // 记录重复文件名
|
|
|
|
|
+ // const formBody = new FormData();
|
|
|
|
|
+ // formBody.append('file', file.raw);
|
|
|
|
|
+ // const data1 = await this.ossService.disposeXmlFile(formBody);
|
|
|
|
|
|
|
|
- if (JSON.stringify(data1) === "{}") {
|
|
|
|
|
|
|
+ if (JSON.stringify(fileData) === "{}") {
|
|
|
this.$message.warning({ message: `数电发票:${file.raw.name}格式错误` });
|
|
this.$message.warning({ message: `数电发票:${file.raw.name}格式错误` });
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- if (this.commonJS.isNotEmpty(data1.InvoiceNumber)) {
|
|
|
|
|
- this.$message.warning({ message: `数电发票:${fileName + "<br/>发票号:" + data1.InvoiceNumber}<br/>已经上传,请勿重复上传`, dangerouslyUseHTMLString: true });
|
|
|
|
|
|
|
+ if (this.commonJS.isNotEmpty(fileData.InvoiceNumber)) {
|
|
|
|
|
+ this.$message.warning({ message: `数电发票:${fileName + "<br/>发票号:" + fileData.InvoiceNumber}<br/>已经上传,请勿重复上传`, dangerouslyUseHTMLString: true });
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -666,46 +673,46 @@ export default {
|
|
|
// 仅处理 XML 文件
|
|
// 仅处理 XML 文件
|
|
|
if (file.raw.name && file.raw.name.toLowerCase().endsWith(".xml")) {
|
|
if (file.raw.name && file.raw.name.toLowerCase().endsWith(".xml")) {
|
|
|
// 创建 FormData 对象并发送文件
|
|
// 创建 FormData 对象并发送文件
|
|
|
- const formBody = new FormData();
|
|
|
|
|
- formBody.append('file', file.raw);
|
|
|
|
|
|
|
+ // const formBody = new FormData();
|
|
|
|
|
+ // formBody.append('file', file.raw);
|
|
|
// 调用后端接口解析 XML 文件
|
|
// 调用后端接口解析 XML 文件
|
|
|
- let data2 = await this.ossService.disposeXmlFile(formBody);
|
|
|
|
|
- if (JSON.stringify(data2) === "{}") {
|
|
|
|
|
|
|
+ // let data2 = await this.ossService.disposeXmlFile(formBody);
|
|
|
|
|
+ if (JSON.stringify(fileData) === "{}") {
|
|
|
this.$message.warning({ message: `数电发票:${file.raw.name}格式错误` });
|
|
this.$message.warning({ message: `数电发票:${file.raw.name}格式错误` });
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
- if (Object.keys(data2).length > 0) {
|
|
|
|
|
- this.fieldComparison(data2, this.fileLabel);
|
|
|
|
|
|
|
+ if (Object.keys(fileData).length > 0) {
|
|
|
|
|
+ this.fieldComparison(fileData, this.fileLabel);
|
|
|
// 检查 data 是否包含 BuyerInformationBuyerName 属性
|
|
// 检查 data 是否包含 BuyerInformationBuyerName 属性
|
|
|
- if (data2 && 'BuyerInformationBuyerName' in data2) {
|
|
|
|
|
|
|
+ if (fileData && 'BuyerInformationBuyerName' in fileData) {
|
|
|
// 验证是否有效,并进行替换操作
|
|
// 验证是否有效,并进行替换操作
|
|
|
- if (typeof data2.BuyerInformationBuyerName === 'string') {
|
|
|
|
|
- var buyerInformationBuyerName = data2.BuyerInformationBuyerName
|
|
|
|
|
|
|
+ if (typeof fileData.BuyerInformationBuyerName === 'string') {
|
|
|
|
|
+ var buyerInformationBuyerName = fileData.BuyerInformationBuyerName
|
|
|
.replace(/(/g, '(')
|
|
.replace(/(/g, '(')
|
|
|
.replace(/)/g, ')');
|
|
.replace(/)/g, ')');
|
|
|
- data2.BuyerInformationBuyerName = buyerInformationBuyerName
|
|
|
|
|
|
|
+ fileData.BuyerInformationBuyerName = buyerInformationBuyerName
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- if (this.toCompany !== data2.BuyerInformationBuyerName) {
|
|
|
|
|
- this.$message.warning({ message: `仅可上传${this.toCompany}的报销数电发票:<br/>${"文件名: " + file.raw.name + "—— 发票号:" + data2.InvoiceNumber}<br>上传失败 `, dangerouslyUseHTMLString: true });
|
|
|
|
|
|
|
+ if (this.toCompany !== fileData.BuyerInformationBuyerName) {
|
|
|
|
|
+ this.$message.warning({ message: `仅可上传${this.toCompany}的报销数电发票:<br/>${"文件名: " + file.raw.name + "—— 发票号:" + fileData.InvoiceNumber}<br>上传失败 `, dangerouslyUseHTMLString: true });
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
- if (this.commonJS.isNotEmpty(data2.InvoiceNumber)) {
|
|
|
|
|
- var flag = this.invoiceReimbursementDispose(data2)
|
|
|
|
|
|
|
+ if (this.commonJS.isNotEmpty(fileData.InvoiceNumber)) {
|
|
|
|
|
+ var flag = this.invoiceReimbursementDispose(fileData)
|
|
|
if (flag) {
|
|
if (flag) {
|
|
|
- this.$message.warning({ message: `数电发票:${file.raw.name + "-" + data2.InvoiceNumber}<br/>已经上传,请勿重复上传`, dangerouslyUseHTMLString: true });
|
|
|
|
|
|
|
+ this.$message.warning({ message: `数电发票:${file.raw.name + "-" + fileData.InvoiceNumber}<br/>已经上传,请勿重复上传`, dangerouslyUseHTMLString: true });
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
//查询当前发票号是否已经被报销
|
|
//查询当前发票号是否已经被报销
|
|
|
- let isUsed = await this.ossService.isUsedByInvoiceNumber(data2.InvoiceNumber);
|
|
|
|
|
|
|
+ let isUsed = await this.ossService.isUsedByInvoiceNumber(fileData.InvoiceNumber);
|
|
|
if (isUsed) {
|
|
if (isUsed) {
|
|
|
- this.$message.warning({ message: `数电发票:${file.raw.name + "<br/> 发票号:" + data2.InvoiceNumber}<br/>已经发起或已完成报销,无法重复报销`, dangerouslyUseHTMLString: true });
|
|
|
|
|
|
|
+ this.$message.warning({ message: `数电发票:${file.raw.name + "<br/> 发票号:" + fileData.InvoiceNumber}<br/>已经发起或已完成报销,无法重复报销`, dangerouslyUseHTMLString: true });
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
- let inDate = this.formatDate(data2.IssueTime)
|
|
|
|
|
|
|
+ let inDate = this.formatDate(fileData.IssueTime)
|
|
|
if (inDate.indexOf("NaN") != -1 && this.commonJS.isNotEmpty(inDate)) {
|
|
if (inDate.indexOf("NaN") != -1 && this.commonJS.isNotEmpty(inDate)) {
|
|
|
- this.$message.warning({ message: `数电发票:${file.raw.name + "<br/> 发票号:" + data2.InvoiceNumber}<br/>日期格式错误,上传失败。`, dangerouslyUseHTMLString: true });
|
|
|
|
|
|
|
+ this.$message.warning({ message: `数电发票:${file.raw.name + "<br/> 发票号:" + fileData.InvoiceNumber}<br/>日期格式错误,上传失败。`, dangerouslyUseHTMLString: true });
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -714,11 +721,10 @@ export default {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
// let obj = this.allFiles.find(tempFile => {
|
|
// let obj = this.allFiles.find(tempFile => {
|
|
|
-
|
|
|
|
|
// return tempFile.number == fileData.InvoiceNumber
|
|
// return tempFile.number == fileData.InvoiceNumber
|
|
|
// })
|
|
// })
|
|
|
// if (obj) {
|
|
// if (obj) {
|
|
|
- // this.$message.warning({ message: `数电发票:${file.name}<br/>已经上传,请勿重复上传3`, dangerouslyUseHTMLString: true });
|
|
|
|
|
|
|
+ // this.$message.warning({ message: `数电发票:${file.name}<br/>已经上传,请勿重复上传`, dangerouslyUseHTMLString: true });
|
|
|
// return
|
|
// return
|
|
|
// }
|
|
// }
|
|
|
|
|
|
|
@@ -730,7 +736,6 @@ export default {
|
|
|
this.fileList.push(file)
|
|
this.fileList.push(file)
|
|
|
this.dataList = this.dataListNew
|
|
this.dataList = this.dataListNew
|
|
|
|
|
|
|
|
-
|
|
|
|
|
// 清空 fileList,如果 fileList 不为空
|
|
// 清空 fileList,如果 fileList 不为空
|
|
|
if (fileList && fileList.length > 0) {
|
|
if (fileList && fileList.length > 0) {
|
|
|
this.fileList = [];
|
|
this.fileList = [];
|
|
@@ -916,6 +921,7 @@ export default {
|
|
|
|
|
|
|
|
},
|
|
},
|
|
|
deleteFileById(row, index, fileList) {
|
|
deleteFileById(row, index, fileList) {
|
|
|
|
|
+ this.invoiceNoSet.delete(row.number)
|
|
|
// this.$refs.upload.handleRemove(this.dataListNew[index])
|
|
// this.$refs.upload.handleRemove(this.dataListNew[index])
|
|
|
this.dataListNew.splice(index, 1)
|
|
this.dataListNew.splice(index, 1)
|
|
|
|
|
|