feat: 推广粘贴上传功能至所有图片上传页面(purchase/buy/product/semi)
This commit is contained in:
@ -147,7 +147,7 @@
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="24">
|
||||
<el-form-item label="图片上传" required>
|
||||
<el-form-item label="图片上传" required id="upload-purchase-images">
|
||||
<el-upload
|
||||
v-model:file-list="fileList"
|
||||
:http-request="customUpload"
|
||||
@ -244,6 +244,7 @@ import {
|
||||
approvePurchase, getPurchaseApprovers, autoFillPurchase
|
||||
} from '@/api/purchase'
|
||||
import { uploadFile, deleteFile } from '@/api/common/upload'
|
||||
import { usePasteUpload } from '@/hooks/usePasteUpload'
|
||||
import type { FormInstance } from 'element-plus'
|
||||
|
||||
const userStore = useUserStore()
|
||||
@ -490,6 +491,8 @@ const customUpload = async (options: any) => {
|
||||
if (res.code === 200) {
|
||||
const newUrl = res.data.url
|
||||
form.value.images!.push(newUrl)
|
||||
// 同步更新 fileList,触发 el-upload UI 刷新
|
||||
fileList.value.push({ name: newUrl.split('/').pop(), url: getImageUrl(newUrl) })
|
||||
onSuccess(res)
|
||||
} else {
|
||||
ElMessage.error(res.msg || '上传失败')
|
||||
@ -512,6 +515,12 @@ const handleRemoveImage = async (uploadFile: any) => {
|
||||
}
|
||||
}
|
||||
|
||||
// 粘贴上传处理器(PC 端:鼠标悬停 + Ctrl+V 直接粘贴图片)
|
||||
const handlePasteLink = (link: string, field: string) => {
|
||||
// 采购单没有独立的外链输入框,暂不支持网页图片链接自动填入
|
||||
}
|
||||
usePasteUpload(customUpload, 'images', '#upload-purchase-images', handlePasteLink)
|
||||
|
||||
// --- 提交 ---
|
||||
const submitForm = async () => {
|
||||
if (!form.value.name.trim()) { ElMessage.warning('请选择或填写采购物品'); return }
|
||||
|
||||
Reference in New Issue
Block a user