|
|
@ -8,7 +8,8 @@ |
|
|
|
:append-to-body="false" |
|
|
|
:modal="false" |
|
|
|
:modal-append-to-body="false" |
|
|
|
:show-close="false" |
|
|
|
:show-close="true" |
|
|
|
@close="close(0)" |
|
|
|
> |
|
|
|
<div id="StepsFormTree"> |
|
|
|
<el-steps |
|
|
@ -62,8 +63,10 @@ |
|
|
|
@select="tableHandleSelect" |
|
|
|
@select-all="tableHandleSelectAll" |
|
|
|
:tree-props="{children: 'children', hasChildren: 'hasChildren'}"> |
|
|
|
<!-- todo:第一层只显示名字 --> |
|
|
|
<el-table-column |
|
|
|
type="selection" |
|
|
|
:selectable="((row,index)=>{return index != 0})" |
|
|
|
width="55"> |
|
|
|
</el-table-column> |
|
|
|
<el-table-column |
|
|
@ -82,9 +85,8 @@ |
|
|
|
:label="detailsTableColumns[2].label" |
|
|
|
> |
|
|
|
<template slot-scope="scope"> |
|
|
|
<!-- {{scope.$index}} |
|
|
|
{{scope.row}} --> |
|
|
|
<filterSelect |
|
|
|
v-if="scope.$index != 0" |
|
|
|
:selectModel="scope.row[detailsTableColumns[2].prop]" |
|
|
|
:selectItem="detailsTableColumns[2]" |
|
|
|
:tableScope="scope" |
|
|
@ -363,23 +365,127 @@ export default { |
|
|
|
} |
|
|
|
}, |
|
|
|
methods: { |
|
|
|
// 勾选表格数据 |
|
|
|
toggleSelection(rows,type){ |
|
|
|
rows.forEach(row => { |
|
|
|
this.$refs.bomTree_Ref.toggleRowSelection(row,type); |
|
|
|
}); |
|
|
|
}, |
|
|
|
// filterSelect点击option事件 |
|
|
|
filterOptionSelectHandle(item,props,val,scope){ |
|
|
|
this.$emit("push", item,props,val,scope); |
|
|
|
}, |
|
|
|
// // filterSelect点击清除事件 |
|
|
|
// // filterSelect点击清除事件to |
|
|
|
filterClearHandle(item,scope){ |
|
|
|
this.$emit("clear", item,scope); |
|
|
|
}, |
|
|
|
// 递归:获取同级 |
|
|
|
findPeer(row,type){ |
|
|
|
let _peerArr = []//同级 |
|
|
|
let data = this.CreateFormData.details |
|
|
|
for(let i = 0;i<data.length;i++){ |
|
|
|
if(data[i].itemCode = row.parentCode){ |
|
|
|
data[i].isCheck = false |
|
|
|
_peerArr = data[i].children; |
|
|
|
break |
|
|
|
} |
|
|
|
else{ |
|
|
|
this.findPeer(data[i]) |
|
|
|
} |
|
|
|
} |
|
|
|
console.log('获取所有同级',_peerArr) |
|
|
|
return _peerArr |
|
|
|
}, |
|
|
|
// todo:【选中】勾选递归:获取所有同级(同级下的chilred未被选中的) |
|
|
|
findPeerForCheckHandle(row,data){ |
|
|
|
if(!data){data = this.CreateFormData.details} |
|
|
|
let _peerArr = []//同级 |
|
|
|
for(let i = 0;i<data.length;i++){ |
|
|
|
if(data[i].itemCode == row.parentCode){ |
|
|
|
console.log("aaa") |
|
|
|
// 去除有已选子集的 |
|
|
|
data[i].children.forEach(item=>{ |
|
|
|
if(item.children && item.children.length > 0){ |
|
|
|
let sonHasCheck = 0 |
|
|
|
item.children.forEach(son=>{ |
|
|
|
if(son.isCheck){sonHasCheck ++} |
|
|
|
}) |
|
|
|
if(sonHasCheck == 0){ |
|
|
|
item.isCheck=true |
|
|
|
_peerArr.push(item) |
|
|
|
} |
|
|
|
}else{ |
|
|
|
item.isCheck=true |
|
|
|
_peerArr.push(item) |
|
|
|
} |
|
|
|
}) |
|
|
|
break |
|
|
|
} |
|
|
|
else{ |
|
|
|
console.log("bbb") |
|
|
|
if(data[i].children && data[i].children.length > 0){ |
|
|
|
this.findPeerForCheckHandle(row,data[i].children) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
console.log('获取所有同级(同级下的chilred未被选中的)',_peerArr) |
|
|
|
return _peerArr |
|
|
|
}, |
|
|
|
// todo:【选中】勾选递归:获取父级的所有同级(同级下的chilred未被选中的) |
|
|
|
findParentPeerForCheckHandle(row,data){ |
|
|
|
if(!data){data = this.CreateFormData.details} |
|
|
|
let _parentPeerArr = []//父级同级 |
|
|
|
let _parentRow = null//父级 |
|
|
|
for(let i = 0;i<data.length;i++){ |
|
|
|
if(data[i].itemCode == row.parentCode){ |
|
|
|
console.log(11,data[i].itemCode) |
|
|
|
_parentRow = data[i] |
|
|
|
break |
|
|
|
}else{ |
|
|
|
console.log(222) |
|
|
|
if(data[i].children && data[i].children.length > 0){ |
|
|
|
this.findParentPeerForCheckHandle(row,data[i].children) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
console.log(442,_parentRow) |
|
|
|
// if(_parentRow){ |
|
|
|
// _parentPeerArr = this.findPeerForCheckHandle(_parentRow) |
|
|
|
// } |
|
|
|
// console.log('获取父级的同级(同级下的chilred未被选中的)',_parentPeerArr) |
|
|
|
return _parentPeerArr |
|
|
|
}, |
|
|
|
// todo:【取消】勾选递归:如果他父级的同级有选中,获取父级 |
|
|
|
findPeerForCancleCheckHandle(row){ |
|
|
|
}, |
|
|
|
// 1、选择的时候,同级默认选择,父级的同级(子集未被勾选的)默认选择 |
|
|
|
// 2、取消勾选的时候,同级取消选择,父级的同级如果有被勾选,则父级默认选择 |
|
|
|
// 3、全选,最底层选中 |
|
|
|
// 4、全不选,全不不选择 |
|
|
|
// 选择操作 |
|
|
|
tableHandleSelect(selection, row){ |
|
|
|
this.selectData = selection |
|
|
|
const isCheck = selection.length && selection.indexOf(row) !== -1 |
|
|
|
if(selection.length <= 0){} |
|
|
|
if (isCheck) { |
|
|
|
row.isCheck = true |
|
|
|
console.log("勾选",selection, row) |
|
|
|
console.log(472,this.CreateFormData.details) |
|
|
|
let _peerArr = this.findPeerForCheckHandle(row) |
|
|
|
// let _parentPeerArr = this.findParentPeerForCheckHandle(row) |
|
|
|
// let _allCheck = [..._peerArr,..._parentPeerArr] |
|
|
|
this.$nextTick(()=>{ |
|
|
|
this.toggleSelection(_peerArr,true) |
|
|
|
}) |
|
|
|
}else{ |
|
|
|
console.log("取消",selection, row) |
|
|
|
// 同级取消勾选 |
|
|
|
row.isCheck = false |
|
|
|
let _peerArr = this.findPeer(row) |
|
|
|
this.$nextTick(()=>{ |
|
|
|
this.toggleSelection(_peerArr,false) |
|
|
|
}) |
|
|
|
// 取消的时候,如果他父级的同级有选中,则他的父级选中 |
|
|
|
console.log("取消勾选",selection, row) |
|
|
|
} |
|
|
|
}, |
|
|
|
// 获取最底层 |
|
|
@ -403,15 +509,16 @@ export default { |
|
|
|
console.log("全选",selection) |
|
|
|
// 获取所有底层 |
|
|
|
this.selectData = this.getLastFloors(this.CreateFormData.details) |
|
|
|
console.log(407,this.$refs.bomTree_Ref) |
|
|
|
this.$refs.bomTree_Ref.clearSelection(); |
|
|
|
this.selectData.forEach(item=>{ |
|
|
|
item.isCheck = true |
|
|
|
this.$refs.bomTree_Ref.toggleRowSelection(item,true); |
|
|
|
}) |
|
|
|
}else{ |
|
|
|
console.log("全不选",selection) |
|
|
|
this.$refs.bomTree_Ref.clearSelection(); |
|
|
|
this.selectData = [] |
|
|
|
this.CreateFormData.details.forEach(item=>{item.isCheck = false}) |
|
|
|
} |
|
|
|
}, |
|
|
|
//结束退出 |
|
|
|