master #20
|
|
@ -7,11 +7,11 @@
|
|||
<el-input v-model="filterText" style="width: 100%;" size="small"
|
||||
clearable placeholder="输入关键字进行过滤" prefix-icon="el-icon-search"/>
|
||||
</div>
|
||||
<!-- 部门 -->
|
||||
<!-- 部门 check-strictly-->
|
||||
<el-empty :image-size="100" description="似乎没有数据" v-show="deptList.length === 0"/>
|
||||
<el-scrollbar style="height:350px">
|
||||
<el-tree :data="deptList" ref="tree" :props="deptProps" empty-text="" node-key="deptId" default-expand-all
|
||||
:show-checkbox="showCheckbox" check-strictly highlight-current
|
||||
<el-tree :data="deptList" ref="tree" :props="deptProps" empty-text="" node-key="value" default-expand-all
|
||||
:show-checkbox="showCheckbox" highlight-current :check-strictly="multiple===false"
|
||||
@check-change="handleCheckChange" @node-click="(node,check)=>handle(node,check)"
|
||||
:filter-node-method="filterNode">
|
||||
<div class="custom-tree-node" slot-scope="{ node }" style="width: 100%">
|
||||
|
|
@ -20,7 +20,6 @@
|
|||
</el-tree>
|
||||
</el-scrollbar>
|
||||
</div>
|
||||
|
||||
<div class="selected">
|
||||
<div class="count">
|
||||
<span>已选 {{ selectList.length }} 项</span>
|
||||
|
|
@ -120,6 +119,7 @@ export default {
|
|||
* @param checked 是否选中
|
||||
*/
|
||||
handleCheckChange(data, checked) {
|
||||
// if (data.children === undefined) {
|
||||
// 左侧有选择框
|
||||
if (this.showCheckbox) {
|
||||
// 左侧有选择框 + 多选
|
||||
|
|
@ -132,12 +132,16 @@ export default {
|
|||
}
|
||||
}
|
||||
if (checked) {
|
||||
if(data.children === undefined){
|
||||
this.selectList.push(data);
|
||||
}
|
||||
|
||||
} else if (data === '1') {
|
||||
this.$refs.tree.setCheckedKeys([]);
|
||||
this.selectList = [];
|
||||
}
|
||||
} else {// 左侧有选择框 + 单选
|
||||
console.log('左侧有选择框 + 单选')
|
||||
//不添加重复的数据到右边
|
||||
for (let i = 0; i < this.selectList.length; i++) {
|
||||
if (this.selectList[i].value === data.value) {
|
||||
|
|
@ -147,13 +151,15 @@ export default {
|
|||
}
|
||||
if (checked) {
|
||||
this.$refs.tree.setCheckedNodes([data]);
|
||||
// this.$refs.tree.setCheckedKeys([]);
|
||||
this.selectList = [data];
|
||||
} else if (data === '1') {
|
||||
this.$refs.tree.setCheckedKeys([]);
|
||||
this.selectList = [];
|
||||
this.$refs.tree.setCheckedKeys([]);
|
||||
}
|
||||
}
|
||||
}
|
||||
// }
|
||||
this._value = this.selectList
|
||||
},
|
||||
|
||||
|
|
@ -164,6 +170,7 @@ export default {
|
|||
* @param check checked(checkbox选择框)是否选中
|
||||
*/
|
||||
handle(node, check) {
|
||||
if (check.isLeaf !== false) {
|
||||
if (this.multiple) {
|
||||
//不添加重复的数据到右边
|
||||
for (let i = 0; i < this.selectList.length; i++) {
|
||||
|
|
@ -178,6 +185,7 @@ export default {
|
|||
check.checked = true
|
||||
this.selectList = [node];
|
||||
}
|
||||
}
|
||||
this._value = this.selectList
|
||||
},
|
||||
//左侧无选择框时,右侧显示×
|
||||
|
|
@ -203,9 +211,10 @@ export default {
|
|||
cancelButtonText: "取消",
|
||||
type: "warning"
|
||||
}).then(() => {
|
||||
this.handleCheckChange("1");
|
||||
if (!this.showCheckbox) {
|
||||
this.selectList = []
|
||||
}else {
|
||||
this.handleCheckChange("1");
|
||||
}
|
||||
});
|
||||
},
|
||||
|
|
@ -221,15 +230,15 @@ export default {
|
|||
<style lang="less" scoped>
|
||||
@containWidth: 278px;
|
||||
|
||||
/deep/ .el-tree-node {
|
||||
.is-leaf + .el-checkbox .el-checkbox__inner {
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.el-checkbox .el-checkbox__inner {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
///deep/ .el-tree-node {
|
||||
// .is-leaf + .el-checkbox .el-checkbox__inner {
|
||||
// display: inline-block;
|
||||
// }
|
||||
//
|
||||
// .el-checkbox .el-checkbox__inner {
|
||||
// display: none;
|
||||
// }
|
||||
//}
|
||||
|
||||
/deep/ .el-dialog__body {
|
||||
padding: 10px 20px;
|
||||
|
|
|
|||
Loading…
Reference in New Issue