Newer
Older
KaiFengPC / src / views / project / processControl / constructionPermits / operate.vue
@鲁yixuan 鲁yixuan on 19 Aug 29 KB updata
<template>
  <div class="operate" v-loading.fullscreen.lock="loading" element-loading-text="加载中..." element-loading-background="rgba(0, 0, 0, 0.6)">
    <el-steps :active="active" finish-status="success" align-center class="steps">
      <el-step title="施工许可提交" />
      <el-step title="项目预审" />
      <el-step title="人工审查" />
      <el-step title="审核通过" />
    </el-steps>
    <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="formItem110">
            <el-select
              v-model="form.projectNo"
              placeholder="请选择项目名称"
              style="width: 100%"
              @change="projectChange"
              :disabled="opts.type !== 'add'"
            >
              <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="formItem110">
            <el-input v-model="form.projectNo" :disabled="true" />
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="项目类型:" prop="projectTypeId" class="formItem110">
            <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="项目面积:" prop="projectArea" class="formItem110">
            <el-input v-model="form.projectArea" :disabled="true" />
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="用地类型:" prop="spongeLandType" class="formItem110">
            <el-input v-model="form.spongeLandTypeName" :disabled="true" />
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="绿地率%:" prop="greenRate" class="formItem110">
            <el-input v-model="form.greenRate" :disabled="true" />
          </el-form-item>
        </el-col>
      </el-row>
      <el-row :gutter="20">
        <el-col :span="8">
          <el-form-item label="建设单位:" prop="chargeDepartment" class="formItem110">
            <el-input v-model="form.chargeDepartment" :disabled="true" />
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="建设状态:" prop="buildStatus" class="formItem110">
            <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" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="年径流污染去除率%:" prop="annualRunoffPollutionControlRate" class="formItem140">
              <el-input v-model="form.annualRunoffPollutionControlRate" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="硬化地面率%:" prop="hardGroundRate" class="formItem140">
              <el-input v-model="form.hardGroundRate" />
            </el-form-item>
          </el-col>
        </el-row>
      </div>
      <el-divider content-position="left">责任部门</el-divider>
      <el-row :gutter="20">
        <el-col :span="8">
          <el-form-item label="责任部门:" prop="chargeDepartment" class="formItem110">
            <el-input v-model="form.chargeDepartment" :disabled="true" />
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="责任人:" prop="chargeUser" class="formItem110">
            <el-input v-model="form.chargeUser" :disabled="true" />
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="联系方式:" prop="phone" class="formItem110">
            <el-input v-model="form.phone" :disabled="true" />
          </el-form-item>
        </el-col>
      </el-row>
      <el-row :gutter="20">
        <el-col :span="8">
          <el-form-item label="设计单位:" prop="designUnit" class="formItem110">
            <el-input v-model="form.designUnitName" :disabled="true" />
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="施工单位:" prop="constructUnit" class="formItem110">
            <el-input v-model="form.constructUnitName" :disabled="true" />
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="运维单位:" prop="operationUnit" class="formItem110">
            <el-input v-model="form.operationUnitName" :disabled="true" />
          </el-form-item>
        </el-col>
      </el-row>
      <el-divider content-position="left">项目投资</el-divider>
      <el-row :gutter="20">
        <el-col :span="12">
          <el-form-item label="投资批复文件说明(已批复项目填写):" prop="investFileName">
            <el-input v-model="form.investFileName" :disabled="true" />
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <div class="fileName" v-show="fileInfo.fileName">
            <span>{{ fileInfo.fileName }}</span>
            <!-- <el-button type="primary" link>下载</el-button> -->
          </div>
        </el-col>
      </el-row>
      <el-row :gutter="20">
        <el-col :span="8">
          <el-form-item label="项目总投资(含主体工程)(万元):" prop="totalInvest" class="mb5">
            <el-input v-model="form.totalInvest" :disabled="true" />
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="地方政府投资(万元):" prop="govermentInvest" class="mb5">
            <el-input v-model="form.govermentInvest" :disabled="true" />
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="社会资本投入(万元):" prop="socialInvest" class="mb5">
            <el-input v-model="form.socialInvest" :disabled="true" />
          </el-form-item>
        </el-col>
      </el-row>
      <el-row :gutter="20">
        <el-col :span="8">
          <el-form-item label="项目运作模式:" prop="projectOperationPatternName" class="mb5">
            <el-input v-model="form.projectOperationPatternName" :disabled="true" />
          </el-form-item>
        </el-col>
        <el-col :span="10">
          <el-form-item label="海绵相关投资(不含主体工程)(万元):" prop="spongeInvest" class="mb5">
            <el-input v-model="form.spongeInvest" :disabled="true" />
          </el-form-item>
        </el-col>
      </el-row>
      <el-table :data="form.list1" v-if="projectInvestList[0]">
        <el-table-column v-for="it in projectInvestList[0].list" :label="it.propertyName" :prop="it.propertyKey">
          <template #default="{ row }">
            <el-input v-model="row[it.propertyKey]" :disabled="opts.type === 'audit'" />
          </template>
        </el-table-column>
      </el-table>
      <el-divider content-position="left">立项资料</el-divider>
      <div class="box" v-for="item in projectApprovalFileList">
        <el-row :gutter="24">
          <el-col :span="24">
            <el-form-item :label="`${item.name}:`" class="formItem140">
              <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">
                  <div class="name ellipsis" :title="img.name">{{ img.name || '--' }}</div>
                </div>
              </div>
            </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 planningStageFileList">
          <el-row :gutter="24">
            <el-col :span="24">
              <el-form-item :label="`${item.name}:`" class="formItem140">
                <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">
                    <div class="name ellipsis" :title="img.name">{{ img.name || '--' }}</div>
                  </div>
                </div>
              </el-form-item>
            </el-col>
          </el-row>
        </div>
        <el-form-item label="其他说明:" prop="permissionDescription" class="formItem140 mb0">
          <el-input v-model="form.permissionDescription" type="textarea" resize="none" :disabled="true" />
        </el-form-item>
      </div>
      <el-divider content-position="left">施工阶段资料</el-divider>
      <div class="box" v-for="(item, i) in form.projectProcessAttachmentSaveRequestList">
        <el-row :gutter="24">
          <el-col :span="8">
            <!-- 必填  :rules="opts.type === 'add' || (i < 2 && opts.type === 'audit') ? rules['filieDescription'] : []"-->
            <el-form-item
              :label="`${item.name}:`"
              :prop="'projectProcessAttachmentSaveRequestList.' + i + '.' + 'filieDescription'"
              class="formItem140"
              :rules="opts.type === 'add' || (i < 2 && opts.type === 'audit') ? rules['filieDescription'] : []"
            >
              <el-input
                v-model="item.filieDescription"
                placeholder="请输入资料说明"
                style="width: 200px"
                :disabled="i < 2 && opts.type === 'audit'"
              />
            </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']"
              :disabled="i < 2 && opts.type === 'audit'"
            />
          </el-col>
        </el-row>
      </div>
      <el-row :gutter="20">
        <el-col :span="12">
          <el-form-item label="指定处理人:" prop="dealUsers" class="formItem110">
            <el-select v-model="form.dealUsers" placeholder="请选择指定处理人" style="width: 100%" :disabled="opts.type === 'audit'">
              <el-option v-for="dict in userLists" :key="dict.userId" :label="dict.nickName" :value="dict.userId" />
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="流程抄送人:" prop="pushUsers" class="formItem110">
            <el-select v-model="form.pushUsers" placeholder="请选择流程抄送人" style="width: 100%" :disabled="opts.type === 'audit'">
              <el-option v-for="dict in userLists" :key="dict.userId" :label="dict.nickName" :value="dict.userId" />
            </el-select>
          </el-form-item>
        </el-col>
      </el-row>
      <el-form-item label="审核意见:" prop="approveComment" class="formItem110" v-if="opts.type === 'audit'">
        <el-input v-model="form.approveComment" type="textarea" resize="none" />
      </el-form-item>
      <el-divider content-position="left" v-if="form.status && form.status !== 'start'">流程日志</el-divider>
      <div class="stapesBox" v-if="form.status && form.status !== 'start'">
        <el-steps direction="vertical" :active="stapesDate.length">
          <el-step v-for="i in stapesDate" :title="i.activityName" style="width: 300px">
            <template #description>
              <div class="direction">时间:{{ i.endTime }}</div>
              <div class="direction">分配人:{{ i.assigneeName }}</div>
              <div class="direction">任务备注:{{ i.comment }}</div>
            </template>
          </el-step>
        </el-steps>
      </div>
    </el-form>
  </div>
