fuliqi
2024-11-28 0ead7315c0e6076aded0dac7a6ff0b89c632287b
src/views/projectEngineering/projectLibrary/component/InvestInfo.vue
@@ -1,11 +1,11 @@
<template>
  <div class="basic-info">
    <el-form ref="demoFormRef" :disabled="disabled" :model="investment" class="dialog_form">
    <el-form ref="demoFormRef" :disabled="disabled" :model="investmentForm" class="dialog_form">
      <el-row :gutter="20">
        <el-col :span="6">
          <el-form-item label="建设地点是否跨域" label-width="120px" prop="fundsType" style="width: 100%">
            <el-select
              v-model="investment.beCrossRegion"
              v-model="investmentForm.beCrossRegion"
              clearable
              placeholder="请选择"
              style="width: 100%"
@@ -18,8 +18,9 @@
        <el-col :span="6">
          <el-form-item label="项目建设地点" label-width="120px" prop="investmentType" style="width: 100%">
            <el-select
              v-model="investment.constructionLocation"
              v-model="investmentForm.constructionLocation"
              clearable
              disabled
              placeholder="请选择"
              style="width: 100%"
            >
@@ -30,7 +31,8 @@
        </el-col>
        <el-col :span="6">
          <el-form-item label="建设详细地址" label-width="120px" prop="fundsType" style="width: 100%">
            <el-input v-model.trim="investment.detailedAddress" class="item" clearable disabled maxlength="255" placeholder="请输入" />
            <el-input v-model.trim="investmentForm.detailedAddress" class="item" clearable disabled maxlength="255"
                      placeholder="请输入"/>
          </el-form-item>
        </el-col>
      </el-row>
@@ -38,7 +40,7 @@
        <el-col :span="6">
          <el-form-item label="是否是补码项目" label-width="120px" prop="projectType" style="width: 100%">
            <el-select
              v-model="investment.beCompensationProject"
              v-model="investmentForm.beCompensationProject"
              clearable
              placeholder="请选择"
              style="width: 100%"
@@ -50,32 +52,42 @@
        </el-col>
        <el-col :span="12">
          <el-form-item label="补码原因" label-width="120px" prop="projectstatus" style="width: 100%">
            <el-input v-model.trim="investment.compensationReason" class="item" clearable maxlength="255" placeholder="请输入" />
            <el-input v-model.trim="investmentForm.compensationReason" class="item" clearable maxlength="255"
                      placeholder="请输入"/>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row :gutter="20">
        <el-col :span="6">
          <el-form-item label="计划开工时间" label-width="120px" prop="plannedStartDate" style="width: 100%">
            <!--            <el-date-picker v-model="plannedStartDate" placeholder="选择时间" style="width: 100%" type="date" @change="chaneStartWork" />-->
            <el-input v-model.trim="plannedStartDate" class="item" clearable disabled maxlength="255" placeholder="请输入" />
            <el-date-picker v-model="investmentForm.plannedStartDate"
                            placeholder="选择时间"
                            style="width: 100%"
                            disabled
                            type="date"
                            value-format="yyyy-MM-dd HH:mm:ss"/>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="拟建成时间" label-width="120px" prop="expectedCompletionDate" style="width: 100%">
            <!--            <el-date-picker v-model="expectedCompletionDate" placeholder="选择时间" style="width: 100%" type="date" @change="chaneCompleted" />-->
            <el-input v-model.trim="expectedCompletionDate" class="item" clearable disabled maxlength="255" placeholder="请输入" />
            <el-date-picker
              v-model="investmentForm.expectedCompletionDate"
              placeholder="选择时间"
              disabled
              style="width: 100%"
              type="date"
              value-format="yyyy-MM-dd HH:mm:ss"/>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="国际行业分类" label-width="120px" prop="engineering" style="width: 100%">
            <el-select
              v-model="investment.nationalIndustryClassification"
              v-model="investmentForm.nationalIndustryClassification"
              clearable
              placeholder="请选择"
              style="width: 100%"
            >
              <el-option v-for="item in dict.type.sys_whether_project" :key="item.value" :label="item.label"
              <el-option v-for="item in dict.type.sys_industry_classification" :key="item.value" :label="item.label"
                         :value="item.value"/>
            </el-select>
          </el-form-item>
@@ -84,13 +96,14 @@
      <el-row :gutter="20">
        <el-col :span="6">
          <el-form-item label="所属行业分类" label-width="120px" prop="department" style="width: 100%">
            <el-input v-model.trim="investment.industryClassification" class="item" clearable maxlength="255" placeholder="请输入" />
            <el-input v-model.trim="investmentForm.industryClassification" class="item" clearable maxlength="255"
                      placeholder="请输入"/>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="项目建成性质" label-width="120px" prop="design" style="width: 100%">
            <el-select
              v-model="investment.projectNature"
              v-model="investmentForm.projectNature"
              clearable
              placeholder="请选择"
              style="width: 100%"
@@ -103,7 +116,7 @@
        <el-col :span="6">
          <el-form-item label="项目属性" label-width="120px" prop="putUnder" style="width: 100%">
            <el-select
              v-model="investment.projectAttribute"
              v-model="investmentForm.projectAttribute"
              clearable
              placeholder="请选择"
              style="width: 100%"
@@ -118,7 +131,7 @@
        <el-col :span="18">
          <el-form-item label="是否使用土地" label-width="120px" prop="approvalType" style="width: 100%">
            <el-select
              v-model="investment.useEarth"
              v-model="investmentForm.useEarth"
              clearable
              placeholder="请选择"
              style="width: 100%"
