feat: 产品迭代7月份
All checks were successful
构建并部署前端到测试环境 / build-and-deploy (push) Successful in 5m51s

This commit is contained in:
luo
2026-07-27 16:30:29 +08:00
parent cc6fc9243e
commit f0a2b84e53
75 changed files with 2926 additions and 534 deletions

View File

@@ -57,7 +57,8 @@
import { Close, Document, UploadFilled } from '@element-plus/icons-vue'
import type { UploadFile, UploadInstance, UploadRawFile } from 'element-plus'
import { StorageService } from '@/api/modules'
import type { RefundAttachment } from '@/types/api/refund'
import type { RefundAttachment } from '@/types/api/refund'
import type { FilePurpose } from '@/api/modules/storage'
interface Props {
modelValue?: string[] | string
@@ -65,13 +66,21 @@
maxCount?: number
accept?: string
tip?: string
purpose?: FilePurpose
maxSizeMb?: number
singleColumnCsv?: boolean
maxCsvRows?: number
}
const props = withDefaults(defineProps<Props>(), {
voucherName: '凭证',
maxCount: 5,
accept: '',
tip: ''
tip: '',
purpose: 'attachment',
maxSizeMb: 0,
singleColumnCsv: false,
maxCsvRows: 0
})
const emit = defineEmits<{
@@ -185,6 +194,27 @@
const file = uploadFile.raw
if (!file) return
if (props.maxSizeMb > 0 && file.size > props.maxSizeMb * 1024 * 1024) {
ElMessage.warning(`文件不能超过 ${props.maxSizeMb}MB`)
removeUploadFile(uploadFile)
return
}
if (props.singleColumnCsv) {
const content = await file.text()
const rows = content.replace(/^\uFEFF/, '').split(/\r?\n/).filter(Boolean)
if (props.maxCsvRows > 0 && Math.max(rows.length - 1, 0) > props.maxCsvRows) {
ElMessage.warning(`CSV 数据行不能超过 ${props.maxCsvRows}`)
removeUploadFile(uploadFile)
return
}
if (rows.some((row) => row.includes(','))) {
ElMessage.warning('CSV 只能包含一列资产标识')
removeUploadFile(uploadFile)
return
}
}
if (props.accept) {
const accepted = props.accept.split(',').some((type) => {
const value = type.trim().toLowerCase()
@@ -220,7 +250,7 @@
const uploadUrlRes = await StorageService.getUploadUrl({
file_name: file.name,
content_type: contentType,
purpose: 'attachment'
purpose: props.purpose
})
if (uploadUrlRes.code !== 0) {