</template>

<script setup>
import { ref, reactive, onMounted } from 'vue';
import { required, isNumber } from '@/utils/validate-helper';
import { getProjectInfoNewList, getDicts } from '@/api/project/projectApproval';
import ImageFileUpload from '@/components/ImageFileUpload/index.vue'; //图片文件上传
import { projectInfoNewDetail, getFileLIst, getProjectCompanyList } from '@/api/project/projectInformationNew';
import {
  projectConstructionPermitsAdd,
  projectConstructionPermitsEdit,
  projectConstructionPermitsStartWorkFlow,
  userList,
  projectConstructionPermitsDetail,
  workflowProcess,
  projectConstructionPermitsApprove,
} from '@/api/project/constructionPermits';
import { inheritAttr } from '@/utils/v3';
import { useDicts } from '@/hooks';
import useUserStore from '@/store/modules/user';

const { proxy } = getCurrentInstance();
const showDetail = ref(false);
const fileObj = ref({});
const { findText } = useDicts(proxy);
const { pro_project_approval } = proxy.useDict('pro_project_approval');
const { planning_stage } = proxy.useDict('planning_stage');
const { construction_permits } = proxy.useDict('construction_permits');
const emit = defineEmits(['close']);
const props = defineProps({
  curRow: {
    type: Object,
    default: () => ({}),
  },
  opts: {
    type: Object,
    default: () => ({}),
  },
  types: {
    type: Array,
    default: [],
  },
  projectContentType: {
    type: Array,
    default: () => [],
  },
  curStatus: {
    type: String,
    default: '',
  },
});
const { curRow, opts } = props;
const loading = ref(false);
const active = ref(0);
const form = reactive({
  projectName: '',
  projectNo: '',
  projectNo: '',
  projectTypeId: '',
  projectTypeIdName: '',
  projectArea: '',
  spongeLandType: '',
  spongeLandTypeName: '',
  greenRate: '',
  chargeDepartment: '',
  buildStatus: '',
  buildStatusName: '',
  annualRunoffTotalControlRate: '',
  annualRunoffPollutionControlRate: '',
  hardGroundRate: '',
  chargeDepartment: '',
  chargeUser: '',
  phone: '',
  designUnit: '',
  designUnitName: '',
  constructUnit: '',
  constructUnitName: '',
  operationUnit: '',
  operationUnitName: '',
  investFileName: '',
  totalInvest: '',
  govermentInvest: '',
  socialInvest: '',
  projectOperationPattern: '',
  projectOperationPatternName: '',
  spongeInvest: '',
  permissionDescription: '',
  list1: [{}],
  projectProcessAttachmentSaveRequestList: [],
  fileSaveRequestList: [],
  dealUsers: '',
  pushUsers: '',
  projectItemDescriptionSaveRequestList: [],
  status: '',
  approveComment: '',
  workflowInstanceId: '',
});

