Commit 18dbcd05 authored by yanzhengyang's avatar yanzhengyang

选择用户公共组件修改BUG

parent 846b2a34
...@@ -12,8 +12,8 @@ ...@@ -12,8 +12,8 @@
</el-form> </el-form>
<div class="demo-collapse"> <div class="demo-collapse">
<el-collapse v-model="activeNames"> <el-collapse v-model="activeNames">
<el-collapse-item :title="item[deptKey]" :name="item.id" v-for="(item, index) in filteredDeptList" :key="index" style="margin-left: 20px"> <el-collapse-item :title="item[deptKey]" :name="item.deptId" v-for="(item, index) in filteredDeptList" :key="index" style="margin-left: 20px">
<div v-for="it in (Array.isArray(item[nameKey]) ? item[nameKey] : [item[nameKey]])" :key="it[nameKey]"> <div v-for="(it,idx) in (Array.isArray(item[nameKey]) ? item[nameKey] : [item[nameKey]])" :key="idx">
<el-checkbox <el-checkbox
v-model="checked1" v-model="checked1"
:label="it[nameKey]" :label="it[nameKey]"
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
</div> </div>
<div class="box-right-content"> <div class="box-right-content">
<div class="content-item" v-for="(item, index) in selectedItems" :key="index"> <div class="content-item" v-for="(item, index) in selectedItems" :key="index">
<span style="font-size: 14px;font-weight: 400">{{ item }}</span> <span style="width: 100px;font-size: 14px;font-weight: 400">{{ item }}</span>
<el-button icon="Delete" @click="removeItem(index)" type="primary" circle></el-button> <el-button icon="Delete" @click="removeItem(index)" type="primary" circle></el-button>
</div> </div>
</div> </div>
...@@ -83,16 +83,16 @@ const allRole = ref(''); ...@@ -83,16 +83,16 @@ const allRole = ref('');
const checked1 = ref([]); const checked1 = ref([]);
const selectedItems = ref([]); const selectedItems = ref([]);
const filteredDeptList = ref(props.deptList); const filteredDeptList = ref(props.deptList);
const activeNames = ref([props.deptList[0].id]); // 新增展开项绑定 const activeNames = ref([props.deptList[0].deptId]); // 新增展开项绑定
// 计算左侧总项数:遍历deptList并计算所有成员数量 // 计算左侧总项数:遍历deptList并计算所有成员数量
const totalItems = computed(() => { const totalItems = computed(() => {
return props.deptList.reduce((total, dept) => total + dept.name.length, 0); return props.deptList.reduce((total, dept) => total + dept[props.nameKey].length, 0);
}); });
// 搜索功能:根据输入内容过滤部门列表 // 搜索功能:根据输入内容过滤部门列表
const selectSearch = () => { const selectSearch = () => {
if (!allRole.value) { if (!allRole.value) {
filteredDeptList.value = props.deptList; // 如果搜索框为空,恢复所有项 filteredDeptList.value = props.deptList; // 如果搜索框为空,恢复所有项
activeNames.value = [props.deptList[0].id]; activeNames.value = [props.deptList[0].deptId];
checked1.value = [];// 清空展开项 checked1.value = [];// 清空展开项
} else { } else {
const searchTerm = allRole.value.toLowerCase(); const searchTerm = allRole.value.toLowerCase();
...@@ -111,7 +111,7 @@ const selectSearch = () => { ...@@ -111,7 +111,7 @@ const selectSearch = () => {
// 自动添加匹配的成员到选中列表(去重) // 自动添加匹配的成员到选中列表(去重)
checked1.value = [...new Set([...checked1.value, ...matchedNames])]; checked1.value = [...new Set([...checked1.value, ...matchedNames])];
activeNames.value = filteredDeptList.value.map(item => item.id); activeNames.value = filteredDeptList.value.map(item => item.deptId);
} }
}; };
...@@ -146,7 +146,7 @@ const closeDialog = () => { ...@@ -146,7 +146,7 @@ const closeDialog = () => {
clearAllSelected(); // 清空已选项 clearAllSelected(); // 清空已选项
allRole.value = ''; // 清空搜索框 allRole.value = ''; // 清空搜索框
filteredDeptList.value = props.deptList; filteredDeptList.value = props.deptList;
activeNames.value = [props.deptList[0].id] // 重置展开项绑定 activeNames.value = [props.deptList[0].deptId] // 重置展开项绑定
}; };
// 提交选择 // 提交选择
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment