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