|
@@ -1,28 +1,27 @@
|
|
|
<template>
|
|
|
<Dialog v-model="dialogVisible" title="标本信息导入" width="600">
|
|
|
+ <el-alert title="可单独上传xlsx表或者图片压缩包。需确保图片命名规范,不与旧图片命名重复。" type="warning" style="margin-bottom: 10px"/>
|
|
|
<el-upload
|
|
|
ref="uploadRef"
|
|
|
v-model:file-list="fileList"
|
|
|
- :action="importUrl + '?updateSupport=' + updateSupport"
|
|
|
+ :action=" importUrl + '?updateSupport=' + updateSupport"
|
|
|
:auto-upload="false"
|
|
|
:disabled="formLoading"
|
|
|
:headers="uploadHeaders"
|
|
|
:limit="1"
|
|
|
:on-error="submitFormError"
|
|
|
:on-exceed="handleExceed"
|
|
|
- :on-success="submitFormSuccess"
|
|
|
-
|
|
|
accept=".xlsx, .xls"
|
|
|
drag
|
|
|
>
|
|
|
<Icon icon="ep:upload" />
|
|
|
- <div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
|
|
|
+ <div class="el-upload__text">将xlsx表拖到此处,或<em>点击上传</em></div>
|
|
|
<template #tip>
|
|
|
<div class="el-upload__tip text-center">
|
|
|
-<!-- <div class="el-upload__tip">-->
|
|
|
+ <div class="el-upload__tip">
|
|
|
<el-checkbox v-model="updateSupport" />
|
|
|
-<!-- 是否更新已经存在的标本数据-->
|
|
|
-<!-- </div>-->
|
|
|
+ 是否更新已经存在的标本数据
|
|
|
+ </div>
|
|
|
<span>仅允许导入 xls、xlsx 格式文件。</span>
|
|
|
<el-link
|
|
|
:underline="false"
|
|
@@ -46,18 +45,18 @@
|
|
|
:disabled="formLoading"
|
|
|
:limit="1"
|
|
|
:on-error="submitFormError"
|
|
|
- :http-request="httpRequest"
|
|
|
-
|
|
|
+ :headers="uploadHeaders"
|
|
|
+ accept=".zip"
|
|
|
>
|
|
|
<el-icon class="el-icon--upload" ><upload-filled /></el-icon>
|
|
|
<div class="el-upload__text">
|
|
|
- <em>点击批量上传图片</em>
|
|
|
+ <div class="el-upload__text">将图片压缩包拖到此处,或<em>点击上传</em></div>
|
|
|
</div>
|
|
|
<template #tip>
|
|
|
<div class="el-upload__tip text-center">
|
|
|
- <el-checkbox v-model="updateSupport" />
|
|
|
+<!-- <el-checkbox v-model="updateSupport" />-->
|
|
|
<!-- 是否更新已经存在的标本图片-->
|
|
|
- <span>仅允许导入jpg、png、gif 格式文件。</span>
|
|
|
+ <span>仅允许导入 .zip 格式文件。</span>
|
|
|
</div>
|
|
|
</template>
|
|
|
</el-upload>
|
|
@@ -72,6 +71,7 @@
|
|
|
import download from '@/utils/download'
|
|
|
import { getAccessToken, getTenantId } from '@/utils/auth'
|
|
|
import {SpecimenInfoApi} from "@/api/museums/specimeninfo";
|
|
|
+import { ref, nextTick } from 'vue';
|
|
|
import {UploadFilled} from "@element-plus/icons-vue";
|
|
|
import {useUpload} from "@/components/UploadFile/src/useUpload";
|
|
|
|
|
@@ -79,8 +79,10 @@ defineOptions({ name: 'SpecimenImportForm' })
|
|
|
const dialogVisible = ref(false) // 弹窗的是否展示
|
|
|
const formLoading = ref(false) // 表单的加载中
|
|
|
const uploadRef = ref()
|
|
|
+const uploadimageRef = ref()
|
|
|
// const uploadimageRef = ref()
|
|
|
const message = useMessage() // 消息弹窗
|
|
|
+import axios from 'axios';
|
|
|
const updateSupport = ref(0) // 是否更新已经存在的用户数据
|
|
|
//const updateImageSupport = ref() //是否更新已经存在的标本图片
|
|
|
const fileList = ref([]) // 文件列表
|
|
@@ -103,7 +105,7 @@ const { httpRequest } = useUpload()
|
|
|
|
|
|
/** 提交表单 */
|
|
|
const submitForm = async () => {
|
|
|
- if (fileList.value.length == 0) {
|
|
|
+ if (fileList.value.length == 0 && imageList.value.length == 0) {
|
|
|
message.error('请上传文件')
|
|
|
return
|
|
|
}
|
|
@@ -113,8 +115,26 @@ const submitForm = async () => {
|
|
|
'tenant-id': getTenantId()
|
|
|
}
|
|
|
formLoading.value = true
|
|
|
- uploadRef.value!.submit()
|
|
|
+ const formData = new FormData()
|
|
|
+ if (fileList.value.length > 0) {
|
|
|
+ formData.append('file', fileList.value[0].raw, fileList.value[0].name)
|
|
|
+ }
|
|
|
+ if (imageList.value.length > 0) {
|
|
|
+ formData.append('imageFile', imageList.value[0].raw, imageList.value[0].name)
|
|
|
+ }
|
|
|
|
|
|
+ axios.post(importUrl + '?updateSupport=' + updateSupport.value, formData, {
|
|
|
+ headers: {
|
|
|
+ ...uploadHeaders.value,
|
|
|
+ 'Content-Type': 'multipart/form-data'
|
|
|
+ }
|
|
|
+ }).then((response) => {
|
|
|
+ submitFormSuccess(response)
|
|
|
+ }).catch((error) => {
|
|
|
+ submitFormError()
|
|
|
+ }).finally(() => {
|
|
|
+ formLoading.value = false
|
|
|
+ })
|
|
|
}
|
|
|
|
|
|
/** 文件上传成功 */
|
|
@@ -129,13 +149,13 @@ const submitFormSuccess = (response: any) => {
|
|
|
const data = response.data
|
|
|
let text = '上传成功数量:' + data.createSpecimenNumbers.length + ';'
|
|
|
for (let specimenInfodata of data.createSpecimenNumbers) {
|
|
|
- text += '< ' + specimenInfodata + ' >'
|
|
|
+ text += '标本编号:' + specimenInfodata + '、'
|
|
|
}
|
|
|
- text += '更新成功数量:' + data.updateSpecimenNumbers.length + ';'
|
|
|
+ text += '。更新成功数量:' + data.updateSpecimenNumbers.length + ';'
|
|
|
for (const specimenInfodata of data.updateSpecimenNumbers) {
|
|
|
- text += '< ' + specimenInfodata + ' >'
|
|
|
+ text += '标本编号:' + specimenInfodata + '、'
|
|
|
}
|
|
|
- text += '更新失败数量:' + Object.keys(data.failureSpecimenNumbers).length + ';'
|
|
|
+ text += '。更新失败数量:' + Object.keys(data.failureSpecimenNumbers).length + ';'
|
|
|
for (const specimenInfodata in data.failureSpecimenNumbers) {
|
|
|
text += '< ' + specimenInfodata + ': ' + data.failureSpecimenNumbers[specimenInfodata] + ' >'
|
|
|
}
|
|
@@ -173,6 +193,7 @@ const resetForm = async (): Promise<void> => {
|
|
|
formLoading.value = false
|
|
|
await nextTick()
|
|
|
uploadRef.value?.clearFiles()
|
|
|
+ uploadimageRef.value?.clearFiles()
|
|
|
}
|
|
|
|
|
|
/** 文件数超出提示 */
|
|
@@ -202,5 +223,4 @@ const submitImageSuccess = (response: any) => {
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
</script>
|