Browse Source

FWHL-89SCP针对供应商上传文件增加程序校验,避免后期丢失

hella_online_20241226
王宇飞 3 months ago
parent
commit
887e7b5e19
  1. 9
      src/api/wms/supplierdeliverRequestMain/index.ts
  2. 2
      src/components/ConfigGlobal/src/ConfigGlobal.vue
  3. 45
      src/components/UploadFile/src/UploadFile.vue
  4. 4
      src/views/wms/purchasereceiptManage/supplierdeliver/supplierdeliverInspectionDetail/supplierdeliverInspectionDetail.data.ts

9
src/api/wms/supplierdeliverRequestMain/index.ts

@ -129,4 +129,11 @@ export const deleteOldLabels = async (id) => {
// 查看履历表
export const querySupplierResume = (asnNumber:string) => {
return request.get({ url: `/wms/supplierdeliver-request-main/querySupplierResume?asnNumber=` + asnNumber })
}
}
// 校验是否上传成功
export const checkUploadFileData = async (data) => {
return await request.post({ url: `/infra/file/uploadFileData`,data})
}

2
src/components/ConfigGlobal/src/ConfigGlobal.vue

@ -54,7 +54,7 @@ const currentLocale = computed(() => localeStore.currentLocale)
<template>
<ElConfigProvider
:locale="currentLocale.elLocale"
:message="{ max: 1 }"
:message="{ max: 2 }"
:namespace="variables.elNamespace"
:size="size"
>

45
src/components/UploadFile/src/UploadFile.vue

@ -65,7 +65,7 @@ const props = defineProps({
drag: propTypes.bool.def(false), //
isShowTip: propTypes.bool.def(true), //
isShowFile: propTypes.bool.def(true), //
checkUploadUrl:propTypes.func.def(), //
})
// ========== ==========
const valueRef = ref(props.modelValue)
@ -108,19 +108,38 @@ const beforeUpload: UploadProps['beforeUpload'] = (file: UploadRawFile) => {
// uploadRef.value.data.path = uploadFile.name
// }
//
const handleFileSuccess: UploadProps['onSuccess'] = (res: any,uploadFile: any): void => {
const handleFileSuccess: UploadProps['onSuccess'] = async (res: any,uploadFile: any): Promise<void> => {
console.log('文件上传成功',res)
if(res&&res.code==0){
message.success(t('ts.上传成功'))
const fileListNew = fileList.value
fileListNew.pop()
fileList.value = fileListNew
uploadList.value.push({ name: uploadFile.name, url: res.data })
// if (uploadList.value.length == uploadNumber.value) {
if(fileList.value.every(it => it.status == 'success')) {
fileList.value = fileList.value.concat(uploadList.value)
uploadList.value = []
uploadNumber.value = 0
emit('update:modelValue', listToString(fileList.value),res,uploadFile)
if(res.data&&res.data.code==200&&props.checkUploadUrl){
let checkRes = await props.checkUploadUrl(res.data.data)
console.log('checkRes',checkRes)
console.log('fileList.value',fileList.value)
console.log('uploadFile',uploadFile)
ElMessage.closeAll()
if(checkRes['fileExists']=="YES"){
message.success(t('ts.上传成功'))
}else{
let findItem = fileList.value.find(item=>item.uid == uploadFile.uid)
if(findItem){
uploadRef?.value?.handleRemove(findItem)
}
message.error(checkRes['msg'])
}
}else{
message.success(t('ts.上传成功'))
const fileListNew = fileList.value
fileListNew.pop()
fileList.value = fileListNew
uploadList.value.push({ name: uploadFile.name, url: res.data })
// if (uploadList.value.length == uploadNumber.value) {
if(fileList.value.every(it => it.status == 'success')) {
fileList.value = fileList.value.concat(uploadList.value)
uploadList.value = []
uploadNumber.value = 0
emit('update:modelValue', listToString(fileList.value),res,uploadFile)
}
}
}else{
message.error(res.msg)

4
src/views/wms/purchasereceiptManage/supplierdeliver/supplierdeliverInspectionDetail/supplierdeliverInspectionDetail.data.ts

@ -1,5 +1,7 @@
import type { CrudSchema } from '@/hooks/web/useCrudSchemas'
import { dateFormatter } from '@/utils/formatTime'
import * as SupplierdeliverRequestMainApi from '@/api/wms/supplierdeliverRequestMain'
import { getBaseUrl } from '@/utils/systemParam'
export const SupplierdeliverInspectionDetail = useCrudSchemas(reactive<CrudSchema[]>([
{
@ -16,6 +18,8 @@ export const SupplierdeliverInspectionDetail = useCrudSchemas(reactive<CrudSchem
tableName: 'SupplierdeliverInspectionDetail',
},
fileType:['pdf'],
updateUrl: getBaseUrl()+import.meta.env.VITE_API_URL+'/infra/file/uploadFile',
checkUploadUrl: SupplierdeliverRequestMainApi.checkUploadFileData,
fileSize:100,
limit:20000
}

Loading…
Cancel
Save