@gct-paas/v-ben 0.1.6-dev.3 → 0.1.6-dev.30
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.min.css +1 -1
- package/dist/loader.esm.min.js +2 -1
- package/es/_virtual/_rolldown/runtime.mjs +13 -0
- package/es/components/index.mjs +1 -0
- package/es/components/v-ben-button/src/PopConfirmButton.vue_vue_type_script_lang.mjs +1 -1
- package/es/components/v-ben-table/index.d.ts +2 -0
- package/es/components/v-ben-table/index.mjs +1 -0
- package/es/components/v-ben-table/src/BasicTable.vue.d.ts +49 -25
- package/es/components/v-ben-table/src/BasicTable.vue.mjs +34 -16
- package/es/components/v-ben-table/src/BasicTable.vue_vue_type_script_lang.mjs +110 -17
- package/es/components/v-ben-table/src/BasicTable.vue_vue_type_style_index_0_lang.css +81 -0
- package/es/components/v-ben-table/src/components/TableAction.vue_vue_type_script_setup_true_lang.mjs +4 -10
- package/es/components/v-ben-table/src/components/TableAction.vue_vue_type_style_index_0_lang.css +13 -12
- package/es/components/v-ben-table/src/components/TableActionAuto.vue_vue_type_script_setup_true_lang.mjs +3 -3
- package/es/components/v-ben-table/src/components/TableActionAuto.vue_vue_type_style_index_0_lang.css +13 -12
- package/es/components/v-ben-table/src/const.d.ts +12 -0
- package/es/components/v-ben-table/src/const.mjs +14 -0
- package/es/components/v-ben-table/src/hooks/useColumns.d.ts +8 -0
- package/es/components/v-ben-table/src/hooks/useColumns.mjs +180 -0
- package/es/components/v-ben-table/src/hooks/usePagination.d.ts +10 -0
- package/es/components/v-ben-table/src/hooks/usePagination.mjs +63 -0
- package/es/components/v-ben-table/src/hooks/useTable.d.ts +6 -0
- package/es/components/v-ben-table/src/hooks/useTable.mjs +21 -0
- package/es/components/v-ben-table/src/hooks/useTableExpand.d.ts +9 -0
- package/es/components/v-ben-table/src/hooks/useTableExpand.mjs +62 -0
- package/es/components/v-ben-table/src/hooks/useTableRowDrag.d.ts +7 -0
- package/es/components/v-ben-table/src/hooks/useTableRowDrag.mjs +148 -0
- package/es/components/v-ben-table/src/hooks/useTableScroll.d.ts +17 -0
- package/es/components/v-ben-table/src/hooks/useTableScroll.mjs +126 -0
- package/es/components/v-ben-table/src/props.d.ts +8 -1
- package/es/components/v-ben-table/src/props.mjs +46 -1
- package/es/components/v-ben-table/src/types/pagination.d.ts +1 -1
- package/es/components/v-ben-table/src/types/table.d.ts +16 -0
- package/es/components/v-ben-table/src/utils/dom-utils.d.ts +13 -0
- package/es/components/v-ben-table/src/utils/dom-utils.mjs +36 -0
- package/es/hooks/useDesign.mjs +10 -0
- package/es/hooks/useRefs.d.ts +5 -0
- package/es/hooks/useRefs.mjs +17 -0
- package/es/index.d.ts +2 -0
- package/es/index.mjs +4 -1
- package/es/locale/auto-register.d.ts +2 -0
- package/es/locale/auto-register.mjs +13 -0
- package/es/locale/sys/component.d.ts +6 -0
- package/es/locale/sys/component.mjs +6 -0
- package/es/locale/sys.mjs +9 -0
- package/es/setup-app.d.ts +2 -0
- package/es/setup-app.mjs +7 -0
- package/es/types/sortablejs.d.ts +24 -0
- package/package.json +7 -7
|
@@ -1,40 +1,133 @@
|
|
|
1
1
|
import HeaderCell_default from "./components/HeaderCell.vue.mjs";
|
|
2
|
-
import { basicProps } from "./props.mjs";
|
|
3
|
-
import {
|
|
2
|
+
import { basicProps, basicTableInternalPropKeys } from "./props.mjs";
|
|
3
|
+
import { useColumns } from "./hooks/useColumns.mjs";
|
|
4
|
+
import { usePagination } from "./hooks/usePagination.mjs";
|
|
5
|
+
import { useTableScroll } from "./hooks/useTableScroll.mjs";
|
|
6
|
+
import { useTableExpand } from "./hooks/useTableExpand.mjs";
|
|
7
|
+
import { useTableRowDrag } from "./hooks/useTableRowDrag.mjs";
|
|
8
|
+
import { useDesign } from "../../../hooks/useDesign.mjs";
|
|
9
|
+
import { HolderOutlined } from "@ant-design/icons-vue";
|
|
10
|
+
import { computed, defineComponent, nextTick, onMounted, onUnmounted, ref, toRaw, unref } from "vue";
|
|
4
11
|
import { omit } from "lodash-es";
|
|
5
12
|
//#region src/components/v-ben-table/src/BasicTable.vue?vue&type=script&lang.ts
|
|
13
|
+
var RESERVED_SLOT_NAMES = ["headerCell", "bodyCell"];
|
|
6
14
|
var BasicTable_vue_vue_type_script_lang_default = defineComponent({
|
|
7
15
|
name: "BasicTable",
|
|
8
|
-
components: {
|
|
16
|
+
components: {
|
|
17
|
+
HeaderCell: HeaderCell_default,
|
|
18
|
+
HolderOutlined
|
|
19
|
+
},
|
|
9
20
|
props: basicProps,
|
|
10
|
-
emits: [
|
|
11
|
-
|
|
21
|
+
emits: [
|
|
22
|
+
"change",
|
|
23
|
+
"register",
|
|
24
|
+
"expanded-rows-change",
|
|
25
|
+
"resizeColumn",
|
|
26
|
+
"row-drag-end"
|
|
27
|
+
],
|
|
28
|
+
setup(props, { attrs, emit, slots, expose }) {
|
|
12
29
|
const tableElRef = ref(null);
|
|
13
|
-
const
|
|
30
|
+
const wrapRef = ref(null);
|
|
14
31
|
const formRef = ref(null);
|
|
32
|
+
const { prefixCls } = useDesign("basic-table");
|
|
33
|
+
const getProps = computed(() => {
|
|
34
|
+
return {
|
|
35
|
+
...props,
|
|
36
|
+
...attrs
|
|
37
|
+
};
|
|
38
|
+
});
|
|
39
|
+
const { getPaginationInfo, setPagination, getPagination, getShowPagination, setShowPagination } = usePagination(getProps);
|
|
40
|
+
const getPaginationRef = computed(() => unref(getPaginationInfo));
|
|
41
|
+
const getRowSelectionRef = computed(() => {
|
|
42
|
+
return unref(getProps).rowSelection ?? null;
|
|
43
|
+
});
|
|
44
|
+
const getDataSourceRef = computed(() => {
|
|
45
|
+
return unref(getProps).dataSource ?? [];
|
|
46
|
+
});
|
|
47
|
+
const { getViewColumns, getColumnsRef, handleResizeColumn } = useColumns(getProps, getPaginationRef);
|
|
48
|
+
const { getScrollRef, redoHeight } = useTableScroll(getProps, tableElRef, getColumnsRef, getRowSelectionRef, getPaginationRef, getDataSourceRef, wrapRef, formRef);
|
|
49
|
+
const slotNames = computed(() => Object.keys(slots).filter((name) => !RESERVED_SLOT_NAMES.includes(name)));
|
|
50
|
+
const { getExpandOption, expandedRowKeys, expandAll } = useTableExpand(getProps, getDataSourceRef, computed(() => !!slots.expandedRowRender || !!slots.expandIcon), emit);
|
|
15
51
|
const getBindValues = computed(() => {
|
|
16
|
-
let propsData = {
|
|
17
|
-
|
|
52
|
+
let propsData = {
|
|
53
|
+
...attrs,
|
|
54
|
+
...unref(getProps),
|
|
55
|
+
scroll: unref(getScrollRef),
|
|
56
|
+
tableLayout: "fixed",
|
|
57
|
+
columns: toRaw(unref(getViewColumns)),
|
|
58
|
+
pagination: toRaw(unref(getPaginationInfo)),
|
|
59
|
+
rowSelection: unref(getRowSelectionRef),
|
|
60
|
+
dataSource: unref(getDataSourceRef),
|
|
61
|
+
...unref(getExpandOption)
|
|
62
|
+
};
|
|
63
|
+
propsData = omit(propsData, [
|
|
64
|
+
...basicTableInternalPropKeys,
|
|
65
|
+
"class",
|
|
66
|
+
"onChange"
|
|
67
|
+
]);
|
|
18
68
|
return propsData;
|
|
19
69
|
});
|
|
70
|
+
const { showDragIcon, initRowDrag, destroyRowDrag } = useTableRowDrag(wrapRef, getProps, getBindValues, getViewColumns, expandedRowKeys, slots, emit);
|
|
71
|
+
const getWrapperClass = computed(() => {
|
|
72
|
+
const values = unref(getBindValues);
|
|
73
|
+
return [
|
|
74
|
+
prefixCls,
|
|
75
|
+
attrs.class,
|
|
76
|
+
{
|
|
77
|
+
[`${prefixCls}-form-container`]: values.useSearchForm,
|
|
78
|
+
[`${prefixCls}--inset`]: values.inset
|
|
79
|
+
}
|
|
80
|
+
];
|
|
81
|
+
});
|
|
82
|
+
function onResizeColumn(width, column) {
|
|
83
|
+
handleResizeColumn(width, column);
|
|
84
|
+
emit("resizeColumn", width, column);
|
|
85
|
+
}
|
|
20
86
|
function handleTableChange(...args) {
|
|
21
87
|
emit("change", ...args);
|
|
88
|
+
const { onChange } = unref(getProps);
|
|
89
|
+
if (onChange && typeof onChange === "function") onChange(...args);
|
|
22
90
|
}
|
|
91
|
+
const getEmptyDataIsShowTable = computed(() => {
|
|
92
|
+
const { emptyDataIsShowTable, useSearchForm, dataSource } = props;
|
|
93
|
+
if (emptyDataIsShowTable || !useSearchForm) return true;
|
|
94
|
+
return !!dataSource?.length;
|
|
95
|
+
});
|
|
96
|
+
expose({
|
|
97
|
+
expandAll,
|
|
98
|
+
redoHeight,
|
|
99
|
+
setPagination,
|
|
100
|
+
getPagination,
|
|
101
|
+
getShowPagination,
|
|
102
|
+
setShowPagination
|
|
103
|
+
});
|
|
104
|
+
emit("register", { expandAll });
|
|
105
|
+
onMounted(() => {
|
|
106
|
+
redoHeight();
|
|
107
|
+
nextTick(() => {
|
|
108
|
+
initRowDrag();
|
|
109
|
+
});
|
|
110
|
+
});
|
|
111
|
+
onUnmounted(() => {
|
|
112
|
+
destroyRowDrag();
|
|
113
|
+
});
|
|
23
114
|
return {
|
|
24
115
|
formRef,
|
|
25
116
|
tableElRef,
|
|
117
|
+
wrapRef,
|
|
26
118
|
getBindValues,
|
|
119
|
+
getWrapperClass,
|
|
27
120
|
handleTableChange,
|
|
28
|
-
|
|
29
|
-
getEmptyDataIsShowTable
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
121
|
+
handleResizeColumn: onResizeColumn,
|
|
122
|
+
getEmptyDataIsShowTable,
|
|
123
|
+
slotNames,
|
|
124
|
+
emptyFull: props.emptyFull,
|
|
125
|
+
redoHeight,
|
|
126
|
+
expandedRowKeys,
|
|
127
|
+
isTreeTable: props.isTreeTable,
|
|
128
|
+
rowDraggable: props.rowDraggable,
|
|
129
|
+
showDragIcon
|
|
34
130
|
};
|
|
35
|
-
},
|
|
36
|
-
mounted() {
|
|
37
|
-
this.expandKeysList = this.getBindValues.expandedRowKeys;
|
|
38
131
|
}
|
|
39
132
|
});
|
|
40
133
|
//#endregion
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
.vben-basic-table {
|
|
2
|
+
max-width: 100%;
|
|
3
|
+
height: 100%;
|
|
4
|
+
}
|
|
5
|
+
.vben-basic-table .ant-table-thead > tr > th {
|
|
6
|
+
padding: 10px;
|
|
7
|
+
}
|
|
8
|
+
.vben-basic-table .ant-table-tbody > tr > td,
|
|
9
|
+
.vben-basic-table .ant-table-thead > tr > td,
|
|
10
|
+
.vben-basic-table .ant-table-tbody > tr > th,
|
|
11
|
+
.vben-basic-table .ant-table-thead > tr > th {
|
|
12
|
+
border-right: 1px solid transparent !important;
|
|
13
|
+
}
|
|
14
|
+
.vben-basic-table .ant-table-tbody > tr > td,
|
|
15
|
+
.vben-basic-table .ant-table-thead > tr > td {
|
|
16
|
+
padding: 10px;
|
|
17
|
+
}
|
|
18
|
+
.vben-basic-table-form-container {
|
|
19
|
+
padding: 16px;
|
|
20
|
+
}
|
|
21
|
+
.vben-basic-table-form-container .ant-form {
|
|
22
|
+
width: 100%;
|
|
23
|
+
margin-bottom: 16px;
|
|
24
|
+
padding: 12px 10px 6px;
|
|
25
|
+
border-radius: 2px;
|
|
26
|
+
}
|
|
27
|
+
.vben-basic-table .ant-table-cell .ant-tag {
|
|
28
|
+
margin-right: 0;
|
|
29
|
+
}
|
|
30
|
+
.vben-basic-table .ant-table-wrapper {
|
|
31
|
+
padding: 6px;
|
|
32
|
+
border-radius: 2px;
|
|
33
|
+
}
|
|
34
|
+
.vben-basic-table .ant-table-wrapper .ant-table-title {
|
|
35
|
+
padding: 0 0 8px !important;
|
|
36
|
+
}
|
|
37
|
+
.vben-basic-table .ant-table-wrapper .ant-table.ant-table-bordered .ant-table-title {
|
|
38
|
+
border: none !important;
|
|
39
|
+
}
|
|
40
|
+
.vben-basic-table .empty-basic-table-wrapper.ant-table-wrapper:has(
|
|
41
|
+
div.ant-spin-nested-loading > div.ant-spin-container > div.ant-table-empty
|
|
42
|
+
) .ant-spin-nested-loading > div.ant-spin-container > div.ant-table-empty > div.ant-table-container > div.ant-table-body {
|
|
43
|
+
max-height: none !important;
|
|
44
|
+
}
|
|
45
|
+
.vben-basic-table .ant-table {
|
|
46
|
+
width: 100%;
|
|
47
|
+
overflow-x: hidden;
|
|
48
|
+
}
|
|
49
|
+
.vben-basic-table .ant-pagination {
|
|
50
|
+
margin: 10px 0 0 !important;
|
|
51
|
+
}
|
|
52
|
+
.vben-basic-table--inset .ant-table-wrapper {
|
|
53
|
+
padding: 0;
|
|
54
|
+
}
|
|
55
|
+
.ant-table-thead th {
|
|
56
|
+
background-color: #f5f5f5;
|
|
57
|
+
}
|
|
58
|
+
.ant-table-tbody > tr:hover:not(.ant-table-expanded-row) > td:has(.gct-handle) {
|
|
59
|
+
padding-left: 24px;
|
|
60
|
+
}
|
|
61
|
+
.ant-table-tbody > tr:hover:not(.ant-table-expanded-row) > td:has(.gct-handle) .gct-handle {
|
|
62
|
+
position: absolute;
|
|
63
|
+
left: 6px;
|
|
64
|
+
}
|
|
65
|
+
.ant-table-tbody > tr:hover:not(.ant-table-expanded-row) > td:has(.gct-handle) .gct-handle .handle-icon {
|
|
66
|
+
visibility: visible;
|
|
67
|
+
}
|
|
68
|
+
.ant-table .ant-table-tbody > tr > td:has(.gct-handle) {
|
|
69
|
+
padding-left: 24px !important;
|
|
70
|
+
}
|
|
71
|
+
.ant-table .ant-table-tbody > tr > td:has(.gct-handle) .gct-handle {
|
|
72
|
+
position: absolute;
|
|
73
|
+
left: 6px;
|
|
74
|
+
cursor: pointer;
|
|
75
|
+
}
|
|
76
|
+
.ant-table .ant-table-tbody > tr > td:has(.gct-handle) .gct-handle .handle-icon {
|
|
77
|
+
visibility: hidden;
|
|
78
|
+
}
|
|
79
|
+
.ant-table .ant-table-tbody > tr > td:has(.gct-handle) .gct-handle:hover .handle-icon {
|
|
80
|
+
color: var(--ant-primary-color);
|
|
81
|
+
}
|
package/es/components/v-ben-table/src/components/TableAction.vue_vue_type_script_setup_true_lang.mjs
CHANGED
|
@@ -2,19 +2,13 @@ import { isBoolean, isFunction, isString } from "../../../../utils/is.mjs";
|
|
|
2
2
|
import { PopConfirmButton } from "../../../v-ben-button/index.mjs";
|
|
3
3
|
import { Dropdown as Dropdown$1 } from "../../../v-ben-dropdown/index.mjs";
|
|
4
4
|
import "../../../index.mjs";
|
|
5
|
-
import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, createVNode, defineComponent, mergeProps, normalizeClass, openBlock, renderList, renderSlot, resolveComponent, toDisplayString, toRaw, unref, withCtx } from "vue";
|
|
6
5
|
import { MoreOutlined } from "@ant-design/icons-vue";
|
|
7
|
-
import {
|
|
6
|
+
import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, createVNode, defineComponent, mergeProps, normalizeClass, openBlock, renderList, renderSlot, resolveComponent, toDisplayString, toRaw, unref, withCtx } from "vue";
|
|
8
7
|
import { permission, useNamespace } from "@gct-paas/core";
|
|
8
|
+
import { Divider, Tooltip } from "ant-design-vue";
|
|
9
9
|
//#region src/components/v-ben-table/src/components/TableAction.vue?vue&type=script&setup=true&lang.ts
|
|
10
|
-
var _hoisted_1 = {
|
|
11
|
-
|
|
12
|
-
class: "text-14px"
|
|
13
|
-
};
|
|
14
|
-
var _hoisted_2 = {
|
|
15
|
-
key: 0,
|
|
16
|
-
class: "text-14px"
|
|
17
|
-
};
|
|
10
|
+
var _hoisted_1 = { key: 0 };
|
|
11
|
+
var _hoisted_2 = { key: 0 };
|
|
18
12
|
var TableAction_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
|
|
19
13
|
__name: "TableAction",
|
|
20
14
|
props: {
|
package/es/components/v-ben-table/src/components/TableAction.vue_vue_type_style_index_0_lang.css
CHANGED
|
@@ -1,37 +1,38 @@
|
|
|
1
|
-
.
|
|
1
|
+
.gct-basic-table-action {
|
|
2
2
|
display: flex;
|
|
3
3
|
align-items: center;
|
|
4
4
|
}
|
|
5
|
-
.
|
|
5
|
+
.gct-basic-table-action .action-divider {
|
|
6
6
|
display: table;
|
|
7
7
|
}
|
|
8
|
-
.
|
|
8
|
+
.gct-basic-table-action.left {
|
|
9
9
|
justify-content: flex-start;
|
|
10
10
|
}
|
|
11
|
-
.
|
|
11
|
+
.gct-basic-table-action.center {
|
|
12
12
|
justify-content: center;
|
|
13
13
|
}
|
|
14
|
-
.
|
|
14
|
+
.gct-basic-table-action.right {
|
|
15
15
|
justify-content: flex-end;
|
|
16
16
|
}
|
|
17
|
-
.
|
|
17
|
+
.gct-basic-table-action button {
|
|
18
18
|
display: flex;
|
|
19
19
|
align-items: center;
|
|
20
20
|
}
|
|
21
|
-
.
|
|
21
|
+
.gct-basic-table-action button span {
|
|
22
22
|
margin-left: 0 !important;
|
|
23
|
+
font-size: 14px;
|
|
23
24
|
}
|
|
24
|
-
.
|
|
25
|
+
.gct-basic-table-action button.ant-btn-circle span {
|
|
25
26
|
margin: auto !important;
|
|
26
27
|
}
|
|
27
|
-
.
|
|
28
|
-
.
|
|
28
|
+
.gct-basic-table-action .ant-divider,
|
|
29
|
+
.gct-basic-table-action .ant-divider-vertical {
|
|
29
30
|
margin: 0 2px;
|
|
30
31
|
}
|
|
31
|
-
.
|
|
32
|
+
.gct-basic-table-action .icon-more {
|
|
32
33
|
transform: rotate(90deg);
|
|
33
34
|
}
|
|
34
|
-
.
|
|
35
|
+
.gct-basic-table-action .icon-more svg {
|
|
35
36
|
font-size: 1.1em;
|
|
36
37
|
font-weight: 700;
|
|
37
38
|
}
|
|
@@ -2,10 +2,10 @@ import { isFunction, isString } from "../../../../utils/is.mjs";
|
|
|
2
2
|
import { PopConfirmButton } from "../../../v-ben-button/index.mjs";
|
|
3
3
|
import { Dropdown as Dropdown$1 } from "../../../v-ben-dropdown/index.mjs";
|
|
4
4
|
import "../../../index.mjs";
|
|
5
|
-
import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, createVNode, defineComponent, mergeProps, normalizeClass, openBlock, renderList, renderSlot, resolveComponent, toDisplayString, toRaw, unref, withCtx, withModifiers } from "vue";
|
|
6
5
|
import { MoreOutlined } from "@ant-design/icons-vue";
|
|
7
|
-
import {
|
|
6
|
+
import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, createVNode, defineComponent, mergeProps, normalizeClass, openBlock, renderList, renderSlot, resolveComponent, toDisplayString, toRaw, unref, withCtx, withModifiers } from "vue";
|
|
8
7
|
import { permission, useNamespace } from "@gct-paas/core";
|
|
8
|
+
import { Divider, Tooltip } from "ant-design-vue";
|
|
9
9
|
//#region src/components/v-ben-table/src/components/TableActionAuto.vue?vue&type=script&setup=true&lang.ts
|
|
10
10
|
var _hoisted_1 = {
|
|
11
11
|
key: 0,
|
|
@@ -38,7 +38,7 @@ var TableActionAuto_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ *
|
|
|
38
38
|
},
|
|
39
39
|
setup(__props) {
|
|
40
40
|
const props = __props;
|
|
41
|
-
const ns = useNamespace("basic-table-action");
|
|
41
|
+
const ns = useNamespace("basic-table-action-auto");
|
|
42
42
|
const hasPermission = permission.has;
|
|
43
43
|
function isIfShow(action) {
|
|
44
44
|
const ifShow = action.ifShow ?? true;
|
package/es/components/v-ben-table/src/components/TableActionAuto.vue_vue_type_style_index_0_lang.css
CHANGED
|
@@ -1,37 +1,38 @@
|
|
|
1
|
-
.
|
|
1
|
+
.gct-basic-table-action-auto {
|
|
2
2
|
display: flex;
|
|
3
3
|
align-items: center;
|
|
4
4
|
}
|
|
5
|
-
.
|
|
5
|
+
.gct-basic-table-action-auto .action-divider {
|
|
6
6
|
display: table;
|
|
7
7
|
}
|
|
8
|
-
.
|
|
8
|
+
.gct-basic-table-action-auto.left {
|
|
9
9
|
justify-content: flex-start;
|
|
10
10
|
}
|
|
11
|
-
.
|
|
11
|
+
.gct-basic-table-action-auto.center {
|
|
12
12
|
justify-content: center;
|
|
13
13
|
}
|
|
14
|
-
.
|
|
14
|
+
.gct-basic-table-action-auto.right {
|
|
15
15
|
justify-content: flex-end;
|
|
16
16
|
}
|
|
17
|
-
.
|
|
17
|
+
.gct-basic-table-action-auto button {
|
|
18
18
|
display: flex;
|
|
19
19
|
align-items: center;
|
|
20
20
|
}
|
|
21
|
-
.
|
|
21
|
+
.gct-basic-table-action-auto button span {
|
|
22
22
|
margin-left: 0 !important;
|
|
23
|
+
font-size: 14px;
|
|
23
24
|
}
|
|
24
|
-
.
|
|
25
|
+
.gct-basic-table-action-auto button.ant-btn-circle span {
|
|
25
26
|
margin: auto !important;
|
|
26
27
|
}
|
|
27
|
-
.
|
|
28
|
-
.
|
|
28
|
+
.gct-basic-table-action-auto .ant-divider,
|
|
29
|
+
.gct-basic-table-action-auto .ant-divider-vertical {
|
|
29
30
|
margin: 0 10px;
|
|
30
31
|
}
|
|
31
|
-
.
|
|
32
|
+
.gct-basic-table-action-auto .icon-more {
|
|
32
33
|
transform: rotate(90deg);
|
|
33
34
|
}
|
|
34
|
-
.
|
|
35
|
+
.gct-basic-table-action-auto .icon-more svg {
|
|
35
36
|
font-size: 1.1em;
|
|
36
37
|
font-weight: 700;
|
|
37
38
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** 默认列对齐 */
|
|
2
|
+
export declare const DEFAULT_ALIGN: "left";
|
|
3
|
+
/** autoCreateKey 时使用的默认行 key 字段 */
|
|
4
|
+
export declare const ROW_KEY = "key";
|
|
5
|
+
export declare const INDEX_COLUMN_FLAG = "INDEX";
|
|
6
|
+
export declare const ACTION_COLUMN_FLAG = "ACTION";
|
|
7
|
+
/** 可选每页条数 */
|
|
8
|
+
export declare const PAGE_SIZE_OPTIONS: string[];
|
|
9
|
+
/** 默认每页条数 */
|
|
10
|
+
export declare const PAGE_SIZE = 20;
|
|
11
|
+
/** 开启列宽拖拽时,未指定 width 的列默认宽度 */
|
|
12
|
+
export declare const DEFAULT_RESIZABLE_COLUMN_WIDTH = 150;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
//#region src/components/v-ben-table/src/const.ts
|
|
2
|
+
/** 默认列对齐 */
|
|
3
|
+
var DEFAULT_ALIGN = "left";
|
|
4
|
+
var INDEX_COLUMN_FLAG = "INDEX";
|
|
5
|
+
var ACTION_COLUMN_FLAG = "ACTION";
|
|
6
|
+
/** 可选每页条数 */
|
|
7
|
+
var PAGE_SIZE_OPTIONS = [
|
|
8
|
+
"20",
|
|
9
|
+
"50",
|
|
10
|
+
"80",
|
|
11
|
+
"100"
|
|
12
|
+
];
|
|
13
|
+
//#endregion
|
|
14
|
+
export { ACTION_COLUMN_FLAG, DEFAULT_ALIGN, INDEX_COLUMN_FLAG, PAGE_SIZE_OPTIONS };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { BasicColumn, BasicTableProps } from '../types/table';
|
|
2
|
+
import { PaginationProps } from '../types/pagination';
|
|
3
|
+
import { ComputedRef } from 'vue';
|
|
4
|
+
export declare function useColumns(propsRef: ComputedRef<BasicTableProps>, getPaginationRef: ComputedRef<boolean | PaginationProps>): {
|
|
5
|
+
getColumnsRef: ComputedRef<BasicColumn[]>;
|
|
6
|
+
getViewColumns: ComputedRef<BasicColumn[]>;
|
|
7
|
+
handleResizeColumn: (width: number, column: BasicColumn) => void;
|
|
8
|
+
};
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import { isBoolean, isFunction } from "../../../../utils/is.mjs";
|
|
2
|
+
import { ACTION_COLUMN_FLAG, INDEX_COLUMN_FLAG } from "../const.mjs";
|
|
3
|
+
import { computed, ref, unref, watch } from "vue";
|
|
4
|
+
import { cloneDeep } from "lodash-es";
|
|
5
|
+
import { permission, t } from "@gct-paas/core";
|
|
6
|
+
//#region src/components/v-ben-table/src/hooks/useColumns.ts
|
|
7
|
+
function normalizeColumnWidth(width) {
|
|
8
|
+
if (width === void 0 || width === null || width === "") return;
|
|
9
|
+
if (typeof width === "number" && !Number.isNaN(width)) return width;
|
|
10
|
+
if (typeof width === "string") {
|
|
11
|
+
const numericWidth = Number.parseInt(width, 10);
|
|
12
|
+
if (!Number.isNaN(numericWidth)) return numericWidth;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
function applyResizable(item, tableResizable) {
|
|
16
|
+
if (!tableResizable || item.resizable === false) return;
|
|
17
|
+
if (typeof item.width === "string" && item.width.includes("%")) return;
|
|
18
|
+
item.resizable = true;
|
|
19
|
+
const width = normalizeColumnWidth(item.width);
|
|
20
|
+
if (width !== void 0) {
|
|
21
|
+
item.width = width;
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
item.width = 150;
|
|
25
|
+
}
|
|
26
|
+
function handleItem(item, ellipsis, tableResizable) {
|
|
27
|
+
const { key, dataIndex, children } = item;
|
|
28
|
+
item.align = item.align || "left";
|
|
29
|
+
if (ellipsis) {
|
|
30
|
+
if (!key && dataIndex !== void 0) item.key = Array.isArray(dataIndex) ? dataIndex.join(".") : String(dataIndex);
|
|
31
|
+
if (!isBoolean(item.ellipsis)) Object.assign(item, { ellipsis: { showTitle: false } });
|
|
32
|
+
}
|
|
33
|
+
if (children && children.length) handleChildren(children, !!ellipsis, tableResizable);
|
|
34
|
+
applyResizable(item, tableResizable);
|
|
35
|
+
const originalCustomCell = item.customCell;
|
|
36
|
+
/** 只有内容超出的时候才出 title */
|
|
37
|
+
item.customCell = (record, rowIndex) => {
|
|
38
|
+
return {
|
|
39
|
+
...originalCustomCell && originalCustomCell(record, rowIndex),
|
|
40
|
+
onMouseenter(event) {
|
|
41
|
+
if (!item.ellipsis) return;
|
|
42
|
+
const el = event.target;
|
|
43
|
+
if (el.scrollWidth > el.clientWidth) el.setAttribute("title", el.textContent ?? "");
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
function handleChildren(children, ellipsis, tableResizable) {
|
|
49
|
+
if (!children) return;
|
|
50
|
+
children.forEach((item) => {
|
|
51
|
+
const { children: childCols } = item;
|
|
52
|
+
handleItem(item, ellipsis, tableResizable);
|
|
53
|
+
handleChildren(childCols, ellipsis, tableResizable);
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
function handleIndexColumn(propsRef, getPaginationRef, columns) {
|
|
57
|
+
const { showIndexColumn, indexColumnProps, isTreeTable } = unref(propsRef);
|
|
58
|
+
let pushIndexColumns = false;
|
|
59
|
+
if (unref(isTreeTable)) return;
|
|
60
|
+
columns.forEach(() => {
|
|
61
|
+
const indIndex = columns.findIndex((column) => column.flag === INDEX_COLUMN_FLAG);
|
|
62
|
+
if (showIndexColumn) pushIndexColumns = indIndex === -1;
|
|
63
|
+
else if (!showIndexColumn && indIndex !== -1) columns.splice(indIndex, 1);
|
|
64
|
+
});
|
|
65
|
+
if (!pushIndexColumns) return;
|
|
66
|
+
const isFixedLeft = columns.some((item) => item.fixed === "left");
|
|
67
|
+
columns.unshift({
|
|
68
|
+
flag: INDEX_COLUMN_FLAG,
|
|
69
|
+
width: 70,
|
|
70
|
+
title: t("sys.component.table.index"),
|
|
71
|
+
align: "center",
|
|
72
|
+
customRender: ({ index }) => {
|
|
73
|
+
const getPagination = unref(getPaginationRef);
|
|
74
|
+
if (isBoolean(getPagination)) return `${index + 1}`;
|
|
75
|
+
const { current = 1, pageSize = 20 } = getPagination;
|
|
76
|
+
return ((current < 1 ? 1 : current) - 1) * pageSize + index + 1;
|
|
77
|
+
},
|
|
78
|
+
...isFixedLeft ? { fixed: "left" } : {},
|
|
79
|
+
...indexColumnProps
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
function handleActionColumn(propsRef, columns) {
|
|
83
|
+
const { actionColumn } = unref(propsRef);
|
|
84
|
+
if (!actionColumn) return;
|
|
85
|
+
const hasIndex = columns.findIndex((column) => column.flag === ACTION_COLUMN_FLAG);
|
|
86
|
+
if (hasIndex === -1) columns.push({
|
|
87
|
+
...columns[hasIndex],
|
|
88
|
+
fixed: "right",
|
|
89
|
+
...actionColumn,
|
|
90
|
+
flag: ACTION_COLUMN_FLAG
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
function sortFixedColumn(columns) {
|
|
94
|
+
const fixedLeftColumns = [];
|
|
95
|
+
const fixedRightColumns = [];
|
|
96
|
+
const defColumns = [];
|
|
97
|
+
for (const column of columns) {
|
|
98
|
+
if (column.fixed === "left") {
|
|
99
|
+
fixedLeftColumns.push(column);
|
|
100
|
+
continue;
|
|
101
|
+
}
|
|
102
|
+
if (column.fixed === "right") {
|
|
103
|
+
fixedRightColumns.push(column);
|
|
104
|
+
continue;
|
|
105
|
+
}
|
|
106
|
+
defColumns.push(column);
|
|
107
|
+
}
|
|
108
|
+
return [
|
|
109
|
+
...fixedLeftColumns,
|
|
110
|
+
...defColumns,
|
|
111
|
+
...fixedRightColumns
|
|
112
|
+
].filter((item) => !item.defaultHidden);
|
|
113
|
+
}
|
|
114
|
+
function hasColumnAuth(auth) {
|
|
115
|
+
if (!auth) return true;
|
|
116
|
+
if (Array.isArray(auth)) return auth.some((key) => permission.has(String(key)));
|
|
117
|
+
return permission.has(String(auth));
|
|
118
|
+
}
|
|
119
|
+
function isIfShow(column) {
|
|
120
|
+
const ifShow = column.ifShow;
|
|
121
|
+
if (isBoolean(ifShow)) return ifShow;
|
|
122
|
+
if (isFunction(ifShow)) return ifShow(column);
|
|
123
|
+
return true;
|
|
124
|
+
}
|
|
125
|
+
function updateColumnWidth(columns, column, width) {
|
|
126
|
+
const { dataIndex, key } = column;
|
|
127
|
+
for (const col of columns) {
|
|
128
|
+
if (dataIndex !== void 0 && col.dataIndex === dataIndex || key !== void 0 && col.key === key) {
|
|
129
|
+
col.width = width;
|
|
130
|
+
return true;
|
|
131
|
+
}
|
|
132
|
+
if (col.children?.length && updateColumnWidth(col.children, column, width)) return true;
|
|
133
|
+
}
|
|
134
|
+
return false;
|
|
135
|
+
}
|
|
136
|
+
function useColumns(propsRef, getPaginationRef) {
|
|
137
|
+
const columnsRef = ref(unref(propsRef).columns);
|
|
138
|
+
const getColumnsRef = computed(() => {
|
|
139
|
+
const columns = cloneDeep(unref(columnsRef));
|
|
140
|
+
handleIndexColumn(propsRef, getPaginationRef, columns);
|
|
141
|
+
handleActionColumn(propsRef, columns);
|
|
142
|
+
if (!columns) return [];
|
|
143
|
+
const { ellipsis, resizable = true } = unref(propsRef);
|
|
144
|
+
columns.forEach((item) => {
|
|
145
|
+
const { customRender, slots } = item;
|
|
146
|
+
handleItem(item, Reflect.has(item, "ellipsis") ? !!item.ellipsis : !!ellipsis && !customRender && !slots, resizable);
|
|
147
|
+
});
|
|
148
|
+
return columns;
|
|
149
|
+
});
|
|
150
|
+
const getViewColumns = computed(() => {
|
|
151
|
+
const viewColumns = sortFixedColumn(unref(getColumnsRef));
|
|
152
|
+
const mapFn = (column) => {
|
|
153
|
+
const { slots } = column;
|
|
154
|
+
if (!slots || !slots?.title) {
|
|
155
|
+
column.customTitle = column.title;
|
|
156
|
+
Reflect.deleteProperty(column, "title");
|
|
157
|
+
}
|
|
158
|
+
return column;
|
|
159
|
+
};
|
|
160
|
+
return cloneDeep(viewColumns).filter((column) => hasColumnAuth(column.auth) && isIfShow(column)).map((column) => {
|
|
161
|
+
if (column.children?.length) column.children = column.children.map(mapFn);
|
|
162
|
+
return mapFn(column);
|
|
163
|
+
});
|
|
164
|
+
});
|
|
165
|
+
watch(() => unref(propsRef).columns, (columns) => {
|
|
166
|
+
columnsRef.value = columns;
|
|
167
|
+
});
|
|
168
|
+
function handleResizeColumn(width, column) {
|
|
169
|
+
column.width = width;
|
|
170
|
+
const columns = unref(columnsRef);
|
|
171
|
+
if (updateColumnWidth(columns, column, width)) columnsRef.value = [...columns];
|
|
172
|
+
}
|
|
173
|
+
return {
|
|
174
|
+
getColumnsRef,
|
|
175
|
+
getViewColumns,
|
|
176
|
+
handleResizeColumn
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
//#endregion
|
|
180
|
+
export { useColumns };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { PaginationProps } from '../types/pagination';
|
|
2
|
+
import { BasicTableProps } from '../types/table';
|
|
3
|
+
import { ComputedRef } from 'vue';
|
|
4
|
+
export declare function usePagination(refProps: ComputedRef<BasicTableProps>): {
|
|
5
|
+
getPagination: () => boolean | PaginationProps;
|
|
6
|
+
getPaginationInfo: ComputedRef<boolean | PaginationProps>;
|
|
7
|
+
setShowPagination: (flag: boolean) => Promise<void>;
|
|
8
|
+
getShowPagination: () => boolean;
|
|
9
|
+
setPagination: (info: Partial<PaginationProps>) => void;
|
|
10
|
+
};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { isBoolean } from "../../../../utils/is.mjs";
|
|
2
|
+
import { PAGE_SIZE_OPTIONS } from "../const.mjs";
|
|
3
|
+
import { LeftOutlined, RightOutlined } from "@ant-design/icons-vue";
|
|
4
|
+
import { computed, h, ref, unref, watch } from "vue";
|
|
5
|
+
import { t } from "@gct-paas/core";
|
|
6
|
+
//#region src/components/v-ben-table/src/hooks/usePagination.ts
|
|
7
|
+
function itemRender({ page, type, originalElement }) {
|
|
8
|
+
if (type === "prev") return page === 0 ? null : h(LeftOutlined);
|
|
9
|
+
if (type === "next") return page === 1 ? null : h(RightOutlined);
|
|
10
|
+
return originalElement;
|
|
11
|
+
}
|
|
12
|
+
function usePagination(refProps) {
|
|
13
|
+
const configRef = ref({});
|
|
14
|
+
const show = ref(true);
|
|
15
|
+
watch(() => unref(refProps).pagination, (pagination) => {
|
|
16
|
+
if (!isBoolean(pagination) && pagination) configRef.value = {
|
|
17
|
+
...unref(configRef),
|
|
18
|
+
...pagination
|
|
19
|
+
};
|
|
20
|
+
}, { deep: true });
|
|
21
|
+
const getPaginationInfo = computed(() => {
|
|
22
|
+
const { pagination } = unref(refProps);
|
|
23
|
+
if (!unref(show) || isBoolean(pagination) && !pagination) return false;
|
|
24
|
+
return {
|
|
25
|
+
current: 1,
|
|
26
|
+
pageSize: 20,
|
|
27
|
+
size: "small",
|
|
28
|
+
defaultPageSize: 20,
|
|
29
|
+
showTotal: (total) => t("sys.component.table.total", { total }),
|
|
30
|
+
showSizeChanger: true,
|
|
31
|
+
pageSizeOptions: PAGE_SIZE_OPTIONS,
|
|
32
|
+
itemRender,
|
|
33
|
+
showQuickJumper: true,
|
|
34
|
+
...isBoolean(pagination) ? {} : pagination ?? {},
|
|
35
|
+
...unref(configRef)
|
|
36
|
+
};
|
|
37
|
+
});
|
|
38
|
+
function setPagination(info) {
|
|
39
|
+
const paginationInfo = unref(getPaginationInfo);
|
|
40
|
+
configRef.value = {
|
|
41
|
+
...!isBoolean(paginationInfo) ? paginationInfo : {},
|
|
42
|
+
...info
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
function getPagination() {
|
|
46
|
+
return unref(getPaginationInfo);
|
|
47
|
+
}
|
|
48
|
+
function getShowPagination() {
|
|
49
|
+
return unref(show);
|
|
50
|
+
}
|
|
51
|
+
async function setShowPagination(flag) {
|
|
52
|
+
show.value = flag;
|
|
53
|
+
}
|
|
54
|
+
return {
|
|
55
|
+
getPagination,
|
|
56
|
+
getPaginationInfo,
|
|
57
|
+
setShowPagination,
|
|
58
|
+
getShowPagination,
|
|
59
|
+
setPagination
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
//#endregion
|
|
63
|
+
export { usePagination };
|