From 1e128cecfe4c1cb5690f6ac36e506748baf6670a Mon Sep 17 00:00:00 2001 From: wangyu <823267011@qq.com> Date: Fri, 8 May 2026 17:49:43 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E6=8A=A5=E9=94=80/=E6=8B=A8=E6=AC=BE):=20?= =?UTF-8?q?=E5=8F=91=E7=A5=A8=E6=98=8E=E7=BB=86=E4=B8=8E=E9=99=84=E4=BB=B6?= =?UTF-8?q?=E5=8F=8C=E5=90=91=E8=81=94=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 移除手动添加条目按钮,条目只能通过上传文件产生 - 删除附件时同步移除该文件的所有明细条目 - 删除条目时同步从附件列表移除对应文件(含该文件下全部条目) - 无明细时隐藏明细表格区域 Co-Authored-By: Claude Sonnet 4.6 --- .../src/views/hrm/requests/appropriation.vue | 44 ++++++++++++------ ruoyi-ui/src/views/hrm/requests/reimburse.vue | 45 ++++++++++++------- 2 files changed, 60 insertions(+), 29 deletions(-) diff --git a/ruoyi-ui/src/views/hrm/requests/appropriation.vue b/ruoyi-ui/src/views/hrm/requests/appropriation.vue index ff1a3ad..8d47e4d 100644 --- a/ruoyi-ui/src/views/hrm/requests/appropriation.vue +++ b/ruoyi-ui/src/views/hrm/requests/appropriation.vue @@ -54,8 +54,9 @@ -
上传发票、收据、付款截图等(支持 PDF/图片,上传后自动识别)
+ :file-type="['pdf', 'jpg', 'jpeg', 'png', 'doc', 'docx']" multiple + @delete="onFileDelete" /> +
上传发票、收据、付款截图等(支持 PDF/图片,上传后自动识别明细)
@@ -67,9 +68,9 @@
拨款明细 - (上传发票后自动填充,也可手动添加) + (上传发票后自动识别,删除条目将同步移除对应文件)
-
+
事由说明 金额(元) @@ -95,8 +96,7 @@
@@ -350,23 +350,27 @@ export default { try { const res = await ocrAppropriationInvoice(ossId) if (res.code === 200 && res.data) { - const { items, totalAmount } = res.data + const { items, totalAmount, sellerName, invoiceDate, invoiceType } = res.data + // 拼接发票头部信息作为事由前缀:发票类型 · 销售方 · 开票日期 + const prefix = [invoiceType, sellerName, invoiceDate].filter(Boolean).join(' · ') if (items && items.length) { const startIdx = this.invoiceItems.length items.forEach((item, i) => { + const reason = [prefix, item.itemName].filter(Boolean).join(' / ') this.invoiceItems.push({ ossId: Number(ossId), itemName: item.itemName || '', - reason: item.itemName || '', + reason, amount: item.amount || 0, sortNo: startIdx + i }) }) } else if (totalAmount) { + // 没有明细时用总金额创建一条,事由取发票头部信息 this.invoiceItems.push({ ossId: Number(ossId), - itemName: '', - reason: '', + itemName: sellerName || '', + reason: prefix || '', amount: totalAmount, sortNo: this.invoiceItems.length }) @@ -382,12 +386,24 @@ export default { } }, - addInvoiceItem () { - this.invoiceItems.push({ ossId: null, itemName: '', reason: '', amount: 0, sortNo: this.invoiceItems.length }) + removeInvoiceItem (idx) { + const item = this.invoiceItems[idx] + if (item.ossId) { + // 删除该文件下所有条目 + const ossId = String(item.ossId) + this.invoiceItems = this.invoiceItems.filter(it => String(it.ossId) !== ossId) + // 从附件 CSV 中移除该文件 + const ids = (this.form.accessoryApplyIds || '').split(',').filter(id => id && id !== ossId) + this.form.accessoryApplyIds = ids.join(',') + } else { + this.invoiceItems.splice(idx, 1) + } + this.recalcTotal() }, - removeInvoiceItem (idx) { - this.invoiceItems.splice(idx, 1) + onFileDelete (deletedFile) { + const ossId = String(deletedFile.ossId) + this.invoiceItems = this.invoiceItems.filter(item => String(item.ossId) !== ossId) this.recalcTotal() }, diff --git a/ruoyi-ui/src/views/hrm/requests/reimburse.vue b/ruoyi-ui/src/views/hrm/requests/reimburse.vue index 06036c8..db46c9e 100644 --- a/ruoyi-ui/src/views/hrm/requests/reimburse.vue +++ b/ruoyi-ui/src/views/hrm/requests/reimburse.vue @@ -54,8 +54,9 @@ -
上传发票、收据、付款截图等(支持 PDF/图片,上传后自动识别)
+ :file-type="['pdf', 'jpg', 'jpeg', 'png', 'doc', 'docx']" multiple + @delete="onFileDelete" /> +
上传发票、收据、付款截图等(支持 PDF/图片,上传后自动识别明细)
@@ -67,9 +68,9 @@
发票明细 - (上传发票后自动填充,也可手动添加) + (上传发票后自动识别,删除条目将同步移除对应文件)
-
+
事由说明 金额(元) @@ -95,8 +96,7 @@
@@ -325,24 +325,27 @@ export default { try { const res = await ocrReimburseInvoice(ossId) if (res.code === 200 && res.data) { - const { items, totalAmount } = res.data + const { items, totalAmount, sellerName, invoiceDate, invoiceType } = res.data + // 拼接发票头部信息作为事由前缀:发票类型 · 销售方 · 开票日期 + const prefix = [invoiceType, sellerName, invoiceDate].filter(Boolean).join(' · ') if (items && items.length) { const startIdx = this.invoiceItems.length items.forEach((item, i) => { + const reason = [prefix, item.itemName].filter(Boolean).join(' / ') this.invoiceItems.push({ ossId: Number(ossId), itemName: item.itemName || '', - reason: item.itemName || '', + reason, amount: item.amount || 0, sortNo: startIdx + i }) }) } else if (totalAmount) { - // 没有明细时用总金额创建一条 + // 没有明细时用总金额创建一条,事由取发票头部信息 this.invoiceItems.push({ ossId: Number(ossId), - itemName: '', - reason: '', + itemName: sellerName || '', + reason: prefix || '', amount: totalAmount, sortNo: this.invoiceItems.length }) @@ -358,12 +361,24 @@ export default { } }, - addInvoiceItem () { - this.invoiceItems.push({ ossId: null, itemName: '', reason: '', amount: 0, sortNo: this.invoiceItems.length }) + removeInvoiceItem (idx) { + const item = this.invoiceItems[idx] + if (item.ossId) { + // 删除该文件下所有条目 + const ossId = String(item.ossId) + this.invoiceItems = this.invoiceItems.filter(it => String(it.ossId) !== ossId) + // 从附件 CSV 中移除该文件 + const ids = (this.form.accessoryApplyIds || '').split(',').filter(id => id && id !== ossId) + this.form.accessoryApplyIds = ids.join(',') + } else { + this.invoiceItems.splice(idx, 1) + } + this.recalcTotal() }, - removeInvoiceItem (idx) { - this.invoiceItems.splice(idx, 1) + onFileDelete (deletedFile) { + const ossId = String(deletedFile.ossId) + this.invoiceItems = this.invoiceItems.filter(item => String(item.ossId) !== ossId) this.recalcTotal() },