<template> <div class="operate"> <el-form ref="ruleForm" :model="form" :rules="rules" :disabled="opts.type === 'view'"> <el-row :gutter="20"> <el-col :span="8"> <el-form-item label="项目名称:" prop="projectNo" class="formItem140"> <el-select v-model="form.projectNo" placeholder="请选择项目名称" style="width: 100%" @change="projectChange" > <el-option v-for="dict in projectList" :key="dict.projectNo" :label="dict.projectName" :value="dict.projectNo" /> </el-select> </el-form-item> </el-col> <el-col :span="8"> <el-form-item label="项目编码:" prop="projectNo" class="formItem140"> <el-input v-model="form.projectNo" :disabled="true" /> </el-form-item> </el-col> <el-col :span="8"> <el-form-item label="项目类型:" prop="projectTypeId" class="formItem140"> <el-input v-model="form.projectTypeIdName" :disabled="true" /> </el-form-item> </el-col> </el-row> <el-row :gutter="20"> <el-col :span="8"> <el-form-item label="项目面积m²:" prop="projectArea" class="formItem140"> <el-input v-model="form.projectArea" placeholder="请输入项目面积" /> </el-form-item> </el-col> <el-col :span="8"> <el-form-item label="用地类型:" prop="spongeLandType" class="formItem140"> <el-select v-model="form.spongeLandType" placeholder="请选择用地类型" style="width: 100%" > <el-option v-for="dict in sponge_land_type" :key="dict.value" :label="dict.label" :value="dict.value" /> </el-select> </el-form-item> </el-col> <el-col :span="8"> <el-form-item label="绿地率:" prop="greenRate" class="formItem140"> <el-input v-model="form.greenRate" placeholder="请输入绿地率" /> </el-form-item> </el-col> </el-row> <el-row :gutter="20"> <el-col :span="8"> <el-form-item label="建设单位:" prop="chargeDepartment" class="formItem140"> <el-input v-model="form.chargeDepartment" :disabled="true" /> </el-form-item> </el-col> <el-col :span="16"> <el-form-item label="建设状态:" prop="buildStatus" class="formItem140"> <el-input v-model="form.buildStatusName" :disabled="true" /> </el-form-item> </el-col> </el-row> <el-divider content-position="left">建设目标</el-divider> <div class="pl20"> <el-row :gutter="20"> <el-col :span="8"> <el-form-item label="年径流总量控制率:" prop="annualRunoffTotalControlRate" class="formItem140"> <el-input v-model="form.annualRunoffTotalControlRate" placeholder="请输入年径流总量控制率"/> </el-form-item> </el-col> <el-col :span="8"> <el-form-item label="年径流污染去除率:" prop="annualRunoffPollutionControlRate" class="formItem140"> <el-input v-model="form.annualRunoffPollutionControlRate" placeholder="请输入年径流污染去除率" /> </el-form-item> </el-col> <el-col :span="8"> <el-form-item label="硬化地面率:" prop="hardGroundRate" class="formItem140"> <el-input v-model="form.hardGroundRate" placeholder="请输入硬化地面率" /> </el-form-item> </el-col> </el-row> </div> <el-divider content-position="left">立项阶段资料</el-divider> <div class="pl20"> <div class="box" v-for="item in projectApprovalFileList"> <el-row :gutter="20"> <el-col :span="12"> <el-form-item :label="`${item.name}:`" class="formItem140" > <el-input v-model="item.filieDescription" :disabled="true" /> </el-form-item> </el-col> <el-col :span="2"> <el-upload class="upload-demo" action="/prod-api/system/upload" :headers="uploadHeader" :before-upload="(rawFile) => beforeUpload(rawFile, ['.rar', '.zip', '.doc', '.docx', '.pdf'])" :on-success="(response) => onSuccess(response, item)" :on-error="(error, uploadFile, uploadFiles) => onError(error, uploadFile, uploadFiles)" :show-file-list="false" :disabled="true" > <el-button icon="Upload" size="mini" type="primary" :disabled="true" >上传文件</el-button > </el-upload> </el-col> <el-col :span="10"> <span class="tips">支持文件格式:.rar .zip .doc .docx .pdf ,单个文件不能超过500kb</span> </el-col> </el-row> <el-row :gutter="20"> <el-col :span="12" :offset="12"> <div class="fileSaveRequestList"> <div class="file-item" v-for="(it, index) in item.fileList"> <span>{{ it.name }}</span> <el-button type="danger" link @click="reoveFile(item.fileList, index)" :disabled="true" >删除</el-button> </div> </div> </el-col> </el-row> </div> </div> <el-divider content-position="left">规划阶段资料</el-divider> <div class="pl20"> <div class="box" v-for="(item, i) in form.projectProcessAttachmentSaveRequestList"> <el-row :gutter="20"> <el-col :span="12"> <el-form-item :label="`${item.name}:`" :prop="'projectProcessAttachmentSaveRequestList.' + i + '.' + 'filieDescription'" class="formItem140" :rules="rules['filieDescription']" > <el-input v-model="item.filieDescription" placeholder="请输入资料说明" /> </el-form-item> </el-col> <el-col :span="2"> <el-upload class="upload-demo" action="/prod-api/system/upload" :headers="uploadHeader" :before-upload="(rawFile) => beforeUpload(rawFile, ['.rar', '.zip', '.doc', '.docx', '.pdf'])" :on-success="(response) => onSuccess(response, item)" :on-error="(error, uploadFile, uploadFiles) => onError(error, uploadFile, uploadFiles)" :show-file-list="false" > <el-button icon="Upload" size="mini" type="primary" >上传文件</el-button > </el-upload> </el-col> <el-col :span="10"> <span class="tips">支持文件格式:.rar .zip .doc .docx .pdf ,单个文件不能超过500kb</span> </el-col> </el-row> <el-row :gutter="20"> <el-col :span="12" :offset="12"> <div class="fileSaveRequestList"> <div class="file-item" v-for="(it, index) in item.fileList"> <span>{{ it.name }}</span> <el-button type="danger" link @click="reoveFile(item.fileList, index)" >删除</el-button> </div> </div> </el-col> </el-row> </div> <el-form-item label="补充说明:" prop="permissionDescription" class="formItem140"> <el-input v-model="form.permissionDescription" type="textarea" resize="none" /> </el-form-item> </div> </el-form> </div> </template> <script setup> import { reactive, onMounted } from 'vue' import { required } from '@/utils/validate-helper' import { getProjectInfoNewList, getDicts } from '@/api/projectApproval' import { projectInfoNewDetail } from '@/api/projectInformationNew' import { projectPlanningPermissionAdd, projectPlanningPermissionEdit, projectPlanningPermissionDetail } from '@/api/planPermission' import { inheritAttr } from '@/utils/v3' import { useDicts } from '@/hooks' import uploadHeader from '@/utils/getUploadHeader' const { proxy } = getCurrentInstance(); const { sponge_land_type, findText } = useDicts(proxy) const { pro_project_approval } = proxy.useDict('pro_project_approval') const { planning_stage } = proxy.useDict('planning_stage') const emit = defineEmits(['close']) const props = defineProps({ curRow: { type: Object, default: () => ({}) }, opts: { type: Object, default: () => ({}) }, types: { type: Array, default: ([]) } }) const { curRow, opts } = props const form = reactive({ projectName: '', projectNo: '', projectTypeId: '', projectTypeIdName: '', projectArea: '', spongeLandType: '', greenRate: '', chargeDepartment: '', buildStatus: '', buildStatusName: '', annualRunoffTotalControlRate: '', annualRunoffPollutionControlRate: '', hardGroundRate: '', projectProcessAttachmentSaveRequestList: [], permissionDescription: '', sysFileSaveRequestList:[] }) const rules = reactive({ projectName: required('项目名称'), projectNo: required('项目编码'), projectTypeId: required('项目类型'), projectArea: required('项目面积'), spongeLandType: required('用地类型'), greenRate: required('绿地率'), chargeDepartment: required('建设单位'), buildStatus: required('建设状态'), annualRunoffTotalControlRate: required('年径流总量控制率'), annualRunoffPollutionControlRate: required('年径流污染去除率'), hardGroundRate: required('可研批复'), filieDescription: required('内容'), }) const projectList = ref([]) const projectApprovalFileList = ref([]) const getProjectList = async () => { const res = await getProjectInfoNewList() if(res?.code !== 200) return projectList.value = res?.data || [] if(opts.type === 'add' && projectList.value.length) { projectChange(projectList.value[0].projectNo) } } const getProjectApprovalFileList = async (projectNo) => { const res = await projectInfoNewDetail(projectNo) if(res?.code !== 200) return const fileGroup = res.data.fileGroup projectApprovalFileList.value = [] for (const key in fileGroup) { if(key === 'pro_project_approval'){ if (Object.hasOwnProperty.call(fileGroup, key)) { const element = fileGroup[key]; for (const item of element) { const info = pro_project_approval.value.find(it => it.value === item.dictData) if(!info) continue projectApprovalFileList.value.push({ fileList: item.fileList, dictData: item.dictData, dictType: item.dictType, filieDescription: item.filieDescription, projectNo: item.projectNo, name: info.label }) } } } } } const projectChange = async (val) => { const it = projectList.value.find(item => item.projectNo === val) inheritAttr(it, form) form.projectTypeIdName = props.types.find(it => it.id === form.projectTypeId)?.projectTypeName form.buildStatusName = findText('build_status', form.buildStatus) getProjectApprovalFileList(form.projectNo) getDictMaps('planning_stage') } const beforeUpload = (rawFile) => { console.log(rawFile) } const onSuccess = (response, item) => { console.log(response) item.fileList.push({ ...response.data, refType: item.dictType, refField: item.dictData }) } const onError = (error, uploadFile, uploadFiles) => { console.log(error, uploadFile, uploadFiles) } const reoveFile = (fileList, index) => { proxy.$modal .confirm("是否确认删除?") .then(async () => { fileList.splice(index, 1) }) .catch(() => {}); } const getDictMaps = async (dictType) => { const res = await getDicts(dictType) if(res?.code !== 200) return if(res?.data){ form.projectProcessAttachmentSaveRequestList = [] for (const item of res.data) { form.projectProcessAttachmentSaveRequestList.push({ fileList: [], dictData: item.dictValue, dictType: item.dictType, filieDescription: '', projectNo: '', name: item.dictLabel }) } console.log(form.projectProcessAttachmentSaveRequestList) } setTimeout(() => { if(proxy.$refs.ruleForm){ proxy.$refs.ruleForm.clearValidate() } }) } const getDetail = async () => { const res = await projectPlanningPermissionDetail(curRow.id) if(res?.code !== 200) return inheritAttr(res.data, form) form.projectTypeIdName = props.types.find(it => it.id === form.projectTypeId)?.projectTypeName form.buildStatusName = findText('build_status', form.buildStatus) getProjectApprovalFileList(form.projectNo) const fileGroup = res.data.fileGroup form.projectProcessAttachmentSaveRequestList = [] for (const key in fileGroup) { if(key === 'planning_stage'){ if (Object.hasOwnProperty.call(fileGroup, key)) { const element = fileGroup[key]; for (const item of element) { const info = planning_stage.value.find(it => it.value === item.dictData) if(!info) continue form.projectProcessAttachmentSaveRequestList.push({ fileList: item.fileList, dictData: item.dictData, dictType: item.dictType, filieDescription: item.filieDescription, projectNo: item.projectNo, name: info.label }) } } } } } const submit = () => { proxy.$refs.ruleForm.validate(async (valid, fields) => { if(valid){ const params = JSON.parse(JSON.stringify(form)) for (const item of params.projectProcessAttachmentSaveRequestList) { item.projectNo = params.projectNo for (const it of item.fileList) { params.sysFileSaveRequestList.push(it) } } console.log(params) let methed = '' if(curRow?.id) { params.id = curRow.id methed = projectPlanningPermissionEdit } else { methed = projectPlanningPermissionAdd } const res = await methed(params) if(res?.code !== 200) return proxy.$modal.msgSuccess('操作成功!') emit('close') } else { console.log('error submit!', fields) } }) } onMounted(() => { getProjectList() if(curRow?.id) { getDetail() } }) defineExpose({ submit }) </script> <style lang="scss" scoped> .operate { .tips { margin-left: 10px; line-height: 30px } .pl140 { padding-left: 140px; } .pl20 { margin-left: 20px; } .fileSaveRequestList { .file-item { white-space: nowrap; display: flex; align-items: center; .del { flex-shrink: 0; color: #f56c6c; cursor: pointer; margin-left: 10px; } } } .box { margin-bottom: 10px; } } </style>