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