From 85e67370ba0068182faa2c8a1754356bd5b08a22 Mon Sep 17 00:00:00 2001 From: Kagol Date: Mon, 18 Nov 2024 20:25:26 +0800 Subject: [PATCH] fix(base-select): fix data display error when set disabled and hover-expand --- packages/renderless/src/base-select/index.ts | 17 +++ packages/renderless/src/base-select/vue.ts | 12 +- packages/vue/src/base-select/src/index.ts | 4 + packages/vue/src/base-select/src/pc.vue | 123 +++++++++++-------- 4 files changed, 106 insertions(+), 50 deletions(-) diff --git a/packages/renderless/src/base-select/index.ts b/packages/renderless/src/base-select/index.ts index b6c3b5e6f5..c2ea6f6dca 100644 --- a/packages/renderless/src/base-select/index.ts +++ b/packages/renderless/src/base-select/index.ts @@ -1971,6 +1971,23 @@ export const watchShowClose = } // 以下为tiny 新增功能 +/** + * 兼容不同主题多选禁用的展示类型 + * default 和 smb 主题,displayOnly 时显示为 tagText,否则为 tag + * aurora 主题 displayOnly||disabled 时显示为tagText,否则为 tag + */ +export const computedShowTagText = + ({ state }) => + () => + state.isDisplayOnly + +/** + * 兼容不同主题多选,tag 在disabled 和 required 时是否显示关闭按钮的区别 + * default 主题 ,禁用显示关闭按钮,required目前和aurora保持一致不显示,待设计图补充时更新 + * aurora 主题,禁用时无禁用效果,required 时不显示关闭按钮 + */ +export const isTagClosable = () => (item) => !item.required + export const computedGetIcon = ({ designConfig, props }) => () => { diff --git a/packages/renderless/src/base-select/vue.ts b/packages/renderless/src/base-select/vue.ts index d01ba74f9f..fe1241b1e4 100644 --- a/packages/renderless/src/base-select/vue.ts +++ b/packages/renderless/src/base-select/vue.ts @@ -97,7 +97,9 @@ import { onClickCollapseTag, computedIsExpand, updateSelectedData, - hidePanel + hidePanel, + computedShowTagText, + isTagClosable } from './index' import debounce from '../common/deps/debounce' import { isNumber } from '../common/type' @@ -154,7 +156,9 @@ export const api = [ 'clearSearchText', 'onClickCollapseTag', 'updateSelectedData', - 'hidePanel' + 'hidePanel', + 'computedShowTagText', + 'isTagClosable' ] const initState = ({ reactive, computed, props, api, emitter, parent, constants, useBreakpoint, vm, designConfig }) => { @@ -271,6 +275,8 @@ const initStateAdd = ({ computed, props, api, parent }) => { formItemSize: computed(() => (parent.formItem || { state: {} }).state.formItemSize), selectDisabled: computed(() => api.computedSelectDisabled()), isDisplayOnly: computed(() => props.displayOnly || (parent.form || {}).displayOnly), + isDisabled: computed(() => props.disabled || (parent.form || {}).disabled), + isShowTagText: computed(() => api.computedShowTagText()), gridCheckedData: computed(() => api.getcheckedData()), searchSingleCopy: computed(() => props.allowCopy && !props.multiple && props.filterable), childrenName: computed(() => 'children'), @@ -364,6 +370,8 @@ const initApi = ({ computedGetTagType: computedGetTagType({ designConfig, props }), clearSearchText: clearSearchText({ state, api }), clearNoMatchValue: clearNoMatchValue({ props, emit }), + computedShowTagText: computedShowTagText({ state }), + isTagClosable: isTagClosable(), updateSelectedData: updateSelectedData({ state }), hidePanel: hidePanel({ state }) }) diff --git a/packages/vue/src/base-select/src/index.ts b/packages/vue/src/base-select/src/index.ts index 7257d68804..40e27e7e1f 100644 --- a/packages/vue/src/base-select/src/index.ts +++ b/packages/vue/src/base-select/src/index.ts @@ -344,6 +344,10 @@ export default defineComponent({ allText: { type: String, default: '' + }, + showAllTextTag: { + type: Boolean, + default: false } }, setup(props, context) { diff --git a/packages/vue/src/base-select/src/pc.vue b/packages/vue/src/base-select/src/pc.vue index 25a5931317..87841b9cfb 100644 --- a/packages/vue/src/base-select/src/pc.vue +++ b/packages/vue/src/base-select/src/pc.vue @@ -70,11 +70,15 @@
- + + {{ state.selected.length - 1 }} + + - - + {{ allText || t('ui.base.all') }} - - + @@ -694,6 +720,7 @@ export default defineComponent({ 'showProportion', 'clickExpand', 'maxVisibleRows', + 'showAllTextTag', 'allText' ], setup(props, context) {