소스 검색

修改职员

zhaoke 3 년 전
부모
커밋
ff2dc1b8e9
3개의 변경된 파일64개의 추가작업 그리고 35개의 파일을 삭제
  1. 1 4
      src/components/organization/index.vue
  2. 33 5
      src/components/rolelist/index.vue
  3. 30 26
      src/views/staffManagement/compontents/staffEdit.vue

+ 1 - 4
src/components/organization/index.vue

@@ -18,10 +18,7 @@
           </el-scrollbar>
         </div>
         <div class="dptBox" v-show="active == 1">
-          <Rolelist :type="true" @radioChange="radioChange" :radioCheck="radioCheck" :number="8" :active="true" class="lessData" :dataList="mainData" />
-        </div>
-        <div class="dptBox" v-show="active == 2">
-          <Rolelist :number="8" @checkClick="checkClick" @checkChange="checkChange" :checkBoxList="checkBoxList" :active="true" class="lessData" :dataList="lessData" />
+          <Rolelist :type="true" @radioChange="radioChange" :radioCheck="radioCheck" :number="8" :active="true" class="lessData" :mainData="mainData" />
         </div>
       </div>
     </div>

+ 33 - 5
src/components/rolelist/index.vue

@@ -21,10 +21,16 @@
               </el-checkbox-group>
             </el-row>
           </template>
-          <template v-else>
+          <p class="center" v-if="loading">加载中...</p>
+          <p class="center" v-if="noMore">没有更多数据了~</p>
+        </div>
+      </template>
+      <template v-else-if="mainData.length">
+        <div :class="active ? 'bgActive' : 'bgActivecheckbox'" class="paren_content">
+          <template v-if="type">
             <el-row :gutter="16">
               <el-radio-group style="display: block;" @change="radioChange" v-model="radio">
-                <el-col :span="number" v-for="(item, index) in dataList" :key="index">
+                <el-col :span="number" v-for="(item, index) in mainData" :key="index">
                   <div @click.stop="handleBg(index)" :class="active && msg === index ? 'bgColor' : ''" class="cide">
                     <div class="cide_header">
                       <p>{{ item.name }}</p>
@@ -35,8 +41,6 @@
               </el-radio-group>
             </el-row>
           </template>
-          <p class="center" v-if="loading">加载中...</p>
-          <p class="center" v-if="noMore">没有更多数据了~</p>
         </div>
       </template>
       <template v-else>
@@ -69,6 +73,10 @@ export default {
       type: Array,
       default: () => [],
     },