const rules = reactive({
  projectName: required('项目名称'),
  projectNo: required('项目编码'),
  projectTypeId: required('项目类型'),
  projectArea: isNumber('项目面积', { required: true }),
  spongeLandType: required('用地类型'),
  greenRate: isNumber('绿地率%', { required: true }),
  chargeDepartment: required('建设单位'),
  buildStatus: required('建设状态'),
  annualRunoffTotalControlRate: isNumber('年径流总量控制率', {
    required: true,
  }),
  annualRunoffPollutionControlRate: isNumber('年径流污染去除率', {
    required: true,
  }),
  hardGroundRate: isNumber('硬化地面率', { required: true }),
  chargeDepartment: required('责任部门'),
  chargeUser: required('责任人'),
  phone: required('联系方式'),
  designUnit: required('设计单位'),
  designUnit: required('施工单位'),
  operationUnit: required('运维单位'),
  investFileName: required('投资批复文件名称'),
  totalInvest: isNumber('项目总投资', { required: true }),
  govermentInvest: isNumber('地方政府投资', { required: true }),
  socialInvest: isNumber('社会资本投入', { required: true }),
  projectOperationPattern: required('项目运作模式'),
  spongeInvest: isNumber('海绵相关投资', { required: true }),
  filieDescription: required('内容'),
  approveComment: required('审核意见'),
});

