| | |
| | | :on-success="handleDrawingUploadSuccess" |
| | | :on-remove="handleDrawingRemove" |
| | | :before-upload="handleDrawingBeforeUpload" |
| | | :limit="1" |
| | | :limit="5" |
| | | accept=".pdf,.jpg,.jpeg,.png,.dwg" |
| | | list-type="picture-card" |
| | | > |
| | |
| | | // 处理图纸文件反显 |
| | | if (data.salesLedgerFiles && data.salesLedgerFiles.length > 0) { |
| | | drawingFileList.value = data.salesLedgerFiles.map(file => ({ |
| | | id: file.id, // 带上id用于删除时调用接口 |
| | | name: file.name, |
| | | url: file.url |
| | | })); |
| | |
| | | console.log('上传成功响应', response); |
| | | console.log('response.data', response.data); |
| | | if (response.code === 200) { |
| | | modelForm.value.tempFileIds = [response.data?.tempId]; |
| | | modelForm.value.salesLedgerFiles = [{ |
| | | // 支持多文件,追加到数组 |
| | | modelForm.value.tempFileIds.push(response.data?.tempId); |
| | | modelForm.value.salesLedgerFiles.push({ |
| | | tempId: response.data?.tempId, |
| | | originalName: response.data?.originalName || file.name, |
| | | tempPath: response.data?.tempPath, |
| | | type: response.data?.type || 13 |
| | | }]; |
| | | }); |
| | | proxy.$modal.msgSuccess("上传成功"); |
| | | } else { |
| | | proxy.$modal.msgError(response.msg || "上传失败"); |
| | |
| | | }; |
| | | |
| | | const handleDrawingRemove = (file) => { |
| | | modelForm.value.tempFileIds = []; |
| | | modelForm.value.salesLedgerFiles = []; |
| | | // 如果是编辑模式下已存在的文件(带有id),调用删除接口 |
| | | if (file.id) { |
| | | delLedgerFile({ id: file.id }).then(res => { |
| | | if (res.code === 200) { |
| | | proxy.$modal.msgSuccess("删除成功"); |
| | | } |
| | | }).catch(err => { |
| | | console.error("删除文件失败:", err); |
| | | }); |
| | | } |
| | | // 从数组中移除对应的文件 |
| | | const index = modelForm.value.salesLedgerFiles.findIndex(item => |
| | | item.tempId === file.response?.data?.tempId || item.tempId === file.tempId |
| | | ); |
| | | if (index > -1) { |
| | | modelForm.value.tempFileIds.splice(index, 1); |
| | | modelForm.value.salesLedgerFiles.splice(index, 1); |
| | | } |
| | | }; |
| | | |
| | | onMounted(() => { |