+    mainData: {
+      type: Array,
+      default: () => [],
+    },
     radioCheck: {
       type: Number,
       default: 0,
@@ -131,12 +139,32 @@ export default {
     },
     //多选框
     checkChange (arr) {
-      this.$emit("checkChange", arr);
+      const datas = this.formatChecks(arr);;
+      // if (this.roleType == 'account') {
+      //   datas = this.formatChecks(arr, 'UserId');
+      // }
+      this.$emit("checkChange", datas);
     },
     //单选框
     radioChange (val) {
       this.$emit("radioChange", val);
     },
+    //格式化选中回调
+    formatChecks (arr, key) {
+      const datas = [];
+      // const ids = []
+      this.dataList.forEach((item, index) => {
+        arr.forEach(p => {
+          if (index == p) {
+            datas.push(item);
+          }
+        })
+      })
+      // datas.forEach(item => {
+      //   ids.push(item[key])
+      // })
+      return datas;
+    },
     //多选框默认选中
     checkBoxs (arr, ids) {
       const datas = []

+ 30 - 26
src/views/staffManagement/compontents/staffEdit.vue

@@ -1,7 +1,7 @@
 <!--
  * @Author: your name
  * @Date: 2022-02-10 14:49:20
- * @LastEditTime: 2022-02-10 17:18:44
+ * @LastEditTime: 2022-02-11 10:34:04
  * @LastEditors: Please set LastEditors
  * @Description: 编辑职员
  * @FilePath: \Foshan4A4.0\src\views\staffManagement\compontents\staffEdit.vue
@@ -38,12 +38,12 @@
     </div>
     <div class="power-content flex-wrap">
       <div class="r24 flex1 part">
-        <Organization ref="Organization" :defaultProps="defaultProps" :mainData="mainData" :vice="true" :data="data" @getTreeData="getOrgan" @getTreeindex="getTreeindex" @radioChange="radioChange" :checkedKeys="orgCheckedKeys" :checkBoxList="checkBoxList" :radioCheck="radioNum" nodekey="OrganId" title="选择组织" />
+        <Organization ref="Organization" :defaultProps="defaultProps" :mainData="mainData" :vice="true" :data="data" @getTreeData="getOrgan" @radioChange="radioChange" :checkedKeys="orgCheckedKeys" :radioCheck="radioNum" nodekey="OrganId" title="选择组织" />
       </div>
       <!--开启多对多-->
       <template v-if="OpenAuthData">
         <div class="flex1 part">
-          <Rolelist @checkChange="checkChange" :checkBoxList="roleCheckBoxs" :roleType="roleType" :active="true" class="hucRole" :number="4" title="账号列表" />
+          <Rolelist @checkChange="accountChange" :checkBoxList="checkBoxList" :roleType="roleType" :active="true" class="hucRole" :number="4" title="账号列表" />
         </div>
       </template>
       <!--未开启多对多-->
@@ -210,6 +210,20 @@ export default {
       },
       deep: true,
     },
+    mainData: {
+      handler (arr) {
+        if (this.radioCheck) {
+          let ids = null;
+          arr.forEach((item, index) => {
+            if (item.JobId == this.radioCheck) {
+              ids = index;
+            }
+          })
+          this.radioNum = ids;
+        }
+      },
+      deep: true,
+    }
   },
   created () {
     const { OrganId, Status, OfficerId } = this.$route.query;
@@ -308,7 +322,7 @@ export default {
             UserList.forEach(item => {
               datas.push(item.UserId);
             })
-            this.roleCheckBoxs = datas;
+            this.checkBoxList = datas;
           }
           this.checkedList = TacList;
           this.loginCheckBoxs = TacList;
@@ -344,6 +358,7 @@ export default {
     //获取组织选中的数据
     getOrgan (arr) {
       const { OrganId } = arr[0];
+      this.AppId = OrganId;
       this.getJobListByOrgan(OrganId);
     },
     //获取指定数据
@@ -362,13 +377,11 @@ export default {
       arr.push(obj);
       this.$store.dispatch("auth/changeAuthArrs", arr);
     },
-    //岗位选择
-    getTreeindex (index) {
-      console.log(index)
-    },
     //根据主岗查询角色
     radioChange (val) {
-      console.log(val)
+      const { JobId } = this.mainData[val];
+      this.JobId = JobId;
+      this.radioCheck = null;
     },
     //根据岗位获取角色
     async getRoleByJob (id, index) {
@@ -413,19 +426,9 @@ export default {
         const res = await organgitpost(params);
         if (res.code === 0) {
           const datas = res.returnData;
-          if (this.orgTypes.length < 2) {
-            datas.forEach((item, index) => {
-              item.name = item.JobName;
-              if (item.JobId == this.radioCheck) {
-                this.radioNum = index;
-              }
-            });
-          } else {
-            this.radioCheck = null;
-            datas.forEach((item) => {
-              item.name = item.JobName;
-            });
-          }
+          datas.forEach((item) => {
+            item.name = item.JobName;
+          });
           this.mainData = datas;
         } else {
           this.$message.error(res.message);
@@ -458,6 +461,10 @@ export default {
         console.log("出错了", error);
       }
     },
+    //账号列表选取
+    accountChange (arr) {
+      this.checkBoxList = arr;
+    },
     //角色选取
     checkChange (arr) {
       const datas = [];
@@ -499,10 +506,6 @@ export default {
             this.$message.error("请选中一个组织后再新增");
             return false;
           }
-          if (!this.radioCheck && this.lessChecksData.length > 1) {
-            this.$message.error("已选择副岗,请选中一个主岗后再新增");
-            return false;
-          }
         } else {
           this.AppId = this.oldOrganId
         }
@@ -533,6 +536,7 @@ export default {
           Status: Number(this.Status),
           OrganId: this.AppId,
           OfficerId: this.OfficerId,
+          UserList: this.checkBoxList
         });
         if (res.code === 0) {
           this.$message.success(res.message);