Przeglądaj źródła

人员根据部门过滤

linweizeng 2 lat temu
rodzic
commit
bf8ab4be55

+ 63 - 8
src/business/platform/org/employee/mixins/panelTree.js

@@ -108,9 +108,10 @@ export default {
         },
         // 点击节点
         handleNodeClick (data) {
+            console.log(data)
             const ids = []
             this.getChildrenIds(data, ids)
-            if (data.id === '0') return
+            if (data.id === '0' || data.disabled) return
             this.partyId = data.id
             this.loadListData()
         },
@@ -228,7 +229,7 @@ export default {
                 return
             }
             const params = {}
-            params.type = type
+            params.type = type === '2' ? '1' : type
             if (resetParams && this.isUseScope) {
                 params.partyId = this.currentOrgIdValue
                 params.includeSub = false
@@ -274,12 +275,14 @@ export default {
         loadPosTreeNode (node, resolve) {
             let params = {}
             const type = this.partyTypeIdValue !== '' ? this.partyTypeIdValue : '1'
+            console.log(this.isUseScope)
             if (this.isUseScope) {
                 // 选择器范围模式参数
-                params.type = type
-                params.includeSub = type === '1'
+                params.type = type === '2' ? '1' : type
+                params.includeSub = type === '1' || type === '2'
                 if (type === '2') {
-                    params.partyId = node.level === 0 ? null : node.data.id
+                    // params.partyId = node.level === 0 ? null : node.data.id
+                    params.posId = node.level === 0 ? null : node.data.id
                 }
                 if (type === '3') {
                     params.partyId = this.currentOrgIdValue
@@ -300,6 +303,7 @@ export default {
                 Object.assign(params, this.moreSearchParams)
             }
             if (this.$utils.isEmpty(node.data) || node.data.id === '0') {
+                console.log('6',params)
                 getPositionTreeData(params).then(res => {
                     this.loadingTree = false
                     const arr = JSON.parse(JSON.stringify(res.data))
@@ -311,7 +315,7 @@ export default {
                     })
                     let arrList
                     const frist = this.$store.getters.level.first || ''
-                    if (type === '1' && this.filtrate && frist) {
+                    if ((type === '1' || type === '2') && this.filtrate && frist) {
                         const showBoo = arr.some((item) => item.id === frist)
                         if (showBoo) {
                             arrList = arr.filter((item) => item.id === frist)
@@ -322,12 +326,16 @@ export default {
                         arrList = arr
                     }
 
+                    if (type === '2') {
+                        this.getPosiData(arrList, true)
+                    }
+
                     let treeData
                     if (this.$utils.isEmpty(node.data)) {
                         treeData = arrList
                         resolve(this.toTree(treeData))
                     } else {
-                        treeData = type !== '2' ? arrList : this.filterPositionTreeChildren(arrList, 'root')
+                        treeData = type === '1' || type === '2' ? arrList : this.filterPositionTreeChildren(arrList, 'root')
                         resolve(this.toTree(treeData))
                     }
                 }).catch(res => {
@@ -335,6 +343,7 @@ export default {
                     resolve([])
                 })
             } else if (node.data.id !== '0') {
+                console.log('5',params)
                 if (type === '2') {
                     params = {}
                     params.type = '1'
@@ -343,13 +352,59 @@ export default {
                 getPositionTreeData(params).then(res => {
                     this.loadingTree = false
                     const arr = JSON.parse(JSON.stringify(res.data))
-                    resolve(this.toTree(arr))
+
+                    let arrList = []
+                    const second = this.$store.getters.level.second || ''
+                    console.log(second)
+                    if ((type === '1' || type === '2') && this.filtrate && second) {
+                        const showBoo = arr.some((item) => item.id === second)
+                        if (showBoo) {
+                            arrList = arr.filter((item) => item.id === second)
+                        } else {
+                            arrList = arr
+                        }
+                    } else {
+                        arrList = arr
+                    }
+                    if (type === '2') {
+                        this.getPosiData(arrList, node.data.disabled)
+                    }
+
+                    resolve(this.toTree(arrList))
                 }).catch(res => {
                     this.loadingTree = false
                     resolve([])
                 })
             }
         },
+        getPosiData (arrList, disabled) {
+            const positions = this.$store.getters.userInfo.employee.positions
+            if (positions) {
+                const positionsList = positions.split(',')
+                console.log(positionsList)
+                positionsList.forEach(item => {
+                    const index = arrList.findIndex(it => it.id === item)
+                    console.log(index)
+                    if (index >= 0) {
+                        arrList[index].disabled = true
+                    }
+                })
+            }
+            // 如果上级可以选择 也就是 disabled false,下级一定是false
+            if (!disabled) {
+                arrList.forEach(item => {
+                    item.disabled = false
+                })
+            } else {
+                arrList.forEach(item => {
+                    if (item.disabled) {
+                        item.disabled = false
+                    } else {
+                        item.disabled = true
+                    }
+                })
+            }
+        },
         // 加载角色树
         loadRoleTreeData () {
             if (this.isUseScope) {

+ 7 - 2
src/business/platform/org/employee/panel.vue

@@ -47,7 +47,12 @@
                         pid-key="parentId"
                         highlight-current
                         @node-click="handleNodeClick"
-                    />
+                    >
+                    <!-- <span slot-scope="{ node, data }" class="custom-tree-node" :style="node.disabled ? 'cursor:not-allowed;color:#dcdfe6': ''">
+
+                        {{ node.label }}
+                    </span> -->
+                    </el-tree>
                 </el-scrollbar>
             </div>
         </div>
@@ -183,7 +188,7 @@ export default {
             moreSearchParams: {},
             lazyTree: true,
             defaultExpandedKeys: ['0'],
-            defaultExpandAll: false,
+            defaultExpandAll: true,
             lazyOrgTree: true,
             partyTypeIdValue: '',
             currentOrgIdValue: '',