Commit cdf0a600e505daf429446b8a7968269e1034de04

Authored by vben
1 parent efbde0d5

perf: perf table

src/components/Button/src/PopConfirmButton.vue
@@ -13,6 +13,7 @@ @@ -13,6 +13,7 @@
13 inheritAttrs: false, 13 inheritAttrs: false,
14 components: { Popconfirm, BasicButton }, 14 components: { Popconfirm, BasicButton },
15 props: { 15 props: {
  16 + size: propTypes.oneOf(['large', 'default', 'small']).def(),
16 enable: propTypes.bool.def(true), 17 enable: propTypes.bool.def(true),
17 okText: propTypes.string, 18 okText: propTypes.string,
18 cancelText: propTypes.string, 19 cancelText: propTypes.string,
@@ -31,7 +32,7 @@ @@ -31,7 +32,7 @@
31 return popValues; 32 return popValues;
32 }); 33 });
33 return () => { 34 return () => {
34 - const Button = h(BasicButton, omit(unref(attrs), 'icon'), extendSlots(slots)); 35 + const Button = h(BasicButton, unref(getBindValues), extendSlots(slots));
35 if (!props.enable) { 36 if (!props.enable) {
36 return Button; 37 return Button;
37 } 38 }
src/components/Table/index.ts
@@ -2,11 +2,9 @@ import { createAsyncComponent } from '/@/utils/factory/createAsyncComponent'; @@ -2,11 +2,9 @@ import { createAsyncComponent } from '/@/utils/factory/createAsyncComponent';
2 2
3 export { default as BasicTable } from './src/BasicTable.vue'; 3 export { default as BasicTable } from './src/BasicTable.vue';
4 export { default as TableAction } from './src/components/TableAction.vue'; 4 export { default as TableAction } from './src/components/TableAction.vue';
5 -// export { default as TableImg } from './src/components/TableImg.vue';  
6 export { default as EditTableHeaderIcon } from './src/components/EditTableHeaderIcon.vue'; 5 export { default as EditTableHeaderIcon } from './src/components/EditTableHeaderIcon.vue';
7 6
8 export const TableImg = createAsyncComponent(() => import('./src/components/TableImg.vue')); 7 export const TableImg = createAsyncComponent(() => import('./src/components/TableImg.vue'));
9 -// export const TableAction = createAsyncComponent(() => import('./src/components/TableAction.vue'));  
10 8
11 export * from './src/types/table'; 9 export * from './src/types/table';
12 export * from './src/types/pagination'; 10 export * from './src/types/pagination';
src/components/Table/src/components/TableAction.vue
@@ -5,7 +5,10 @@ @@ -5,7 +5,10 @@
5 <Icon :icon="action.icon" class="mr-1" v-if="action.icon" /> 5 <Icon :icon="action.icon" class="mr-1" v-if="action.icon" />
6 {{ action.label }} 6 {{ action.label }}
7 </PopConfirmButton> 7 </PopConfirmButton>
8 - <Divider type="vertical" v-if="divider && index < getActions.length" /> 8 + <Divider
  9 + type="vertical"
  10 + v-if="divider && index < getActions.length - (dropDownActions ? 0 : 1)"
  11 + />
9 </template> 12 </template>
10 <Dropdown :trigger="['hover']" :dropMenuList="getDropList" v-if="dropDownActions"> 13 <Dropdown :trigger="['hover']" :dropMenuList="getDropList" v-if="dropDownActions">
11 <slot name="more" /> 14 <slot name="more" />
@@ -44,17 +47,31 @@ @@ -44,17 +47,31 @@
44 }, 47 },
45 setup(props) { 48 setup(props) {
46 const { prefixCls } = useDesign('basic-table-action'); 49 const { prefixCls } = useDesign('basic-table-action');
47 - let table = {}; 50 + let table: Partial<TableActionType> = {};
48 if (!props.outside) { 51 if (!props.outside) {
49 table = useTableContext(); 52 table = useTableContext();
50 } 53 }
51 54
  55 + // const getSize = computed(() => {
  56 + // const size = table?.getSize?.();
  57 + // if (size === 'middle' || !size) {
  58 + // return;
  59 + // }
  60 +
  61 + // if (size === 'default') {
  62 + // return 'large';
  63 + // }
  64 + // return size;
  65 + // });
  66 +
52 const getActions = computed(() => { 67 const getActions = computed(() => {
53 return (props.actions || []).map((action) => { 68 return (props.actions || []).map((action) => {
54 const { popConfirm } = action; 69 const { popConfirm } = action;
  70 + // const size = unref(getSize);
55 return { 71 return {
56 type: 'link', 72 type: 'link',
57 size: 'small', 73 size: 'small',
  74 + // ...(size ? { size } : {}),
58 ...action, 75 ...action,
59 ...(popConfirm || {}), 76 ...(popConfirm || {}),
60 onConfirm: popConfirm?.confirm, 77 onConfirm: popConfirm?.confirm,
src/components/Table/src/components/editable/EditableCell.vue
@@ -85,6 +85,18 @@ @@ -85,6 +85,18 @@
85 return unref(ruleMessage) && unref(ruleVisible); 85 return unref(ruleMessage) && unref(ruleVisible);
86 }); 86 });
87 87
  88 + // const getSize = computed(() => {
  89 + // const size = table?.getSize?.();
  90 + // if (size === 'middle' || !size) {
  91 + // return;
  92 + // }
  93 +
  94 + // if (size === 'default') {
  95 + // return 'large';
  96 + // }
  97 + // return size;
  98 + // });
  99 +
88 const getIsCheckComp = computed(() => { 100 const getIsCheckComp = computed(() => {
89 const component = unref(getComponent); 101 const component = unref(getComponent);
90 return ['Checkbox', 'Switch'].includes(component); 102 return ['Checkbox', 'Switch'].includes(component);
@@ -300,6 +312,7 @@ @@ -300,6 +312,7 @@
300 handleOptionsChange, 312 handleOptionsChange,
301 getWrapperStyle, 313 getWrapperStyle,
302 getRowEditable, 314 getRowEditable,
  315 + // getSize,
303 }; 316 };
304 }, 317 },
305 }); 318 });
src/components/Table/src/components/editable/helper.ts
@@ -8,10 +8,10 @@ const { t } = useI18n(); @@ -8,10 +8,10 @@ const { t } = useI18n();
8 */ 8 */
9 export function createPlaceholderMessage(component: ComponentType) { 9 export function createPlaceholderMessage(component: ComponentType) {
10 if (component.includes('Input')) { 10 if (component.includes('Input')) {
11 - return t('component.form.input'); 11 + return t('common.inputText');
12 } 12 }
13 if (component.includes('Picker')) { 13 if (component.includes('Picker')) {
14 - return t('component.form.choose'); 14 + return t('common.chooseText');
15 } 15 }
16 16
17 if ( 17 if (
@@ -20,7 +20,7 @@ export function createPlaceholderMessage(component: ComponentType) { @@ -20,7 +20,7 @@ export function createPlaceholderMessage(component: ComponentType) {
20 component.includes('Radio') || 20 component.includes('Radio') ||
21 component.includes('Switch') 21 component.includes('Switch')
22 ) { 22 ) {
23 - return t('component.form.choose'); 23 + return t('common.chooseText');
24 } 24 }
25 return ''; 25 return '';
26 } 26 }
src/components/Table/src/hooks/useTableScroll.ts
@@ -143,7 +143,7 @@ export function useTableScroll( @@ -143,7 +143,7 @@ export function useTableScroll(
143 143
144 const table = unref(tableElRef); 144 const table = unref(tableElRef);
145 const tableWidth = table?.$el?.offsetWidth ?? 0; 145 const tableWidth = table?.$el?.offsetWidth ?? 0;
146 - return tableWidth > width ? tableWidth - 24 : width; 146 + return tableWidth > width ? '100%' : width;
147 }); 147 });
148 148
149 const getScrollRef = computed(() => { 149 const getScrollRef = computed(() => {
src/components/Table/src/style/index.less
@@ -51,7 +51,7 @@ @@ -51,7 +51,7 @@
51 // 51 //
52 .ant-table { 52 .ant-table {
53 width: 100%; 53 width: 100%;
54 - overflow-x: auto; 54 + overflow-x: hidden;
55 border: none; 55 border: none;
56 56
57 &-title { 57 &-title {
@@ -107,22 +107,11 @@ @@ -107,22 +107,11 @@
107 border: 1px solid @border-color !important; 107 border: 1px solid @border-color !important;
108 } 108 }
109 109
110 - .ant-table td {  
111 - white-space: nowrap;  
112 - }  
113 -  
114 .ant-table-tbody > tr > td, 110 .ant-table-tbody > tr > td,
115 .ant-table-tbody > tr > th, 111 .ant-table-tbody > tr > th,
116 .ant-table-thead > tr > td, 112 .ant-table-thead > tr > td,
117 .ant-table-thead > tr > th { 113 .ant-table-thead > tr > th {
118 - white-space: pre;  
119 - }  
120 -  
121 - .ant-table-tbody > tr > td > span,  
122 - .ant-table-tbody > tr > th > span,  
123 - .ant-table-thead > tr > td > span,  
124 - .ant-table-thead > tr > th > span {  
125 - display: block; 114 + white-space: nowrap;
126 } 115 }
127 116
128 .ant-table-row-cell-last { 117 .ant-table-row-cell-last {
src/views/demo/page/form/high/PersonTable.vue
@@ -30,7 +30,6 @@ @@ -30,7 +30,6 @@
30 title: '工号', 30 title: '工号',
31 dataIndex: 'no', 31 dataIndex: 'no',
32 editRow: true, 32 editRow: true,
33 -  
34 // customRender: renderEditableRow({ dataIndex: 'no', placeholder: '请输入工号' }), 33 // customRender: renderEditableRow({ dataIndex: 'no', placeholder: '请输入工号' }),
35 }, 34 },
36 { 35 {