From d11e80011a2fd5d07e0299c7438fe82d04bf0fac Mon Sep 17 00:00:00 2001 From: Harry Yang Date: Tue, 3 Jan 2023 17:16:14 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BE=9B=E5=BA=94=E5=95=86=E6=AF=94=E9=80=89?= =?UTF-8?q?=E6=9D=90=E6=96=99=20=E9=99=84=E4=BB=B6=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../templates/admin/business/process-edit.ftl | 41 +++++++++++--- .../templates/admin/business/process-new.ftl | 56 ++++++++++++------- 2 files changed, 68 insertions(+), 29 deletions(-) diff --git a/src/main/resources/templates/admin/business/process-edit.ftl b/src/main/resources/templates/admin/business/process-edit.ftl index ee007bd..dcb7fb1 100644 --- a/src/main/resources/templates/admin/business/process-edit.ftl +++ b/src/main/resources/templates/admin/business/process-edit.ftl @@ -297,11 +297,26 @@ 上传附件 + + + 上传附件 + <#--展示已经上传的文件--> +
+ + + {{attachment.name}} + + +
+ 暂未上传 +
@@ -551,6 +566,7 @@ } const methods = { + isNotEmpty, changeMode(mode) { this.mode = mode }, @@ -918,13 +934,6 @@ return ret } - const mapAttachment = attachments => { - return attachments && JSON.stringify(attachments.map(file => ({ - uri: file.response.data.url, - name: file.response.data.originName - }))) - } - const form = { ...processForm, processType, @@ -947,7 +956,7 @@ details: computePurchaseAmountDetail(detail.budgetCostId) })), supplierMaterials: supplierMaterialsForm.filter(hasProperties).map(item => ({ - ...item, attachment: mapAttachment(item.attachment) + ...item, attachment: JSON.stringify(item.attachment) })), } @@ -1036,6 +1045,10 @@ scope.row['attachment'] = fileList }, + removeSupplierMaterialAttachment(scope, attachmentToRemove) { + scope.row['attachment'] = scope.row['attachment'].filter(item => item === attachmentToRemove) + }, + handleSupplierMaterialExceed(scope, files, fileList) { this.$message.warning("当前限制选择只能选择10个文件"); scope.row['attachment'] = fileList @@ -1051,7 +1064,17 @@ handleSupplierMaterialFileUploaded(scope, response, file, fileList) { if (response.success) { - scope.row['attachment'] = fileList + let attachments = scope.row['attachment'] + if (isEmpty(attachments)) { + attachments = [] + scope.row['attachment'] = attachments + } + attachments.push({ + uri: response.data.url, + name: file.name + }) + + this.$message.success("上传成功"); } else { this.$message.warning("上传失败"); diff --git a/src/main/resources/templates/admin/business/process-new.ftl b/src/main/resources/templates/admin/business/process-new.ftl index 9103450..ec70c0f 100644 --- a/src/main/resources/templates/admin/business/process-new.ftl +++ b/src/main/resources/templates/admin/business/process-new.ftl @@ -409,19 +409,27 @@ @@ -680,6 +688,7 @@ isEmpty, isBlank, hasText, + isNotEmpty, changeMode(mode) { this.mode = mode }, @@ -1094,12 +1103,6 @@ return ret } - const mapAttachment = attachments => { - return attachments && JSON.stringify(attachments.map(file => ({ - uri: file.response.data.url, - name: file.response.data.originName - }))) - } const form = { ...processForm, processType, @@ -1120,7 +1123,7 @@ })), // 剔除空行 supplierMaterials: supplierMaterialsForm.filter(hasProperties).map(item => ({ - ...item, attachment: mapAttachment(item.attachment) + ...item, attachment: JSON.stringify(item.attachment) // 转化为 字符串 })), } const loading = this.$loading({ @@ -1217,12 +1220,16 @@ }, handleSupplierMaterialRemove(scope, fileList) { - scope.row['fileList'] = fileList + scope.row['attachment'] = fileList + }, + + removeSupplierMaterialAttachment(scope, attachmentToRemove) { + scope.row['attachment'] = scope.row['attachment'].filter(item => item === attachmentToRemove) }, handleSupplierMaterialExceed(scope, files, fileList) { this.$message.warning("当前限制选择只能选择10个文件"); - scope.row['fileList'] = fileList + scope.row['attachment'] = fileList }, beforeSupplierMaterialRemove(scope, file, fileList) { @@ -1235,9 +1242,18 @@ handleSupplierMaterialFileUploaded(scope, response, file, fileList) { if (response.success) { - scope.row['fileList'] = fileList + console.log(fileList) + let attachments = scope.row['attachment'] + if (isEmpty(attachments)) { + attachments = [] + scope.row['attachment'] = attachments + } + attachments.push({ + uri: response.data.url, + name: file.name + }) - this.fileListSupplierMaterial = fileList + this.$message.success("上传成功"); } else { this.$message.warning("上传失败");