const stapesDate = ref([]);

const projectList = ref([]);
const projectApprovalFileList = ref([]);
const planningStageFileList = ref([]);

const fileInfo = reactive({
  fileName: '',
});

const projectInvestList = ref([]);
const userLists = ref([]);

const projectCompanyList = 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 getProjectCompanyLists = async () => {
  const res = await getProjectCompanyList();
  if (res?.code !== 200) return;
  projectCompanyList.value = res?.data || [];
};

// const getProjectInvestList = async () => {
//   const res = await getProjectItemDescriptionConfigList({ projectTypeId: form.projectTypeId })
//   if(res?.code !== 200) return
//   const projectItemDescriptionConfigList = res?.data || []
//   projectInvestList.value = props.projectContentType.slice(3).map(item => {
//     const list = projectItemDescriptionConfigList.filter(it => it.projectContentType === item.value)
//     const obj = {}
//     for (const item of list) {
//       obj[item.propertyKey] = ''
//     }
//     form.list1 = [obj]
//     return {
//       list: JSON.parse(JSON.stringify(list)),
//       label: item.label
//     }
//   })
// }

const getFileInfo = async (id, refType, refField, callback) => {
  const res = await getFileLIst({ refId: id, refType, refField });
  if (res?.code !== 200) return;
  callback && callback(res.data);
};

const getProjectTypeFileList = async (fileGroup, type, list, filterList) => {
  for (const key in fileGroup) {
    if (key === type) {
      if (Object.hasOwnProperty.call(fileGroup, key)) {
        const element = fileGroup[key];
        for (const item of element) {
          const info = filterList.value.find(it => it.value === item.dictData);
          if (!info) continue;
          const dictDatas = list.map(it => it.dictData);
          if (dictDatas.includes(item.dictData)) continue;
          list.push({
            fileList: item.fileList,
            dictData: item.dictData,
            dictType: item.dictType,
            filieDescription: item.filieDescription,
            projectNo: item.projectNo,
            name: info.label,
          });
        }
      }
    }
  }
};

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值
  }
};

const projectChange = async val => {
  form.list1 = [{}];
  const res = await projectInfoNewDetail(val);
  if (res?.code !== 200) return;
  fileObj.value.refId = res.data.id; //项目返回的id值
  inheritAttr(res.data, form);
  form.projectTypeIdName = props.types.find(it => it.id === form.projectTypeId)?.projectTypeName;
  form.spongeLandTypeName = findText('sponge_land_type', form.spongeLandType);
  form.buildStatusName = findText('build_status', form.buildStatus);
  form.projectOperationPatternName = findText('project_operation_pattern', form.projectOperationPattern);
  form.designUnitName = projectCompanyList.value.find(item => item.id === form.designUnit)?.unitName || '';
  form.constructUnitName = projectCompanyList.value.find(item => item.id === form.constructUnit)?.unitName || '';
  form.operationUnitName = projectCompanyList.value.find(item => item.id === form.operationUnit)?.unitName || '';

  getFileInfo(res.data.id, 'projectInfoNew', 'investmentApproval', data => {
    console.log(data);
    fileInfo.fileName = data?.[0]?.name || '';
  });

  // getProjectInvestList()
  const projectItemDescriptionConfigList = res?.data?.projectItemDescriptionList || [];
  projectInvestList.value = props.projectContentType.slice(3).map(item => {
    const list = projectItemDescriptionConfigList.filter(it => it.projectContentType === item.value);
    const obj = {};
    for (const item of list) {
      obj[item.propertyKey] = item.propertyValue;
    }
    form.list1 = [obj];
    return {
      list: JSON.parse(JSON.stringify(list)),
      label: item.label,
    };
  });

  const fileGroup = res.data.fileGroup;
  projectApprovalFileList.value = [];
  getProjectTypeFileList(fileGroup, 'pro_project_approval', projectApprovalFileList.value, pro_project_approval);
  planningStageFileList.value = [];
  getProjectTypeFileList(fileGroup, 'planning_stage', planningStageFileList.value, planning_stage);
  getDictMaps('construction_permits');
};

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);
    // form.projectProcessAttachmentSaveRequestList = form.projectProcessAttachmentSaveRequestList.slice(0, 2);
  }

  setTimeout(() => {
    if (proxy.$refs.ruleForm) {
      proxy.$refs.ruleForm.clearValidate();
    }
  });
};

