소스 검색

报销删除xml后汇总金额不变

huangguoce 7 시간 전
부모
커밋
3f29d08327
2개의 변경된 파일50개의 추가작업 그리고 54개의 파일을 삭제
  1. 49 52
      src/views/common/NewDigitalInvoiceUploadComponent.vue
  2. 1 2
      src/views/common/reimbursement/ReimbursementComponent.vue

+ 49 - 52
src/views/common/NewDigitalInvoiceUploadComponent.vue

@@ -614,12 +614,6 @@ export default {
 				const fileData = await this.ossService.disposeXmlFile(fileBody);
 				//判断文件是否重复
 				let fileIndex = this.dataList.findIndex(fileItem => {
-					console.log(fileItem.number, fileData.InvoiceNumber);
-					console.log(fileItem.number, fileData.InvoiceNumber);
-					console.log(fileItem.number, fileData.InvoiceNumber);
-					console.log(fileItem.number, fileData.InvoiceNumber);
-					console.log(fileItem.number, fileData.InvoiceNumber);
-
 					return fileItem.number == fileData.InvoiceNumber
 				})
 				if (fileIndex != -1) {
@@ -719,13 +713,14 @@ export default {
 						}
 					}
 				}
-				let obj = this.allFiles.find(tempFile => {
-					return tempFile.name == file.name
-				})
-				if (obj) {
-					this.$message.warning({ message: `数电发票:${file.name}<br/>已经上传,请勿重复上传`, dangerouslyUseHTMLString: true });
-					return
-				}
+				// let obj = this.allFiles.find(tempFile => {
+
+				// 	return tempFile.number == fileData.InvoiceNumber
+				// })
+				// if (obj) {
+				// 	this.$message.warning({ message: `数电发票:${file.name}<br/>已经上传,请勿重复上传3`, dangerouslyUseHTMLString: true });
+				// 	return
+				// }
 
 
 
@@ -796,13 +791,13 @@ export default {
 
 				// 如果没有找到匹配的字段,抛出错误
 				if (matchedKeys.length === 0) {
-					if(!field.includes("UndefinedLabel")){
+					if (!field.includes("UndefinedLabel")) {
 						throw new Error(`未找到发票字段: ${field},请核对XML文件`)
 					}
 				}
 				// 替换属性名
 				for (let key of matchedKeys) {
-					if(!field.includes("UndefinedLabel")) {
+					if (!field.includes("UndefinedLabel")) {
 						if (key !== field) {
 							obj[field] = obj[key];
 							delete obj[key];
@@ -817,51 +812,53 @@ export default {
 			// 遍历当前的数据列表
 			if (this.dataListNew.length > 0) {
 				for (let item of this.dataListNew) {
+					if (file.number == item.number) {
+						// 如果 item.raw 存在且有效
+						if (item.raw !== undefined && item.raw !== null && item.raw !== {}) {
+							// 设置文件的 URL
+							item.url = item.raw.url;
 
-					// 如果 item.raw 存在且有效
-					if (item.raw !== undefined && item.raw !== null && item.raw !== {}) {
-						// 设置文件的 URL
-						item.url = item.raw.url;
-
-						// 仅处理 XML 文件
-						if (item.raw.name && item.raw.name.toLowerCase().endsWith(".xml")) {
-							// 创建 FormData 对象并发送文件
-							const formBody = new FormData();
-							formBody.append('file', item.raw);
+							// 仅处理 XML 文件
+							if (item.raw.name && item.raw.name.toLowerCase().endsWith(".xml")) {
+								// 创建 FormData 对象并发送文件
+								const formBody = new FormData();
+								formBody.append('file', item.raw);
 
-							try {
-								// 调用后端接口解析 XML 文件
-								let data = await this.ossService.disposeXmlFile(formBody);
-								// 检查 data 是否包含 BuyerInformationBuyerName 属性
-								if (data && 'BuyerInformationBuyerName' in data) {
-									this.fieldComparison(data, this.fileLabel);
-									// 验证是否有效,并进行替换操作
-									if (typeof data.BuyerInformationBuyerName === 'string') {
-										var buyerInformationBuyerName = data.BuyerInformationBuyerName
-											.replace(/(/g, '(')
-											.replace(/)/g, ')');
-										data.BuyerInformationBuyerName = buyerInformationBuyerName
+								try {
+									// 调用后端接口解析 XML 文件
+									let data = await this.ossService.disposeXmlFile(formBody);
+									// 检查 data 是否包含 BuyerInformationBuyerName 属性
+									if (data && 'BuyerInformationBuyerName' in data) {
+										this.fieldComparison(data, this.fileLabel);
+										// 验证是否有效,并进行替换操作
+										if (typeof data.BuyerInformationBuyerName === 'string') {
+											var buyerInformationBuyerName = data.BuyerInformationBuyerName
+												.replace(/(/g, '(')
+												.replace(/)/g, ')');
+											data.BuyerInformationBuyerName = buyerInformationBuyerName
+										}
 									}
-								}
 
-								if (Object.keys(data).length > 0) {
-									// 解析成功,更新数据行
-									await this.invoiceReimbursementDisposeData(data, item);
+									if (Object.keys(data).length > 0) {
+										// 解析成功,更新数据行
+										await this.invoiceReimbursementDisposeData(data, item);
+									}
+									// else {
+									// 	// XML 格式错误,删除文件
+									// 	this.$message.warning('上传的数电发票格式错误');
+									// 	const index = this.fileList.findIndex(f => f.name === item.name);
+									// 	if (index !== -1) {
+									// 		this.deleteFileById(this.fileList[index], index, this.fileList);
+									// 	}
+									// }
+								} catch (error) {
+									this.$message.error('处理 XML 文件失败');
+									console.log('XML 处理失败', error);
 								}
-								// else {
-								// 	// XML 格式错误,删除文件
-								// 	this.$message.warning('上传的数电发票格式错误');
-								// 	const index = this.fileList.findIndex(f => f.name === item.name);
-								// 	if (index !== -1) {
-								// 		this.deleteFileById(this.fileList[index], index, this.fileList);
-								// 	}
-								// }
-							} catch (error) {
-								this.$message.error('处理 XML 文件失败');
-								console.log('XML 处理失败', error);
 							}
 						}
 					}
+
 				}
 
 				// 更新表格数据

+ 1 - 2
src/views/common/reimbursement/ReimbursementComponent.vue

@@ -3153,7 +3153,7 @@ export default {
                 if (item.uniqueId == uniqueId) {
                     if (item.number) {
                         item.number = (parseFloat(item.number) - parseFloat(row.count)).toFixed(2)
-                        // this.handleOrdinaryNumberInput(item, 1)
+                        this.handleOrdinaryNumberInput(item, 1)
                     }
 
                 }
@@ -3277,7 +3277,6 @@ export default {
 
                 let count = parseFloat(Number(row.number || 0) + Number(row.ordinaryNumber || 0) + Number(row.subsidy || 0)).toFixed(2)
                 if (!isNaN(count)) {
-
                     row.numberCount = count
                     this.handleTableInfo(this.inputForm.sourceType)
                     this.tableRef.updateFooter(this.tableData)