@@ -132,14 +145,17 @@
      <el-row :gutter="20">
        <el-col :span="18">
          <el-form-item class="item" label="主要建设内容及规模" label-width="120px" prop="content">
            <el-input v-model.trim="investment.contentScale" class="item" clearable maxlength="255" placeholder="请输入" type="textarea" />
            <el-input v-model.trim="investmentForm.contentScale" class="item" clearable maxlength="255"
                      placeholder="请输入"
                      type="textarea"/>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row :gutter="20">
        <el-col :span="18">
          <el-form-item class="item" label="建管平台代码" label-width="120px" prop="content">
            <el-input v-model.trim="investment.code" class="item" clearable maxlength="255" placeholder="请输入" type="textarea" />
            <el-input v-model.trim="investmentForm.code" class="item" clearable maxlength="255" placeholder="请输入"
                      type="textarea"/>
          </el-form-item>
        </el-col>
      </el-row>
@@ -148,10 +164,15 @@
</template>
<script>
import { formatDate } from '@/utils';
import Cookies from "js-cookie";
import {
  addProjectInvestmentInfo,
  editProjectInvestmentInfo,
  getProjectInvestmentInfoById
} from "@/api/projectEngineering/projectInvestmentInfo";
export default {
  dicts: ['sys_cross_domain','sys_administrative_divisions','sys_whether_project','sys_industry_belong','sys_project_attributes'],
  dicts: ['sys_cross_domain', 'sys_industry_classification', 'sys_administrative_divisions', 'sys_whether_project', 'sys_industry_belong', 'sys_project_attributes'],
  name: 'InvestmentForm',
  props: {
    disabled: {
@@ -162,7 +183,9 @@
  },
  data() {
    return {
      investment: {
      projectForm: {},
      investmentForm: {
        id: '',
        beCrossRegion: '',
        constructionLocation: '',
        detailedAddress: '',
@@ -179,48 +202,6 @@
        code: '',
        projectId: ''
      },
      projectForm: {
        projectName: '',
        projectCode: '',
        projectType: '',
        projectStatus: '1',
        fundType: '',
        investType: '',
        importanceType: '',
        projectPhase: '储备规划阶段',
        tag: '',
        competentDepartment: '',
        projectLocation: '',
        longitude: '',
        latitude: '',
        managementCentralization: '',
        projectApplicationPhase: '',
        projectApprovalType: '',
        investmentCatalogue: '',
        approvalPlan: '',
        isSetProject: '',
        setTime: '',
        assignmentStatus: '',
        area: '',
        winTime: '',
        winUnit: '',
        winAmount: '',
        address: '',
        engineeringIdList: [],
        content: '',
        contact: '',
        projectOwnerUnit: '',
        planStartTime: '',
        planCompleteTime: '',
        projectContactPerson: '',
        fileIdList: [],
        sysOssVos: [],
        engineeringInfos: [],
        year: '',
        yearInvestAmount: '',
        competentDepartmentList: [],
        managementCentralizationList: []
      },
      plannedStartDate: '',
      expectedCompletionDate: '',
      sys_cross_domain: [],
@@ -232,34 +213,59 @@
    };
  },
  mounted() {
    this.updateFormData();
    // 从Cookies中获取缓存数据
    const investmentForm = Cookies.get("investmentForm");
    const projectForm = Cookies.get("projectForm");
    // 尝试解析JSON数据
    const parsedInvestmentForm = investmentForm ? JSON.parse(investmentForm) : null;
    const parsedProjectForm = projectForm ? JSON.parse(projectForm) : null;
    // 设置investment和projectForm对象
    this.investmentForm = parsedInvestmentForm || {};
    this.projectForm = parsedProjectForm || {};
    // 如果projectForm存在id且没有缓存,则调用api
    if (this.projectForm.id && !investmentForm) {
      this.getInvestment();
    }
    this.investmentForm.constructionLocation = this.projectForm.area;
    this.investmentForm.detailedAddress = this.projectForm.projectAddress;
    this.investmentForm.plannedStartDate = this.projectForm.planStartTime;
    this.investmentForm.expectedCompletionDate = this.projectForm.planCompleteTime;
  },
  beforeDestroy() {
    Cookies.set("investmentForm", JSON.stringify(this.investmentForm));
  },
  methods: {
    chaneCompleted(val) {
      if (!val) return;
      this.investment.expectedCompletionDate = formatDate(val);
    getInvestment() {
      getProjectInvestmentInfoById(this.investmentForm.id).then(res => {
        this.investmentForm = res.data;
      });
    },
    chaneStartWork(val) {
      if (!val) return;
      this.investment.plannedStartDate = formatDate(val);
    submit() {
      if (!this.projectForm.id) {
        this.$message.error("请先保存投资管理基本信息")
      } else {
        this.investmentForm.projectId = this.projectForm.id;
        if (this.investmentForm.id != null) {
          editProjectInvestmentInfo(this.investmentForm).then(response => {
            this.$modal.msgSuccess("修改成功");
            //跳转到下个组件
            this.$emit('toNext', 2);
          });
        } else {
          addProjectInvestmentInfo(this.investmentForm).then(response => {
            this.$modal.msgSuccess("新增成功");
            this.investmentForm.id = response.data
            //跳转到下个组件
            this.$emit('toNext', 2);
          });
        }
      }
    },
    updateFormData() {
      if(this.projectForm) {
        this.plannedStartDate = this.projectForm.planStartTime.slice(0, 10);
        this.expectedCompletionDate = this.projectForm.planCompleteTime.slice(0, 10);
        this.investment.constructionLocation = this.projectForm.area;
        this.investment.detailedAddress = this.projectForm.address;
      }
    }
  },
  watch: {
    projectForm: {
      deep: true,
      handler() {
        this.updateFormData();
      }
    }
  }
};
</script>