xiangpei
2025-06-05 d328bd467ffcb660e81d546a0b242e39320acb6d
src/views/projectEngineering/projectLibrary/projectDetails.vue
@@ -1,7 +1,8 @@
<template>
  <div>
  <el-card class="card-container">
    <div class="flex-container mb-4">
      <el-tabs v-model="currentTab" @tab-click="handleClick">
      <el-tabs v-model="currentTab" @tab-click="handleClick" v-show="isShow">
        <el-tab-pane
          v-for="item in TABS_DATA"
          :key="item.value"
@@ -18,189 +19,258 @@
      :is="componentName"
      ref="childRef"
      :disabled="disabled"
      @toNext="changeTable"
      @updateIsShow="updateIsShow"
      @basicInfoForm="basicInfoForm"
      @investInfoForm="investInfoForm"
      @investmentFundsForm="investmentFundsForm"
      @legalPersonForm="legalPersonForm"
      @policyInfoForm="policyInfoForm"
      @documentsInfoForm="documentsInfoForm"
      :isShow="isShow"
      class="full-width custom-height"
    />
    <div v-if="audit" class="button-container">
      <el-button
        class="save-button"
        type="primary"
        @click="saveProject(2)"
      >通过</el-button>
      <el-button
        class="save-button"
        type="danger"
        @click="showDialog"
      >驳回</el-button>
    </div>
    <div v-if="!disabled" class="button-container">
      <el-button class="save-button" type="primary" @click="submit">保存</el-button>
      <el-button
        class="save-button"
        type="primary"
        @click="saveProject(0)"
        >草稿</el-button
      >
<!--      <el-button class="save-button" type="primary" @click="submit(1)"-->
<!--        >保存</el-button>-->
      <el-button class="save-button" type="primary" @click="saveProject(1)"
      >保存</el-button>
      <el-button class="reset-button" @click="reset">重置</el-button>
      <!-- <el-button v-else class="cancel-button" @click="cancel">取消</el-button> -->
    </div>
  </el-card>
    <el-dialog :visible.sync="remarkShow" width="1000px" title="驳回信息" append-to-body>
      <el-form ref="form" label-width="80px">
        <el-form-item label="驳回原因">
          <el-input type="textarea" v-model="remark"></el-input>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="cancelAuditing">取 消</el-button>
        <el-button type="primary" @click="submitAuditing">确 定</el-button>
      </div>
    </el-dialog>
