|
@@ -39,7 +39,7 @@
|
|
|
ref="uploadimageRef"
|
|
|
v-model:file-list="imageList"
|
|
|
drag
|
|
|
- :action="importUrl + '?updateSupport=' + updateSupport"
|
|
|
+ :action="importUrl + '?updateSupport=' + updateSupport + '&updateType=' + updateType"
|
|
|
:on-success="submitImageSuccess"
|
|
|
:auto-upload="false"
|
|
|
:disabled="formLoading"
|
|
@@ -88,7 +88,7 @@ const uploadimageRef = ref()
|
|
|
|
|
|
const message = useMessage() // 消息弹窗
|
|
|
import axios from 'axios';
|
|
|
-
|
|
|
+const updateType = ref(-1)
|
|
|
const updateSupport = ref(true) // 是否更新已经存在的用户数据
|
|
|
const fileList = ref([]) // 文件列表
|
|
|
const imageList = ref([])
|
|
@@ -97,16 +97,21 @@ const importUrl =
|
|
|
import.meta.env.VITE_BASE_URL + import.meta.env.VITE_API_URL + '/museums/specimen-info/import-specimen-with-images'
|
|
|
|
|
|
/** 打开弹窗 */
|
|
|
-const open = () => {
|
|
|
+const open = (typeNum : any) => {
|
|
|
loading.value = true
|
|
|
dialogVisible.value = true
|
|
|
updateSupport.value = true
|
|
|
+ if(typeNum != null && typeNum != '' && typeNum != undefined){
|
|
|
+ updateType.value = typeNum
|
|
|
+ }else {
|
|
|
+ updateType.value = -1
|
|
|
+ }
|
|
|
fileList.value = []
|
|
|
imageList.value = []
|
|
|
resetForm()
|
|
|
}
|
|
|
defineExpose({open}) // 提供 open 方法,用于打开弹窗
|
|
|
-const {httpRequest} = useUpload()
|
|
|
+const { httpRequest } = useUpload()
|
|
|
|
|
|
/** 提交表单 */
|
|
|
const submitForm = async () => {
|
|
@@ -129,7 +134,8 @@ const submitForm = async () => {
|
|
|
}
|
|
|
|
|
|
try {
|
|
|
- const response = await axios.post(importUrl + '?updateSupport=' + updateSupport.value, formData, {
|
|
|
+ const response = await axios.post(importUrl + '?updateSupport=' + updateSupport.value
|
|
|
+ + '&updateType=' + updateType.value, formData, {
|
|
|
headers: {
|
|
|
...uploadHeaders.value,
|
|
|
'Content-Type': 'multipart/form-data'
|
|
@@ -149,13 +155,11 @@ const emits = defineEmits(['success'])
|
|
|
const submitFormSuccess = (response: any) => {
|
|
|
console.log('上传响应:', response)
|
|
|
// console.log(response.data.code != 0 , response.data.code)
|
|
|
- console.log(666)
|
|
|
if (response.data.code != 0) {
|
|
|
message.error(response.data.msg)
|
|
|
- // formLoading.value = false
|
|
|
return
|
|
|
}
|
|
|
- if (response.data.code== -19) {
|
|
|
+ if (response.data.code == -19) {
|
|
|
message.error(response.data.msg)
|
|
|
// formLoading.value = false
|
|
|
return
|
|
@@ -163,9 +167,9 @@ const submitFormSuccess = (response: any) => {
|
|
|
// 拼接提示语
|
|
|
const data = response.data.data
|
|
|
// console.log(data)
|
|
|
- let text
|
|
|
+ let text = '';
|
|
|
if(data.createSpecimenNumbers != null){
|
|
|
- text = '上传成功数量:' + data.createSpecimenNumbers.length + ';'
|
|
|
+ text += '上传成功数量:' + data.createSpecimenNumbers.length + ';'
|
|
|
for (let specimenInfodata of data.createSpecimenNumbers) {
|
|
|
text += '标本编号:' + specimenInfodata + '、'
|
|
|
}
|
|
@@ -176,21 +180,26 @@ const submitFormSuccess = (response: any) => {
|
|
|
text += '标本编号:' + specimenInfodata + '、'
|
|
|
}
|
|
|
}
|
|
|
- if(data.failureSpecimenNumbers != null) {
|
|
|
+ console.log('上传响应:2', response)
|
|
|
+ if(JSON.stringify(data.failureSpecimenNumbers) != '{}' &&data.failureSpecimenNumbers != null) {
|
|
|
text += '。更新失败数量:' + Object.keys(data.failureSpecimenNumbers).length + ';'
|
|
|
for (const specimenInfodata in data.failureSpecimenNumbers) {
|
|
|
text += '< ' + specimenInfodata + ': ' + data.failureSpecimenNumbers[specimenInfodata] + ' >'
|
|
|
}
|
|
|
}
|
|
|
- if(data.createSpecimenImages != null) {
|
|
|
- text = '图片上传成功数量:' + data.createSpecimenImages.length + ';'
|
|
|
+ console.log('上传响应:3', response)
|
|
|
+ if(data.createSpecimenImages != null){
|
|
|
+
|
|
|
+ text += '图片上传成功数量:' + data.createSpecimenImages.length + ';'
|
|
|
for (let specimenInfodata of data.createSpecimenImages) {
|
|
|
text += '图片名称:' + specimenInfodata + '、'
|
|
|
}
|
|
|
}
|
|
|
- if(JSON.stringify(data.failureSpecimenImages) != '{}' &&data.failureSpecimenImages != null) {
|
|
|
- text = '图片上传失败数量:' + Object.keys(data.failureSpecimenImages).length + ';'
|
|
|
- for (let specimenInfodata of data.failureSpecimenImages) {
|
|
|
+ console.log('上传响应:4', response)
|
|
|
+
|
|
|
+ if(JSON.stringify(data.failureSpecimenImages) != '{}' && data.failureSpecimenImages != null) {
|
|
|
+ text += '图片上传失败数量:' + Object.keys(data.failureSpecimenImages).length + ';'
|
|
|
+ for (let specimenInfodata in data.failureSpecimenImages) {
|
|
|
text += '< ' + specimenInfodata + ': ' + data.failureSpecimenImages[specimenInfodata] + ' >'
|
|
|
}
|
|
|
}
|
|
@@ -228,7 +237,7 @@ const handleExceed = (): void => {
|
|
|
}
|
|
|
/** 下载模板操作 */
|
|
|
const importTemplate = async () => {
|
|
|
- const res = await SpecimenInfoApi.importSpecimenInfoTemplate()
|
|
|
+ const res = await SpecimenInfoApi.importSpecimenInfoTemplate(updateType.value)
|
|
|
download.excel(res, '标本批量导入模版.xls')
|
|
|
}
|
|
|
|