From be935300089c97ea7477edd6e888a43ab244c44f Mon Sep 17 00:00:00 2001
From: xiangpei <xiangpei@timesnew.cn>
Date: 星期二, 10 十二月 2024 09:35:07 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'

---
 src/views/projectEngineering/projectLibrary/component/BasicInfo.vue |  103 +++++++++++++++++++++++++++++----------------------
 1 files changed, 58 insertions(+), 45 deletions(-)

diff --git a/src/views/projectEngineering/projectLibrary/component/BasicInfo.vue b/src/views/projectEngineering/projectLibrary/component/BasicInfo.vue
index 1319e34..0dade99 100644
--- a/src/views/projectEngineering/projectLibrary/component/BasicInfo.vue
+++ b/src/views/projectEngineering/projectLibrary/component/BasicInfo.vue
@@ -107,7 +107,7 @@
               placeholder="璇烽�夋嫨"
               style="width: 100%"
               collapse-tags
-              @change="changeDepartment">
+            >
               <el-option
                 v-for="item in approvalList"
                 :key="item.id"
@@ -139,7 +139,6 @@
               placeholder="璇烽�夋嫨"
               style="width: 100%"
               collapse-tags
-              @change="changePutUnder"
             >
               <el-option v-for="item in dict.type.sys_centralized_management" :key="item.value" :label="item.label"
                          :value="item.value"/>
@@ -305,6 +304,7 @@
 import {approvalList} from "@/api/system/dept";
 
 export default {
+  name: 'BasicInfo',
   dicts: ['sys_funding_type', 'sys_investment_type', 'sys_project_type', 'sys_project_status', 'sys_competent_department'
     , 'sys_administrative_divisions', 'sys_centralized_management', 'sys_approval_type', 'sys_key_categories', 'sys_annual_plan'],
   components: {
@@ -316,7 +316,11 @@
     disabled: {
       type: Boolean,
       default: false
-    }
+    },
+    isShow: {
+      type: Boolean,
+      required: true,
+    },
   },
   data() {
     return {
@@ -360,8 +364,10 @@
         year: '',
         yearInvestAmount: '',
         competentDepartmentList: [],
-        managementCentralizationList: []
+        managementCentralizationList: [],
       },
+      subclass: '',
+      largeCategory: '',
       approvalList: [],
       setTime: '',
       planStartTime: '',
@@ -373,8 +379,6 @@
       hasMore: true,
       selectOptions: [],
       accept: ['pdf', 'docx', 'xlsx', 'jpg', 'jpeg'],
-      largeCategory: '',
-      subclass: '',
       mapCreateInfo: {},
       demoFormRef: null,
       rules: {
@@ -392,28 +396,32 @@
   },
   mounted() {
     this.projectForm.id = this.$route.query.projectId;
-    const projectForm = Cookies.get("projectForm");
+    const projectForm = localStorage.getItem("projectForm");
+    //鍒濆鍖栦富绠¢儴闂ㄤ笅鎷夋
+    this.getApprovalList();
     if (projectForm) {
       this.projectForm = JSON.parse(projectForm);
+      this.$emit('updateIsShow', true);
     } else {
-      //鍒濆鍖栦富绠¢儴闂ㄤ笅鎷夋
-      this.getApprovalList();
+      this.projectForm.id = this.$route.query.projectId;
       // 鍦ㄧ粍浠跺垱寤烘椂鑾峰彇椤圭洰淇℃伅锛屽鏋� projectId 瀛樺湪
       if (this.projectForm.id) {
         this.getProjectInfo(this.projectForm.id);
       } else {
         this.getProjectCodeApi();
+        this.$emit('updateIsShow', true);
       }
       // this.handleLoadMore(1);
     }
   },
   beforeDestroy() {
-    Cookies.set("projectForm", JSON.stringify(this.projectForm));
+    localStorage.setItem("projectForm", JSON.stringify(this.projectForm));
   },
   methods: {
     getProjectInfo(id) {
       getProject(id).then(res => {
         this.projectForm = res.data;
+        this.$emit('updateIsShow', true);
       });
     },
     getApprovalList() {
@@ -421,10 +429,11 @@
         this.approvalList = res.data;
       });
     },
-    submit() {
+    submit(usedStatus) {
       this.$refs["projectForm"].validate(valid => {
         if (valid) {
-          if (this.projectForm.id != null) {
+          this.projectForm.usedStatus = usedStatus;
+          if (this.projectForm.id) {
             updateProject(this.projectForm).then(response => {
               this.$modal.msgSuccess("淇敼鎴愬姛");
               //璺宠浆鍒颁笅涓粍浠�
@@ -446,22 +455,23 @@
         this.projectForm.projectCode = res.data;
       });
     },
-    changeDepartment(val) {
-      if (!val.length) {
-        this.largeCategory = '';
-        return;
-      }
-      const labels = this.approvalList.filter(item => val.includes(item.id)).map(item => item.value);
-      this.largeCategory = labels.join(',');
-    },
-    changePutUnder(val) {
-      if (!val.length) {
-        this.subclass = '';
-        return;
-      }
-      const labels = this.dict.type.sys_centralized_management.filter(item => val.includes(item.value)).map(item => item.label);
-      this.subclass = labels.join(',');
-    },
+    // changeDepartment(val) {
+    //   console.log("瑙﹀彂浜嬩欢" + val + this.approvalList)
+    //   if (!val.length) {
+    //     this.largeCategory = '';
+    //     return;
+    //   }
+    //   const labels = this.approvalList.filter(item => val.includes(item.id)).map(item => item.value);
+    //   this.largeCategory = labels.join(',');
+    // },
+    // changePutUnder(val) {
+    //   if (!val.length) {
+    //     this.subclass = '';
+    //     return;
+    //   }
+    //   const labels = this.dict.type.sys_centralized_management.filter(item => val.includes(item.value)).map(item => item.label);
+    //   this.subclass = labels.join(',');
+    // },
     async loadDataList(newPage) {
       try {
         this.loading = true;
@@ -500,28 +510,31 @@
         this.$message.success('鑾峰彇鍦板潃鎴愬姛');
         this.dialogMap = false;
       } else {
-        this.$message.error('鑾峰彇鍧愭爣澶辫触');
+        this.$message.error('璇峰厛鐐瑰嚮鍦板浘閫夋嫨鍦板潃');
       }
     },
 
   },
   watch: {
-    'projectForm.managementCentralizationList'(val) {
-      if (val) {
-        const labels = this.dict.type.sys_centralized_management
-          .filter(item => val.includes(item.value))
-          .map(item => item.label);
-        this.subclass = labels.join(',');
-      }
-    },
-    'projectForm.competentDepartmentList'(val) {
-      if (val) {
-        const labels = this.approvalList
-          .filter(item => val.includes(item.id))
-          .map(item => item.value);
-        this.largeCategory = labels.join(',');
-      }
-    },
+    'projectForm': {
+      handler(newVal, oldVal) {
+        setTimeout(() => {
+          if (newVal.managementCentralizationList) {
+            const labels = this.dict.type.sys_centralized_management
+              .filter(item => newVal.managementCentralizationList.includes(item.value))
+              .map(item => item.label);
+            this.subclass = labels.join(',');
+          }
+          if (newVal.competentDepartmentList) {
+            const labels = this.approvalList
+              .filter(item => newVal.competentDepartmentList.includes(item.id))
+              .map(item => item.value);
+            this.largeCategory = labels.join(',');
+          }
+        }, 1000);
+      },
+      deep: true
+    }
   }
 };
 </script>

--
Gitblit v1.8.0