const getUserList = async () => {
  const res = await userList();
  if (res?.code !== 200) return;
  userLists.value = res?.data || [];
};

const submit = type => {
  proxy.$refs.ruleForm.validate(async (valid, fields) => {
    if (valid) {
      if (type === 2) {
        if (!form.dealUsers) return proxy.$modal.msgError('请指定处理人!');
        if (!form.pushUsers) return proxy.$modal.msgError('请指定抄送人!');
      }
      loading.value = true;
      const params = JSON.parse(JSON.stringify(form));
      delete params.list1;
      for (const item of params.projectProcessAttachmentSaveRequestList) {
        item.projectNo = params.projectNo;
        for (const it of item.fileList) {
          params.fileSaveRequestList.push(it);
        }
      }
      params.projectItemDescriptionSaveRequestList = [];
      for (let j = 0; j < projectInvestList.value.length; j++) {
        const formList = form.list1;
        const item = projectInvestList.value[j];
        for (const it of item.list) {
          for (const key in formList[0]) {
            if (Object.hasOwnProperty.call(formList[0], key)) {
              const element = formList[0][key];
              if (key === it.propertyKey) {
                it.propertyValue = element;
              }
            }
          }
          params.projectItemDescriptionSaveRequestList.push(it);
        }
      }
      console.log(params);
      let methed = '';
      if (type === 1) {
        if (curRow?.id) {
          params.id = curRow.id;
          methed = projectConstructionPermitsEdit;
        } else {
          methed = projectConstructionPermitsAdd;
        }
      } else {
        if (curRow?.id) {
          params.id = curRow.id;
        }
        methed = projectConstructionPermitsStartWorkFlow;
      }
      try {
        const res = await methed(params);
        loading.value = false;
        if (res?.code !== 200) return;
        proxy.$modal.msgSuccess('操作成功!');
        emit('close');
      } catch (error) {
        loading.value = false;
      }
    } else {
      console.log('error submit!', fields);
    }
  });
};

const handleAudit = result => {
  proxy.$refs.ruleForm.validate(async (valid, fields) => {
    if (valid) {
      const params = JSON.parse(JSON.stringify(form));
      delete params.list1;
      params.fileSaveRequestList = [];
      for (let i = 0; i < params.projectProcessAttachmentSaveRequestList.length; i++) {
        if (opts.type === 'audit' && i < 2) continue;
        const item = params.projectProcessAttachmentSaveRequestList[i];
        if (result === 'true' && !item.filieDescription) {
          return proxy.$modal.msgError(`${item.name}文件说明不能为空!`);
        }
        item.projectNo = params.projectNo;
        for (const it of item.fileList) {
          params.fileSaveRequestList.push(it);
        }
      }
      loading.value = true;
      if (opts.type === 'audit') {
        params.projectProcessAttachmentSaveRequestList = params.projectProcessAttachmentSaveRequestList.slice(2);
      }
      params.projectItemDescriptionSaveRequestList = [];
      for (let j = 0; j < projectInvestList.value.length; j++) {
        const formList = form.list1;
        const item = projectInvestList.value[j];
        for (const it of item.list) {
          for (const key in formList[0]) {
            if (Object.hasOwnProperty.call(formList[0], key)) {
              const element = formList[0][key];
              if (key === it.propertyKey) {
                it.propertyValue = element;
              }
            }
          }
          params.projectItemDescriptionSaveRequestList.push(it);
        }
      }

      params.approveResult = result;
      params.submitUserId = useUserStore().userId;
      params.id = curRow.id;
      console.log(params);
      try {
        const res = await projectConstructionPermitsApprove(params);
        loading.value = false;
        if (res?.code !== 200) return;
        proxy.$modal.msgSuccess('操作成功!');
        emit('close');
      } catch (error) {
        loading.value = false;
      }
    } else {
      console.log('error submit!', fields);
    }
  });
};

