From 2435fbda7cd32023d286e6d90ae8aeec57ba2fc0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E5=90=8C=E6=B5=B7?= <14166000+zhangtonghai@user.noreply.gitee.com> Date: Tue, 5 Nov 2024 15:20:01 +0800 Subject: [PATCH] =?UTF-8?q?=E7=AE=B1=E7=AE=A1=20=E6=89=B9=E9=87=8F?= =?UTF-8?q?=E5=8F=98=E5=8A=A8=E5=AF=BC=E5=85=A5=20=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E4=B8=8A=E4=BC=A0=20=E7=9B=B4=E6=8E=A5=E8=A7=A6=E5=8F=91=20?= =?UTF-8?q?=E4=BF=9D=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/File/index.vue | 74 +++++++++++-------- .../TemplatImport/TenantAuditStepModal.vue | 7 ++ 2 files changed, 50 insertions(+), 31 deletions(-) diff --git a/src/components/File/index.vue b/src/components/File/index.vue index f659b2c5..097e1ea1 100644 --- a/src/components/File/index.vue +++ b/src/components/File/index.vue @@ -15,21 +15,28 @@ ref="RefsUpload" :file-list="upFileList" :before-upload="beforeUpload" - :maxCount="maxCount" + :maxCount="1" accept=".xlsm,.xlsx,.xls,.pdf,.txt,.pms,.jpeg,.png" :rules="[{ required: true, message: '请上传文件!' }]" @remove="handleRemove" @change="ChangeUpload" :showUploadList="false" > - + + 选择文件 -

请先保存,再进行文件上传。

@@ -215,33 +222,38 @@ newFileList.splice(index, 1) upFileList.value = newFileList } - function ChangeUpload(e) { - const postData = new FormData() - const list = unref(upFileList) - list.forEach((item) => { - postData.append('formCollection[]', item) - }) - postData.append('linkId', props.id) - postData.append('typeCode', formData.typeCode) - postData.append('typeName', formData.typeName) - loading.value = true - AddMultiFiles(postData) - .then((res) => { - loading.value = false - visible.value = false - upFileList.value = [] - if (props.showFileList) { - dsFileList.value.init() - emits('handleSuccess', { id: res.data }) - } else { - emits('handleSuccess') - } - createMessage.success('上传成功!') - }) - .catch((res) => { - loading.value = false - createMessage.error('上传失败!') - }) + async function ChangeUpload() { + let FnUp = (id) => { + console.log('FnUp', 1111111111) + const postData = new FormData() + const list = unref(upFileList) + // list.forEach((item) => { + // postData.append('formCollection[]', item) + // }) + postData.append('formCollection', list[list.length - 1]) + postData.append('linkId', id) + postData.append('typeCode', formData.typeCode) + postData.append('typeName', formData.typeName) + loading.value = true + AddMultiFiles(postData) + .then((res) => { + loading.value = false + visible.value = false + upFileList.value = [] + if (props.showFileList) { + dsFileList.value.init() + emits('handleSuccess', { id: res.data }) + } else { + emits('handleSuccess') + } + createMessage.success('上传成功!') + }) + .catch((res) => { + loading.value = false + createMessage.error('上传失败!') + }) + } + emits('FnUpload', FnUp) } function beforeUpload(file) { // 判断文件大小 @@ -282,7 +294,7 @@ // 附件列表组件 const dsFileList = ref(null) - const emits = defineEmits(['handleSuccess', 'FnTriggerSave']) + const emits = defineEmits(['handleSuccess', 'FnTriggerSave', 'FnUpload']) // 提交上传 const handleOk = async () => { const res = await fileForm.value.validateFields() diff --git a/src/views/ContainerManagement/TemplatImport/TenantAuditStepModal.vue b/src/views/ContainerManagement/TemplatImport/TenantAuditStepModal.vue index f5f0847c..6edd13f4 100644 --- a/src/views/ContainerManagement/TemplatImport/TenantAuditStepModal.vue +++ b/src/views/ContainerManagement/TemplatImport/TenantAuditStepModal.vue @@ -64,6 +64,7 @@ :succinct="true" :id="rowId" @FnTriggerSave="FnTriggerSave" + @FnUpload="FnUpload" @handleSuccess="handleSuccess" :SetSelect="{ show: true, @@ -234,6 +235,12 @@ } const dsFile = ref() + async function FnUpload(FnUp) { + if (!rowId.value) { + await handleSave(false) + } + FnUp(rowId.value) + } async function FnTriggerSave() { await handleSave(false) if (rowId.value) {