From 7adbf0551f6a6b307e66cdd6537ab45fc5a2bf11 Mon Sep 17 00:00:00 2001
From: fuliqi <fuliqi@qq.com>
Date: 星期五, 29 十一月 2024 04:00:10 +0800
Subject: [PATCH] bug修复和页面查询

---
 src/views/projectEngineering/projectLibrary/component/InvestInfo.vue |   69 +++++++++++++++++-----------------
 1 files changed, 35 insertions(+), 34 deletions(-)

diff --git a/src/views/projectEngineering/projectLibrary/component/InvestInfo.vue b/src/views/projectEngineering/projectLibrary/component/InvestInfo.vue
index beda437..d1f5d7f 100644
--- a/src/views/projectEngineering/projectLibrary/component/InvestInfo.vue
+++ b/src/views/projectEngineering/projectLibrary/component/InvestInfo.vue
@@ -164,7 +164,6 @@
 </template>
 
 <script>
-import Cookies from "js-cookie";
 import {
   addProjectInvestmentInfo,
   editProjectInvestmentInfo,
@@ -179,28 +178,28 @@
       type: Boolean,
       default: false,
       required: true
-    }
+    },
   },
   data() {
     return {
       projectForm: {},
       investmentForm: {
-        id: '',
-        beCrossRegion: '',
-        constructionLocation: '',
-        detailedAddress: '',
-        beCompensationProject: '',
-        compensationReason: '',
-        plannedStartDate: '',
-        expectedCompletionDate: '',
-        nationalIndustryClassification: '',
-        industryClassification: '',
-        projectNature: '',
-        projectAttribute: '',
-        useEarth: '',
-        contentScale: '',
-        code: '',
-        projectId: '',
+        // id: '',
+        // beCrossRegion: '',
+        // constructionLocation: '',
+        // detailedAddress: '',
+        // beCompensationProject: '',
+        // compensationReason: '',
+        // plannedStartDate: '',
+        // expectedCompletionDate: '',
+        // nationalIndustryClassification: '',
+        // industryClassification: '',
+        // projectNature: '',
+        // projectAttribute: '',
+        // useEarth: '',
+        // contentScale: '',
+        // code: '',
+        // projectId: '',
       },
       plannedStartDate: '',
       expectedCompletionDate: '',
@@ -213,15 +212,14 @@
     };
   },
   mounted() {
-    this.investmentForm.projectId = this.$route.query.projectId
     // 浠嶤ookies涓幏鍙栫紦瀛樻暟鎹�
-    const investmentForm = Cookies.get("investmentForm");
-    const projectForm = Cookies.get("projectForm");
+    const investmentForm = localStorage.getItem("investmentForm");
+    const projectForm = localStorage.getItem("projectForm");
 
     // 灏濊瘯瑙f瀽JSON鏁版嵁
     const parsedInvestmentForm = investmentForm ? JSON.parse(investmentForm) : null;
     const parsedProjectForm = projectForm ? JSON.parse(projectForm) : null;
-
+    console.log(parsedInvestmentForm)
     // 璁剧疆investment鍜宲rojectForm瀵硅薄
     if(parsedInvestmentForm) {
       this.investmentForm = parsedInvestmentForm;
@@ -230,25 +228,28 @@
       this.projectForm = parsedProjectForm;
     }
     // 濡傛灉璺敱瀛樺湪id涓旀病鏈夌紦瀛橈紝瑙嗕负缂栬緫鎴栨煡鐪嬶紝璋冪敤api
-    if (this.investmentForm.projectId && !investmentForm) {
+    if (this.$route.query.projectId && !investmentForm) {
       this.getInvestment();
+    }else {
+      this.investmentForm.constructionLocation = this.projectForm.area;
+      this.investmentForm.detailedAddress = this.projectForm.projectAddress;
+      this.investmentForm.plannedStartDate = this.projectForm.planStartTime;
+      this.investmentForm.expectedCompletionDate = this.projectForm.planCompleteTime;
     }
-    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));
+    if(Object.keys(this.investmentForm).length !==0) localStorage.setItem("investmentForm", JSON.stringify(this.investmentForm));
   },
   methods: {
     getInvestment() {
-      getProjectInvestmentInfoById(this.investmentForm.projectId ).then(res => {
+      getProjectInvestmentInfoById(this.$route.query.projectId).then(res => {
         this.investmentForm = res.data;
-        this.investmentForm.constructionLocation = this.projectForm.area;
-        this.investmentForm.detailedAddress = this.projectForm.projectAddress;
-        this.investmentForm.plannedStartDate = this.projectForm.planStartTime;
-        this.investmentForm.expectedCompletionDate = this.projectForm.planCompleteTime;
+          this.$nextTick(() => {
+            this.investmentForm.constructionLocation = this.projectForm.area;
+            this.investmentForm.detailedAddress = this.projectForm.projectAddress;
+            this.investmentForm.plannedStartDate = this.projectForm.planStartTime;
+            this.investmentForm.expectedCompletionDate = this.projectForm.planCompleteTime;
+          })
       });
     },
     submit() {
@@ -256,7 +257,7 @@
         this.$message.error("璇峰厛淇濆瓨鎶曡祫绠$悊鍩烘湰淇℃伅")
       } else {
         this.investmentForm.projectId = this.projectForm.id;
-        if (this.investmentForm.id != null) {
+        if (this.investmentForm.id) {
           editProjectInvestmentInfo(this.investmentForm).then(response => {
             this.$modal.msgSuccess("淇敼鎴愬姛");
             //璺宠浆鍒颁笅涓粍浠�

--
Gitblit v1.8.0