</div>
</template>
<script>
import BasicInfo from '@/views/projectEngineering/projectLibrary/component/BasicInfo';
import InvestInfo from '@/views/projectEngineering/projectLibrary/component/InvestInfo';
import InvestmentFunds from '@/views/projectEngineering/projectLibrary/component/investmentFunds';
import LegalPerson from '@/views/projectEngineering/projectLibrary/component/legalPerson';
import PolicyInfo from '@/views/projectEngineering/projectLibrary/component/PolicyInfo';
import DocumentsInfo from '@/views/projectEngineering/projectLibrary/component/DocumentsInfo';
import { addProject, getProject, updateProject, getProjectCode } from '@/api/projectInfo';
import BasicInfo from "@/views/projectEngineering/projectLibrary/component/BasicInfo";
import InvestInfo from "@/views/projectEngineering/projectLibrary/component/InvestInfo";
import InvestmentFunds from "@/views/projectEngineering/projectLibrary/component/investmentFunds";
import LegalPerson from "@/views/projectEngineering/projectLibrary/component/legalPerson";
import ProjectFrom from "@/views/projectEngineering/projectLibrary/component/ProjectFrom";
import PolicyInfo from "@/views/projectEngineering/projectLibrary/component/PolicyInfo";
import DocumentsInfo from "@/views/projectEngineering/projectLibrary/component/DocumentsInfo";
import { editProject } from "@/api/projectEngineering/projectInfo";
export default {
  name: "ProjectDetails",
  data() {
    return {
      currentTab: '项目管理基础信息',
      id: this.$route.query.id || '',
      isShow: false,
      currentTab: "项目管理基础信息",
      disabled: false,
      remarkShow: false,
      audit: false,
      remark: '',
      projectForm: {},
      componentName: BasicInfo,
      projectId: null,
      TABS_DATA: [
        {
          label: '项目管理基础信息',
          value: '项目管理基础信息',
          componentName: BasicInfo
          label: "项目管理基础信息",
          value: "项目管理基础信息",
          componentName: BasicInfo,
        },
        // {
        //   label: "投资管理基础信息",
        //   value: "投资管理基础信息",
        //   componentName: InvestInfo,
        // },
        {
          label: "项目投资及资金来源",
          value: "项目投资及资金来源",
          componentName: InvestmentFunds,
        },
        {
          label: '投资管理基础信息',
          value: '任务下发',
          componentName: InvestInfo
          label: "项目(法人)单位登记信息",
          value: "项目(法人)单位登记信息",
          componentName: LegalPerson,
        },
        {
          label: ' 项目投资及资金来源',
          value: '项目投资及资金来源',
          componentName: InvestmentFunds
          label: "项目发起依据",
          value: "项目发起依据",
          componentName: ProjectFrom,
        },
        {
          label: '项目(法人)单位登记信息',
          value: '项目(法人)单位登记信息',
          componentName: LegalPerson
        },
        {
          label: '投资项目产业政策符合情况',
          value: '投资项目产业政策符合情况',
          componentName: PolicyInfo
        },
        {
          label: '相关文书',
          value: '相关文书',
          componentName: DocumentsInfo
        }
        // {
        //   label: "投资项目产业政策符合情况",
        //   value: "投资项目产业政策符合情况",
        //   componentName: PolicyInfo,
        // },
        // {
        //   label: "相关文书",
        //   value: "相关文书",
        //   componentName: DocumentsInfo,
        // },
      ],
      childRef: null,
      baseInfoRules: [
        {name: 'projectName', message: '请输入项目名称'},
        {name: 'content', message: '请输入建设内容'},
        {name: 'fundTypeList', message: '请选择资金类型'},
        {name: 'investType', message: '请选择项目投资类别'},
        {name: 'constructionNature', message: '请选择建设性质'},
        {name: 'attractInvestment', message: '请选择是否招商引资项目'},
        {name: 'projectType', message: '请选择项目推进类型'},
        {name: 'projectStatus', message: '请选择项目状态'},
        {name: 'projectPhase', message: '请选择项目阶段'},
        {name: 'projectContactPerson', message: '请输入项目联系人'},
        {name: 'contact', message: '请输入项目联系方式'},
        {name: 'projectOwnerUnit', message: '请选择项目业主单位'},
        {name: 'competentDepartment', message: '请选择主管部门'},
        {name: 'competentDepartmentPerson', message: '请选择主管部门联系人'},
        {name: 'competentDepartmentPhone', message: '请输入主管部门联系方式'},
        {name: 'area', message: '请选择行政区划'},
        {name: 'managementCentralizationList', message: '请选择管理归口'},
        {name: 'projectApprovalType', message: '请选择项目审批类型'},
        {name: 'importanceTypeList', message: '请选择重点分类'},
        {name: 'planStartTime', message: '请选择计划开工时间'},
        {name: 'planCompleteTime', message: '请选择计划竣工时间'},
        {name: 'industryCompetentDepartment', message: '请选择行业主管部门'},
        {name: 'industryCompetentDepartmentPerson', message: '请输入行业主管部门联系人'},
        {name: 'departmentPersonPhone', message: '请输入行业主管部门联系方式'},
      ],
      investmentFundsFormRules: [
        {name: 'totalInvestment', message: '项目总投资额不能为空(且大于0)'},
      ]
    };
  },
  methods: {
    showDialog(){
      this.remark = null;
      this.remarkShow = true;
    },
    cancelAuditing(){
      this.remark = null;
      this.remarkShow = false;
    },
    submitAuditing(){
      this.projectForm.projectInfoForm.remark = this.remark
      this.saveProject(3)
      this.remark = null
      this.remarkShow = false;
    },
    updateIsShow(newValue) {
      this.isShow = newValue;
    },
    basicInfoForm(data) {
      this.projectForm.projectInfoForm = data;
      this.projectId = data.id;
      this.audit = this.$route.query.audit == 1 && this.projectForm.projectInfoForm.auditRole;
    },
    investInfoForm(data) {
      this.projectForm.projectInvestmentInfoForm = data;
      this.projectForm.projectInvestmentInfoForm.projectId = this.projectId;
    },
    investmentFundsForm(data) {
      this.projectForm.projectInvestmentFundingForm = data;
      this.projectForm.projectInvestmentFundingForm.projectId = this.projectId;
    },
    documentsInfoForm(data){
      this.projectForm.documentInfoForm = data;
      this.projectForm.documentInfoForm.projectId = this.projectId;
    },
    legalPersonForm(data) {
      this.projectForm.projectUnitRegistrationInfoForm = data;
      this.projectForm.projectUnitRegistrationInfoForm.projectId = this.projectId;
    },
    policyInfoForm(data) {
      this.projectForm.projectInvestmentPolicyComplianceForm = data;
      this.projectForm.projectInvestmentPolicyComplianceForm.projectId = this.projectId;
    },
    handleClick(tabTarget) {
      this.componentName = this.TABS_DATA[tabTarget.index].componentName;
    },
    submit() {
      if (!this.projectForm.projectName) {
        this.$message.error('请输入项目名称');
        return;
      }
      if (this.projectForm.contact) {
        const phoneRegex = /^1[3-9]\d{9}$/;
        if (!phoneRegex.test(this.projectForm.contact)) {
          this.$message.error('请输入正确的手机号码');
          return;
        }
      }
      if (this.$refs.childRef) {
        this.$refs.childRef.$refs.demoFormRef.validate((valid) => {
          if (valid) {
            const payload = {
              projectInfoInsertDTO: this.projectForm,
              projectInvestmentInfo: this.investment,
              projectInvestmentFunding: this.investmentFunds,
              projectUnitRegistrationInfo: this.legalPerson,
              investmentProjectPolicyComplianceDTO: this.investmentProjectPolicyComplianceDTO,
              fileIdList: this.fileIdList
            };
            if (this.id) {
              updateProject(payload).then(res => {
                if (res.code === 200) {
                  this.$message.success(res.msg);
                  this.$router.push({ path: '/projectEngineering/project/projectLibrary' });
                } else {
                  this.$message.error(res.msg);
                }
              });
            } else {
              addProject(payload).then(res => {
                if (res.code === 200) {
                  this.$message.success(res.msg);
                  this.$router.push({ path: '/projectEngineering/project/projectLibrary' });
                } else {
                  this.$message.error(res.msg);
                }
              });
            }
          }
        });
      }
    changeTable(index) {
      this.componentName = this.TABS_DATA[index].componentName;
      this.currentTab = this.TABS_DATA[index].value;
    },
    getProjectInfo(id) {
      getProject(id, 0).then(res => {
        if (res.data) {
          this.investment = res.data.projectInvestmentInfo || {};
          this.investmentFunds = res.data.projectInvestmentFunding || {};
          this.legalPerson = res.data.projectUnitRegistrationInfo || {};
          this.investmentProjectPolicyComplianceDTO = res.data.investmentProjectPolicyComplianceDTO || {};
          if (res.data.investmentProjectPolicyComplianceDTO && res.data.investmentProjectPolicyComplianceDTO.sysOssVos.length > 0) {
            this.fileList = res.data.investmentProjectPolicyComplianceDTO.sysOssVos.map(item => ({
              fileId: item.ossId,
              name: item.originalName,
              url: item.url
            }));
          } else {
            this.fileList = [];
          }
          if (res.data.fileIdList) {
            this.fileIdList = res.data.fileIdList;
            this.documentsInfoList = res.data.sysOssVos.map(item => ({
              fileId: item.ossId,
              name: item.originalName,
              url: item.url
            }));
          }
          this.projectForm = res.data.projectInfoInsertDTO || {};
          this.projectList = res.data.projectInfoInsertDTO.sysOssVos.map(item => ({
            fileId: item.ossId,
            name: item.originalName,
            url: item.url
          }));
        }
      });
    submit(usedStatus) {
      this.$refs.childRef.submit(usedStatus);
    },
    reset() {
      if (this.id) {
        this.getProjectInfo(this.id);
      this.$refs.childRef.reset();
    },
    saveProject(num) {
      this.projectForm.projectInfoForm.usedStatus = num;
      const msg = this.formValidate()
      if (msg && num != 0) {  // 草稿不校验
        this.$message.error(msg)
      } else {
        this.getProjectCodeApi();
        this.resetPlanLibrary();
        this.fileList = [];
        this.fileIdList = [];
        this.projectList = [];
        this.documentsInfoList = [];
        editProject(this.projectForm).then((res) => {
          this.$message.success("保存成功");
          this.$store.dispatch("tagsView/delView", this.$route);
          this.$router.push('/projectEngineering/project/projectLibrary')
        })
      }
    },
    cancel() {
      this.$router.push({ path: '/projectEngineering/project/reserveProjects', query: { projectCategory: '1' } });
      localStorage.removeItem('fileIdList');
    },
    getProjectCodeApi() {
      getProjectCode().then(res => {
        if (res.code === 200) {
          this.projectForm.projectCode = res.msg;
    /**
     * 临时使用这种方式校验
     */
    formValidate() {
      let msg = "";
      for (let i = 0; i < this.baseInfoRules.length; i++) {
        if (! this.projectForm.projectInfoForm[this.baseInfoRules[i].name]) {
          msg = this.baseInfoRules[i].message
          return msg
        }
      });
      }
      console.log(this.projectForm, "项目信息")
      if (this.projectForm.projectInvestmentFundingForm) {
        for (let i = 0; i < this.investmentFundsFormRules.length; i++) {
          const name = this.investmentFundsFormRules[i].name
          if (! this.projectForm.projectInvestmentFundingForm[name]) {
            msg = this.investmentFundsFormRules[i].message
            return msg
          } else if (name == 'totalInvestment' && parseFloat(this.projectForm.projectInvestmentFundingForm[name]) <= 0) {
            // 如果是总投资额,不仅不能为空还必须大于0
            msg = this.investmentFundsFormRules[i].message
            return msg
          }
        }
      }
      return msg;
    },
  },
  created() {
    // 在组件创建时获取项目信息,如果 id 存在
    if (this.id) {
      this.getProjectInfo(this.id);
    } else {
      this.getProjectCodeApi();
  mounted() {
    if (this.$route.query.disabled) {
      this.disabled = true;
    }
  },
};
</script>
<style scoped>
::v-deep .el-tabs__nav-wrap::after {
  background-color: rgba(0, 0, 0, 0) !important;
}