wujingjing
2025-02-19 404600d8352b4ecac6daf963b63e01bec543fcb3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import { buildProps } from 'element-plus/es/utils/vue/props/runtime';
import { PropType } from 'vue';
 
export type TableHeaderItem = {
    prop: string;
    label: string;
    colWidth?: number;
    type?: 'image' | 'tag';
};
 
export type RowOperateType = {
    text: string;
    icon: string;
    buttonType: '' | 'default' | 'text' | 'success' | 'warning' | 'info' | 'primary' | 'danger';
    click: (row) => void;
};
 
export const YWTableProps = buildProps({
    /** @description 行 key,树形表格必须要 */
    rowKey: {
        type: String,
        default: 'ID',
    },
    treeProps: {
        type: Object as PropType<{ hasChildren: string; children: string }>,
        default: () => ({
            children: 'Children',
            hasChildren: 'HasChildren',
        }),
    },
 
    /** @description 表格行样式 */
    rowClassName: {
        type: String,
        default: undefined,
    },
    /** @description 表格数据 */
    data: {
        type: Array,
        default: [],
    },
    /** @description 表头 */
    header: {
        type: Array<TableHeaderItem>,
        default: [],
    },
    /** @description 行操作列 */
    rowOperate: {
        type: Array<RowOperateType>,
        default: [],
    },
    /** @description 是否有可选 */
    hasSelection: {
        type: Boolean,
        default: false,
    },
 
    /** @description 是否加索引 */
    hasSerialNo: {
        type: Boolean,
        default: false,
    },
    /** @description 操作列宽度 */
    optColWidth: {
        type: Number,
        default: undefined,
    },
} as const);