@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.
Files changed (303) hide show
  1. package/es/AutoComplete/AutoComplete.js +84 -0
  2. package/es/AutoComplete/index.js +7 -0
  3. package/es/BadgeStatus/Badge.js +51 -0
  4. package/es/BadgeStatus/color.js +14 -0
  5. package/es/BadgeStatus/index.js +8 -0
  6. package/es/CardSelect/CardSelect.js +141 -0
  7. package/es/CardSelect/index.js +7 -0
  8. package/es/CardSelect/style/index.js +29 -0
  9. package/es/CheckButton/CheckButton.js +122 -0
  10. package/es/CheckButton/index.js +7 -0
  11. package/es/CheckButton/style/index.js +44 -0
  12. package/es/ConfigProvider/ConfigProvider.js +73 -0
  13. package/es/ConfigProvider/context.js +26 -0
  14. package/es/ConfigProvider/index.js +9 -0
  15. package/es/DragModal/DragModal.js +212 -0
  16. package/es/DragModal/index.js +7 -0
  17. package/es/DragModal/style/index.js +86 -0
  18. package/es/EditTable/Body.js +189 -0
  19. package/es/EditTable/CellRender.js +12 -0
  20. package/es/EditTable/EditTable.js +434 -0
  21. package/es/EditTable/FormItem.js +169 -0
  22. package/es/EditTable/Group.js +204 -0
  23. package/es/EditTable/Header.js +63 -0
  24. package/es/EditTable/HeaderRender.js +12 -0
  25. package/es/EditTable/components/ContextMenu/Menu.js +86 -0
  26. package/es/EditTable/components/ContextMenu/index.js +96 -0
  27. package/es/EditTable/components/Search/Search.js +163 -0
  28. package/es/EditTable/components/Search/Sort.js +119 -0
  29. package/es/EditTable/components/Search/index.js +2 -0
  30. package/es/EditTable/consts.js +13 -0
  31. package/es/EditTable/context.js +88 -0
  32. package/es/EditTable/hooks/index.js +19 -0
  33. package/es/EditTable/hooks/useGroup.js +48 -0
  34. package/es/EditTable/hooks/useResizeObserver.js +27 -0
  35. package/es/EditTable/hooks/useValidate.js +112 -0
  36. package/es/EditTable/index.js +25 -0
  37. package/es/EditTable/props.js +60 -0
  38. package/es/EditTable/style/body.js +63 -0
  39. package/es/EditTable/style/form.js +33 -0
  40. package/es/EditTable/style/group.js +33 -0
  41. package/es/EditTable/style/header.js +72 -0
  42. package/es/EditTable/style/index.js +52 -0
  43. package/es/EditTable/style/menu.js +27 -0
  44. package/es/EditTable/style/table.js +46 -0
  45. package/es/EditTable/utils.js +110 -0
  46. package/es/Ellipsis/Ellipsis.js +148 -0
  47. package/es/Ellipsis/index.js +7 -0
  48. package/es/Ellipsis/style/index.js +26 -0
  49. package/es/Empty/Empty.js +63 -0
  50. package/es/Empty/image.js +3 -0
  51. package/es/Empty/index.js +7 -0
  52. package/es/FullPage/FullPage.js +19 -0
  53. package/es/FullPage/index.js +7 -0
  54. package/es/Icon/Icon.js +49 -0
  55. package/es/Icon/index.js +7 -0
  56. package/es/LocaleProvider/LocaleProvider.js +31 -0
  57. package/es/LocaleProvider/index.js +7 -0
  58. package/es/LocaleReciver/index.js +24 -0
  59. package/es/Markdown/Markdown.js +118 -0
  60. package/es/Markdown/index.js +7 -0
  61. package/es/PermissionButton/PermissionButton.js +118 -0
  62. package/es/PermissionButton/confirm.js +94 -0
  63. package/es/PermissionButton/index.js +9 -0
  64. package/es/PermissionButton/shared.js +1 -0
  65. package/es/ProLayout/Basic/BasicLayout.js +422 -0
  66. package/es/ProLayout/Basic/BasicLayoutStyle.js +51 -0
  67. package/es/ProLayout/Basic/Header.js +111 -0
  68. package/es/ProLayout/Basic/HeaderStyle.js +10 -0
  69. package/es/ProLayout/PageContainer/index.js +354 -0
  70. package/es/ProLayout/PageContainer/style.js +85 -0
  71. package/es/ProLayout/RouteContext.js +28 -0
  72. package/es/ProLayout/SiderMenu/BaseMenu.js +241 -0
  73. package/es/ProLayout/SiderMenu/SiderMenu.js +274 -0
  74. package/es/ProLayout/SiderMenu/index.js +2 -0
  75. package/es/ProLayout/SiderMenu/style.js +204 -0
  76. package/es/ProLayout/TopHeader/index.js +170 -0
  77. package/es/ProLayout/TopHeader/style.js +154 -0
  78. package/es/ProLayout/defaultSettings.js +113 -0
  79. package/es/ProLayout/index.js +10 -0
  80. package/es/ProLayout/style/index.js +14 -0
  81. package/es/ProLayout/util.js +58 -0
  82. package/es/ProTable/Alert.js +40 -0
  83. package/es/ProTable/Content.js +97 -0
  84. package/es/ProTable/Header.js +33 -0
  85. package/es/ProTable/Pagination.js +55 -0
  86. package/es/ProTable/ProTable.js +279 -0
  87. package/es/ProTable/hooks/index.js +2 -0
  88. package/es/ProTable/hooks/useTableInject.js +6 -0
  89. package/es/ProTable/hooks/useTableSelection.js +115 -0
  90. package/es/ProTable/index.js +8 -0
  91. package/es/ProTable/setting.js +138 -0
  92. package/es/ProTable/style/index.js +113 -0
  93. package/es/RadioButton/RadioButton.js +53 -0
  94. package/es/RadioButton/index.js +8 -0
  95. package/es/RadioButton/style/index.js +25 -0
  96. package/es/Scrollbar/Bar.js +76 -0
  97. package/es/Scrollbar/Scrollbar.js +161 -0
  98. package/es/Scrollbar/Thumb.js +150 -0
  99. package/es/Scrollbar/constants.js +1 -0
  100. package/es/Scrollbar/index.js +7 -0
  101. package/es/Scrollbar/scrollbarProps.js +100 -0
  102. package/es/Scrollbar/style/index.js +85 -0
  103. package/es/Scrollbar/thumbProps.js +10 -0
  104. package/es/Scrollbar/util.js +39 -0
  105. package/es/Search/Item.js +239 -0
  106. package/es/Search/Search.js +90 -0
  107. package/es/Search/hooks/index.js +117 -0
  108. package/es/Search/hooks/useRouteQuery.js +86 -0
  109. package/es/Search/hooks/useSearchItems.js +50 -0
  110. package/es/Search/hooks/useTermOptions.js +29 -0
  111. package/es/Search/index.js +10 -0
  112. package/es/Search/setting.js +245 -0
  113. package/es/Search/style/index.js +5 -0
  114. package/es/Search/style/item.js +40 -0
  115. package/es/Search/style/search.js +177 -0
  116. package/es/Search/util.js +270 -0
  117. package/es/Skeleton/Skeleton.js +27 -0
  118. package/es/Skeleton/components/DashBoardCard.js +27 -0
  119. package/es/Skeleton/components/DashBoardChart.js +27 -0
  120. package/es/Skeleton/components/Detail.js +27 -0
  121. package/es/Skeleton/components/Drawer.js +27 -0
  122. package/es/Skeleton/components/Item.js +54 -0
  123. package/es/Skeleton/components/List.js +27 -0
  124. package/es/Skeleton/components/ListCard.js +28 -0
  125. package/es/Skeleton/components/ListCardItem.js +20 -0
  126. package/es/Skeleton/components/ListTable.js +27 -0
  127. package/es/Skeleton/components/Page.js +26 -0
  128. package/es/Skeleton/components/Search.js +16 -0
  129. package/es/Skeleton/components/Tree.js +27 -0
  130. package/es/Skeleton/index.js +28 -0
  131. package/es/Skeleton/style/index.js +195 -0
  132. package/es/TimeFormat/TimeFormat.js +36 -0
  133. package/es/TimeFormat/index.js +7 -0
  134. package/es/Title/Title.js +26 -0
  135. package/es/Title/index.js +7 -0
  136. package/es/Title/style/index.js +34 -0
  137. package/es/ValueItem/ValueItem.js +113 -0
  138. package/es/ValueItem/index.js +7 -0
  139. package/es/ValueItem/util.js +17 -0
  140. package/es/VirtualTable/VirtualTable.js +271 -0
  141. package/es/VirtualTable/data.js +60 -0
  142. package/es/VirtualTable/index.js +7 -0
  143. package/es/VirtualTable/style/index.js +34 -0
  144. package/es/components.js +21 -0
  145. package/es/index.js +17 -0
  146. package/es/locale/en-US.js +120 -0
  147. package/es/locale/zh-CN.js +120 -0
  148. package/es/style/styleRegister.js +19 -0
  149. package/es/style/variable.js +4 -0
  150. package/es/style.js +1 -0
  151. package/es/utils/constants.js +10 -0
  152. package/lib/AutoComplete/AutoComplete.js +84 -0
  153. package/lib/AutoComplete/index.js +7 -0
  154. package/lib/BadgeStatus/Badge.js +51 -0
  155. package/lib/BadgeStatus/color.js +14 -0
  156. package/lib/BadgeStatus/index.js +8 -0
  157. package/lib/CardSelect/CardSelect.js +141 -0
  158. package/lib/CardSelect/index.js +7 -0
  159. package/lib/CardSelect/style/index.js +29 -0
  160. package/lib/CheckButton/CheckButton.js +122 -0
  161. package/lib/CheckButton/index.js +7 -0
  162. package/lib/CheckButton/style/index.js +44 -0
  163. package/lib/ConfigProvider/ConfigProvider.js +73 -0
  164. package/lib/ConfigProvider/context.js +26 -0
  165. package/lib/ConfigProvider/index.js +9 -0
  166. package/lib/DragModal/DragModal.js +212 -0
  167. package/lib/DragModal/index.js +7 -0
  168. package/lib/DragModal/style/index.js +86 -0
  169. package/lib/EditTable/Body.js +189 -0
  170. package/lib/EditTable/CellRender.js +12 -0
  171. package/lib/EditTable/EditTable.js +434 -0
  172. package/lib/EditTable/FormItem.js +169 -0
  173. package/lib/EditTable/Group.js +204 -0
  174. package/lib/EditTable/Header.js +63 -0
  175. package/lib/EditTable/HeaderRender.js +12 -0
  176. package/lib/EditTable/components/ContextMenu/Menu.js +86 -0
  177. package/lib/EditTable/components/ContextMenu/index.js +96 -0
  178. package/lib/EditTable/components/Search/Search.js +163 -0
  179. package/lib/EditTable/components/Search/Sort.js +119 -0
  180. package/lib/EditTable/components/Search/index.js +2 -0
  181. package/lib/EditTable/consts.js +13 -0
  182. package/lib/EditTable/context.js +88 -0
  183. package/lib/EditTable/hooks/index.js +19 -0
  184. package/lib/EditTable/hooks/useGroup.js +48 -0
  185. package/lib/EditTable/hooks/useResizeObserver.js +27 -0
  186. package/lib/EditTable/hooks/useValidate.js +112 -0
  187. package/lib/EditTable/index.js +25 -0
  188. package/lib/EditTable/props.js +60 -0
  189. package/lib/EditTable/style/body.js +63 -0
  190. package/lib/EditTable/style/form.js +33 -0
  191. package/lib/EditTable/style/group.js +33 -0
  192. package/lib/EditTable/style/header.js +72 -0
  193. package/lib/EditTable/style/index.js +52 -0
  194. package/lib/EditTable/style/menu.js +27 -0
  195. package/lib/EditTable/style/table.js +46 -0
  196. package/lib/EditTable/utils.js +110 -0
  197. package/lib/Ellipsis/Ellipsis.js +148 -0
  198. package/lib/Ellipsis/index.js +7 -0
  199. package/lib/Ellipsis/style/index.js +26 -0
  200. package/lib/Empty/Empty.js +63 -0
  201. package/lib/Empty/image.js +3 -0
  202. package/lib/Empty/index.js +7 -0
  203. package/lib/FullPage/FullPage.js +19 -0
  204. package/lib/FullPage/index.js +7 -0
  205. package/lib/Icon/Icon.js +49 -0
  206. package/lib/Icon/index.js +7 -0
  207. package/lib/LocaleProvider/LocaleProvider.js +31 -0
  208. package/lib/LocaleProvider/index.js +7 -0
  209. package/lib/LocaleReciver/index.js +24 -0
  210. package/lib/Markdown/Markdown.js +118 -0
  211. package/lib/Markdown/index.js +7 -0
  212. package/lib/PermissionButton/PermissionButton.js +118 -0
  213. package/lib/PermissionButton/confirm.js +94 -0
  214. package/lib/PermissionButton/index.js +9 -0
  215. package/lib/PermissionButton/shared.js +1 -0
  216. package/lib/ProLayout/Basic/BasicLayout.js +422 -0
  217. package/lib/ProLayout/Basic/BasicLayoutStyle.js +51 -0
  218. package/lib/ProLayout/Basic/Header.js +111 -0
  219. package/lib/ProLayout/Basic/HeaderStyle.js +10 -0
  220. package/lib/ProLayout/PageContainer/index.js +354 -0
  221. package/lib/ProLayout/PageContainer/style.js +85 -0
  222. package/lib/ProLayout/RouteContext.js +28 -0
  223. package/lib/ProLayout/SiderMenu/BaseMenu.js +241 -0
  224. package/lib/ProLayout/SiderMenu/SiderMenu.js +274 -0
  225. package/lib/ProLayout/SiderMenu/index.js +2 -0
  226. package/lib/ProLayout/SiderMenu/style.js +204 -0
  227. package/lib/ProLayout/TopHeader/index.js +170 -0
  228. package/lib/ProLayout/TopHeader/style.js +154 -0
  229. package/lib/ProLayout/defaultSettings.js +113 -0
  230. package/lib/ProLayout/index.js +10 -0
  231. package/lib/ProLayout/style/index.js +14 -0
  232. package/lib/ProLayout/util.js +58 -0
  233. package/lib/ProTable/Alert.js +40 -0
  234. package/lib/ProTable/Content.js +97 -0
  235. package/lib/ProTable/Header.js +33 -0
  236. package/lib/ProTable/Pagination.js +55 -0
  237. package/lib/ProTable/ProTable.js +279 -0
  238. package/lib/ProTable/hooks/index.js +2 -0
  239. package/lib/ProTable/hooks/useTableInject.js +6 -0
  240. package/lib/ProTable/hooks/useTableSelection.js +115 -0
  241. package/lib/ProTable/index.js +8 -0
  242. package/lib/ProTable/setting.js +138 -0
  243. package/lib/ProTable/style/index.js +113 -0
  244. package/lib/RadioButton/RadioButton.js +53 -0
  245. package/lib/RadioButton/index.js +8 -0
  246. package/lib/RadioButton/style/index.js +25 -0
  247. package/lib/Scrollbar/Bar.js +76 -0
  248. package/lib/Scrollbar/Scrollbar.js +161 -0
  249. package/lib/Scrollbar/Thumb.js +150 -0
  250. package/lib/Scrollbar/constants.js +1 -0
  251. package/lib/Scrollbar/index.js +7 -0
  252. package/lib/Scrollbar/scrollbarProps.js +100 -0
  253. package/lib/Scrollbar/style/index.js +85 -0
  254. package/lib/Scrollbar/thumbProps.js +10 -0
  255. package/lib/Scrollbar/util.js +39 -0
  256. package/lib/Search/Item.js +239 -0
  257. package/lib/Search/Search.js +90 -0
  258. package/lib/Search/hooks/index.js +117 -0
  259. package/lib/Search/hooks/useRouteQuery.js +86 -0
  260. package/lib/Search/hooks/useSearchItems.js +50 -0
  261. package/lib/Search/hooks/useTermOptions.js +29 -0
  262. package/lib/Search/index.js +10 -0
  263. package/lib/Search/setting.js +245 -0
  264. package/lib/Search/style/index.js +5 -0
  265. package/lib/Search/style/item.js +40 -0
  266. package/lib/Search/style/search.js +177 -0
  267. package/lib/Search/util.js +270 -0
  268. package/lib/Skeleton/Skeleton.js +27 -0
  269. package/lib/Skeleton/components/DashBoardCard.js +27 -0
  270. package/lib/Skeleton/components/DashBoardChart.js +27 -0
  271. package/lib/Skeleton/components/Detail.js +27 -0
  272. package/lib/Skeleton/components/Drawer.js +27 -0
  273. package/lib/Skeleton/components/Item.js +54 -0
  274. package/lib/Skeleton/components/List.js +27 -0
  275. package/lib/Skeleton/components/ListCard.js +28 -0
  276. package/lib/Skeleton/components/ListCardItem.js +20 -0
  277. package/lib/Skeleton/components/ListTable.js +27 -0
  278. package/lib/Skeleton/components/Page.js +26 -0
  279. package/lib/Skeleton/components/Search.js +16 -0
  280. package/lib/Skeleton/components/Tree.js +27 -0
  281. package/lib/Skeleton/index.js +28 -0
  282. package/lib/Skeleton/style/index.js +195 -0
  283. package/lib/TimeFormat/TimeFormat.js +36 -0
  284. package/lib/TimeFormat/index.js +7 -0
  285. package/lib/Title/Title.js +26 -0
  286. package/lib/Title/index.js +7 -0
  287. package/lib/Title/style/index.js +34 -0
  288. package/lib/ValueItem/ValueItem.js +113 -0
  289. package/lib/ValueItem/index.js +7 -0
  290. package/lib/ValueItem/util.js +17 -0
  291. package/lib/VirtualTable/VirtualTable.js +271 -0
  292. package/lib/VirtualTable/data.js +60 -0
  293. package/lib/VirtualTable/index.js +7 -0
  294. package/lib/VirtualTable/style/index.js +34 -0
  295. package/lib/components.js +21 -0
  296. package/lib/index.js +17 -0
  297. package/lib/locale/en-US.js +120 -0
  298. package/lib/locale/zh-CN.js +120 -0
  299. package/lib/style/styleRegister.js +19 -0
  300. package/lib/style/variable.js +4 -0
  301. package/lib/style.js +1 -0
  302. package/lib/utils/constants.js +10 -0
  303. 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,2 @@
1
+ export * from './useTableSelection'
2
+ export * from './useTableInject'
@@ -0,0 +1,6 @@
1
+ import { inject, } from 'vue'
2
+ import { PROTABLE_ROW_SELECTION_KEY, } from './useTableSelection'
3
+
4
+ export const useTableInject = () => {
5
+ return inject(PROTABLE_ROW_SELECTION_KEY, null )
6
+ }
@@ -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,8 @@
1
+ import ProTable from './ProTable.js'
2
+
3
+ ProTable.install = function (app) {
4
+ app.component(ProTable.name, ProTable)
5
+ }
6
+
7
+ export default ProTable
8
+ export * from './hooks'
@@ -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])