lilei 3 anos atrás
pai
commit
d6f8a8f705

+ 18 - 0
src/api/expenseManagement.js

@@ -193,3 +193,21 @@ export const queryDingTalkDeptUser = (params) => {
     method: 'post'
   })
 }
+
+ // 同步钉钉部门人员
+ export const refashDingTalkAllDeptUser = (params) => {
+   return axios({
+     url: `/dingTalk/syncAllDeptUser `,
+     data: params,
+     method: 'post'
+   })
+ }
+ 
+// 获取所以部门人员
+ export const getDingTalkAllDeptUser = (params) => {
+   return axios({
+     url: `/dingTalk/getAllDeptUser`,
+     data: params,
+     method: 'post'
+   })
+ }

+ 23 - 27
src/views/common/dingDepartUser.js

@@ -1,4 +1,4 @@
-import { getDingTalkDepartmentList, queryDingTalkDeptUser } from '@/api/expenseManagement'
+import { getDingTalkAllDeptUser, refashDingTalkAllDeptUser } from '@/api/expenseManagement'
 const DingDepartUser = {
   template: `
       <a-tree-select
@@ -8,7 +8,6 @@ const DingDepartUser = {
           :dropdown-style="{ maxHeight: '400px', overflow: 'auto' }"
           :tree-data="treeData"
           :placeholder="placeholder"
-          :load-data="onLoadData"
           multiple
           treeCheckable
           :treeCheckStrictly="true"
@@ -39,7 +38,7 @@ const DingDepartUser = {
     };
   },
   mounted() {
-    this.genTreeNode(1)
+    this.genTreeNode()
   },
   watch: {
     value(newValue, oldValue) {
@@ -63,7 +62,7 @@ const DingDepartUser = {
       const ret = []
       data.map(item => {
         if(type == 'bm'){
-          ret.push({
+          const node = {
             title: item.name,
             id:item.deptId,
             value: item.deptId,
@@ -72,7 +71,11 @@ const DingDepartUser = {
             createDeptGroup: item.createDeptGroup,
             disableCheckbox: true,
             checkable: false
-          })
+          }
+          if(item.deptUserList||item.deptList){
+            node.children = this.formatData(item.deptUserList||item.deptList,item.deptList?'bm':'yg')
+          }
+          ret.push(node)
         }else{
           ret.push({
             title: item.name,
@@ -91,29 +94,22 @@ const DingDepartUser = {
       })
       return ret
     },
-    // 获取部门
-    genTreeNode(parentId, isLeaf = false) {
-       Promise.all([
-         getDingTalkDepartmentList({deptId:parentId}),
-         queryDingTalkDeptUser({deptId:parentId,pageNo:1,pageSize:10})
-         ]).then(res => {
-          const res1 = res[0].data||[]
-          const res2 = res[1].data||[]
-          this.treeData = this.treeData.concat(this.formatData(res1,'bm')).concat(this.formatData(res2,'yg'));
-          if(res1.length==0&&res2.length==0){
-            this.$message.info("没有下一级了")
-          }
-       })
-    },
-    onLoadData(treeNode) {
-      return new Promise(resolve => {
-        const { value } = treeNode.dataRef;
-         this.genTreeNode(value)
-         setTimeout(()=>{
-           resolve();
-         },1000)
-      });
+    // 获取部门人员
+    async genTreeNode() {
+       let ret = await getDingTalkAllDeptUser().then(res => res.data)
+       const res1 = ret.deptList||[]
+       const res2 = ret.deptUserList||[]
+       this.treeData = this.treeData.concat(this.formatData(res1,'bm')).concat(this.formatData(res2,'yg'));
     },
+    // 更新人员数据
+    updateDeptUser(){
+      refashDingTalkAllDeptUser().then(res => {
+        this.$message.info(res.message)
+        if(res.status == 200){
+          this.genTreeNode()
+        }
+      })
+    }
   },
 };
 

+ 29 - 13
src/views/expenseManagement/expenseReimbursement/chooseDepartUserModal.vue

@@ -19,21 +19,37 @@
             :label-col="formItemLayout.labelCol"
             :wrapper-col="formItemLayout.wrapperCol">
             <a-form-model-item label="审批人员" prop="approvers">
-              <dingDepartUser
-                id="departUser-approvers"
-                v-model="form.approvers"
-                @change="changeApprovers"
-                allowClear
-                placeholder="请选择审批人员"
-              ></dingDepartUser>
+              <a-row>
+                <a-col span="20">
+                  <dingDepartUser
+                    ref="departUserApp"
+                    id="departUser-approvers"
+                    v-model="form.approvers"
+                    @change="changeApprovers"
+                    allowClear
+                    placeholder="请选择审批人员"
+                  ></dingDepartUser>
+                </a-col>
+                <a-col span="4">
+                  <a-button type="link" shape="round" @click="$refs.departUserApp.updateDeptUser()">刷新人员</a-button>
+                </a-col>
+              </a-row>
             </a-form-model-item>
             <a-form-model-item label="抄送人" prop="ccList">
-              <dingDepartUser
-                id="departUser-ccList"
-                v-model="form.ccList"
-                allowClear
-                placeholder="请选择抄送人"
-              ></dingDepartUser>
+              <a-row>
+                <a-col span="20">
+                  <dingDepartUser
+                    ref="departUserCc"
+                    id="departUser-ccList"
+                    v-model="form.ccList"
+                    allowClear
+                    placeholder="请选择抄送人"
+                  ></dingDepartUser>
+                </a-col>
+                <a-col span="4">
+                  <a-button type="link" shape="round" @click="$refs.departUserCc.updateDeptUser()">刷新人员</a-button>
+                </a-col>
+              </a-row>
             </a-form-model-item>
           </a-form-model>
         </div>