|
@@ -1,10 +1,14 @@
|
|
|
<template>
|
|
|
<div :class="[prefixCls, getAlign]" @click="onCellClick">
|
|
|
<template v-for="(action, index) in getActions" :key="`${index}-${action.label}`">
|
|
|
- <PopConfirmButton v-bind="action">
|
|
|
- <Icon :icon="action.icon" class="mr-1" v-if="action.icon" />
|
|
|
- {{ action.label }}
|
|
|
- </PopConfirmButton>
|
|
|
+ <Tooltip v-bind="getTooltip(action.tooltip)">
|
|
|
+ <PopConfirmButton v-bind="action">
|
|
|
+ <Tooltip v-bind="getTooltip(action.tooltip)">
|
|
|
+ <Icon :icon="action.icon" class="mr-1" v-if="action.icon" />
|
|
|
+ {{ action.label }}
|
|
|
+ </Tooltip>
|
|
|
+ </PopConfirmButton>
|
|
|
+ </Tooltip>
|
|
|
<Divider
|
|
|
type="vertical"
|
|
|
class="action-divider"
|
|
@@ -31,7 +35,7 @@
|
|
|
<script lang="ts">
|
|
|
import { defineComponent, PropType, computed, toRaw } from 'vue';
|
|
|
import { MoreOutlined } from '@ant-design/icons-vue';
|
|
|
- import { Divider } from 'ant-design-vue';
|
|
|
+ import { Divider, Tooltip } from 'ant-design-vue';
|
|
|
import Icon from '/@/components/Icon/index';
|
|
|
import { ActionItem, TableActionType } from '/@/components/Table';
|
|
|
import { PopConfirmButton } from '/@/components/Button';
|
|
@@ -39,13 +43,13 @@
|
|
|
import { useDesign } from '/@/hooks/web/useDesign';
|
|
|
import { useTableContext } from '../hooks/useTableContext';
|
|
|
import { usePermission } from '/@/hooks/web/usePermission';
|
|
|
- import { isBoolean, isFunction } from '/@/utils/is';
|
|
|
+ import { isBoolean, isFunction, isString } from '/@/utils/is';
|
|
|
import { propTypes } from '/@/utils/propTypes';
|
|
|
import { ACTION_COLUMN_FLAG } from '../const';
|
|
|
|
|
|
export default defineComponent({
|
|
|
name: 'TableAction',
|
|
|
- components: { Icon, PopConfirmButton, Divider, Dropdown, MoreOutlined },
|
|
|
+ components: { Icon, PopConfirmButton, Divider, Dropdown, MoreOutlined, Tooltip },
|
|
|
props: {
|
|
|
actions: {
|
|
|
type: Array as PropType<ActionItem[]>,
|
|
@@ -124,6 +128,16 @@
|
|
|
return actionColumn?.align ?? 'left';
|
|
|
});
|
|
|
|
|
|
+ const getTooltip = computed(() => {
|
|
|
+ return (data) => {
|
|
|
+ if (isString(data)) {
|
|
|
+ return { title: data };
|
|
|
+ } else {
|
|
|
+ return data;
|
|
|
+ }
|
|
|
+ };
|
|
|
+ });
|
|
|
+
|
|
|
function onCellClick(e: MouseEvent) {
|
|
|
if (!props.stopButtonPropagation) return;
|
|
|
const target = e.target as HTMLElement;
|
|
@@ -132,7 +146,7 @@
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- return { prefixCls, getActions, getDropdownList, getAlign, onCellClick };
|
|
|
+ return { prefixCls, getActions, getDropdownList, getAlign, onCellClick, getTooltip };
|
|
|
},
|
|
|
});
|
|
|
</script>
|