rayyy-vue-table-components 1.2.39 → 1.3.1
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/README.md +17 -11
- package/dist/index.es.js +3680 -3722
- package/dist/index.umd.js +8 -12
- package/dist/rayyy-vue-table-components.css +1 -1
- package/dist/src/components/index.d.ts +1 -33
- package/dist/src/components/layout/MainPanel.vue.d.ts +5 -1
- package/dist/src/components/layout/SearchableListPanel.vue.d.ts +2 -0
- package/dist/src/router/constants.d.ts +4 -2
- package/dist/src/types/components.d.ts +3 -1
- package/dist/src/views/InstallGuidePage.vue.d.ts +2 -0
- package/package.json +2 -2
- package/src/components/index.ts +51 -33
- package/src/components/layout/DetailLayout.vue +56 -0
- package/src/components/layout/MainPanel.vue +8 -3
- package/src/components/layout/SearchableListPanel.vue +5 -1
- package/src/components/tables/SortTable.vue +10 -5
- package/src/components/tables/TitleTable.vue +76 -0
- package/src/types/components.d.ts +3 -1
- /package/dist/src/views/{demo/TransferItemDemo.vue.d.ts → DocsCenterPage.vue.d.ts} +0 -0
|
@@ -10,39 +10,7 @@ export { default as TransferItem } from './transfer/transferItem.vue';
|
|
|
10
10
|
export { default as FunctionHeader } from './layout/FunctionHeader.vue';
|
|
11
11
|
export { default as MainPanel } from './layout/MainPanel.vue';
|
|
12
12
|
export { default as SearchableListPanel } from './layout/SearchableListPanel.vue';
|
|
13
|
-
export type { BaseTableProps } from '../types/components.d';
|
|
14
|
-
export type { BaseTableEmits } from '../types/components.d';
|
|
15
|
-
export type { BaseTableInstance } from '../types/components.d';
|
|
16
|
-
export type { BaseBtnProps } from '../types/components.d';
|
|
17
|
-
export type { BaseBtnEmits } from '../types/components.d';
|
|
18
|
-
export type { BaseBtnInstance } from '../types/components.d';
|
|
19
|
-
export type { BaseDialogProps } from '../types/components.d';
|
|
20
|
-
export type { BaseDialogEmits } from '../types/components.d';
|
|
21
|
-
export type { BaseDialogInstance } from '../types/components.d';
|
|
22
|
-
export type { BaseInputProps } from '../types/components.d';
|
|
23
|
-
export type { BaseInputEmits } from '../types/components.d';
|
|
24
|
-
export type { BaseInputInstance } from '../types/components.d';
|
|
25
|
-
export type { SortTableProps } from '../types/components.d';
|
|
26
|
-
export type { SortTableEmits } from '../types/components.d';
|
|
27
|
-
export type { SortTableInstance } from '../types/components.d';
|
|
28
|
-
export type { SearchBarProps } from '../types/components.d';
|
|
29
|
-
export type { SearchBarEmits } from '../types/components.d';
|
|
30
|
-
export type { SearchBarInstance } from '../types/components.d';
|
|
31
|
-
export type { SearchBarSlots } from '../types/components.d';
|
|
32
|
-
export type { TransferDialogProps } from '../types/components.d';
|
|
33
|
-
export type { TransferDialogEmits } from '../types/components.d';
|
|
34
|
-
export type { TransferDialogInstance } from '../types/components.d';
|
|
35
|
-
export type { TransferItemProps } from '../types/components.d';
|
|
36
|
-
export type { TransferItemEmits } from '../types/components.d';
|
|
37
|
-
export type { TransferItemInstance } from '../types/components.d';
|
|
38
|
-
export type { MainPanelProps } from '../types/components.d';
|
|
39
|
-
export type { MainPanelEmits } from '../types/components.d';
|
|
40
|
-
export type { MainPanelInstance } from '../types/components.d';
|
|
41
|
-
export type { FunctionHeaderProps } from '../types/components.d';
|
|
42
|
-
export type { FunctionHeaderEmits } from '../types/components.d';
|
|
43
|
-
export type { FunctionHeaderInstance } from '../types/components.d';
|
|
44
|
-
export type { PluginOptions } from '../types/components.d';
|
|
45
|
-
export type { VueTableComponentsPlugin } from '../types/components.d';
|
|
13
|
+
export type { BaseTableProps, BaseTableEmits, BaseTableInstance, BaseBtnProps, BaseBtnEmits, BaseBtnInstance, BaseDialogProps, BaseDialogEmits, BaseDialogInstance, BaseInputProps, BaseInputEmits, BaseInputInstance, SortTableProps, SortTableEmits, SortTableInstance, SearchBarProps, SearchBarEmits, SearchBarInstance, SearchBarSlots, TransferDialogProps, TransferDialogEmits, TransferDialogInstance, TransferItemProps, TransferItemEmits, TransferItemInstance, MainPanelProps, MainPanelEmits, MainPanelInstance, SearchableListPanelProps, SearchableListPanelEmits, SearchableListPanelInstance, SearchableListPanelSlots, FunctionHeaderProps, FunctionHeaderEmits, FunctionHeaderInstance, PluginOptions, VueTableComponentsPlugin } from '../types/components.d';
|
|
46
14
|
export type { default as BaseTableType } from './tables/BaseTable.vue';
|
|
47
15
|
export type { default as BaseBtnType } from './items/BaseBtn.vue';
|
|
48
16
|
export type { default as BaseInputType } from './form/BaseInput.vue';
|
|
@@ -14,7 +14,11 @@ declare function __VLS_template(): {
|
|
|
14
14
|
rootEl: any;
|
|
15
15
|
};
|
|
16
16
|
type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
|
|
17
|
-
declare const __VLS_component: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}
|
|
17
|
+
declare const __VLS_component: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {} & {
|
|
18
|
+
"click:back": () => any;
|
|
19
|
+
}, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
20
|
+
"onClick:back"?: (() => any) | undefined;
|
|
21
|
+
}>, {
|
|
18
22
|
title: string;
|
|
19
23
|
showBack: boolean | string | object;
|
|
20
24
|
depth: number;
|
|
@@ -23,10 +23,12 @@ declare function __VLS_template(): {
|
|
|
23
23
|
type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
|
|
24
24
|
declare const __VLS_component: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {} & {
|
|
25
25
|
search: (data: string | null) => any;
|
|
26
|
+
"click:back": () => any;
|
|
26
27
|
updatePage: (page: number) => any;
|
|
27
28
|
updatePageSize: (limit: number) => any;
|
|
28
29
|
}, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
29
30
|
onSearch?: ((data: string | null) => any) | undefined;
|
|
31
|
+
"onClick:back"?: (() => any) | undefined;
|
|
30
32
|
onUpdatePage?: ((page: number) => any) | undefined;
|
|
31
33
|
onUpdatePageSize?: ((limit: number) => any) | undefined;
|
|
32
34
|
}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
|
@@ -2,6 +2,8 @@ export declare const ROUTES: {
|
|
|
2
2
|
readonly ROOT: "/";
|
|
3
3
|
readonly HOME: "/home";
|
|
4
4
|
readonly DEMO: "/demo";
|
|
5
|
+
readonly INSTALL_GUIDE: "/install-guide";
|
|
6
|
+
readonly DOCS_CENTER: "/docs-center";
|
|
5
7
|
readonly SEARCHABLE_LIST_PANEL: "/demo/searchable-list-panel";
|
|
6
8
|
readonly BASE_MULTIPLE_INPUT: "/demo/base-multiple-input";
|
|
7
9
|
readonly TRANSFER_DIALOG: "/demo/transfer-dialog";
|
|
@@ -12,7 +14,6 @@ export declare const ROUTES: {
|
|
|
12
14
|
readonly BASE_FORM: "/demo/base-form";
|
|
13
15
|
readonly SORT_TABLE: "/demo/sort-table";
|
|
14
16
|
readonly SEARCH_BAR: "/demo/search-bar";
|
|
15
|
-
readonly TRANSFER_ITEM: "/demo/transfer-item";
|
|
16
17
|
readonly FUNCTION_HEADER: "/demo/function-header";
|
|
17
18
|
readonly MAIN_PANEL: "/demo/main-panel";
|
|
18
19
|
readonly NOT_FOUND: "/:catchAll(.*)";
|
|
@@ -21,6 +22,8 @@ export declare const ROUTE_NAMES: {
|
|
|
21
22
|
readonly HOME_LAYOUT: "HomeLayout";
|
|
22
23
|
readonly HOME: "Home";
|
|
23
24
|
readonly DEMO: "Demo";
|
|
25
|
+
readonly INSTALL_GUIDE: "InstallGuide";
|
|
26
|
+
readonly DOCS_CENTER: "DocsCenter";
|
|
24
27
|
readonly SEARCHABLE_LIST_PANEL: "SearchableListPanel";
|
|
25
28
|
readonly BASE_MULTIPLE_INPUT: "BaseMultipleInput";
|
|
26
29
|
readonly TRANSFER_DIALOG: "TransferDialog";
|
|
@@ -30,7 +33,6 @@ export declare const ROUTE_NAMES: {
|
|
|
30
33
|
readonly BASE_DIALOG: "BaseDialog";
|
|
31
34
|
readonly SORT_TABLE: "SortTable";
|
|
32
35
|
readonly SEARCH_BAR: "SearchBar";
|
|
33
|
-
readonly TRANSFER_ITEM: "TransferItem";
|
|
34
36
|
readonly FUNCTION_HEADER: "FunctionHeader";
|
|
35
37
|
readonly MAIN_PANEL: "MainPanel";
|
|
36
38
|
readonly NOT_FOUND: "NotFoundPage";
|
|
@@ -346,6 +346,8 @@ export interface SearchableListPanelEmits {
|
|
|
346
346
|
(e: 'updatePage', page: number): boolean
|
|
347
347
|
/** 更新頁面大小事件 */
|
|
348
348
|
(e: 'updatePageSize', limit: number): boolean
|
|
349
|
+
/** 返回按鈕點擊事件 */
|
|
350
|
+
(e: 'click:back'): void
|
|
349
351
|
}
|
|
350
352
|
|
|
351
353
|
/** SearchableListPanel 組件實例類型 */
|
|
@@ -413,7 +415,7 @@ export interface MainPanelProps {
|
|
|
413
415
|
/** MainPanel 組件 Emits 類型 */
|
|
414
416
|
export interface MainPanelEmits {
|
|
415
417
|
/** 返回按鈕點擊事件 */
|
|
416
|
-
(e: 'back'
|
|
418
|
+
(e: 'click:back'): void
|
|
417
419
|
}
|
|
418
420
|
|
|
419
421
|
/** MainPanel 組件實例類型 */
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
declare const _default: import('vue').DefineComponent<{}, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, HTMLDivElement>;
|
|
2
|
+
export default _default;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rayyy-vue-table-components",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.1",
|
|
4
4
|
"description": "Vue 3 + Element Plus 表格組件庫",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.umd.js",
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
},
|
|
65
65
|
"repository": {
|
|
66
66
|
"type": "git",
|
|
67
|
-
"url": "
|
|
67
|
+
"url": ""
|
|
68
68
|
},
|
|
69
69
|
"scripts": {
|
|
70
70
|
"dev": "vite",
|
package/src/components/index.ts
CHANGED
|
@@ -13,39 +13,57 @@ export { default as MainPanel } from './layout/MainPanel.vue'
|
|
|
13
13
|
export { default as SearchableListPanel } from './layout/SearchableListPanel.vue'
|
|
14
14
|
|
|
15
15
|
// 導出組件類型
|
|
16
|
-
export type {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
16
|
+
export type {
|
|
17
|
+
// BaseTable 組件類型
|
|
18
|
+
BaseTableProps,
|
|
19
|
+
BaseTableEmits,
|
|
20
|
+
BaseTableInstance,
|
|
21
|
+
// BaseBtn 組件類型
|
|
22
|
+
BaseBtnProps,
|
|
23
|
+
BaseBtnEmits,
|
|
24
|
+
BaseBtnInstance,
|
|
25
|
+
// BaseDialog 組件類型
|
|
26
|
+
BaseDialogProps,
|
|
27
|
+
BaseDialogEmits,
|
|
28
|
+
BaseDialogInstance,
|
|
29
|
+
// BaseInput 組件類型
|
|
30
|
+
BaseInputProps,
|
|
31
|
+
BaseInputEmits,
|
|
32
|
+
BaseInputInstance,
|
|
33
|
+
// SortTable 組件類型
|
|
34
|
+
SortTableProps,
|
|
35
|
+
SortTableEmits,
|
|
36
|
+
SortTableInstance,
|
|
37
|
+
// SearchBar 組件類型
|
|
38
|
+
SearchBarProps,
|
|
39
|
+
SearchBarEmits,
|
|
40
|
+
SearchBarInstance,
|
|
41
|
+
SearchBarSlots,
|
|
42
|
+
// TransferDialog 組件類型
|
|
43
|
+
TransferDialogProps,
|
|
44
|
+
TransferDialogEmits,
|
|
45
|
+
TransferDialogInstance,
|
|
46
|
+
// TransferItem 組件類型
|
|
47
|
+
TransferItemProps,
|
|
48
|
+
TransferItemEmits,
|
|
49
|
+
TransferItemInstance,
|
|
50
|
+
// MainPanel 組件類型
|
|
51
|
+
MainPanelProps,
|
|
52
|
+
MainPanelEmits,
|
|
53
|
+
MainPanelInstance,
|
|
54
|
+
// SearchableListPanel 組件類型
|
|
55
|
+
SearchableListPanelProps,
|
|
56
|
+
SearchableListPanelEmits,
|
|
57
|
+
SearchableListPanelInstance,
|
|
58
|
+
SearchableListPanelSlots,
|
|
59
|
+
// FunctionHeader 組件類型
|
|
60
|
+
FunctionHeaderProps,
|
|
61
|
+
FunctionHeaderEmits,
|
|
62
|
+
FunctionHeaderInstance,
|
|
63
|
+
// 插件類型
|
|
64
|
+
PluginOptions,
|
|
65
|
+
VueTableComponentsPlugin
|
|
66
|
+
} from '../types/components.d'
|
|
49
67
|
|
|
50
68
|
// 重新導出組件定義類型
|
|
51
69
|
export type { default as BaseTableType } from './tables/BaseTable.vue'
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { MainPanel, BaseBtn } from '@/components'
|
|
3
|
+
|
|
4
|
+
defineProps<{
|
|
5
|
+
title: string
|
|
6
|
+
showBack?: boolean | string | object
|
|
7
|
+
isEditable: boolean
|
|
8
|
+
pageLoading?: boolean
|
|
9
|
+
}>()
|
|
10
|
+
|
|
11
|
+
const emit = defineEmits<{
|
|
12
|
+
(e: 'update:saveEdit', value: boolean): void
|
|
13
|
+
(e: 'update:cancelEdit'): void
|
|
14
|
+
}>()
|
|
15
|
+
|
|
16
|
+
const saveDetailEdit = () => {
|
|
17
|
+
emit('update:saveEdit', false)
|
|
18
|
+
}
|
|
19
|
+
const cancelDetailEdit = () => {
|
|
20
|
+
emit('update:cancelEdit')
|
|
21
|
+
}
|
|
22
|
+
</script>
|
|
23
|
+
|
|
24
|
+
<template>
|
|
25
|
+
<MainPanel :title="title" :show-back="showBack">
|
|
26
|
+
<template #main>
|
|
27
|
+
<div class="detail-container" v-loading="pageLoading">
|
|
28
|
+
<slot name="detailHeader"></slot>
|
|
29
|
+
|
|
30
|
+
<div class="content-wrapper">
|
|
31
|
+
<slot name="main"></slot>
|
|
32
|
+
</div>
|
|
33
|
+
</div>
|
|
34
|
+
</template>
|
|
35
|
+
|
|
36
|
+
<template #footer>
|
|
37
|
+
<div class="border-t pt-4 w-full flex items-center justify-end" v-if="isEditable">
|
|
38
|
+
<BaseBtn text="儲存" type="primary" is-fill @click="saveDetailEdit" />
|
|
39
|
+
<BaseBtn text="捨棄" type="primary" @click="cancelDetailEdit" />
|
|
40
|
+
</div>
|
|
41
|
+
</template>
|
|
42
|
+
</MainPanel>
|
|
43
|
+
</template>
|
|
44
|
+
|
|
45
|
+
<style lang="scss" scoped>
|
|
46
|
+
.detail-container {
|
|
47
|
+
@apply h-full flex flex-col;
|
|
48
|
+
max-height: calc(100vh - 100px);
|
|
49
|
+
min-height: calc(100vh - 140px);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.content-wrapper {
|
|
53
|
+
@apply flex-1 overflow-y-auto;
|
|
54
|
+
max-height: calc(100vh - 100px);
|
|
55
|
+
}
|
|
56
|
+
</style>
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
2
|
import { FunctionHeader } from '@/components'
|
|
3
3
|
import { useRouter } from 'vue-router'
|
|
4
|
-
import { ROUTES } from '@/router/constants.ts'
|
|
5
4
|
|
|
6
5
|
const props = withDefaults(
|
|
7
6
|
defineProps<{
|
|
@@ -15,14 +14,20 @@ const props = withDefaults(
|
|
|
15
14
|
depth: 1,
|
|
16
15
|
},
|
|
17
16
|
)
|
|
18
|
-
|
|
17
|
+
|
|
18
|
+
const emit = defineEmits<{
|
|
19
|
+
(e: 'click:back'): void
|
|
20
|
+
}>()
|
|
21
|
+
const onBackClick = () => {
|
|
22
|
+
emit('click:back')
|
|
23
|
+
}
|
|
19
24
|
</script>
|
|
20
25
|
|
|
21
26
|
<template>
|
|
22
27
|
<function-header
|
|
23
28
|
:title="props.title"
|
|
24
29
|
:showBack="props.showBack"
|
|
25
|
-
@back="
|
|
30
|
+
@back="onBackClick"
|
|
26
31
|
:depth="props.depth"
|
|
27
32
|
/>
|
|
28
33
|
|
|
@@ -19,6 +19,7 @@ const emits = defineEmits<{
|
|
|
19
19
|
(e: 'search', data: string | null): void
|
|
20
20
|
(e: 'updatePage', page: number): boolean
|
|
21
21
|
(e: 'updatePageSize', limit: number): boolean
|
|
22
|
+
(e: 'click:back'): void
|
|
22
23
|
}>()
|
|
23
24
|
|
|
24
25
|
const showAllFeatures = computed(() => {
|
|
@@ -39,10 +40,13 @@ const updatePage = (page: number) => {
|
|
|
39
40
|
const changePageSize = (limit: number) => {
|
|
40
41
|
emits('updatePageSize', limit)
|
|
41
42
|
}
|
|
43
|
+
const onBackClick = () => {
|
|
44
|
+
emits('click:back')
|
|
45
|
+
}
|
|
42
46
|
</script>
|
|
43
47
|
|
|
44
48
|
<template>
|
|
45
|
-
<main-panel :title="props.title" :show-back="showBack">
|
|
49
|
+
<main-panel :title="props.title" :show-back="showBack" @click:back="onBackClick">
|
|
46
50
|
<template #searchBar>
|
|
47
51
|
<search-bar
|
|
48
52
|
:show-filter="showAllFeatures || showFilter"
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
import type { SortChangValue, TableColumn } from '@/types'
|
|
3
3
|
import type { TableColumnCtx } from 'element-plus'
|
|
4
4
|
import type { VNode } from 'vue'
|
|
5
|
-
import BaseTable from './BaseTable.vue'
|
|
6
5
|
import { Setting } from '@element-plus/icons-vue'
|
|
6
|
+
import { BaseTable } from '@/components'
|
|
7
7
|
|
|
8
8
|
defineProps<{
|
|
9
9
|
data: T[]
|
|
@@ -13,7 +13,10 @@ defineProps<{
|
|
|
13
13
|
loading?: boolean
|
|
14
14
|
showSummary?: boolean
|
|
15
15
|
showOverFlowTooltip?: boolean
|
|
16
|
-
summaryMethod?: (param: {
|
|
16
|
+
summaryMethod?: (param: {
|
|
17
|
+
columns: TableColumnCtx<Record<string, unknown>>[]
|
|
18
|
+
data: T[]
|
|
19
|
+
}) => (string | VNode)[]
|
|
17
20
|
sortTableRowClassName?: (data: { row: T; rowIndex: number }) => string
|
|
18
21
|
}>()
|
|
19
22
|
|
|
@@ -44,7 +47,10 @@ const handleColumnSortChange = (data: SortChangValue<T>) => {
|
|
|
44
47
|
<div class="w-full mb-4">
|
|
45
48
|
<div class="flex items-center h-12 bg-gray-200 px-1.5 rounded-t justify-end">
|
|
46
49
|
<div class="flex items-center mr-4">
|
|
47
|
-
<div
|
|
50
|
+
<div
|
|
51
|
+
class="cursor-pointer text-blue-800 text-xl flex items-center justify-center hover:text-blue-600"
|
|
52
|
+
@click="openTransferDialog"
|
|
53
|
+
>
|
|
48
54
|
<el-icon><Setting /></el-icon>
|
|
49
55
|
</div>
|
|
50
56
|
</div>
|
|
@@ -67,5 +73,4 @@ const handleColumnSortChange = (data: SortChangValue<T>) => {
|
|
|
67
73
|
</div>
|
|
68
74
|
</template>
|
|
69
75
|
|
|
70
|
-
<style scoped lang="scss">
|
|
71
|
-
</style>
|
|
76
|
+
<style scoped lang="scss"></style>
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
<script setup lang="ts" generic="T extends Record<string, unknown>">
|
|
2
|
+
import type { VNode } from 'vue'
|
|
3
|
+
import type { TableColumnCtx } from 'element-plus'
|
|
4
|
+
import type { TableColumn } from 'src/types'
|
|
5
|
+
import { BaseTable, BaseBtn } from '@/components'
|
|
6
|
+
|
|
7
|
+
// 使用泛型 T 來定義數據類型
|
|
8
|
+
defineProps<{
|
|
9
|
+
data: T[]
|
|
10
|
+
columns: TableColumn<T>[]
|
|
11
|
+
tableTitle?: string
|
|
12
|
+
showSelection?: boolean
|
|
13
|
+
loading?: boolean
|
|
14
|
+
showSummary?: boolean
|
|
15
|
+
showOverFlowTooltip?: boolean
|
|
16
|
+
summaryMethod?: (param: {
|
|
17
|
+
columns: TableColumnCtx<Record<string, unknown>>[]
|
|
18
|
+
data: T[]
|
|
19
|
+
}) => (string | VNode)[]
|
|
20
|
+
}>()
|
|
21
|
+
|
|
22
|
+
const emit = defineEmits<{
|
|
23
|
+
(e: 'click:add'): void
|
|
24
|
+
(e: 'click:edit'): void
|
|
25
|
+
(e: 'click:delete'): void
|
|
26
|
+
(e: 'update:selectRow', value: T[]): void
|
|
27
|
+
(e: 'click:cell', column: TableColumn<T>, row: T): void
|
|
28
|
+
}>()
|
|
29
|
+
|
|
30
|
+
const addInvoiceDetail = () => {
|
|
31
|
+
emit('click:add')
|
|
32
|
+
}
|
|
33
|
+
const deleteSelectRow = () => {
|
|
34
|
+
emit('click:delete')
|
|
35
|
+
}
|
|
36
|
+
const handleSelectionChange = (selectList: T[]) => {
|
|
37
|
+
emit('update:selectRow', selectList)
|
|
38
|
+
}
|
|
39
|
+
const handleCellClick = (column: TableColumn<T>, row: T) => {
|
|
40
|
+
emit('click:cell', column, row)
|
|
41
|
+
}
|
|
42
|
+
</script>
|
|
43
|
+
|
|
44
|
+
<template>
|
|
45
|
+
<div class="w-full mb-4">
|
|
46
|
+
<!-- 表格標題區域:包含標題文本和操作按鈕 -->
|
|
47
|
+
<div class="flex items-center h-12 bg-gray-200 px-1.5 rounded-t justify-between" v-if="tableTitle">
|
|
48
|
+
<p class="font-bold text-20">{{ tableTitle }}</p>
|
|
49
|
+
|
|
50
|
+
<div class="flex items-center">
|
|
51
|
+
<slot name="tableSearch" />
|
|
52
|
+
|
|
53
|
+
<div class="flex items-center">
|
|
54
|
+
<BaseBtn text="新增" type="primary" @click="addInvoiceDetail" />
|
|
55
|
+
<BaseBtn text="刪除" type="primary" @click="deleteSelectRow" />
|
|
56
|
+
</div>
|
|
57
|
+
</div>
|
|
58
|
+
</div>
|
|
59
|
+
|
|
60
|
+
<!-- 表格主體 -->
|
|
61
|
+
<base-table
|
|
62
|
+
v-loading="loading"
|
|
63
|
+
element-loading-text="數據加載中..."
|
|
64
|
+
:data="data"
|
|
65
|
+
:columns="columns"
|
|
66
|
+
:show-summary="showSummary"
|
|
67
|
+
:summary-method="summaryMethod"
|
|
68
|
+
:show-selection="showSelection"
|
|
69
|
+
:show-over-flow-tooltip="showOverFlowTooltip"
|
|
70
|
+
@selection-change="handleSelectionChange"
|
|
71
|
+
@cell-click="handleCellClick"
|
|
72
|
+
/>
|
|
73
|
+
</div>
|
|
74
|
+
</template>
|
|
75
|
+
|
|
76
|
+
<style scoped lang="scss"></style>
|
|
@@ -347,6 +347,8 @@ export interface SearchableListPanelEmits {
|
|
|
347
347
|
(e: 'updatePage', page: number): boolean
|
|
348
348
|
/** 更新頁面大小事件 */
|
|
349
349
|
(e: 'updatePageSize', limit: number): boolean
|
|
350
|
+
/** 返回按鈕點擊事件 */
|
|
351
|
+
(e: 'click:back'): void
|
|
350
352
|
}
|
|
351
353
|
|
|
352
354
|
/** SearchableListPanel 組件實例類型 */
|
|
@@ -414,7 +416,7 @@ export interface MainPanelProps {
|
|
|
414
416
|
/** MainPanel 組件 Emits 類型 */
|
|
415
417
|
export interface MainPanelEmits {
|
|
416
418
|
/** 返回按鈕點擊事件 */
|
|
417
|
-
(e: 'back'
|
|
419
|
+
(e: 'click:back'): void
|
|
418
420
|
}
|
|
419
421
|
|
|
420
422
|
/** MainPanel 組件實例類型 */
|
|
File without changes
|