feat: 表格编辑showTooltip优化
This commit is contained in:
parent
b77fd9e712
commit
46d32374fd
|
@ -83,39 +83,10 @@
|
||||||
<slot name="action" v-bind="{ record, rowIndex }" />
|
<slot name="action" v-bind="{ record, rowIndex }" />
|
||||||
</template>
|
</template>
|
||||||
<template v-else-if="item.showTooltip">
|
<template v-else-if="item.showTooltip">
|
||||||
<a-tooltip placement="top" :content="String(record[item.dataIndex as string])">
|
|
||||||
<a-input
|
|
||||||
v-if="
|
|
||||||
editActiveKey === `${item.dataIndex}${rowIndex}` &&
|
|
||||||
item.editable &&
|
|
||||||
item.editType === ColumnEditTypeEnum.INPUT
|
|
||||||
"
|
|
||||||
ref="currentInputRef"
|
|
||||||
v-model="record[item.dataIndex as string]"
|
|
||||||
@blur="handleEditInputBlur()"
|
|
||||||
@press-enter="handleEditInputEnter(record)"
|
|
||||||
/>
|
|
||||||
<template v-else>
|
|
||||||
<div class="one-line-text max-w-[300px]">
|
|
||||||
<slot :name="item.slotName" v-bind="{ record, rowIndex, column }">
|
|
||||||
{{ record[item.dataIndex as string] || '-' }}
|
|
||||||
</slot>
|
|
||||||
</div>
|
|
||||||
<MsIcon
|
|
||||||
v-if="item.editable && !record.deleted"
|
|
||||||
class="ml-2 cursor-pointer"
|
|
||||||
:class="{ 'ms-table-edit-active': editActiveKey === rowIndex }"
|
|
||||||
type="icon-icon_edit_outlined"
|
|
||||||
@click="handleEdit(item.dataIndex as string, rowIndex)"
|
|
||||||
/>
|
|
||||||
</template>
|
|
||||||
</a-tooltip>
|
|
||||||
</template>
|
|
||||||
<template v-else-if="item.ellipsis">
|
|
||||||
<a-input
|
<a-input
|
||||||
v-if="
|
v-if="
|
||||||
editActiveKey === `${item.dataIndex}${rowIndex}` &&
|
editActiveKey === `${item.dataIndex}${rowIndex}` &&
|
||||||
item.editable &&
|
item.editType &&
|
||||||
item.editType === ColumnEditTypeEnum.INPUT
|
item.editType === ColumnEditTypeEnum.INPUT
|
||||||
"
|
"
|
||||||
ref="currentInputRef"
|
ref="currentInputRef"
|
||||||
|
@ -123,45 +94,30 @@
|
||||||
@blur="handleEditInputBlur()"
|
@blur="handleEditInputBlur()"
|
||||||
@press-enter="handleEditInputEnter(record)"
|
@press-enter="handleEditInputEnter(record)"
|
||||||
/>
|
/>
|
||||||
<template v-else>
|
<a-tooltip v-else placement="top" :content="String(record[item.dataIndex as string])">
|
||||||
<div class="one-line-text max-w-[300px]">
|
<div class="one-line-text max-w-[300px]">
|
||||||
<slot :name="item.slotName" v-bind="{ record, rowIndex, column }">
|
<slot :name="item.slotName" v-bind="{ record, rowIndex, column }">
|
||||||
{{ record[item.dataIndex as string] || '-' }}
|
{{ record[item.dataIndex as string] || '-' }}
|
||||||
</slot>
|
</slot>
|
||||||
</div>
|
</div>
|
||||||
|
</a-tooltip>
|
||||||
|
<div>
|
||||||
<MsIcon
|
<MsIcon
|
||||||
v-if="item.editable && !record.deleted"
|
v-if="item.editType && editActiveKey !== `${item.dataIndex}${rowIndex}` && !record.deleted"
|
||||||
class="ml-2 cursor-pointer"
|
class="ml-2 cursor-pointer"
|
||||||
:class="{ 'ms-table-edit-active': editActiveKey === rowIndex }"
|
:class="{ 'ms-table-edit-active': editActiveKey === rowIndex }"
|
||||||
type="icon-icon_edit_outlined"
|
type="icon-icon_edit_outlined"
|
||||||
@click="handleEdit(item.dataIndex as string, rowIndex)"
|
@click="handleEdit(item.dataIndex as string, rowIndex)"
|
||||||
/>
|
/>
|
||||||
</template>
|
</div>
|
||||||
|
<div>
|
||||||
|
<slot :name="item.revokeDeletedSlot" v-bind="{ record, rowIndex, column }"></slot>
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<template v-else>
|
<template v-else>
|
||||||
<a-input
|
<slot :name="item.slotName" v-bind="{ record, rowIndex, column }">
|
||||||
v-if="
|
{{ record[item.dataIndex as string] || '-' }}
|
||||||
editActiveKey === `${item.dataIndex}${rowIndex}` &&
|
</slot>
|
||||||
item.editable &&
|
|
||||||
item.editType === ColumnEditTypeEnum.INPUT
|
|
||||||
"
|
|
||||||
ref="currentInputRef"
|
|
||||||
v-model="record[item.dataIndex as string]"
|
|
||||||
@blur="handleEditInputBlur()"
|
|
||||||
@press-enter="handleEditInputEnter(record)"
|
|
||||||
/>
|
|
||||||
<template v-else>
|
|
||||||
<slot :name="item.slotName" v-bind="{ record, rowIndex, column }">
|
|
||||||
{{ record[item.dataIndex as string] || '-' }}
|
|
||||||
</slot>
|
|
||||||
<MsIcon
|
|
||||||
v-if="item.editable && item.dataIndex === editKey && !record.deleted"
|
|
||||||
class="ml-2 cursor-pointer"
|
|
||||||
:class="{ 'ms-table-edit-active': editActiveKey === rowIndex }"
|
|
||||||
type="icon-icon_edit_outlined"
|
|
||||||
@click="handleEdit(item.dataIndex as string, rowIndex)"
|
|
||||||
/>
|
|
||||||
</template>
|
|
||||||
</template>
|
</template>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
@ -376,7 +332,6 @@
|
||||||
currentInputRef.value[0].focus();
|
currentInputRef.value[0].focus();
|
||||||
} else {
|
} else {
|
||||||
nextTick(() => {
|
nextTick(() => {
|
||||||
debugger;
|
|
||||||
currentInputRef.value[0].focus();
|
currentInputRef.value[0].focus();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,10 +41,10 @@
|
||||||
<a-divider orientation="center" class="non-sort"
|
<a-divider orientation="center" class="non-sort"
|
||||||
><span class="text-xs text-[var(--color-text-4)]">{{ t('msTable.columnSetting.nonSort') }}</span></a-divider
|
><span class="text-xs text-[var(--color-text-4)]">{{ t('msTable.columnSetting.nonSort') }}</span></a-divider
|
||||||
>
|
>
|
||||||
<Draggable tag="div" :list="couldSortColumn" class="list-group" handle=".handle" item-key="dateIndex">
|
<Draggable tag="div" :list="couldSortColumn" ghost-class="ghost" item-key="dateIndex">
|
||||||
<template #item="{ element, index }">
|
<template #item="{ element, index }">
|
||||||
<div class="column-drag-item">
|
<div class="column-drag-item">
|
||||||
<div class="handle flex w-[90%] items-center">
|
<div class="flex w-[90%] items-center">
|
||||||
<MsIcon type="icon-icon_drag" class="text-[16px] text-[var(--color-text-4)]" />
|
<MsIcon type="icon-icon_drag" class="text-[16px] text-[var(--color-text-4)]" />
|
||||||
<span class="ml-[8px]">{{ t(element.title as string) }}</span>
|
<span class="ml-[8px]">{{ t(element.title as string) }}</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -29,6 +29,10 @@ export interface MsTableColumnData extends TableColumnData {
|
||||||
isTag?: boolean;
|
isTag?: boolean;
|
||||||
// editType
|
// editType
|
||||||
editType?: ColumnEditTypeEnum;
|
editType?: ColumnEditTypeEnum;
|
||||||
|
// 撤销删除的组件
|
||||||
|
revokeDeletedSlot?: string;
|
||||||
|
// 表格列排序字段
|
||||||
|
sortIndex?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type MsTableErrorStatus = boolean | 'error' | 'empty';
|
export type MsTableErrorStatus = boolean | 'error' | 'empty';
|
||||||
|
|
|
@ -22,7 +22,9 @@ export enum TableKeyEnum {
|
||||||
|
|
||||||
// 具有特殊功能的列
|
// 具有特殊功能的列
|
||||||
export enum SpecialColumnEnum {
|
export enum SpecialColumnEnum {
|
||||||
// 编辑列
|
// 系统id
|
||||||
|
ID = 'num',
|
||||||
|
// 名称
|
||||||
NAME = 'name',
|
NAME = 'name',
|
||||||
// 状态列
|
// 状态列
|
||||||
ENABLE = 'enable',
|
ENABLE = 'enable',
|
||||||
|
|
|
@ -2,6 +2,7 @@ import { defineStore } from 'pinia';
|
||||||
import { MsTableSelectorItem, MsTableState, TableOpenDetailMode } from './types';
|
import { MsTableSelectorItem, MsTableState, TableOpenDetailMode } from './types';
|
||||||
import { MsTableColumn } from '@/components/pure/ms-table/type';
|
import { MsTableColumn } from '@/components/pure/ms-table/type';
|
||||||
import { parse, stringify } from '@/utils/serializeMap';
|
import { parse, stringify } from '@/utils/serializeMap';
|
||||||
|
import { SpecialColumnEnum } from '@/enums/tableEnum';
|
||||||
|
|
||||||
const msTableStore = defineStore('msTable', {
|
const msTableStore = defineStore('msTable', {
|
||||||
// 开启数据持久化
|
// 开启数据持久化
|
||||||
|
@ -25,6 +26,18 @@ const msTableStore = defineStore('msTable', {
|
||||||
if (item.showInTable === undefined) {
|
if (item.showInTable === undefined) {
|
||||||
item.showInTable = true;
|
item.showInTable = true;
|
||||||
}
|
}
|
||||||
|
if (item.dataIndex === SpecialColumnEnum.ID) {
|
||||||
|
item.showDrag = false;
|
||||||
|
item.sortIndex = 0;
|
||||||
|
}
|
||||||
|
if (item.dataIndex === SpecialColumnEnum.NAME) {
|
||||||
|
item.showDrag = false;
|
||||||
|
item.sortIndex = 1;
|
||||||
|
}
|
||||||
|
if (item.dataIndex === SpecialColumnEnum.OPERATION || item.dataIndex === SpecialColumnEnum.ACTION) {
|
||||||
|
item.showDrag = false;
|
||||||
|
item.sortIndex = 1000;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
tmpMap.set(tableKey, { mode, column });
|
tmpMap.set(tableKey, { mode, column });
|
||||||
this.selectorColumnMap = tmpMap;
|
this.selectorColumnMap = tmpMap;
|
||||||
|
|
|
@ -12,8 +12,7 @@
|
||||||
></a-input-search>
|
></a-input-search>
|
||||||
</div>
|
</div>
|
||||||
<MsBaseTable v-bind="propsRes" v-on="propsEvent">
|
<MsBaseTable v-bind="propsRes" v-on="propsEvent">
|
||||||
<template #name="{ record }">
|
<template #revokeDelete="{ record }">
|
||||||
<span class="one-line-text">{{ record.name }}</span>
|
|
||||||
<a-tooltip background-color="#FFFFFF">
|
<a-tooltip background-color="#FFFFFF">
|
||||||
<template #content>
|
<template #content>
|
||||||
<span class="text-[var(--color-text-1)]">{{ t('system.project.revokeDeleteToolTip') }}</span>
|
<span class="text-[var(--color-text-1)]">{{ t('system.project.revokeDeleteToolTip') }}</span>
|
||||||
|
@ -104,11 +103,10 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'system.organization.name',
|
title: 'system.organization.name',
|
||||||
slotName: 'name',
|
revokeDeletedSlot: 'revokeDelete',
|
||||||
editable: true,
|
|
||||||
editType: ColumnEditTypeEnum.INPUT,
|
editType: ColumnEditTypeEnum.INPUT,
|
||||||
dataIndex: 'name',
|
dataIndex: 'name',
|
||||||
ellipsis: true,
|
showTooltip: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'system.organization.member',
|
title: 'system.organization.member',
|
||||||
|
@ -124,8 +122,7 @@
|
||||||
{
|
{
|
||||||
title: 'system.organization.description',
|
title: 'system.organization.description',
|
||||||
dataIndex: 'description',
|
dataIndex: 'description',
|
||||||
ellipsis: true,
|
showTooltip: true,
|
||||||
tooltip: true,
|
|
||||||
showDrag: true,
|
showDrag: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
<template>
|
<template>
|
||||||
<MsBaseTable v-bind="propsRes" v-on="propsEvent">
|
<MsBaseTable v-bind="propsRes" v-on="propsEvent">
|
||||||
<template #name="{ record }">
|
<template #revokeDelete="{ record }">
|
||||||
<div class="one-line-text max-w-[156px]">{{ record.name }}</div>
|
|
||||||
<a-tooltip background-color="#FFFFFF">
|
<a-tooltip background-color="#FFFFFF">
|
||||||
<template #content>
|
<template #content>
|
||||||
<span class="text-[var(--color-text-1)]">{{ t('system.organization.revokeDeleteToolTip') }}</span>
|
<span class="text-[var(--color-text-1)]">{{ t('system.organization.revokeDeleteToolTip') }}</span>
|
||||||
|
@ -101,12 +100,11 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'system.organization.name',
|
title: 'system.organization.name',
|
||||||
slotName: 'name',
|
|
||||||
dataIndex: 'name',
|
dataIndex: 'name',
|
||||||
width: 200,
|
width: 300,
|
||||||
editable: true,
|
revokeDeletedSlot: 'revokeDelete',
|
||||||
editType: ColumnEditTypeEnum.INPUT,
|
editType: ColumnEditTypeEnum.INPUT,
|
||||||
ellipsis: true,
|
showTooltip: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'system.organization.member',
|
title: 'system.organization.member',
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
<template>
|
<template>
|
||||||
<MsBaseTable v-bind="propsRes" v-on="propsEvent">
|
<MsBaseTable v-bind="propsRes" v-on="propsEvent">
|
||||||
<template #name="{ record }">
|
<template #revokeDelete="{ record }">
|
||||||
<span class="one-line-text">{{ record.name }}</span>
|
|
||||||
<a-tooltip background-color="#FFFFFF">
|
<a-tooltip background-color="#FFFFFF">
|
||||||
<template #content>
|
<template #content>
|
||||||
<span class="text-[var(--color-text-1)]">{{ t('system.project.revokeDeleteToolTip') }}</span>
|
<span class="text-[var(--color-text-1)]">{{ t('system.project.revokeDeleteToolTip') }}</span>
|
||||||
|
@ -96,11 +95,10 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'system.organization.name',
|
title: 'system.organization.name',
|
||||||
slotName: 'name',
|
|
||||||
dataIndex: 'name',
|
dataIndex: 'name',
|
||||||
editable: true,
|
revokeDeletedSlot: 'revokeDelete',
|
||||||
editType: ColumnEditTypeEnum.INPUT,
|
editType: ColumnEditTypeEnum.INPUT,
|
||||||
ellipsis: true,
|
showTooltip: true,
|
||||||
width: 300,
|
width: 300,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -115,8 +113,7 @@
|
||||||
{
|
{
|
||||||
title: 'system.organization.description',
|
title: 'system.organization.description',
|
||||||
dataIndex: 'description',
|
dataIndex: 'description',
|
||||||
ellipsis: true,
|
showTooltip: true,
|
||||||
tooltip: true,
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'system.organization.subordinateOrg',
|
title: 'system.organization.subordinateOrg',
|
||||||
|
|
Loading…
Reference in New Issue