const getDetail = async () => {
  const res = await projectConstructionPermitsDetail(curRow.id);
  if (res?.code !== 200) return;
  fileObj.value.refId = res.data.projectId; //项目返回的id值
  inheritAttr(res.data, form);

  form.projectTypeIdName = props.types.find(it => it.id === form.projectTypeId)?.projectTypeName;
  form.spongeLandTypeName = findText('sponge_land_type', form.spongeLandType);
  form.buildStatusName = findText('build_status', form.buildStatus);
  form.projectOperationPatternName = findText('project_operation_pattern', form.projectOperationPattern);
  form.designUnitName = projectCompanyList.value.find(item => item.id === form.designUnit)?.unitName || '';
  form.constructUnitName = projectCompanyList.value.find(item => item.id === form.constructUnit)?.unitName || '';
  form.operationUnitName = projectCompanyList.value.find(item => item.id === form.operationUnit)?.unitName || '';
  form.dealUsers = form.dealUsers * 1 || '';
  form.pushUsers = form.pushUsers * 1 || '';

  getFileInfo(res.data.id, 'projectInfoNew', 'investmentApproval', data => {
    console.log(data);
    fileInfo.fileName = data?.[0]?.name || '';
  });
  const projectItemDescriptionConfigList = res?.data?.projectItemDescriptionSaveRequestList || [];
  projectInvestList.value = props.projectContentType.slice(3).map(item => {
    const list = projectItemDescriptionConfigList.filter(it => it.projectContentType === item.value);
    const obj = {};
    for (const item of list) {
      obj[item.propertyKey] = item.propertyValue;
    }
    form.list1 = [obj];
    return {
      list: JSON.parse(JSON.stringify(list)),
      label: item.label,
    };
  });

  const fileGroup = res.data.fileGroup;
  projectApprovalFileList.value = [];
  getProjectTypeFileList(fileGroup, 'pro_project_approval', projectApprovalFileList.value, pro_project_approval);
  planningStageFileList.value = [];
  getProjectTypeFileList(fileGroup, 'planning_stage', planningStageFileList.value, planning_stage);
  form.projectProcessAttachmentSaveRequestList = [];
  getProjectTypeFileList(fileGroup, 'construction_permits', form.projectProcessAttachmentSaveRequestList, construction_permits);

  if (form.status && form.status !== 'start') {
    workflowProcessM(res.data.id);
    if (form.status === 'submit') {
      active.value = 0;
    } else if (form.status === 'projectInquiry') {
      active.value = 1;
    } else if (form.status === 'manualReview') {
      active.value = 2;
    } else if (form.status === 'end') {
      active.value = 4;
    }
  }

  if (opts.type === 'audit') {
    const res = await getDicts('construction_permits');
    if (res?.code !== 200) return;
    if (res?.data) {
      res.data = res.data.slice(2);
      for (const item of res.data) {
        form.projectProcessAttachmentSaveRequestList.push({
          fileList: [],
          dictData: item.dictValue,
          dictType: item.dictType,
          filieDescription: '',
          projectNo: '',
          name: item.dictLabel,
        });
      }
    }
  }
};

//获取流程日志
const workflowProcessM = async id => {
  let params = {
    businessKey: id,
    workflowKey: 'projectConstructionPermits',
    workflowUserId: '',
  };
  let { data } = await workflowProcess(params);
  stapesDate.value = data;
};

onMounted(async () => {
  await getProjectCompanyLists();
  getProjectList();
  getUserList();
  if (curRow?.id) {
    getDetail();
  }
});

defineExpose({
  submit,
  handleAudit,
});
</script>

<style lang="scss" scoped>
.operate {
  .steps {
    margin-bottom: 20px;
  }

  .pl20 {
    padding-left: 20px;
  }

  .tips {
    margin-left: 10px;
    line-height: 30px;
  }

  .mb5 {
    margin-bottom: 5px;
  }

  .mb0 {
    margin-bottom: 0;
  }

  .fileName {
    white-space: nowrap;
    line-height: 30px;
  }

  .fileSaveRequestList {
    .file-item {
      white-space: nowrap;
      display: flex;
      align-items: center;
      margin-bottom: 5px;
      line-height: 30px;
    }
  }
  .box {
    margin-bottom: 10px;
  }

  .direction {
    min-width: 190px;
  }

  .stapesBox {
    min-height: 100px;
    margin-bottom: 30px;
    margin-left: 30px;
  }
}
</style>