rayyy-vue-table-components 2.0.35 → 2.0.37
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.es.js +3655 -3644
- package/dist/index.umd.js +6 -6
- package/dist/src/components/tables/BaseTable.vue.d.ts +2 -0
- package/dist/src/locales/en-US.json.d.ts +2 -1
- package/dist/src/locales/index.d.ts +2 -0
- package/dist/src/locales/zh-TW.json.d.ts +2 -1
- package/package.json +1 -1
- package/src/components/tables/BaseTable.vue +83 -65
- package/src/locales/en-US.json +2 -1
- package/src/locales/zh-TW.json +2 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { VNode } from 'vue';
|
|
2
2
|
import { TableColumnCtx } from 'element-plus';
|
|
3
3
|
import { SortChangValue, TableColumn } from '../../types';
|
|
4
|
+
import { Language } from 'element-plus/es/locale';
|
|
4
5
|
declare const _default: <T extends Record<string, unknown> = Record<string, unknown>>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_expose?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
|
|
5
6
|
props: __VLS_PrettifyLocal<Pick<Partial<{}> & Omit<{
|
|
6
7
|
readonly "onSelection-change"?: ((selection: T[]) => any) | undefined;
|
|
@@ -26,6 +27,7 @@ declare const _default: <T extends Record<string, unknown> = Record<string, unkn
|
|
|
26
27
|
}) => string) | undefined;
|
|
27
28
|
showCheckBtn?: boolean;
|
|
28
29
|
showEditBtn?: boolean;
|
|
30
|
+
locale?: Language;
|
|
29
31
|
} & Partial<{}>> & import('vue').PublicProps;
|
|
30
32
|
expose(exposed: import('vue').ShallowUnwrapRef<{}>): void;
|
|
31
33
|
attrs: any;
|
|
@@ -37,6 +37,7 @@ export declare const messages: {
|
|
|
37
37
|
"button.delete": string;
|
|
38
38
|
"common.save": string;
|
|
39
39
|
"common.discard": string;
|
|
40
|
+
"table.empty": string;
|
|
40
41
|
};
|
|
41
42
|
'en-US': {
|
|
42
43
|
"common.select": string;
|
|
@@ -74,6 +75,7 @@ export declare const messages: {
|
|
|
74
75
|
"button.delete": string;
|
|
75
76
|
"common.save": string;
|
|
76
77
|
"common.discard": string;
|
|
78
|
+
"table.empty": string;
|
|
77
79
|
};
|
|
78
80
|
};
|
|
79
81
|
export type LocaleType = keyof typeof messages;
|
package/package.json
CHANGED
|
@@ -4,6 +4,8 @@ import { computed } from 'vue'
|
|
|
4
4
|
import { useI18n } from 'vue-i18n'
|
|
5
5
|
import type { TableColumnCtx } from 'element-plus'
|
|
6
6
|
import type { SortChangValue, TableColumn } from '@/types'
|
|
7
|
+
import type { Language } from 'element-plus/es/locale'
|
|
8
|
+
import { useComponentElementLocale } from '@/utils/i18n'
|
|
7
9
|
|
|
8
10
|
const { t } = useI18n()
|
|
9
11
|
|
|
@@ -21,6 +23,7 @@ type Props<T extends Record<string, unknown> = Record<string, unknown>> = {
|
|
|
21
23
|
baseTableRowClassName?: (data: { row: T; rowIndex: number }) => string
|
|
22
24
|
showCheckBtn?: boolean
|
|
23
25
|
showEditBtn?: boolean
|
|
26
|
+
locale?: Language // 新增:Element Plus locale
|
|
24
27
|
}
|
|
25
28
|
|
|
26
29
|
// 組件屬性默認值
|
|
@@ -77,76 +80,91 @@ const operatorWidth = computed(() => {
|
|
|
77
80
|
return 60
|
|
78
81
|
}
|
|
79
82
|
})
|
|
83
|
+
|
|
84
|
+
// 優先使用 prop,沒有 prop 則使用 composable
|
|
85
|
+
const elementLocale = computed(() => {
|
|
86
|
+
if (props.locale) {
|
|
87
|
+
return props.locale
|
|
88
|
+
}
|
|
89
|
+
return useComponentElementLocale().value
|
|
90
|
+
})
|
|
80
91
|
</script>
|
|
81
92
|
|
|
82
93
|
<template>
|
|
83
|
-
<el-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
<!-- 選擇列 -->
|
|
100
|
-
<el-table-column v-if="showSelection" type="selection" width="60" fixed="left" align="center" />
|
|
101
|
-
|
|
102
|
-
<!-- 數據列 -->
|
|
103
|
-
<el-table-column v-for="(column, index) in columns" :key="index" v-bind="column">
|
|
104
|
-
<template #default="{ row }">
|
|
105
|
-
<div class="cell-content" @click="handleCellClick(column, row)">
|
|
106
|
-
<template v-if="column.formatter">
|
|
107
|
-
{{ column.formatter(row) }}
|
|
108
|
-
</template>
|
|
109
|
-
<component
|
|
110
|
-
v-else-if="column.template"
|
|
111
|
-
:is="{
|
|
112
|
-
setup() {
|
|
113
|
-
return () => column.template?.(row)
|
|
114
|
-
},
|
|
115
|
-
}"
|
|
116
|
-
/>
|
|
117
|
-
<span v-else-if="column.prop">{{ row[column.prop] }}</span>
|
|
118
|
-
</div>
|
|
119
|
-
</template>
|
|
120
|
-
</el-table-column>
|
|
121
|
-
<el-table-column
|
|
122
|
-
v-if="props.showCheckBtn || props.showEditBtn"
|
|
123
|
-
:width="operatorWidth"
|
|
124
|
-
align="center"
|
|
125
|
-
fixed="right"
|
|
94
|
+
<el-config-provider :locale="elementLocale">
|
|
95
|
+
<el-table
|
|
96
|
+
v-if="data.length > 0"
|
|
97
|
+
v-loading="loading"
|
|
98
|
+
:element-loading-text="t('common.loading')"
|
|
99
|
+
:data="data"
|
|
100
|
+
border
|
|
101
|
+
:show-summary="showSummary"
|
|
102
|
+
:show-overflow-tooltip="showOverFlowTooltip"
|
|
103
|
+
:summary-method="getSummaries"
|
|
104
|
+
:row-class-name="tableRowClassName"
|
|
105
|
+
class="data-table"
|
|
106
|
+
@selection-change="handleSelectionChange"
|
|
107
|
+
@current-change="(currentRow: any) => emit('current-change', currentRow)"
|
|
108
|
+
:sort="() => {}"
|
|
109
|
+
@sort-change="onSortChange"
|
|
126
110
|
>
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
</p>
|
|
136
|
-
<el-divider direction="vertical" class="!mx-2" v-if="showCheckBtn && showEditBtn" />
|
|
137
|
-
<p
|
|
138
|
-
class="blue-text cursor-pointer font-bold"
|
|
139
|
-
@click="handleOperateClick(row, 'edit')"
|
|
140
|
-
v-if="showEditBtn"
|
|
141
|
-
>
|
|
142
|
-
{{ t('common.edit') }}
|
|
143
|
-
</p>
|
|
144
|
-
</div>
|
|
145
|
-
</template>
|
|
146
|
-
</el-table-column>
|
|
147
|
-
</el-table>
|
|
111
|
+
<!-- 選擇列 -->
|
|
112
|
+
<el-table-column
|
|
113
|
+
v-if="showSelection"
|
|
114
|
+
type="selection"
|
|
115
|
+
width="60"
|
|
116
|
+
fixed="left"
|
|
117
|
+
align="center"
|
|
118
|
+
/>
|
|
148
119
|
|
|
149
|
-
|
|
120
|
+
<!-- 數據列 -->
|
|
121
|
+
<el-table-column v-for="(column, index) in columns" :key="index" v-bind="column">
|
|
122
|
+
<template #default="{ row }">
|
|
123
|
+
<div class="cell-content" @click="handleCellClick(column, row)">
|
|
124
|
+
<template v-if="column.formatter">
|
|
125
|
+
{{ column.formatter(row) }}
|
|
126
|
+
</template>
|
|
127
|
+
<component
|
|
128
|
+
v-else-if="column.template"
|
|
129
|
+
:is="{
|
|
130
|
+
setup() {
|
|
131
|
+
return () => column.template?.(row)
|
|
132
|
+
},
|
|
133
|
+
}"
|
|
134
|
+
/>
|
|
135
|
+
<span v-else-if="column.prop">{{ row[column.prop] }}</span>
|
|
136
|
+
</div>
|
|
137
|
+
</template>
|
|
138
|
+
</el-table-column>
|
|
139
|
+
<el-table-column
|
|
140
|
+
v-if="props.showCheckBtn || props.showEditBtn"
|
|
141
|
+
:width="operatorWidth"
|
|
142
|
+
align="center"
|
|
143
|
+
fixed="right"
|
|
144
|
+
>
|
|
145
|
+
<template #default="{ row }">
|
|
146
|
+
<div class="flex items-center justify-center">
|
|
147
|
+
<p
|
|
148
|
+
class="blue-text cursor-pointer font-bold"
|
|
149
|
+
@click="handleOperateClick(row, 'check')"
|
|
150
|
+
v-if="showCheckBtn"
|
|
151
|
+
>
|
|
152
|
+
{{ t('common.view') }}
|
|
153
|
+
</p>
|
|
154
|
+
<el-divider direction="vertical" class="!mx-2" v-if="showCheckBtn && showEditBtn" />
|
|
155
|
+
<p
|
|
156
|
+
class="blue-text cursor-pointer font-bold"
|
|
157
|
+
@click="handleOperateClick(row, 'edit')"
|
|
158
|
+
v-if="showEditBtn"
|
|
159
|
+
>
|
|
160
|
+
{{ t('common.edit') }}
|
|
161
|
+
</p>
|
|
162
|
+
</div>
|
|
163
|
+
</template>
|
|
164
|
+
</el-table-column>
|
|
165
|
+
</el-table>
|
|
166
|
+
<el-empty :description="t('table.empty')" v-else />
|
|
167
|
+
</el-config-provider>
|
|
150
168
|
</template>
|
|
151
169
|
|
|
152
170
|
<style scoped lang="scss"></style>
|
package/src/locales/en-US.json
CHANGED