<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="8"> <el-form-item label="建设状态:" prop="buildStatus" class="formItem140"> <el-input v-model="form.buildStatusName" :disabled="true" /> </el-form-item> </el-col> <el-col :span="8"> <el-form-item label="是否落实规划管控指标:" prop="implementIndicators" class="formItem140"> <el-select v-model="form.implementIndicators" placeholder="请选择" style="width: 100%"> <el-option label="是" value="1" /> <el-option label="否" value="0" /> </el-select> </el-form-item> </el-col> </el-row> <!-- 是否豁免项目 isProjectExempt 1:是,0:否 --> <el-divider content-position="left" v-if="form.isProjectExempt == '0' || form.isProjectExempt == ''">建设目标</el-divider> <div class="pl20" v-if="form.isProjectExempt == '0' || form.isProjectExempt == ''"> <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="24"> <el-col :span="24"> <el-form-item :label="`${item.name}:`"> <el-input v-model="item.filieDescription" :disabled="true" style="width: 200px" /> <!-- 文件列表展示 --> <div class="ggFileListShow"> <div class="part flex" v-for="(img, index) in item.fileList" :key="index"> <p class="name ellipsis" :title="img.name">{{ img.name || '--' }}</p> </div> </div> </el-form-item> </el-col> <!-- <el-col :span="12"> <ImageFileUpload listType="text" :limit="10" :saveFileArr="item.fileList" :refType="item.dictType" :refField="item.dictData" :fileType="['pdf', 'doc', 'docx', 'xlsx', 'xls']" :disabled="true" /> </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="24"> <el-col :span="8"> <!--必填 :rules="rules['filieDescription']" --> <el-form-item :label="`${item.name}:`" :prop="'projectProcessAttachmentSaveRequestList.' + i + '.' + 'filieDescription'" class="formItem140" > <el-input v-model="item.filieDescription" :disabled="true" style="width: 200px" placeholder="请输入资料说明" /> </el-form-item> </el-col> <el-col :span="12"> <ImageFileUpload listType="text" :limit="10" :saveFileArr="item.fileList" :refType="item.dictType" :refField="item.dictData" :fileType="['pdf', 'doc', 'docx', 'xlsx', 'xls', 'txt']" /> </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/project/projectApproval'; import { projectInfoNewDetail } from '@/api/project/projectInformationNew'; import { projectPlanningPermissionAdd, projectPlanningPermissionEdit, projectPlanningPermissionDetail } from '@/api/project/planPermission'; import { inheritAttr } from '@/utils/v3'; import { useDicts } from '@/hooks'; import ImageFileUpload from '@/components/ImageFileUpload/index.vue'; //图片文件上传 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({ isProjectExempt: '0', projectName: '', projectNo: '', projectTypeId: '', projectTypeIdName: '', projectArea: '', spongeLandType: '', greenRate: '', chargeDepartment: '', implementIndicators: '0', 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 showDetail = ref(false); const fileObj = ref({}); // 选择附件上传,对应动态参数添加 function uploadGo(item, index) { fileObj.value.refType = item.dictType; fileObj.value.refField = item.dictData; fileObj.value.fileList = item.fileList; fileObj.value.index = index; //动态的第几个 showDetail.value = true; } // 文件列表删除 function deleteGG(list, index) { list.splice(index, 1); } // 确定之后选择的附件 const closeGGDialog = e => { form.projectProcessAttachmentSaveRequestList[fileObj.value.index].fileList = e; showDetail.value = false; }; 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); fileObj.value.refId = projectList.value[0].id; //项目返回的id值 } form.isProjectExempt = projectList.value[0].isProjectExempt; }; 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 => { let it = projectList.value.find(item => item.projectNo === val); fileObj.value.refId = it.id; //项目返回的id值 inheritAttr(it, form); form.isProjectExempt = it.isProjectExempt; 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 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; fileObj.value.refId = res.data.projectId; //项目返回的id值 inheritAttr(res.data, form); form.isProjectExempt = res.data.isProjectExempt; 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) { let params = JSON.parse(JSON.stringify(form)); for (let item of params.projectProcessAttachmentSaveRequestList) { item.projectNo = params.projectNo; for (let it of item.fileList) { params.sysFileSaveRequestList.push(it); } } console.log(params); // 如果不是豁免项目,建设目标为必填 if (params.isProjectExempt == '0' || params.isProjectExempt == '') { if (!!!form.annualRunoffPollutionControlRate || !!!form.annualRunoffTotalControlRate || !!!form.hardGroundRate) { proxy.$modal.msgError('非豁免项目必须填写建设目标,请检查修改!'); return; } } 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>