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/PolicyInfo.vue |   60 +++++++++++++++++++++++++++++++-----------------------------
 1 files changed, 31 insertions(+), 29 deletions(-)

diff --git a/src/views/projectEngineering/projectLibrary/component/PolicyInfo.vue b/src/views/projectEngineering/projectLibrary/component/PolicyInfo.vue
index 815c2dc..344a6c5 100644
--- a/src/views/projectEngineering/projectLibrary/component/PolicyInfo.vue
+++ b/src/views/projectEngineering/projectLibrary/component/PolicyInfo.vue
@@ -10,10 +10,10 @@
         <el-col :span="20">
           <el-form-item label="绗﹀悎琛屼笟鏀跨瓥:" label-width="180px" prop="industryPolicy" style="width: 100%">
             <div style="display: flex">
-              <file-upload v-model="policyInfoForm.fileList"
+              <file-upload v-model="fileList"
                            :fileType="accept"
                            :isShowTip="false"/>
-              <div v-if="policyInfoForm.fileList.length === 0" style="color: #a9afbc; margin-left: 10px">
+              <div v-if="fileList.length === 0" style="color: #a9afbc; margin-left: 10px">
                 鏀寔涓婁紶PDF鏍煎紡鏂囦欢
               </div>
             </div>
@@ -159,7 +159,6 @@
 
 <script>
 
-import Cookies from "js-cookie";
 import {
   addProjectInvestmentPolicyCompliance,
   editProjectInvestmentPolicyCompliance,
@@ -173,25 +172,26 @@
       type: Boolean,
       default: false,
       required: true
-    }
+    },
   },
   data() {
     return {
       policyInfoForm: {
-        id: '',
-        projectId: '',
-        fileList: [],
-        belongsToIndustryAdjustmentDirectory: null,
-        belongsToWesternEncouragedDirectory: null,
-        notBannedOrControlledProject: true,
-        informationIsTrue: true,
-        specialPlanningCompliance: '',
-        energyCheck: null,
-        annualEnergyConsumption: '',
-        annualElectricityConsumption: '',
-        noOnlyCheckType: null,
-        remarks: ''
+        // id: '',
+        // projectId: '',
+        // fileList: [],
+        // belongsToIndustryAdjustmentDirectory: null,
+        // belongsToWesternEncouragedDirectory: null,
+        // notBannedOrControlledProject: true,
+        // informationIsTrue: true,
+        // specialPlanningCompliance: '',
+        // energyCheck: null,
+        // annualEnergyConsumption: '',
+        // annualElectricityConsumption: '',
+        // noOnlyCheckType: null,
+        // remarks: ''
       },
+      fileList: [],
       accept: ['pdf'],
       rules: {
         industrialPolicyProhibition: [{required: true, message: '璇烽�夋嫨', trigger: 'change'}],
@@ -200,35 +200,36 @@
     };
   },
   mounted() {
-    this.policyInfoForm.projectId = this.$route.query.projectId;
-    const policyInfoForm = Cookies.get("policyInfoForm");
-    const projectForm = Cookies.get("projectForm");
+    const policyInfoForm = localStorage.getItem("policyInfoForm");
+    const projectForm = localStorage.getItem("projectForm");
 
     const parsedPolicyInfoForm = policyInfoForm ? JSON.parse(policyInfoForm) : null;
     const parsedProjectForm = projectForm ? JSON.parse(projectForm) : null;
     if (parsedPolicyInfoForm) {
       this.policyInfoForm = parsedPolicyInfoForm
+      if(this.policyInfoForm.fileList) this.fileList = this.policyInfoForm.fileList
     }
     if (parsedProjectForm) {
       this.projectForm = parsedProjectForm
     }
     // 濡傛灉璺敱瀛樺湪id涓旀病鏈夌紦瀛�,瑙嗕负缂栬緫鎴栨煡鐪嬶紝璋冪敤api
-    if (this.policyInfoForm.projectId && !parsedPolicyInfoForm) {
+    if (this.$route.query.projectId && !parsedPolicyInfoForm) {
       this.getProjectInvestmentPolicyCompliance();
+    } else {
+      this.policyInfoForm.informationIsTrue= true;
+      this.policyInfoForm.notBannedOrControlledProject = true;
     }
   },
   beforeDestroy() {
-    Cookies.set("policyInfoForm", JSON.stringify(this.policyInfoForm));
+    if(Object.keys(this.policyInfoForm).length !==0) localStorage.setItem("policyInfoForm", JSON.stringify(this.policyInfoForm));
   },
   methods: {
     getProjectInvestmentPolicyCompliance() {
-      getProjectInvestmentPolicyComplianceById(this.policyInfoForm.projectId).then(res => {
+      getProjectInvestmentPolicyComplianceById(this.$route.query.projectId).then(res => {
         this.policyInfoForm = res.data;
-        if(!this.policyInfoForm.fileList) {
-          this.policyInfoForm.fileList = []
-        }
-        this.policyInfoForm.notBannedOrControlledProject =true
-        this.policyInfoForm.informationIsTrue =true
+        this.policyInfoForm.notBannedOrControlledProject = true
+        this.policyInfoForm.informationIsTrue = true
+        this.fileList =this.policyInfoForm.fileList
       });
     },
     submit() {
@@ -238,7 +239,8 @@
         this.$refs["policyInfoFormRef"].validate(valid => {
           if (valid) {
             this.policyInfoForm.projectId = this.projectForm.id;
-            if (this.policyInfoForm.id != null) {
+            this.policyInfoForm.fileList = this.fileList
+            if (this.policyInfoForm.id) {
               editProjectInvestmentPolicyCompliance(this.policyInfoForm).then(response => {
                 this.$modal.msgSuccess("淇敼鎴愬姛");
                 //璺宠浆鍒颁笅涓粍浠�

--
Gitblit v1.8.0