Browse Source

后线人员分配内部机构

yaoyao 2 years ago
parent
commit
a93052f388

+ 40 - 37
src/views/PeopleManage/Staff/AreaOrganization.vue

@@ -5,38 +5,25 @@
       <el-main ref="elMain" style="padding: 0px">
         <!-- 搜索 新增-展开折叠 -->
         <div style="margin-bottom: 20px; margin-top: 15px" class="flex a-start">
-          <el-button
-            size="small"
-            type="primary"
-            plain
-            icon="el-icon-plus"
-            :label="$t('action.addCompany')"
-            @click="handleAddCompany"
-            >新增子机构</el-button
-          >
-          <el-button
-            size="small"
-            type="info"
-            plain
-            icon="el-icon-sort"
-            @click="fold()"
-            >展开折叠</el-button
-          >
-          <!-- <el-form
-            :inline="true"
-            class="demo-form-inline"
-            size="small"
-            style="margin-left: 30px"
-          >
+          <el-button size="small" type="primary" plain icon="el-icon-plus" :label="$t('action.addCompany')" @click="handleAddCompany">新增子机构</el-button>
+          <el-button size="small" type="info" plain icon="el-icon-sort" @click="fold()" >展开折叠</el-button>
+          <el-form :inline="true" class="demo-form-inline" size="small" style="margin-left: 30px">
+            <el-form-item label="机构名称">
+              <el-cascader v-model="formData.id" size="small"
+                :show-all-levels="false" :options="formListData" :props="{ label: 'name', value: 'id', children: 'children', checkStrictly: true }" clearable
+                filterable></el-cascader>
+            </el-form-item>
+            <el-form-item label="机构类型">
+              <el-select style="width:200px" clearable v-model="formData.comtype" placeholder="请选择">
+                <el-option v-for="val in comtypeoptions" :label="val.label" :value="val.value"
+                  :key="val.value"></el-option>
+              </el-select>
+            </el-form-item>
             <el-form-item>
-              <el-button
-                type="primary"
-                size="small"
-                @click="managementSourceQuery"
-                >查询</el-button
-              >
+              <el-button size="small" @click="resultList">重置</el-button>
+              <el-button type="primary" size="small" @click="findTreeData">查询</el-button>
             </el-form-item>
-          </el-form> -->
+          </el-form>
         </div>
         <!-- 表格渲染 -->
         <el-table
@@ -195,12 +182,6 @@ export default {
     tree,
     KtCommonTable,
   },
-  created() {
-    this.findTreeData(); // 获取左边机构树数据
-    this.$api.dept.sysDeptInternalAgentType().then(res => {
-      this.comtypeoptions = res.data
-    })
-  },
   data() {
     return {
       loading: false,
@@ -265,14 +246,29 @@ export default {
       isshow: false,
       expanded: false, // 在这里定义了展开与否的标志
       parentName: '',
+      formListData: [], // 全部树
+      formData: {},
     };
   },
+  created() {
+    this.findTreeData();
+    this.$api.dept.sysDeptInternalAgentType().then(res => {
+      this.comtypeoptions = res.data
+    })
+    this.$api.dept.sysDeptInternalAgentFindTree().then((res) => {
+      this.formListData = res.data;
+    });
+  },
   mounted() {
     this.changeTreeWidth(); // 初始化树的宽度
     this.filters.id = "9";
     this.findSubDeptPage(); //初始化数据
   },
   methods: {
+    resultList() {
+      this.formData = {}
+      this.findTreeData()
+    },
     //点击每一行的事件
     rowClick(row, treeNode) {
       //点每行展开折叠
@@ -320,8 +316,15 @@ export default {
     },
     findTreeData() {
       // 获取机构树的数据
+      let queryData = {
+        comtype: this.formData.comtype
+      }
+      if (this.formData.id) {
+        queryData.deptId = this.formData.id[this.formData.id.length-1]
+      }
       this.loading = true;
-      this.$api.dept.sysDeptInternalAgentFindTree().then((res) => {
+      this.$api.dept.sysDeptInternalAgentFindTree(queryData).then((res) => {
+        this.ztreeNodes = []
         this.ztreeNodes = res.data;
         this.loading = false;
       });

+ 18 - 9
src/views/PeopleManage/Staff/AreaPeople.vue

@@ -55,7 +55,8 @@
             background: '#F2F7FC',
             fontWeight: '900',
             color: '#606266',
-          }" @selection-change="addListChange" :row-class-name="tableRowClassName">
+          }" >
+          <!-- :row-class-name="tableRowClassName" -->
           <el-table-column type="selection" width="55">
           </el-table-column>
           <el-table-column prop="userId" label="工号">
@@ -160,8 +161,12 @@ export default {
     // 新增
     // 确定新增
     addSubmit() {
+      let ids = []
+      this.$refs.personneTable.selection.forEach(val => {
+        ids.push(val.userId)
+      })
       let data = {
-        userIds: [this.$refs.personneTable.selection[0].userId],
+        userIds: ids,
         deptId: this.deptNBId
       }
       this.$api.dept.sysUserLinkDeptInternalAgentAddOrUpdate(data).then(res => {
@@ -176,17 +181,14 @@ export default {
     },
     refreshPageRequest: function (pageNum) {
       this.addListDataPage.pageNum = pageNum;
-      // this.personnelFindPage()
+      this.handleAddButton()
     },
     handleSizeChange(pageSize) {
       this.addListDataPage.pageSize = pageSize;
-      // this.personnelFindPage()
+      this.handleAddButton()
     },
     addListChange(selection) {
-      if (selection.length > 1) {
-        this.$refs.personneTable.clearSelection(); // 清空所有选择
-        this.$refs.personneTable.toggleRowSelection(selection.pop()); // 设置选择项
-      }
+        console.log(selection, 'selection')
     },
     tableRowClassName(row) {
         if (row.row.flag) {
@@ -259,8 +261,15 @@ export default {
         this.addListDataPage.pageNum = res.data.pageNum
         this.addListDataPage.pageSize = res.data.pageSize
         this.addListDataPage.total = res.data.totalSize
+        this.dialogVisible = true;
+        this.$nextTick().then(() => {
+          res.data.content.forEach(val => {
+            if (val.flag) {
+              this.$refs.personneTable.toggleRowSelection(val)
+            }
+          })
+        })
       })
-      this.dialogVisible = true;
     },
     closeDialog() {
       this.dialogVisible = false;