@meethive/components 0.0.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/es/AutoComplete/AutoComplete.js +84 -0
- package/es/AutoComplete/index.js +7 -0
- package/es/BadgeStatus/Badge.js +51 -0
- package/es/BadgeStatus/color.js +14 -0
- package/es/BadgeStatus/index.js +8 -0
- package/es/CardSelect/CardSelect.js +141 -0
- package/es/CardSelect/index.js +7 -0
- package/es/CardSelect/style/index.js +29 -0
- package/es/CheckButton/CheckButton.js +122 -0
- package/es/CheckButton/index.js +7 -0
- package/es/CheckButton/style/index.js +44 -0
- package/es/ConfigProvider/ConfigProvider.js +73 -0
- package/es/ConfigProvider/context.js +26 -0
- package/es/ConfigProvider/index.js +9 -0
- package/es/DragModal/DragModal.js +212 -0
- package/es/DragModal/index.js +7 -0
- package/es/DragModal/style/index.js +86 -0
- package/es/EditTable/Body.js +189 -0
- package/es/EditTable/CellRender.js +12 -0
- package/es/EditTable/EditTable.js +434 -0
- package/es/EditTable/FormItem.js +169 -0
- package/es/EditTable/Group.js +204 -0
- package/es/EditTable/Header.js +63 -0
- package/es/EditTable/HeaderRender.js +12 -0
- package/es/EditTable/components/ContextMenu/Menu.js +86 -0
- package/es/EditTable/components/ContextMenu/index.js +96 -0
- package/es/EditTable/components/Search/Search.js +163 -0
- package/es/EditTable/components/Search/Sort.js +119 -0
- package/es/EditTable/components/Search/index.js +2 -0
- package/es/EditTable/consts.js +13 -0
- package/es/EditTable/context.js +88 -0
- package/es/EditTable/hooks/index.js +19 -0
- package/es/EditTable/hooks/useGroup.js +48 -0
- package/es/EditTable/hooks/useResizeObserver.js +27 -0
- package/es/EditTable/hooks/useValidate.js +112 -0
- package/es/EditTable/index.js +25 -0
- package/es/EditTable/props.js +60 -0
- package/es/EditTable/style/body.js +63 -0
- package/es/EditTable/style/form.js +33 -0
- package/es/EditTable/style/group.js +33 -0
- package/es/EditTable/style/header.js +72 -0
- package/es/EditTable/style/index.js +52 -0
- package/es/EditTable/style/menu.js +27 -0
- package/es/EditTable/style/table.js +46 -0
- package/es/EditTable/utils.js +110 -0
- package/es/Ellipsis/Ellipsis.js +148 -0
- package/es/Ellipsis/index.js +7 -0
- package/es/Ellipsis/style/index.js +26 -0
- package/es/Empty/Empty.js +63 -0
- package/es/Empty/image.js +3 -0
- package/es/Empty/index.js +7 -0
- package/es/FullPage/FullPage.js +19 -0
- package/es/FullPage/index.js +7 -0
- package/es/Icon/Icon.js +49 -0
- package/es/Icon/index.js +7 -0
- package/es/LocaleProvider/LocaleProvider.js +31 -0
- package/es/LocaleProvider/index.js +7 -0
- package/es/LocaleReciver/index.js +24 -0
- package/es/Markdown/Markdown.js +118 -0
- package/es/Markdown/index.js +7 -0
- package/es/PermissionButton/PermissionButton.js +118 -0
- package/es/PermissionButton/confirm.js +94 -0
- package/es/PermissionButton/index.js +9 -0
- package/es/PermissionButton/shared.js +1 -0
- package/es/ProLayout/Basic/BasicLayout.js +422 -0
- package/es/ProLayout/Basic/BasicLayoutStyle.js +51 -0
- package/es/ProLayout/Basic/Header.js +111 -0
- package/es/ProLayout/Basic/HeaderStyle.js +10 -0
- package/es/ProLayout/PageContainer/index.js +354 -0
- package/es/ProLayout/PageContainer/style.js +85 -0
- package/es/ProLayout/RouteContext.js +28 -0
- package/es/ProLayout/SiderMenu/BaseMenu.js +241 -0
- package/es/ProLayout/SiderMenu/SiderMenu.js +274 -0
- package/es/ProLayout/SiderMenu/index.js +2 -0
- package/es/ProLayout/SiderMenu/style.js +204 -0
- package/es/ProLayout/TopHeader/index.js +170 -0
- package/es/ProLayout/TopHeader/style.js +154 -0
- package/es/ProLayout/defaultSettings.js +113 -0
- package/es/ProLayout/index.js +10 -0
- package/es/ProLayout/style/index.js +14 -0
- package/es/ProLayout/util.js +58 -0
- package/es/ProTable/Alert.js +40 -0
- package/es/ProTable/Content.js +97 -0
- package/es/ProTable/Header.js +33 -0
- package/es/ProTable/Pagination.js +55 -0
- package/es/ProTable/ProTable.js +279 -0
- package/es/ProTable/hooks/index.js +2 -0
- package/es/ProTable/hooks/useTableInject.js +6 -0
- package/es/ProTable/hooks/useTableSelection.js +115 -0
- package/es/ProTable/index.js +8 -0
- package/es/ProTable/setting.js +138 -0
- package/es/ProTable/style/index.js +113 -0
- package/es/RadioButton/RadioButton.js +53 -0
- package/es/RadioButton/index.js +8 -0
- package/es/RadioButton/style/index.js +25 -0
- package/es/Scrollbar/Bar.js +76 -0
- package/es/Scrollbar/Scrollbar.js +161 -0
- package/es/Scrollbar/Thumb.js +150 -0
- package/es/Scrollbar/constants.js +1 -0
- package/es/Scrollbar/index.js +7 -0
- package/es/Scrollbar/scrollbarProps.js +100 -0
- package/es/Scrollbar/style/index.js +85 -0
- package/es/Scrollbar/thumbProps.js +10 -0
- package/es/Scrollbar/util.js +39 -0
- package/es/Search/Item.js +239 -0
- package/es/Search/Search.js +90 -0
- package/es/Search/hooks/index.js +117 -0
- package/es/Search/hooks/useRouteQuery.js +86 -0
- package/es/Search/hooks/useSearchItems.js +50 -0
- package/es/Search/hooks/useTermOptions.js +29 -0
- package/es/Search/index.js +10 -0
- package/es/Search/setting.js +245 -0
- package/es/Search/style/index.js +5 -0
- package/es/Search/style/item.js +40 -0
- package/es/Search/style/search.js +177 -0
- package/es/Search/util.js +270 -0
- package/es/Skeleton/Skeleton.js +27 -0
- package/es/Skeleton/components/DashBoardCard.js +27 -0
- package/es/Skeleton/components/DashBoardChart.js +27 -0
- package/es/Skeleton/components/Detail.js +27 -0
- package/es/Skeleton/components/Drawer.js +27 -0
- package/es/Skeleton/components/Item.js +54 -0
- package/es/Skeleton/components/List.js +27 -0
- package/es/Skeleton/components/ListCard.js +28 -0
- package/es/Skeleton/components/ListCardItem.js +20 -0
- package/es/Skeleton/components/ListTable.js +27 -0
- package/es/Skeleton/components/Page.js +26 -0
- package/es/Skeleton/components/Search.js +16 -0
- package/es/Skeleton/components/Tree.js +27 -0
- package/es/Skeleton/index.js +28 -0
- package/es/Skeleton/style/index.js +195 -0
- package/es/TimeFormat/TimeFormat.js +36 -0
- package/es/TimeFormat/index.js +7 -0
- package/es/Title/Title.js +26 -0
- package/es/Title/index.js +7 -0
- package/es/Title/style/index.js +34 -0
- package/es/ValueItem/ValueItem.js +113 -0
- package/es/ValueItem/index.js +7 -0
- package/es/ValueItem/util.js +17 -0
- package/es/VirtualTable/VirtualTable.js +271 -0
- package/es/VirtualTable/data.js +60 -0
- package/es/VirtualTable/index.js +7 -0
- package/es/VirtualTable/style/index.js +34 -0
- package/es/components.js +21 -0
- package/es/index.js +17 -0
- package/es/locale/en-US.js +120 -0
- package/es/locale/zh-CN.js +120 -0
- package/es/style/styleRegister.js +19 -0
- package/es/style/variable.js +4 -0
- package/es/style.js +1 -0
- package/es/utils/constants.js +10 -0
- package/lib/AutoComplete/AutoComplete.js +84 -0
- package/lib/AutoComplete/index.js +7 -0
- package/lib/BadgeStatus/Badge.js +51 -0
- package/lib/BadgeStatus/color.js +14 -0
- package/lib/BadgeStatus/index.js +8 -0
- package/lib/CardSelect/CardSelect.js +141 -0
- package/lib/CardSelect/index.js +7 -0
- package/lib/CardSelect/style/index.js +29 -0
- package/lib/CheckButton/CheckButton.js +122 -0
- package/lib/CheckButton/index.js +7 -0
- package/lib/CheckButton/style/index.js +44 -0
- package/lib/ConfigProvider/ConfigProvider.js +73 -0
- package/lib/ConfigProvider/context.js +26 -0
- package/lib/ConfigProvider/index.js +9 -0
- package/lib/DragModal/DragModal.js +212 -0
- package/lib/DragModal/index.js +7 -0
- package/lib/DragModal/style/index.js +86 -0
- package/lib/EditTable/Body.js +189 -0
- package/lib/EditTable/CellRender.js +12 -0
- package/lib/EditTable/EditTable.js +434 -0
- package/lib/EditTable/FormItem.js +169 -0
- package/lib/EditTable/Group.js +204 -0
- package/lib/EditTable/Header.js +63 -0
- package/lib/EditTable/HeaderRender.js +12 -0
- package/lib/EditTable/components/ContextMenu/Menu.js +86 -0
- package/lib/EditTable/components/ContextMenu/index.js +96 -0
- package/lib/EditTable/components/Search/Search.js +163 -0
- package/lib/EditTable/components/Search/Sort.js +119 -0
- package/lib/EditTable/components/Search/index.js +2 -0
- package/lib/EditTable/consts.js +13 -0
- package/lib/EditTable/context.js +88 -0
- package/lib/EditTable/hooks/index.js +19 -0
- package/lib/EditTable/hooks/useGroup.js +48 -0
- package/lib/EditTable/hooks/useResizeObserver.js +27 -0
- package/lib/EditTable/hooks/useValidate.js +112 -0
- package/lib/EditTable/index.js +25 -0
- package/lib/EditTable/props.js +60 -0
- package/lib/EditTable/style/body.js +63 -0
- package/lib/EditTable/style/form.js +33 -0
- package/lib/EditTable/style/group.js +33 -0
- package/lib/EditTable/style/header.js +72 -0
- package/lib/EditTable/style/index.js +52 -0
- package/lib/EditTable/style/menu.js +27 -0
- package/lib/EditTable/style/table.js +46 -0
- package/lib/EditTable/utils.js +110 -0
- package/lib/Ellipsis/Ellipsis.js +148 -0
- package/lib/Ellipsis/index.js +7 -0
- package/lib/Ellipsis/style/index.js +26 -0
- package/lib/Empty/Empty.js +63 -0
- package/lib/Empty/image.js +3 -0
- package/lib/Empty/index.js +7 -0
- package/lib/FullPage/FullPage.js +19 -0
- package/lib/FullPage/index.js +7 -0
- package/lib/Icon/Icon.js +49 -0
- package/lib/Icon/index.js +7 -0
- package/lib/LocaleProvider/LocaleProvider.js +31 -0
- package/lib/LocaleProvider/index.js +7 -0
- package/lib/LocaleReciver/index.js +24 -0
- package/lib/Markdown/Markdown.js +118 -0
- package/lib/Markdown/index.js +7 -0
- package/lib/PermissionButton/PermissionButton.js +118 -0
- package/lib/PermissionButton/confirm.js +94 -0
- package/lib/PermissionButton/index.js +9 -0
- package/lib/PermissionButton/shared.js +1 -0
- package/lib/ProLayout/Basic/BasicLayout.js +422 -0
- package/lib/ProLayout/Basic/BasicLayoutStyle.js +51 -0
- package/lib/ProLayout/Basic/Header.js +111 -0
- package/lib/ProLayout/Basic/HeaderStyle.js +10 -0
- package/lib/ProLayout/PageContainer/index.js +354 -0
- package/lib/ProLayout/PageContainer/style.js +85 -0
- package/lib/ProLayout/RouteContext.js +28 -0
- package/lib/ProLayout/SiderMenu/BaseMenu.js +241 -0
- package/lib/ProLayout/SiderMenu/SiderMenu.js +274 -0
- package/lib/ProLayout/SiderMenu/index.js +2 -0
- package/lib/ProLayout/SiderMenu/style.js +204 -0
- package/lib/ProLayout/TopHeader/index.js +170 -0
- package/lib/ProLayout/TopHeader/style.js +154 -0
- package/lib/ProLayout/defaultSettings.js +113 -0
- package/lib/ProLayout/index.js +10 -0
- package/lib/ProLayout/style/index.js +14 -0
- package/lib/ProLayout/util.js +58 -0
- package/lib/ProTable/Alert.js +40 -0
- package/lib/ProTable/Content.js +97 -0
- package/lib/ProTable/Header.js +33 -0
- package/lib/ProTable/Pagination.js +55 -0
- package/lib/ProTable/ProTable.js +279 -0
- package/lib/ProTable/hooks/index.js +2 -0
- package/lib/ProTable/hooks/useTableInject.js +6 -0
- package/lib/ProTable/hooks/useTableSelection.js +115 -0
- package/lib/ProTable/index.js +8 -0
- package/lib/ProTable/setting.js +138 -0
- package/lib/ProTable/style/index.js +113 -0
- package/lib/RadioButton/RadioButton.js +53 -0
- package/lib/RadioButton/index.js +8 -0
- package/lib/RadioButton/style/index.js +25 -0
- package/lib/Scrollbar/Bar.js +76 -0
- package/lib/Scrollbar/Scrollbar.js +161 -0
- package/lib/Scrollbar/Thumb.js +150 -0
- package/lib/Scrollbar/constants.js +1 -0
- package/lib/Scrollbar/index.js +7 -0
- package/lib/Scrollbar/scrollbarProps.js +100 -0
- package/lib/Scrollbar/style/index.js +85 -0
- package/lib/Scrollbar/thumbProps.js +10 -0
- package/lib/Scrollbar/util.js +39 -0
- package/lib/Search/Item.js +239 -0
- package/lib/Search/Search.js +90 -0
- package/lib/Search/hooks/index.js +117 -0
- package/lib/Search/hooks/useRouteQuery.js +86 -0
- package/lib/Search/hooks/useSearchItems.js +50 -0
- package/lib/Search/hooks/useTermOptions.js +29 -0
- package/lib/Search/index.js +10 -0
- package/lib/Search/setting.js +245 -0
- package/lib/Search/style/index.js +5 -0
- package/lib/Search/style/item.js +40 -0
- package/lib/Search/style/search.js +177 -0
- package/lib/Search/util.js +270 -0
- package/lib/Skeleton/Skeleton.js +27 -0
- package/lib/Skeleton/components/DashBoardCard.js +27 -0
- package/lib/Skeleton/components/DashBoardChart.js +27 -0
- package/lib/Skeleton/components/Detail.js +27 -0
- package/lib/Skeleton/components/Drawer.js +27 -0
- package/lib/Skeleton/components/Item.js +54 -0
- package/lib/Skeleton/components/List.js +27 -0
- package/lib/Skeleton/components/ListCard.js +28 -0
- package/lib/Skeleton/components/ListCardItem.js +20 -0
- package/lib/Skeleton/components/ListTable.js +27 -0
- package/lib/Skeleton/components/Page.js +26 -0
- package/lib/Skeleton/components/Search.js +16 -0
- package/lib/Skeleton/components/Tree.js +27 -0
- package/lib/Skeleton/index.js +28 -0
- package/lib/Skeleton/style/index.js +195 -0
- package/lib/TimeFormat/TimeFormat.js +36 -0
- package/lib/TimeFormat/index.js +7 -0
- package/lib/Title/Title.js +26 -0
- package/lib/Title/index.js +7 -0
- package/lib/Title/style/index.js +34 -0
- package/lib/ValueItem/ValueItem.js +113 -0
- package/lib/ValueItem/index.js +7 -0
- package/lib/ValueItem/util.js +17 -0
- package/lib/VirtualTable/VirtualTable.js +271 -0
- package/lib/VirtualTable/data.js +60 -0
- package/lib/VirtualTable/index.js +7 -0
- package/lib/VirtualTable/style/index.js +34 -0
- package/lib/components.js +21 -0
- package/lib/index.js +17 -0
- package/lib/locale/en-US.js +120 -0
- package/lib/locale/zh-CN.js +120 -0
- package/lib/style/styleRegister.js +19 -0
- package/lib/style/variable.js +4 -0
- package/lib/style.js +1 -0
- package/lib/utils/constants.js +10 -0
- package/package.json +164 -0
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
|
+
import { defineComponent, useSlots, watch, onMounted, onUnmounted, computed, ref, reactive, inject } from 'vue'
|
|
3
|
+
import { Spin } from 'ant-design-vue'
|
|
4
|
+
import { debounce } from 'lodash-es'
|
|
5
|
+
import Header from './Header.js'
|
|
6
|
+
import Alert from './Alert.js'
|
|
7
|
+
import Content from './Content.js'
|
|
8
|
+
import JPagination from './Pagination.js'
|
|
9
|
+
import { proTableProps } from './setting'
|
|
10
|
+
import { TableConfig } from '../utils/constants'
|
|
11
|
+
import { useTableInject } from './hooks'
|
|
12
|
+
import useProTableStyle from './style'
|
|
13
|
+
import { onlyMessage } from '@meethive/utils'
|
|
14
|
+
import { useLocaleReceiver } from '../LocaleReciver'
|
|
15
|
+
|
|
16
|
+
export default defineComponent({
|
|
17
|
+
name: 'JProTable',
|
|
18
|
+
components: {
|
|
19
|
+
Spin,
|
|
20
|
+
Header,
|
|
21
|
+
Alert,
|
|
22
|
+
Content,
|
|
23
|
+
JPagination
|
|
24
|
+
},
|
|
25
|
+
props: {
|
|
26
|
+
...proTableProps
|
|
27
|
+
} ,
|
|
28
|
+
setup(props, { expose }) {
|
|
29
|
+
const tableConfig = inject(TableConfig, {
|
|
30
|
+
pagination: {}
|
|
31
|
+
})
|
|
32
|
+
const slots = useSlots()
|
|
33
|
+
|
|
34
|
+
const myPagination = computed(() => {
|
|
35
|
+
const globalPagination = (tableConfig ).pagination || {}
|
|
36
|
+
let showQuickJumper = _nullishCoalesce(_nullishCoalesce(globalPagination.showQuickJumper, () => ( props.pagination.showQuickJumper)), () => ( false))
|
|
37
|
+
return {
|
|
38
|
+
showSizeChanger: true,
|
|
39
|
+
size: 'size',
|
|
40
|
+
pageSizeOptions: ['12', '24', '48', '96'],
|
|
41
|
+
...globalPagination,
|
|
42
|
+
...props.pagination,
|
|
43
|
+
showQuickJumper
|
|
44
|
+
}
|
|
45
|
+
})
|
|
46
|
+
|
|
47
|
+
const loading = ref(false)
|
|
48
|
+
const _dataSource = ref([])
|
|
49
|
+
const _mode = ref(props.mode || props.modeValue || 'CARD')
|
|
50
|
+
const column = ref(4)
|
|
51
|
+
|
|
52
|
+
const page = reactive({
|
|
53
|
+
pageIndex: 0,
|
|
54
|
+
pageSize: 12,
|
|
55
|
+
total: 0,
|
|
56
|
+
loading: false
|
|
57
|
+
})
|
|
58
|
+
|
|
59
|
+
const prefixCls = computed(() => 'pro-table')
|
|
60
|
+
const [wrapSSR, hashId] = useProTableStyle(prefixCls)
|
|
61
|
+
const [contextLocale] = useLocaleReceiver('ProTable')
|
|
62
|
+
|
|
63
|
+
let currentRequestId = 0
|
|
64
|
+
const extraSlots = ['headerRightRender', 'headerLeftRender', 'paginationRender', 'alertRender']
|
|
65
|
+
|
|
66
|
+
const _rowSelection = useTableInject()
|
|
67
|
+
|
|
68
|
+
const showAlert = computed(() => {
|
|
69
|
+
return props.alertShow && (_optionalChain([props, 'access', _ => _.rowSelection, 'optionalAccess', _2 => _2.selectedRowKeys, 'optionalAccess', _3 => _3.length]) || _optionalChain([_rowSelection, 'optionalAccess', _4 => _4.value, 'optionalAccess', _5 => _5.selectedRowKeys, 'optionalAccess', _6 => _6.length]))
|
|
70
|
+
})
|
|
71
|
+
|
|
72
|
+
const showPagination = computed(() => {
|
|
73
|
+
return !!_dataSource.value.length && !props.noPagination && props.type === 'PAGE'
|
|
74
|
+
})
|
|
75
|
+
|
|
76
|
+
const onCheck = (e) => {
|
|
77
|
+
_mode.value = e.target.value
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const handleData = (result, _params) => {
|
|
81
|
+
if (props.type === 'PAGE') {
|
|
82
|
+
// 判断如果是最后一页且最后一页为空,就跳转到前一页
|
|
83
|
+
// 判断条件:如果是total分开查询,判断result的长度;如果不分开查询就判断result.data的长度
|
|
84
|
+
if (props.totalRequest) {
|
|
85
|
+
if (result.length === 0) {
|
|
86
|
+
return true
|
|
87
|
+
} else {
|
|
88
|
+
_dataSource.value = result || []
|
|
89
|
+
page.pageIndex = _optionalChain([_params, 'optionalAccess', _7 => _7.pageIndex]) || 0
|
|
90
|
+
page.pageSize = _optionalChain([_params, 'optionalAccess', _8 => _8.pageSize]) || 12
|
|
91
|
+
page.total = page.pageSize * (page.pageIndex + 1) + 1
|
|
92
|
+
}
|
|
93
|
+
} else {
|
|
94
|
+
if (
|
|
95
|
+
_optionalChain([result, 'optionalAccess', _9 => _9.total]) &&
|
|
96
|
+
_optionalChain([result, 'optionalAccess', _10 => _10.pageSize]) &&
|
|
97
|
+
_optionalChain([result, 'optionalAccess', _11 => _11.pageIndex]) &&
|
|
98
|
+
_optionalChain([result, 'optionalAccess', _12 => _12.data, 'optionalAccess', _13 => _13.length]) === 0
|
|
99
|
+
) {
|
|
100
|
+
return true
|
|
101
|
+
} else {
|
|
102
|
+
_dataSource.value = _optionalChain([result, 'optionalAccess', _14 => _14.data]) || []
|
|
103
|
+
page.pageIndex = _optionalChain([result, 'optionalAccess', _15 => _15.pageIndex]) || 0
|
|
104
|
+
page.pageSize = _optionalChain([result, 'optionalAccess', _16 => _16.pageSize]) || 12
|
|
105
|
+
page.total = _optionalChain([result, 'optionalAccess', _17 => _17.total]) || 0
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
} else {
|
|
109
|
+
_dataSource.value = result || []
|
|
110
|
+
}
|
|
111
|
+
return false
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
const handleSearch = async (_params) => {
|
|
115
|
+
if (Array.isArray(props.dataSource)) {
|
|
116
|
+
_dataSource.value = props.dataSource
|
|
117
|
+
} else if (props.request) {
|
|
118
|
+
const __params = {
|
|
119
|
+
pageIndex: page.pageIndex,
|
|
120
|
+
pageSize: Number(page.pageSize),
|
|
121
|
+
...props.defaultParams,
|
|
122
|
+
..._params,
|
|
123
|
+
terms: [
|
|
124
|
+
...(_optionalChain([props, 'access', _18 => _18.defaultParams, 'optionalAccess', _19 => _19.terms]) || []),
|
|
125
|
+
...(_optionalChain([_params, 'optionalAccess', _20 => _20.terms]) || [])
|
|
126
|
+
]
|
|
127
|
+
}
|
|
128
|
+
loading.value = true
|
|
129
|
+
const resp = await props.request(__params).finally(() => {
|
|
130
|
+
loading.value = false
|
|
131
|
+
})
|
|
132
|
+
if (resp.success) {
|
|
133
|
+
const flag = handleData(resp.result || {}, _params)
|
|
134
|
+
if (flag) {
|
|
135
|
+
// 判断如果是最后一页且最后一页为空,就跳转到前一页
|
|
136
|
+
if (props.totalRequest) {
|
|
137
|
+
onlyMessage(_optionalChain([contextLocale, 'access', _21 => _21.value, 'access', _22 => _22.pagination, 'optionalAccess', _23 => _23.lastPage]) || '', 'error')
|
|
138
|
+
// 置灰下一页
|
|
139
|
+
page.total = page.pageSize * (page.pageIndex > 0 ? page.pageIndex : 1)
|
|
140
|
+
} else {
|
|
141
|
+
page.pageIndex = page.pageIndex > 0 ? page.pageIndex - 1 : 0
|
|
142
|
+
handleSearch({
|
|
143
|
+
..._params,
|
|
144
|
+
pageSize: page.pageSize,
|
|
145
|
+
pageIndex: page.pageIndex
|
|
146
|
+
})
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
} else {
|
|
150
|
+
_dataSource.value = []
|
|
151
|
+
}
|
|
152
|
+
if (props.totalRequest) {
|
|
153
|
+
currentRequestId++
|
|
154
|
+
const requestId = currentRequestId
|
|
155
|
+
page.loading = true
|
|
156
|
+
props.totalRequest(__params).then((res) => {
|
|
157
|
+
if (res.success) {
|
|
158
|
+
page.total = res.result || 0
|
|
159
|
+
}
|
|
160
|
+
}).finally(() => {
|
|
161
|
+
if (requestId === currentRequestId) {
|
|
162
|
+
page.loading = false
|
|
163
|
+
}
|
|
164
|
+
})
|
|
165
|
+
}
|
|
166
|
+
} else {
|
|
167
|
+
_dataSource.value = []
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
const _debounceFn = debounce(handleSearch, 300)
|
|
172
|
+
|
|
173
|
+
const onPageChange = (_page, size) => {
|
|
174
|
+
handleSearch({
|
|
175
|
+
...props.params,
|
|
176
|
+
pageSize: size,
|
|
177
|
+
pageIndex: page.pageSize === size ? (_page ? _page - 1 : 0) : 0
|
|
178
|
+
})
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
const onClose = () => {
|
|
182
|
+
if (props.rowSelection) {
|
|
183
|
+
_optionalChain([props, 'access', _24 => _24.rowSelection, 'access', _25 => _25.onChange, 'optionalCall', _26 => _26([], [])])
|
|
184
|
+
_optionalChain([props, 'access', _27 => _27.rowSelection, 'access', _28 => _28.onSelectNone, 'optionalCall', _29 => _29()])
|
|
185
|
+
} else if (_optionalChain([_rowSelection, 'optionalAccess', _30 => _30.value])) {
|
|
186
|
+
_optionalChain([_rowSelection, 'access', _31 => _31.value, 'optionalAccess', _32 => _32.onSelectNone, 'optionalCall', _33 => _33()])
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* 刷新数据
|
|
192
|
+
* @param _params
|
|
193
|
+
*/
|
|
194
|
+
const reload = (_params) => {
|
|
195
|
+
handleSearch({
|
|
196
|
+
...props.params,
|
|
197
|
+
..._params,
|
|
198
|
+
pageSize: page.pageSize || 12,
|
|
199
|
+
pageIndex: page.pageIndex || 0
|
|
200
|
+
})
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
const _gridColumns = computed(() => {
|
|
204
|
+
if (_optionalChain([props, 'access', _34 => _34.gridColumns, 'optionalAccess', _35 => _35.length])) {
|
|
205
|
+
const arr = props.gridColumns
|
|
206
|
+
const lastValue = _optionalChain([arr, 'access', _36 => _36.slice, 'call', _37 => _37(-1), 'optionalAccess', _38 => _38[0]])
|
|
207
|
+
if (_optionalChain([arr, 'optionalAccess', _39 => _39.length]) < 4) {
|
|
208
|
+
while (arr.length < 4) {
|
|
209
|
+
arr.push(lastValue)
|
|
210
|
+
}
|
|
211
|
+
return arr
|
|
212
|
+
} else {
|
|
213
|
+
return props.gridColumns.slice(0, 4)
|
|
214
|
+
}
|
|
215
|
+
} else {
|
|
216
|
+
return [1, 2, 3, 4]
|
|
217
|
+
}
|
|
218
|
+
})
|
|
219
|
+
|
|
220
|
+
// 监听宽度,计算显示卡片个数
|
|
221
|
+
const windowChange = () => {
|
|
222
|
+
const ele = document.getElementById('jtable-body-spin')
|
|
223
|
+
if (ele) {
|
|
224
|
+
const styles = window.getComputedStyle(ele)
|
|
225
|
+
const width = parseFloat(styles.width)
|
|
226
|
+
if (width <= 992) {
|
|
227
|
+
column.value = _optionalChain([_gridColumns, 'access', _40 => _40.value, 'optionalAccess', _41 => _41[0]]) || 1
|
|
228
|
+
} else if (width > 992 && width <= 1440) {
|
|
229
|
+
column.value = _optionalChain([_gridColumns, 'access', _42 => _42.value, 'optionalAccess', _43 => _43[1]]) || 2
|
|
230
|
+
} else if (width > 1440 && width <= 1600) {
|
|
231
|
+
column.value = _optionalChain([_gridColumns, 'access', _44 => _44.value, 'optionalAccess', _45 => _45[2]]) || 3
|
|
232
|
+
} else if (width > 1600) {
|
|
233
|
+
column.value = _optionalChain([_gridColumns, 'access', _46 => _46.value, 'optionalAccess', _47 => _47[3]]) || 4
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
watch(() => props.params, (newValue) => {
|
|
239
|
+
_debounceFn(newValue || {})
|
|
240
|
+
}, { deep: true, immediate: true })
|
|
241
|
+
|
|
242
|
+
watch(() => props.dataSource, (newVal) => {
|
|
243
|
+
if (newVal && !props.request) {
|
|
244
|
+
handleSearch(props.params)
|
|
245
|
+
}
|
|
246
|
+
}, { deep: true, immediate: true })
|
|
247
|
+
|
|
248
|
+
onMounted(() => {
|
|
249
|
+
windowChange() // 初始化
|
|
250
|
+
window.onresize = () => {
|
|
251
|
+
windowChange()
|
|
252
|
+
}
|
|
253
|
+
})
|
|
254
|
+
|
|
255
|
+
onUnmounted(() => {
|
|
256
|
+
window.onresize = null
|
|
257
|
+
})
|
|
258
|
+
|
|
259
|
+
expose({ reload, dataSource: _dataSource })
|
|
260
|
+
|
|
261
|
+
return {
|
|
262
|
+
slots,
|
|
263
|
+
hashId,
|
|
264
|
+
loading,
|
|
265
|
+
_dataSource,
|
|
266
|
+
_mode,
|
|
267
|
+
column,
|
|
268
|
+
page,
|
|
269
|
+
myPagination,
|
|
270
|
+
showAlert,
|
|
271
|
+
showPagination,
|
|
272
|
+
extraSlots,
|
|
273
|
+
_rowSelection,
|
|
274
|
+
onCheck,
|
|
275
|
+
onPageChange,
|
|
276
|
+
onClose
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
})
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { ref, provide, watch, unref, computed, } from 'vue'
|
|
2
|
+
import { omit } from 'lodash-es'
|
|
3
|
+
|
|
4
|
+
export const PROTABLE_ROW_SELECTION_KEY = Symbol('protable-row-selection-key')
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
export const useTableSelection = (options = {
|
|
25
|
+
type: 'checkbox',
|
|
26
|
+
rowKey: 'id',
|
|
27
|
+
isCheck: true
|
|
28
|
+
}) => {
|
|
29
|
+
const { type = 'checkbox', rowKey = 'id' } = options
|
|
30
|
+
|
|
31
|
+
const selectedRowKeys = ref([])
|
|
32
|
+
const selectedRows = ref([])
|
|
33
|
+
const selectionObj = ref(null)
|
|
34
|
+
|
|
35
|
+
const isCheckRef = computed(() => {
|
|
36
|
+
return unref(options.isCheck)
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
const onSelect = (record, selected) => {
|
|
40
|
+
if (type === 'checkbox') {
|
|
41
|
+
if (selected) {
|
|
42
|
+
selectedRows.value.push(record)
|
|
43
|
+
} else {
|
|
44
|
+
selectedRows.value = selectedRows.value.filter((i) => i[rowKey] !== record[rowKey])
|
|
45
|
+
}
|
|
46
|
+
selectedRowKeys.value = selectedRows.value.map((i) => i[rowKey])
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// 单选
|
|
51
|
+
const onChange = (_selectedRowKeys, _selectedRows) => {
|
|
52
|
+
if (type === 'radio') {
|
|
53
|
+
selectedRowKeys.value = _selectedRowKeys
|
|
54
|
+
selectedRows.value = _selectedRows
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const onSelectAll = (selected, _selectedRows, changeRows) => {
|
|
59
|
+
if (selected) {
|
|
60
|
+
selectedRows.value.push(...changeRows)
|
|
61
|
+
} else {
|
|
62
|
+
const arr = changeRows.map((item) => item[rowKey])
|
|
63
|
+
selectedRows.value = selectedRows.value.filter((i) => !arr.includes(i[rowKey]))
|
|
64
|
+
}
|
|
65
|
+
selectedRowKeys.value = selectedRows.value.map((i) => i[rowKey])
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const onSelectNone = () => {
|
|
69
|
+
selectedRowKeys.value = []
|
|
70
|
+
selectedRows.value = []
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const updateSelection = () => {
|
|
74
|
+
if (isCheckRef.value) {
|
|
75
|
+
// 提供选择上下文
|
|
76
|
+
selectionObj.value = type === 'checkbox'
|
|
77
|
+
? {
|
|
78
|
+
...omit(options, ['isCheck']),
|
|
79
|
+
type,
|
|
80
|
+
rowKey,
|
|
81
|
+
selectedRowKeys,
|
|
82
|
+
onSelect,
|
|
83
|
+
onSelectAll,
|
|
84
|
+
onSelectNone
|
|
85
|
+
}
|
|
86
|
+
: {
|
|
87
|
+
...omit(options, ['isCheck']),
|
|
88
|
+
type,
|
|
89
|
+
rowKey,
|
|
90
|
+
selectedRowKeys,
|
|
91
|
+
onChange,
|
|
92
|
+
onSelectNone
|
|
93
|
+
}
|
|
94
|
+
} else {
|
|
95
|
+
// 清空选择状态
|
|
96
|
+
onSelectNone()
|
|
97
|
+
selectionObj.value = null
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
watch(isCheckRef, () => {
|
|
102
|
+
updateSelection()
|
|
103
|
+
}, {
|
|
104
|
+
immediate: true,
|
|
105
|
+
deep: false // 注意:deep 设为 false
|
|
106
|
+
})
|
|
107
|
+
|
|
108
|
+
provide(PROTABLE_ROW_SELECTION_KEY, selectionObj)
|
|
109
|
+
|
|
110
|
+
return {
|
|
111
|
+
selectedRowKeys,
|
|
112
|
+
selectedRows,
|
|
113
|
+
onSelectNone
|
|
114
|
+
}
|
|
115
|
+
}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { tableProps } from 'ant-design-vue/es/table/Table'
|
|
2
|
+
import { paginationProps } from 'ant-design-vue/es/pagination/Pagination'
|
|
3
|
+
import { omit } from 'lodash-es'
|
|
4
|
+
|
|
5
|
+
export const _headerProps = {
|
|
6
|
+
mode: {
|
|
7
|
+
type: [String, undefined] ,
|
|
8
|
+
default: undefined
|
|
9
|
+
},
|
|
10
|
+
modeValue: {
|
|
11
|
+
type: String,
|
|
12
|
+
default: 'TABLE'
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export const _alertProps = {
|
|
17
|
+
alertShow: {
|
|
18
|
+
type: Boolean,
|
|
19
|
+
default: true
|
|
20
|
+
},
|
|
21
|
+
rowSelection: {
|
|
22
|
+
type: Object,
|
|
23
|
+
default: () => undefined
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export const _contentProps = {
|
|
28
|
+
...tableProps(),
|
|
29
|
+
..._headerProps,
|
|
30
|
+
cardBodyClass: {
|
|
31
|
+
type: String,
|
|
32
|
+
default: ''
|
|
33
|
+
},
|
|
34
|
+
columns: {
|
|
35
|
+
type: Array,
|
|
36
|
+
default: () => []
|
|
37
|
+
},
|
|
38
|
+
dataSource: {
|
|
39
|
+
type: Array,
|
|
40
|
+
default: undefined
|
|
41
|
+
},
|
|
42
|
+
gridColumns: {
|
|
43
|
+
type: Array,
|
|
44
|
+
default: () => [1, 2, 3, 4]
|
|
45
|
+
},
|
|
46
|
+
scroll: {
|
|
47
|
+
type: [Object, Boolean],
|
|
48
|
+
default: () => ({}) // x: 1366
|
|
49
|
+
},
|
|
50
|
+
rowKey: {
|
|
51
|
+
type: [String, Function],
|
|
52
|
+
default: 'id'
|
|
53
|
+
},
|
|
54
|
+
type: {
|
|
55
|
+
type: String,
|
|
56
|
+
default: 'PAGE'
|
|
57
|
+
},
|
|
58
|
+
height: {
|
|
59
|
+
type: Number,
|
|
60
|
+
default: 500
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export const _paginationProps = {
|
|
65
|
+
...omit(paginationProps(), ['onChange']),
|
|
66
|
+
total: {
|
|
67
|
+
type: Number,
|
|
68
|
+
default: 0
|
|
69
|
+
},
|
|
70
|
+
pageSize: {
|
|
71
|
+
type: Number,
|
|
72
|
+
default: 12
|
|
73
|
+
},
|
|
74
|
+
pageIndex: {
|
|
75
|
+
type: Number,
|
|
76
|
+
default: 0
|
|
77
|
+
},
|
|
78
|
+
/**
|
|
79
|
+
* 是否显示分页内容
|
|
80
|
+
*/
|
|
81
|
+
isShowContent: {
|
|
82
|
+
type: Boolean
|
|
83
|
+
},
|
|
84
|
+
/**
|
|
85
|
+
* 总数loading状态
|
|
86
|
+
*/
|
|
87
|
+
totalLoading: {
|
|
88
|
+
type: Boolean,
|
|
89
|
+
default: false
|
|
90
|
+
},
|
|
91
|
+
totalRequest: {
|
|
92
|
+
type: Function,
|
|
93
|
+
default: undefined
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export const proTableProps = {
|
|
98
|
+
..._contentProps,
|
|
99
|
+
..._alertProps,
|
|
100
|
+
bodyStyle: {
|
|
101
|
+
type: Object,
|
|
102
|
+
default: () => ({
|
|
103
|
+
padding: '16px 24px 24px'
|
|
104
|
+
})
|
|
105
|
+
},
|
|
106
|
+
request: {
|
|
107
|
+
type: Function,
|
|
108
|
+
default: undefined
|
|
109
|
+
},
|
|
110
|
+
totalRequest: {
|
|
111
|
+
type: Function,
|
|
112
|
+
default: undefined
|
|
113
|
+
},
|
|
114
|
+
params: {
|
|
115
|
+
type: Object,
|
|
116
|
+
default: () => ({})
|
|
117
|
+
},
|
|
118
|
+
type: {
|
|
119
|
+
type: String,
|
|
120
|
+
default: 'PAGE'
|
|
121
|
+
},
|
|
122
|
+
defaultParams: {
|
|
123
|
+
type: Object,
|
|
124
|
+
default: () => ({})
|
|
125
|
+
},
|
|
126
|
+
noPagination: {
|
|
127
|
+
type: Boolean,
|
|
128
|
+
default: false
|
|
129
|
+
},
|
|
130
|
+
pagination: {
|
|
131
|
+
type: Object,
|
|
132
|
+
default: () => ({
|
|
133
|
+
showSizeChanger: true,
|
|
134
|
+
size: 'size',
|
|
135
|
+
pageSizeOptions: ['12', '24', '48', '96']
|
|
136
|
+
})
|
|
137
|
+
}
|
|
138
|
+
}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import genComponentStyle from '../../style/styleRegister'
|
|
2
|
+
|
|
3
|
+
const genProTableStyle = (config) => {
|
|
4
|
+
const { token } = config
|
|
5
|
+
return {
|
|
6
|
+
'.jtable-body-spin': {
|
|
7
|
+
height: '100%',
|
|
8
|
+
width: '100%',
|
|
9
|
+
backgroundColor: '#fff',
|
|
10
|
+
'.ant-spin-nested-loading': {
|
|
11
|
+
height: '100%',
|
|
12
|
+
'.ant-spin-container': {
|
|
13
|
+
height: '100%'
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
'.jtable-body': {
|
|
17
|
+
width: '100%',
|
|
18
|
+
boxSizing: 'border-box',
|
|
19
|
+
height: '100%',
|
|
20
|
+
display: 'flex',
|
|
21
|
+
flexDirection: 'column'
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
'.jtable-body-header': {
|
|
25
|
+
display: 'flex',
|
|
26
|
+
justifyContent: 'space-between',
|
|
27
|
+
alignItems: 'center',
|
|
28
|
+
marginBottom: '16px',
|
|
29
|
+
width: '100%',
|
|
30
|
+
gap: '8px',
|
|
31
|
+
'.jtable-body-header-left': {
|
|
32
|
+
flex: 1,
|
|
33
|
+
minWidth: 0
|
|
34
|
+
},
|
|
35
|
+
'.jtable-body-header-right': {
|
|
36
|
+
display: 'flex',
|
|
37
|
+
gap: '8px',
|
|
38
|
+
alignItems: 'center',
|
|
39
|
+
'.jtable-body-header-right-button': {
|
|
40
|
+
width: '62px',
|
|
41
|
+
'.right-button-icon': {
|
|
42
|
+
fontSize: '16px',
|
|
43
|
+
color: '#d9d9d9'
|
|
44
|
+
},
|
|
45
|
+
'.ant-radio-button-wrapper': {
|
|
46
|
+
padding: '0 8px'
|
|
47
|
+
},
|
|
48
|
+
'.ant-radio-button-wrapper-checked': {
|
|
49
|
+
color: token.colorPrimary
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
'.jtable-box': {
|
|
55
|
+
flex: 1,
|
|
56
|
+
minHeight: 0,
|
|
57
|
+
'.jtable-card': {
|
|
58
|
+
height: '100%',
|
|
59
|
+
overflowY: 'auto',
|
|
60
|
+
'.jtable-card-items': {
|
|
61
|
+
display: 'grid',
|
|
62
|
+
gridGap: '26px',
|
|
63
|
+
'.jtable-card-item': {
|
|
64
|
+
display: 'flex',
|
|
65
|
+
minWidth: 0
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
'.j-table-empty': {
|
|
69
|
+
marginTop: '100px'
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
'.ant-table-wrapper': {
|
|
73
|
+
height: '100%',
|
|
74
|
+
'.ant-table': {
|
|
75
|
+
height: '100%',
|
|
76
|
+
'.ant-table-container': {
|
|
77
|
+
height: '100%',
|
|
78
|
+
'.ant-table-content': {
|
|
79
|
+
height: '100%'
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
'.j-table-scroll': {
|
|
85
|
+
'.ant-table-container': {
|
|
86
|
+
display: 'flex',
|
|
87
|
+
flexDirection: 'column'
|
|
88
|
+
},
|
|
89
|
+
'.ant-table-body': {
|
|
90
|
+
flex: 1,
|
|
91
|
+
minHeight: 0,
|
|
92
|
+
overflowY: 'auto'
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
'.jtable-alert': {
|
|
97
|
+
marginBottom: '16px'
|
|
98
|
+
},
|
|
99
|
+
'.jtable-pagination': {
|
|
100
|
+
width: '100%',
|
|
101
|
+
display: 'flex',
|
|
102
|
+
justifyContent: 'flex-end',
|
|
103
|
+
marginTop: '16px',
|
|
104
|
+
'.hide-content': {
|
|
105
|
+
[`${token.antCls}-pagination-item,& ${token.antCls}-pagination-jump-prev, & ${token.antCls}-pagination-jump-next`]: {
|
|
106
|
+
display: 'none'
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export default genComponentStyle([genProTableStyle])
|