feat: 表格组件展示tooltip和状态字段支持传入国际化参数

This commit is contained in:
RubyLiu 2023-08-22 18:50:40 +08:00 committed by f2c-ci-robot[bot]
parent affd770918
commit 0d76b11adf
2 changed files with 19 additions and 3 deletions

View File

@ -47,19 +47,26 @@
<div v-else class="title">{{ t(item.title as string) }}</div>
</template>
<template #cell="{ column, record, rowIndex }">
<div class="flex flex-row items-center">
<div class="flex flex-row flex-nowrap items-center" :class="item.isTag ? 'max-w-[360px]' : 'max-w-[300px]'">
<template v-if="item.dataIndex === SpecialColumnEnum.ENABLE">
<slot name="enable" v-bind="{ record }">
<div v-if="record.enable" class="flex items-center">
<icon-check-circle-fill class="mr-[2px] text-[rgb(var(--success-6))]" />
{{ t('msTable.enable') }}
{{ item.enableTitle ? t(item.enableTitle) : t('msTable.enable') }}
</div>
<div v-else class="flex items-center text-[var(--color-text-4)]">
<MsIcon type="icon-icon_disable" class="mr-[2px]" />
{{ t('msTable.disable') }}
{{ item.disableTitle ? t(item.disableTitle) : t('msTable.disable') }}
</div>
</slot>
</template>
<template v-else-if="item.showTooltip">
<a-tooltip placement="top" :content="record[item.dataIndex as string]">
<slot :name="item.slotName" v-bind="{ record, rowIndex, column }">
<span>{{ record[item.dataIndex as string] }}</span>
</slot>
</a-tooltip>
</template>
<template v-else>
<a-input
v-if="editActiveKey === rowIndex && item.dataIndex === editKey"
@ -83,6 +90,7 @@
</template>
</a-table-column>
</template>
<template #empty>
<div class="flex h-[20px] flex-col items-center justify-center">
<span class="text-[14px] text-[var(--color-text-4)]">{{ t('msTable.empty') }}</span>

View File

@ -18,6 +18,14 @@ export interface MsTableColumnData extends TableColumnData {
showInTable?: boolean;
// 是否可编辑
editable?: boolean;
// 是否展示tooltip
showTooltip?: boolean;
// 启用Title 默认为启用
enableTitle?: string;
// 禁用Title 默认为禁用
disableTitle?: string;
// 当展示tooltip时是否是Tag
isTag?: boolean;
}
export type MsTableErrorStatus = boolean | 'error' | 'empty';