fix : 修复公司选择框全选功能

This commit is contained in:
2024-06-15 00:47:17 +08:00
parent 73313a1532
commit 9153c20902

View File

@@ -5,14 +5,16 @@
<div class="picker">
<div class="candidate" v-loading="loading">
<el-input v-model="filterText" @change="getList()"
clearable placeholder="输入部门进行搜索">
clearable placeholder="输入公司进行搜索">
<template #append>
<el-button @click="getList()">搜索</el-button>
</template>
</el-input>
<el-button v-if="isChooseAll" @click="chooseAll">全选</el-button>
<el-button v-else @click="cancelAll">不全选</el-button>
<!-- 人员选择 -->
<el-empty :image-size="100" description="似乎没有数据" v-show="dataList.length === 0"/>
<el-scrollbar style="height:90%;">
<el-scrollbar style="height:87%;">
<div class="tree">
<el-tree :data="dataList" ref="tree" :props="defaultProps" empty-text="" node-key="value"
default-expand-all :show-checkbox="showCheckbox" highlight-current :default-checked-keys="defaultChecked"
@@ -74,6 +76,7 @@ const props = defineProps({
}
});
const radio = ref(0);
const isChooseAll = ref(true);
const chooseId = ref(0);
let selectItem = reactive({
type: -1,
@@ -107,7 +110,22 @@ const _value = computed({
watch(() => filterText.value, (newVal) => {
tree.value.filter(newVal);
});
const matterTree=(list)=>{
list.forEach(item=>{
tree.value.setChecked(item,true)
if(item.children!==undefined){
matterTree(item.children)
}
})
}
const cancelAll=()=>{
isChooseAll.value=true
tree.value.setCheckedNodes([])
}
const chooseAll=()=>{
isChooseAll.value=false
matterTree(dataList.value)
}
const getList = () => {
getSubCompOpt().then(res => {
dataList.value = res.data;
@@ -252,6 +270,7 @@ $containWidth: 480px;
.footer {
float: right;
margin-top: 10px;
}
.picker {
@@ -261,9 +280,9 @@ $containWidth: 480px;
.candidate {
position: absolute;
display: inline-block;
display: block;
width: $containWidth;
height: 98%;
height: 100%;
border: 1px solid #e8e8e8;
:deep(.el-input) {
@@ -281,7 +300,7 @@ $containWidth: 480px;
position: absolute;
display: inline-block;
width: 450px;
height: 98%;
height: 100%;
border: 1px solid #e8e8e8;
.count {