Quellcode durchsuchen

审批流配置-获取部门人员接口更改

cxmo vor 8 Monaten
Ursprung
Commit
cdd93b3b60

+ 4 - 0
src/api/modules/setApi.js

@@ -6,6 +6,10 @@ const departInterence = {
 	systemUserInfo:params=>{
 		return http.get('/system/sysuser/detail',{})
 	},
+	//获取系统用户(树形格式)
+	getSystemUser:params=>{
+		return http.get("/system/department/user_tree",params)
+	},
 
 	/**
 	 * AdminId

+ 21 - 1
src/utils/commonOptions.js

@@ -48,4 +48,24 @@ export function isMobileNo(account) {
     return phonePatter.test(account)
   }
 //验证邮箱的正则
-export const patternEmail = /\w[-\w.+]*@([A-Za-z0-9][-A-Za-z0-9]+\.)+[A-Za-z]{2,14}/
+export const patternEmail = /\w[-\w.+]*@([A-Za-z0-9][-A-Za-z0-9]+\.)+[A-Za-z]{2,14}/
+
+
+//遍历树形结构并设置唯一key
+export function traverseTree(tree,{childKey='children',nodeKey='nodeKey',cb=()=>false,cb2=()=>''}) {
+    let index = 0; // 初始化索引值
+    function dfs(node) {
+        if(cb(node)){ //特殊节点设置key
+            node[nodeKey] = cb2(node)
+        }else{
+            node[nodeKey] = `unique_${index}`; // 为当前节点设置唯一的 key
+        }
+        if (Array.isArray(node[childKey])) {
+            for (let child of node[childKey]) {
+                dfs(child); // 递归调用 DFS 函数处理子节点
+            }
+        }
+        index++; // 更新索引值
+    }
+    dfs(tree); // 从根节点开始进行遍历
+}

+ 2 - 2
src/views/approve_manage/approveEdit.vue

@@ -96,8 +96,8 @@ export default {
                 const Users = data[i].approvers.map((item,index)=>{
                     return {
                         UserType:'user',//目前只有审批节点,都是user
-                        UserId:item.ItemId,
-                        UserName:item.ItemName,
+                        UserId:item.NodeId,
+                        UserName:item.NodeName,
                         Sort:data[i].ApproveType===1?index+1:0
                     }
                 })

+ 2 - 2
src/views/approve_manage/components/flowEdiotr.vue

@@ -46,8 +46,8 @@ export default {
             const approveData = this.flowNodes.map(n=>{
                 const approvers = n.Users.map(i=>{
                     return {
-                        ItemId:i.UserId,
-                        ItemName:i.UserName
+                        NodeId:i.UserId,
+                        NodeName:i.UserName
                     }
                 })
                 return {

+ 5 - 5
src/views/approve_manage/components/flowNode/approveNode.vue

@@ -8,8 +8,8 @@
             </div>
             <div class="content" @click="showDrawer">
                 <ul class="approver-list" v-if="flowNode.approvers.length">
-                    <li class="list-item" v-for="(item,index) in flowNode.approvers" :key="item.ItemId">
-                        {{item.ItemName}}{{index===flowNode.approvers.length-1?'':'、'}}
+                    <li class="list-item" v-for="(item,index) in flowNode.approvers" :key="item.NodeIdKey">
+                        {{item.NodeName}}{{index===flowNode.approvers.length-1?'':'、'}}
                     </li>
                 </ul>
                 <span v-else style="color:#0052D9;display: flex;align-items: center;">
@@ -45,8 +45,8 @@
                             animation="300"
                             tag="ul"
                             class="approve-list">
-                            <li class="list-item" v-for="item in choosedList" :key="item.ItemId">
-                                <span class="name">{{item.ItemName}}</span>
+                            <li class="list-item" v-for="item in choosedList" :key="item.NodeIdKey">
+                                <span class="name">{{item.NodeName}}</span>
                                 <span class="icon-btn">
                                     <i class="el-icon-close" @click.stop="removeChoosedItem(item)"></i>
                                 </span>
@@ -158,7 +158,7 @@ export default {
             this.chooseDialogShow = false
         },
         removeChoosedItem(item){
-            const index = this.choosedList.findIndex(i=>i.ItemId===item.ItemId)
+            const index = this.choosedList.findIndex(i=>i.NodeIdKey===item.NodeIdKey)
             index!==-1&&this.choosedList.splice(index,1)
         },
         editApproveNode(){

+ 27 - 17
src/views/approve_manage/components/treeTransfer.vue

@@ -8,12 +8,12 @@
             </div>
             <div class="content">
                 <el-tree 
-                    node-key="ItemId"
+                    node-key="NodeIdKey"
                     ref="trans-tree"
                     show-checkbox
                     :data="treeData"
                     :props="{
-                        label:'ItemName',
+                        label:'NodeName',
                         children:'Children'
                     }"
                     :filter-node-method="filterNode"
@@ -31,8 +31,8 @@
                 animation="300"
                 tag="ul"
                 class="content">
-                <li class="list-item" v-for="item in choosedList" :key="item.ItemId">
-                    <span class="name">{{item.ItemName}}</span>
+                <li class="list-item" v-for="item in choosedList" :key="item.NodeIdKey">
+                    <span class="name">{{item.NodeName}}</span>
                     <span class="icon-btn" style="color:#C0C4CC;">
                         <i class="el-icon-close" @click.stop="removeItem(item)"></i>
                     </span>
@@ -43,7 +43,8 @@
 </template>
 
 <script>
-import { dataAuthInterface } from "@/api/api.js";
+import { departInterence } from "@/api/api.js";
+import { traverseTree, findInTree } from "@/utils/commonOptions"
 import draggable from 'vuedraggable';
 export default {
     components:{draggable},
@@ -78,16 +79,25 @@ export default {
     },
     methods: {
         getTreeData(){
-            ///datamanage/manual/sysuser/search?KeyWord= ,要用新接口再换
-            dataAuthInterface.userSearch({
+            departInterence.getSystemUser({
                 KeyWord: ''
             }).then(res => {
                 if(res.Ret === 200) {
                     this.treeData = res.Data||[];
+                    //遍历加上唯一的key
+                    traverseTree(
+                        {Children:this.treeData},
+                        {
+                            childKey:'Children',
+                            nodeKey:'NodeIdKey',
+                            cb:(node)=>node.NodeType===3,
+                            cb2:(node)=>node.NodeId+''
+                        }
+                    )
                 }
                 this.$nextTick(()=>{
                     const keys = this.defaultList.map(i=>{
-                        return i.ItemId
+                        return i.NodeId
                     })
                     this.$refs["trans-tree"].setCheckedKeys(keys)
                     this.choosedList = _.cloneDeep(this.defaultList)
@@ -96,40 +106,40 @@ export default {
         },
         filterNode(value,data){
             if(!value) return true
-            return data.ItemName.indexOf(value)!==-1
+            return data.NodeName.indexOf(value)!==-1
         },
         SetCheckedNode(data,{checkedNodes}){
             if(!this.choosedList.length){
                  //只获取人员
                 this.choosedList = checkedNodes.filter(i=>{
-                    if(i.ItemId<10000&&!i.Children)
+                    if(i.NodeType===3)
                         return i
                 })
             }else{
                 //遍历 filterArr choosedList里没有的,push进去
                 const filterArr = checkedNodes.filter(i=>{
-                    if(i.ItemId<10000&&!i.Children)
+                    if(i.NodeType===3)
                         return i
                 })
                 filterArr.forEach(i=>{
-                    const index = this.choosedList.findIndex(item=>i.ItemId===item.ItemId)
+                    const index = this.choosedList.findIndex(item=>i.NodeIdKey===item.NodeIdKey)
                     if(index===-1){this.choosedList.push(i)}
                 })
                 //遍历choosedList,filterArr里没有的,删除
                 const tempArr = _.cloneDeep(this.choosedList)
                 tempArr.forEach(i=>{
-                    const checkIndex = filterArr.findIndex(item=>item.ItemId===i.ItemId)
+                    const checkIndex = filterArr.findIndex(item=>item.NodeIdKey===i.NodeIdKey)
                     if(checkIndex===-1){
-                        const index = this.choosedList.findIndex(item=>item.ItemId===i.ItemId)
+                        const index = this.choosedList.findIndex(item=>item.NodeIdKey===i.NodeIdKey)
                         index!==-1&&this.choosedList.splice(index,1)
                     }
                 })
             }
         },
         removeItem(item){
-            const {ItemId} = item
-            this.$refs["trans-tree"].setChecked(ItemId,false,false)
-            const index = this.choosedList.findIndex(i=>i.ItemId===ItemId)
+            const {NodeIdKey} = item
+            this.$refs["trans-tree"].setChecked(NodeIdKey,false,false)
+            const index = this.choosedList.findIndex(i=>i.NodeIdKey===NodeIdKey)
             index!==-1&&this.choosedList.splice(index,1)
         },
         clearnItem(){