|
|
@@ -5,11 +5,18 @@
|
|
|
<el-select
|
|
|
v-model="ruleFormData.deptIdList"
|
|
|
multiple
|
|
|
+ collapse-tags
|
|
|
+ collapse-tags-tooltip
|
|
|
+ :max-collapse-tags="3"
|
|
|
placeholder="请选择被检查(自查)单位"
|
|
|
filterable
|
|
|
- class="custom-select"
|
|
|
>
|
|
|
- <el-option v-for="item in firstLevelDepts" :key="item.id" :label="item.deptName" :value="item.id" />
|
|
|
+ <template #header>
|
|
|
+ <el-checkbox v-model="checkAll" :indeterminate="indeterminate" @change="handleCheckAllChange">
|
|
|
+ 全部单位
|
|
|
+ </el-checkbox>
|
|
|
+ </template>
|
|
|
+ <el-option v-for="item in firstLevelDepts" :key="item.id" :label="item.deptName" :value="String(item.id)" />
|
|
|
</el-select>
|
|
|
</template>
|
|
|
<template #inspectType>
|
|
|
@@ -36,7 +43,7 @@
|
|
|
</template>
|
|
|
|
|
|
<script setup lang="ts">
|
|
|
- import { onMounted, ref } from 'vue';
|
|
|
+ import { onMounted, ref, watch } from 'vue';
|
|
|
import BasicForm from '@/components/BasicForm.vue';
|
|
|
import GroupSelect from '@/views/disaster/components/GroupSelect.vue';
|
|
|
import { useFormConfigHook } from '@/hooks/useFormConfigHook';
|
|
|
@@ -73,6 +80,16 @@
|
|
|
cloneRuleFormData();
|
|
|
return ruleFormData;
|
|
|
};
|
|
|
+ const checkAll = ref(false);
|
|
|
+ const indeterminate = ref(false);
|
|
|
+ const handleCheckAllChange = () => {
|
|
|
+ if (checkAll.value) {
|
|
|
+ ruleFormData.deptIdList = firstLevelDepts.value.map((item) => String(item.id));
|
|
|
+ console.log(ruleFormData.deptIdList);
|
|
|
+ } else {
|
|
|
+ ruleFormData.deptIdList = [];
|
|
|
+ }
|
|
|
+ };
|
|
|
defineExpose({
|
|
|
handleValidate,
|
|
|
getFormData,
|
|
|
@@ -85,15 +102,15 @@
|
|
|
cloneRuleFormData();
|
|
|
beforeRouteLeave();
|
|
|
});
|
|
|
+ watch(
|
|
|
+ () => ruleFormData.deptIdList,
|
|
|
+ (newVal) => {
|
|
|
+ checkAll.value = newVal.length === firstLevelDepts.value.length;
|
|
|
+ indeterminate.value = newVal.length > 0 && newVal.length < firstLevelDepts.value.length;
|
|
|
+ },
|
|
|
+ );
|
|
|
</script>
|
|
|
|
|
|
<style scoped lang="scss">
|
|
|
@use '../style/task-item.scss' as *;
|
|
|
- .custom-select {
|
|
|
- :deep(.el-select__selection) {
|
|
|
- min-height: 24px;
|
|
|
- max-height: 64px;
|
|
|
- overflow-y: auto;
|
|
|
- }
|
|
|
- }
|
|
|
</style>
|