Bläddra i källkod

fix:人才发展多选

jianghaili 7 månader sedan
förälder
incheckning
5359373cb0
1 ändrade filer med 117 tillägg och 34 borttagningar
  1. 117 34
      my/renzheng/peopleDev.vue

+ 117 - 34
my/renzheng/peopleDev.vue

@@ -16,7 +16,7 @@
             <view class="check-box">
               <view
                 class="check-item"
-                :class="{ 'check-active': up == index }"
+                :class="{ 'check-active': selectedUp.includes(index) }"
                 v-for="(item, index) in upList"
                 :key="index"
                 @click="checkUp(index)"
@@ -29,7 +29,7 @@
             <view class="check-box">
               <view
                 class="check-item"
-                :class="{ 'check-active': people == index }"
+                :class="{ 'check-active': selectedPeople.includes(index) }"
                 v-for="(item, index) in peopleList"
                 :key="index"
                 @click="checkPeople(index)"
@@ -42,7 +42,7 @@
             <view class="check-box">
               <view
                 class="check-item"
-                :class="{ 'check-active': power == index }"
+                :class="{ 'check-active': selectedPower.includes(index) }"
                 v-for="(item, index) in powerList"
                 :key="index"
                 @click="checkPower(index)"
@@ -64,7 +64,8 @@ export default {
   data() {
     return {
       upList: ["考核晋升", "定期晋升", "完善的晋升机制"],
-      up: null,
+      selectedUp: [], // 改为数组存储多个选择
+      
       peopleList: [
         "定期普调",
         "定期绩效调薪",
@@ -76,7 +77,8 @@ export default {
         "股票期权",
         "人才补贴",
       ],
-      people: null,
+      selectedPeople: [], // 改为数组存储多个选择
+      
       powerList: [
         "老员工带新",
         "导师一对一",
@@ -89,9 +91,10 @@ export default {
         "国内外进修",
         "校招培养",
       ],
-      power: null,
-	    companyData:{},
-	    companyPeopleDevelop:[]
+      selectedPower: [], // 改为数组存储多个选择
+      
+      companyData:{},
+      companyPeopleDevelop:[]
     };
   },
   components: {
@@ -100,39 +103,117 @@ export default {
   onLoad(options) {
     if (options.companyData) {
       this.companyData = JSON.parse(options.companyData);
+      
+      // 如果之前有保存的数据,恢复选择状态
+      this.restoreSelections();
     }
   },
   methods: {
+    // 晋升制度多选
     checkUp(index) {
-      this.up = index;
+      const idx = this.selectedUp.indexOf(index);
+      if (idx > -1) {
+        // 如果已选中,则取消选中
+        this.selectedUp.splice(idx, 1);
+      } else {
+        // 如果未选中,则添加
+        this.selectedUp.push(index);
+      }
     },
+    
+    // 人才激励多选
     checkPeople(index) {
-      this.people = index;
+      const idx = this.selectedPeople.indexOf(index);
+      if (idx > -1) {
+        this.selectedPeople.splice(idx, 1);
+      } else {
+        this.selectedPeople.push(index);
+      }
     },
+    
+    // 能力培养多选
     checkPower(index) {
-      this.power = index;
+      const idx = this.selectedPower.indexOf(index);
+      if (idx > -1) {
+        this.selectedPower.splice(idx, 1);
+      } else {
+        this.selectedPower.push(index);
+      }
     },
-    goJobPostingSecond(){
-		if(this.upList[this.up]){
-			this.companyPeopleDevelop.push(this.upList[this.up])
-		}
-		if(this.peopleList[this.people]){
-			this.companyPeopleDevelop.push(this.peopleList[this.people])
-		}
-		if(this.powerList[this.power]){
-			this.companyPeopleDevelop.push(this.powerList[this.power])
-		}
-		if (this.companyPeopleDevelop.length === 0) {
-		  uni.showToast({
-		    title: "请至少选择一项人才发展方向",
-		    icon: "none",
-		  });
-		  return;
-		}
-		const companyData = this.companyData
-		companyData.companyPeopleDevelop = this.companyPeopleDevelop.join(',')
-        uni.navigateTo({ url: "/my/renzheng/editCompanyDesc?companyData=" +
-          encodeURIComponent(JSON.stringify(companyData)) })
+    
+    // 恢复之前的选择(编辑时使用)
+    restoreSelections() {
+      if (this.companyData.companyPeopleDevelop) {
+        const savedData = this.companyData.companyPeopleDevelop.split(',');
+        
+        // 恢复晋升制度选择
+        this.upList.forEach((item, index) => {
+          if (savedData.includes(item)) {
+            this.selectedUp.push(index);
+          }
+        });
+        
+        // 恢复人才激励选择
+        this.peopleList.forEach((item, index) => {
+          if (savedData.includes(item)) {
+            this.selectedPeople.push(index);
+          }
+        });
+        
+        // 恢复能力培养选择
+        this.powerList.forEach((item, index) => {
+          if (savedData.includes(item)) {
+            this.selectedPower.push(index);
+          }
+        });
+      }
+    },
+    
+    goJobPostingSecond() {
+      // 清空之前的数组
+      this.companyPeopleDevelop = [];
+      
+      // 添加选中的晋升制度
+      this.selectedUp.forEach(index => {
+        if (this.upList[index]) {
+          this.companyPeopleDevelop.push(this.upList[index]);
+        }
+      });
+      
+      // 添加选中的人才激励
+      this.selectedPeople.forEach(index => {
+        if (this.peopleList[index]) {
+          this.companyPeopleDevelop.push(this.peopleList[index]);
+        }
+      });
+      
+      // 添加选中的能力培养
+      this.selectedPower.forEach(index => {
+        if (this.powerList[index]) {
+          this.companyPeopleDevelop.push(this.powerList[index]);
+        }
+      });
+      
+      // 验证是否至少选择了一项
+      if (this.companyPeopleDevelop.length === 0) {
+        uni.showToast({
+          title: "请至少选择一项人才发展方向",
+          icon: "none",
+        });
+        return;
+      }
+      
+      // 保存到 companyData
+      const companyData = {
+        ...this.companyData,
+        companyPeopleDevelop: this.companyPeopleDevelop.join(',')
+      };
+      
+      // 跳转到下一步
+      uni.navigateTo({ 
+        url: "/my/renzheng/editCompanyDesc?companyData=" +
+          encodeURIComponent(JSON.stringify(companyData)) 
+      });
     }
   },
 };
@@ -205,6 +286,7 @@ export default {
       .content-index {
         width: 100%;
         .content-item {
+          margin-bottom: 40rpx;
           .content-item-title {
             color: rgba(34, 37, 42, 1);
             font-family: DM Sans;
@@ -225,12 +307,13 @@ export default {
               border-radius: 8rpx;
               background: #9999991a;
               border: 1rpx solid #9999991a;
-
               box-sizing: border-box;
               color: rgba(102, 102, 102, 1);
               font-family: DM Sans;
               font-size: 16rpx;
               font-weight: 400;
+              cursor: pointer;
+              transition: all 0.3s;
             }
             .check-active {
               box-sizing: border-box;
@@ -263,4 +346,4 @@ export default {
     margin-top: 20rpx;
   }
 }
-</style>
+</style>