diff --git a/zdxt-web-client/zdxt-efcode-enforcement-app/src/views/enforcement/my/plan/cp_plan_edit.vue b/zdxt-web-client/zdxt-efcode-enforcement-app/src/views/enforcement/my/plan/cp_plan_edit.vue index 50efe926..7f6967bd 100644 --- a/zdxt-web-client/zdxt-efcode-enforcement-app/src/views/enforcement/my/plan/cp_plan_edit.vue +++ b/zdxt-web-client/zdxt-efcode-enforcement-app/src/views/enforcement/my/plan/cp_plan_edit.vue @@ -134,6 +134,36 @@ + + +
+
+ + (仅限PDF文档,5MB以下) + 模板下载 +
+ + + +
+
+ 仅支持上传5MB以下的PDF格式文档 +
@@ -266,6 +296,8 @@ import { showToast, showSuccessToast, showConfirmDialog } from 'vant'; import { addPlan, editPlan, getPlanDetail, getSubmitDeadline, getManualMatchDays, getMaxInnerUnitAcPersonNum, searchBureauUnitUsers } from '@/api/enforcement/plan'; import { queryEnterpriseListAndQrInfo } from '@/api/enforcement/index'; import { maskPhone } from '@/util/util'; +import { uploadFile } from '@/util/fileUpload'; +import { toFullFileUrl } from '@/util/fileUrl'; const router = useRouter(); const route = useRoute(); const {useCommon} = $globalStore; @@ -316,6 +348,9 @@ const noticeText = computed(() => { return '专项计划时间不受提交截止日限制'; }); +// 附件上传组件状态 +const fileListObj = ref([]); + // 表单数据 const form = ref({ id: '', @@ -344,6 +379,7 @@ const form = ref({ deptId: '', deptName: '', isDelete: 0, + fileList: [], }); // 人员列表 @@ -542,6 +578,26 @@ const loadDetail = (id) => { } } }); + // 回填附件,兼容对象数组和路径字符串数组 + const detailFiles = Array.isArray(data.fileList) ? data.fileList : []; + form.value.fileList = detailFiles.map(item => { + const uploadPath = typeof item === 'string' + ? item + : (item.uploadPath || item.fileUrl || item.filePath || item.url || ''); + return { + uploadPath, + fileName: typeof item === 'object' && item + ? (item.fileName || item.fileSaveName || item.name || '') + : '', + }; + }).filter(item => item.uploadPath); + fileListObj.value = form.value.fileList.map(item => ({ + url: toFullFileUrl(item.uploadPath), + uploadPath: item.uploadPath, + status: 'done', + message: '', + name: item.fileName || item.uploadPath.split('/').pop() || '附件', + })); // 解析人员 if (data.enforceUserNames) { const names = data.enforceUserNames.split(','); @@ -797,6 +853,58 @@ const syncPersonData = () => { form.value.enforceUserCodes = personList.value.map(p => p.code || '').join(','); }; +// 下载附件模板 +const downloadFile = () => { + window.open('http://jdm.szssfj.cn/jdmApi/profile//EnforcementInspectionPlanTemplate.xlsx'); +}; + +// 上传前校验 PDF 类型 +const beforeRead = (file) => { + if (isReadonly.value) return false; + const files = Array.isArray(file) ? file : [file]; + const isValid = files.every(item => item.type === 'application/pdf'); + if (!isValid) { + showToast('仅支持上传PDF格式文档'); + } + return isValid; +}; + +// 上传附件 +const uploadFiles = (file) => { + if (isReadonly.value) return; + const files = Array.isArray(file) ? file : [file]; + form.value.fileList = []; + files.forEach(f => { + uploadFile(f, (res) => { + const uploadPath = res.url || ''; + if (!uploadPath) { + f.status = 'failed'; + f.message = '上传失败'; + form.value.fileList = []; + showToast('附件上传失败,请重试'); + return; + } + f.url = uploadPath; + form.value.fileList = [{ + uploadPath, + fileName: f.file?.name || f.name || '', + }]; + }); + }); +}; + +// 删除附件时同步提交数据 +const deleteFile = (file, detail) => { + if (isReadonly.value) return false; + form.value.fileList.splice(detail.index, 1); + return true; +}; + +// 文件大小超出限制 +const onOversize = () => { + showToast('文件大小不能超过 5MB'); +}; + // 返回 const onBack = () => { router.back(); @@ -824,6 +932,18 @@ const validate = () => { showToast('执法人员不得少于2人'); return false; } + if (!fileListObj.value.length) { + showToast('请上传PDF格式附件(5MB以下)'); + return false; + } + if (fileListObj.value.some(file => file.status === 'uploading')) { + showToast('附件上传中,请稍候'); + return false; + } + if (!form.value.fileList.length || !form.value.fileList[0]?.uploadPath) { + showToast('附件上传失败,请重新上传'); + return false; + } return true; }; @@ -1120,6 +1240,94 @@ const doSubmit = () => { } } +.file-upload { + padding: 16px; + background: #fff; + + .file-upload-center { + display: flex; + align-items: center; + margin-bottom: 12px; + font-size: 14px; + color: #323233; + position: relative; + + .file-required { + color: red; + } + + label { + font-weight: 500; + margin-right: 8px; + white-space: nowrap; + } + + > span { + color: #969799; + font-size: 12px; + white-space: nowrap; + } + + .down-mod { + position: absolute; + right: 0; + display: flex; + align-items: center; + gap: 2px; + color: #faad14; + font-size: 12px; + + a { + color: #faad14; + } + } + } + + .file { + :deep(.van-uploader__upload), + :deep(.van-uploader__preview), + :deep(.van-uploader__preview-image) { + width: 80px; + height: 80px; + } + + :deep(.van-uploader__upload) { + border: 1px dashed #dcdee0; + border-radius: 4px; + background: #fafafa; + } + } + + .preview-cover { + position: absolute; + bottom: 0; + left: 0; + right: 0; + padding: 8px; + background: rgba(0, 0, 0, 0.6); + color: #fff; + font-size: 12px; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; + } +} + +.warning-rule { + margin: 12px 16px 16px; + padding: 6px; + display: flex; + align-items: center; + background: #fff7e6; + color: #faad14; + font-size: 12px; + border-radius: 4px; + + span { + margin-right: 4px; + } +} + .submit-wrap { padding: 22px 0 0; diff --git a/zdxt-web-client/zdxt-efcode-enforcement-app/vite-env/.env.enforcement-prod b/zdxt-web-client/zdxt-efcode-enforcement-app/vite-env/.env.enforcement-prod index d7677f34..003c5d4d 100644 --- a/zdxt-web-client/zdxt-efcode-enforcement-app/vite-env/.env.enforcement-prod +++ b/zdxt-web-client/zdxt-efcode-enforcement-app/vite-env/.env.enforcement-prod @@ -1,9 +1,9 @@ # 执法端生产环境 VITE_PORT = 12002 -VITE_BASE_URL = '/efcode20-enf-app/api/enf-ep' -VITE_CONTEXT_PATH = '/efcode20-enf-app/' -# VITE_BASE_URL = '/efcode20-enf-app-test/api/enf-ep' -# VITE_CONTEXT_PATH = '/efcode20-enf-app-test/' +# VITE_BASE_URL = '/efcode20-enf-app/api/enf-ep' +# VITE_CONTEXT_PATH = '/efcode20-enf-app/' +VITE_BASE_URL = '/efcode20-enf-app-test/api/enf-ep' +VITE_CONTEXT_PATH = '/efcode20-enf-app-test/' VITE_PROXY_TARGET = 'http://localhost:17000' VITE_DEFAULT_LOGIN = '/enforcement/loginByPassword' VITE_APP_ENV = 'prod'