From 0ead7315c0e6076aded0dac7a6ff0b89c632287b Mon Sep 17 00:00:00 2001
From: fuliqi <fuliqi@qq.com>
Date: 星期四, 28 十一月 2024 01:32:41 +0800
Subject: [PATCH] 项目基本信息、投资基本信息

---
 src/views/projectEngineering/projectLibrary/component/InvestInfo.vue |  178 ++++++++++++++++++++++++++++++----------------------------
 1 files changed, 92 insertions(+), 86 deletions(-)

diff --git a/src/views/projectEngineering/projectLibrary/component/InvestInfo.vue b/src/views/projectEngineering/projectLibrary/component/InvestInfo.vue
index 7b22b12..d792807 100644
--- a/src/views/projectEngineering/projectLibrary/component/InvestInfo.vue
+++ b/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="寤虹骞冲彴浠g爜" 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();
+    // 浠嶤ookies涓幏鍙栫紦瀛樻暟鎹�
+    const investmentForm = Cookies.get("investmentForm");
+    const projectForm = Cookies.get("projectForm");
+
+    // 灏濊瘯瑙f瀽JSON鏁版嵁
+    const parsedInvestmentForm = investmentForm ? JSON.parse(investmentForm) : null;
+    const parsedProjectForm = projectForm ? JSON.parse(projectForm) : null;
+
+    // 璁剧疆investment鍜宲rojectForm瀵硅薄
+    this.investmentForm = parsedInvestmentForm || {};
+    this.projectForm = parsedProjectForm || {};
+
+    // 濡傛灉projectForm瀛樺湪id涓旀病鏈夌紦瀛橈紝鍒欒皟鐢╝pi
+    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>
 

--
Gitblit v1.8.0