【issues/5595】BasicTable组件hideSelectAll: true无法隐藏全选框

pull/975/head
zhangdaiscott 2023-12-01 21:25:21 +08:00
parent 75bf9784e4
commit a67f074690
2 changed files with 17 additions and 3 deletions

View File

@ -1,10 +1,17 @@
<!-- 自定义选择列表头实现部分 --> <!-- 自定义选择列表头实现部分 -->
<template> <template>
<!-- update-begin--author:liaozhiyang---date:20231130---forissues/5595BasicTable组件hideSelectAll: true无法隐藏全选框 -->
<template v-if="isRadio"> <template v-if="isRadio">
<!-- radio不存在全选所以放个空标签 --> <!-- radio不存在全选所以放个空标签 -->
<span></span> <span></span>
</template> </template>
<a-checkbox :disabled="disabled" v-else :checked="checked" :indeterminate="isHalf" @update:checked="onChange" /> <template v-else>
<template v-if="hideSelectAll">
<span></span>
</template>
<a-checkbox :disabled="disabled" v-else :checked="checked" :indeterminate="isHalf" @update:checked="onChange" />
</template>
<!-- update-end--author:liaozhiyang---date:20231130---forissues/5595BasicTable组件hideSelectAll: true无法隐藏全选框 -->
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { computed } from 'vue'; import { computed } from 'vue';
@ -23,6 +30,10 @@
type: Number, type: Number,
required: true, required: true,
}, },
hideSelectAll: {
type: Boolean,
default: false,
},
// update-begin--author:liaozhiyang---date:20231016---forQQYUN-6774checkbox // update-begin--author:liaozhiyang---date:20231016---forQQYUN-6774checkbox
disabled: { disabled: {
type: Boolean, type: Boolean,

View File

@ -123,6 +123,7 @@ export function useCustomSelection(
pageSize: currentPageSize.value, pageSize: currentPageSize.value,
// 【QQYUN-6774】解决checkbox禁用后全选仍能勾选问题 // 【QQYUN-6774】解决checkbox禁用后全选仍能勾选问题
disabled: flattedData.value.length == 0, disabled: flattedData.value.length == 0,
hideSelectAll: unref(propsRef)?.rowSelection?.hideSelectAll,
}; };
}); });
@ -130,8 +131,10 @@ export function useCustomSelection(
watch( watch(
() => unref(propsRef)?.rowSelection?.selectedRowKeys, () => unref(propsRef)?.rowSelection?.selectedRowKeys,
(val: string[]) => { (val: string[]) => {
if (Array.isArray(val)) { // 解决selectedRowKeys在页面调用处使用ref失效
setSelectedRowKeys(val); const value = unref(val);
if (Array.isArray(value)) {
setSelectedRowKeys(value);
} }
}, },
{ immediate: true } { immediate: true }