|
@@ -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(){
|