@jetlinks-web/components 2.0.2 → 2.0.3

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 (237) hide show
  1. package/es/AMap/Map.js +124 -0
  2. package/es/AMap/index.js +2 -0
  3. package/es/AMap/util.js +56 -0
  4. package/es/BadgeStatus/Badge.js +54 -0
  5. package/es/BadgeStatus/color.js +21 -0
  6. package/es/BadgeStatus/index.js +3 -0
  7. package/es/CardSelect/CardSelect.js +123 -0
  8. package/es/CardSelect/index.js +2 -0
  9. package/es/CheckButton/CheckButton.js +121 -0
  10. package/es/CheckButton/index.js +2 -0
  11. package/es/ConfigProvider/context.js +12 -0
  12. package/es/ConfigProvider/index.js +31 -0
  13. package/es/Echarts/Echarts.js +47 -0
  14. package/es/Echarts/index.js +2 -0
  15. package/es/Ellipsis/Ellipsis.js +189 -0
  16. package/es/Ellipsis/index.js +2 -0
  17. package/es/Empty/Empty.js +56 -0
  18. package/es/Empty/image.js +2 -0
  19. package/es/Empty/index.js +2 -0
  20. package/es/FullPage/FullPage.js +31 -0
  21. package/es/FullPage/index.js +2 -0
  22. package/es/Icon/icon.js +42 -0
  23. package/{src/Icon/index.ts → es/Icon/index.js} +2 -3
  24. package/es/MonacoEditor/Monaco.js +238 -0
  25. package/es/MonacoEditor/index.js +2 -0
  26. package/es/PermissionButton/index.js +117 -0
  27. package/es/ProLayout/Basic/BasicLayout.js +259 -0
  28. package/es/ProLayout/Basic/Header.js +97 -0
  29. package/es/ProLayout/PageContainer/index.js +324 -0
  30. package/es/ProLayout/PageContainer/typings.js +1 -0
  31. package/es/ProLayout/RouteContext.js +22 -0
  32. package/es/ProLayout/SiderMenu/BaseMenu.js +285 -0
  33. package/es/ProLayout/SiderMenu/SiderMenu.js +278 -0
  34. package/es/ProLayout/SiderMenu/index.js +2 -0
  35. package/es/ProLayout/SiderMenu/typings.js +1 -0
  36. package/es/ProLayout/TopHeader/index.js +163 -0
  37. package/es/ProLayout/defaultSettings.js +66 -0
  38. package/{src/ProLayout/index.ts → es/ProLayout/index.js} +4 -6
  39. package/{src → es}/ProLayout/style/default.less +4 -4
  40. package/es/ProLayout/style/index.js +1 -0
  41. package/es/ProLayout/typings.js +1 -0
  42. package/es/ProLayout/util.js +61 -0
  43. package/es/ProTable/index.js +411 -0
  44. package/es/ProTable/proTableTypes.js +11 -0
  45. package/es/ProTable/style/index.css +65 -0
  46. package/es/ProTable/style/index.js +1 -0
  47. package/es/Scrollbar/Bar.js +114 -0
  48. package/es/Scrollbar/Scrollbar.js +212 -0
  49. package/es/Scrollbar/Thumb.js +189 -0
  50. package/es/Scrollbar/constants.js +1 -0
  51. package/es/Scrollbar/index.js +2 -0
  52. package/es/Scrollbar/scrollbarProps.js +100 -0
  53. package/es/Scrollbar/thumbProps.js +10 -0
  54. package/es/Scrollbar/util.js +30 -0
  55. package/es/Search/Advanced/History.js +183 -0
  56. package/es/Search/Advanced/SaveHistory.js +153 -0
  57. package/es/Search/Advanced/index.js +520 -0
  58. package/es/Search/Item.js +497 -0
  59. package/es/Search/Search.js +249 -0
  60. package/es/Search/hooks/index.js +1 -0
  61. package/es/Search/hooks/useSearchItems.js +40 -0
  62. package/es/Search/index.js +4 -0
  63. package/es/Search/setting.js +91 -0
  64. package/es/Search/style/Item.less +33 -0
  65. package/es/Search/style/Search.less +179 -0
  66. package/es/Search/style/index.js +2 -0
  67. package/es/Search/typing.js +1 -0
  68. package/es/Search/util.js +234 -0
  69. package/es/ValueItem/ValueItem.js +233 -0
  70. package/es/ValueItem/index.js +2 -0
  71. package/es/ValueItem/util.js +16 -0
  72. package/es/index.js +24 -0
  73. package/es/style/index.js +3 -0
  74. package/es/style/variable.css +0 -0
  75. package/{src → es}/style/variable.less +0 -2
  76. package/es/style.js +3 -0
  77. package/lib/AMap/Map.js +124 -0
  78. package/lib/AMap/index.js +9 -0
  79. package/lib/AMap/util.js +62 -0
  80. package/lib/BadgeStatus/Badge.js +54 -0
  81. package/lib/BadgeStatus/color.js +27 -0
  82. package/lib/BadgeStatus/index.js +22 -0
  83. package/lib/CardSelect/CardSelect.js +123 -0
  84. package/lib/CardSelect/index.js +9 -0
  85. package/lib/CheckButton/CheckButton.js +121 -0
  86. package/lib/CheckButton/index.js +9 -0
  87. package/lib/ConfigProvider/context.js +19 -0
  88. package/lib/ConfigProvider/index.js +37 -0
  89. package/lib/Echarts/Echarts.js +47 -0
  90. package/lib/Echarts/index.js +9 -0
  91. package/lib/Ellipsis/Ellipsis.js +189 -0
  92. package/lib/Ellipsis/index.js +9 -0
  93. package/lib/Empty/Empty.js +56 -0
  94. package/lib/Empty/image.js +8 -0
  95. package/lib/Empty/index.js +9 -0
  96. package/lib/FullPage/FullPage.js +31 -0
  97. package/lib/FullPage/index.js +9 -0
  98. package/lib/Icon/icon.js +52 -0
  99. package/lib/Icon/index.js +9 -0
  100. package/lib/MonacoEditor/Monaco.js +238 -0
  101. package/lib/MonacoEditor/index.js +9 -0
  102. package/lib/PermissionButton/index.js +124 -0
  103. package/lib/ProLayout/Basic/BasicLayout.js +268 -0
  104. package/lib/ProLayout/Basic/BasicLayout.less +66 -0
  105. package/lib/ProLayout/Basic/Header.js +103 -0
  106. package/lib/ProLayout/Basic/Header.less +8 -0
  107. package/lib/ProLayout/PageContainer/index.js +327 -0
  108. package/lib/ProLayout/PageContainer/index.less +103 -0
  109. package/lib/ProLayout/PageContainer/typings.js +5 -0
  110. package/lib/ProLayout/RouteContext.js +28 -0
  111. package/lib/ProLayout/SiderMenu/BaseMenu.js +290 -0
  112. package/lib/ProLayout/SiderMenu/SiderMenu.js +287 -0
  113. package/lib/ProLayout/SiderMenu/index.js +20 -0
  114. package/lib/ProLayout/SiderMenu/index.less +212 -0
  115. package/lib/ProLayout/SiderMenu/typings.js +5 -0
  116. package/lib/ProLayout/TopHeader/index.js +168 -0
  117. package/lib/ProLayout/TopHeader/index.less +174 -0
  118. package/lib/ProLayout/defaultSettings.js +72 -0
  119. package/lib/ProLayout/index.js +16 -0
  120. package/lib/ProLayout/style/default.less +4 -0
  121. package/lib/ProLayout/style/index.js +3 -0
  122. package/lib/ProLayout/style/style.less +7 -0
  123. package/lib/ProLayout/typings.js +5 -0
  124. package/lib/ProLayout/util.js +72 -0
  125. package/lib/ProTable/index.js +417 -0
  126. package/lib/ProTable/proTableTypes.js +17 -0
  127. package/lib/ProTable/style/index.css +65 -0
  128. package/lib/ProTable/style/index.js +3 -0
  129. package/lib/ProTable/style/index.less +92 -0
  130. package/lib/Scrollbar/Bar.js +114 -0
  131. package/lib/Scrollbar/Scrollbar.js +212 -0
  132. package/lib/Scrollbar/Thumb.js +189 -0
  133. package/lib/Scrollbar/constants.js +7 -0
  134. package/lib/Scrollbar/index.js +9 -0
  135. package/{src/Scrollbar/scrollbar.ts → lib/Scrollbar/scrollbarProps.js} +106 -108
  136. package/lib/Scrollbar/thumbProps.js +16 -0
  137. package/lib/Scrollbar/util.js +37 -0
  138. package/lib/Search/Advanced/History.js +183 -0
  139. package/lib/Search/Advanced/SaveHistory.js +153 -0
  140. package/lib/Search/Advanced/index.js +520 -0
  141. package/lib/Search/Item.js +497 -0
  142. package/lib/Search/Search.js +249 -0
  143. package/lib/Search/hooks/index.js +16 -0
  144. package/lib/Search/hooks/useSearchItems.js +47 -0
  145. package/lib/Search/index.js +16 -0
  146. package/lib/Search/setting.js +97 -0
  147. package/lib/Search/style/Item.less +33 -0
  148. package/lib/Search/style/Search.less +179 -0
  149. package/lib/Search/style/index.js +4 -0
  150. package/lib/Search/typing.js +5 -0
  151. package/lib/Search/util.js +241 -0
  152. package/lib/ValueItem/ValueItem.js +233 -0
  153. package/lib/ValueItem/index.js +9 -0
  154. package/lib/ValueItem/util.js +22 -0
  155. package/lib/index.js +158 -0
  156. package/lib/style/components.less +1 -0
  157. package/lib/style/index.js +4 -0
  158. package/lib/style/variable.css +0 -0
  159. package/lib/style/variable.less +2 -0
  160. package/lib/style.js +5 -0
  161. package/package.json +122 -13
  162. package/index.ts +0 -64
  163. package/src/AMap/Map.vue +0 -110
  164. package/src/AMap/index.ts +0 -1
  165. package/src/AMap/util.ts +0 -56
  166. package/src/BadgeStatus/Badge.vue +0 -41
  167. package/src/BadgeStatus/color.ts +0 -25
  168. package/src/BadgeStatus/index.ts +0 -4
  169. package/src/CardSelect/CardSelect.vue +0 -136
  170. package/src/CardSelect/index.ts +0 -3
  171. package/src/CheckButton/CheckButton.vue +0 -146
  172. package/src/CheckButton/index.md +0 -27
  173. package/src/CheckButton/index.ts +0 -3
  174. package/src/ConfigProvider/context.ts +0 -17
  175. package/src/ConfigProvider/index.tsx +0 -42
  176. package/src/Echarts/Echarts.vue +0 -43
  177. package/src/Echarts/index.ts +0 -3
  178. package/src/Ellipsis/Ellipsis.vue +0 -182
  179. package/src/Ellipsis/index.ts +0 -3
  180. package/src/Empty/Empty.vue +0 -43
  181. package/src/Empty/image.ts +0 -3
  182. package/src/Empty/index.ts +0 -2
  183. package/src/FullPage/FullPage.vue +0 -30
  184. package/src/FullPage/index.ts +0 -3
  185. package/src/Icon/icon.tsx +0 -40
  186. package/src/MonacoEditor/Monaco.vue +0 -242
  187. package/src/MonacoEditor/index.md +0 -26
  188. package/src/MonacoEditor/index.ts +0 -2
  189. package/src/PermissionButton/index.tsx +0 -110
  190. package/src/ProLayout/Basic/BasicLayout.tsx +0 -392
  191. package/src/ProLayout/Basic/Header.tsx +0 -115
  192. package/src/ProLayout/PageContainer/index.tsx +0 -441
  193. package/src/ProLayout/PageContainer/typings.ts +0 -56
  194. package/src/ProLayout/RouteContext.ts +0 -87
  195. package/src/ProLayout/SiderMenu/BaseMenu.tsx +0 -296
  196. package/src/ProLayout/SiderMenu/SiderMenu.tsx +0 -320
  197. package/src/ProLayout/SiderMenu/index.ts +0 -2
  198. package/src/ProLayout/SiderMenu/typings.ts +0 -49
  199. package/src/ProLayout/TopHeader/index.tsx +0 -210
  200. package/src/ProLayout/defaultSettings.ts +0 -106
  201. package/src/ProLayout/style/index.ts +0 -1
  202. package/src/ProLayout/typings.ts +0 -87
  203. package/src/ProLayout/util.ts +0 -64
  204. package/src/ProTable/index.md +0 -53
  205. package/src/ProTable/index.tsx +0 -551
  206. package/src/ProTable/proTableTypes.ts +0 -70
  207. package/src/ProTable/style/index.ts +0 -1
  208. package/src/Scrollbar/Bar.vue +0 -75
  209. package/src/Scrollbar/Scrollbar.vue +0 -260
  210. package/src/Scrollbar/Thumb.vue +0 -163
  211. package/src/Scrollbar/constants.ts +0 -10
  212. package/src/Scrollbar/index.ts +0 -4
  213. package/src/Scrollbar/thumb.ts +0 -16
  214. package/src/Scrollbar/util.ts +0 -38
  215. package/src/Search/Advanced/History.vue +0 -140
  216. package/src/Search/Advanced/SaveHistory.vue +0 -108
  217. package/src/Search/Advanced/index.vue +0 -435
  218. package/src/Search/Item.vue +0 -525
  219. package/src/Search/Search.vue +0 -398
  220. package/src/Search/hooks/index.ts +0 -1
  221. package/src/Search/hooks/useSearchItems.ts +0 -68
  222. package/src/Search/index.md +0 -57
  223. package/src/Search/index.ts +0 -5
  224. package/src/Search/setting.ts +0 -55
  225. package/src/Search/typing.ts +0 -76
  226. package/src/Search/util.ts +0 -263
  227. package/src/ValueItem/ValueItem.vue +0 -192
  228. package/src/ValueItem/index.ts +0 -3
  229. package/src/ValueItem/util.ts +0 -16
  230. package/src/style/index.ts +0 -3
  231. /package/{src → es}/ProLayout/Basic/BasicLayout.less +0 -0
  232. /package/{src → es}/ProLayout/Basic/Header.less +0 -0
  233. /package/{src → es}/ProLayout/PageContainer/index.less +0 -0
  234. /package/{src → es}/ProLayout/SiderMenu/index.less +0 -0
  235. /package/{src → es}/ProLayout/TopHeader/index.less +0 -0
  236. /package/{src → es}/ProLayout/style/style.less +0 -0
  237. /package/{src → es}/ProTable/style/index.less +0 -0
@@ -1,551 +0,0 @@
1
- import { Empty, AIcon } from '../../../components';
2
- import { Table, Pagination, Button, Alert, Spin, RadioGroup, RadioButton } from 'ant-design-vue'
3
- import type { RadioChangeEvent } from 'ant-design-vue/es/radio';
4
- import type { TableProps } from 'ant-design-vue/es/table';
5
- import { tableProps as _tableProps } from 'ant-design-vue/es/table';
6
- import {
7
- defineComponent,
8
- onMounted,
9
- onUnmounted,
10
- PropType,
11
- ref,
12
- watch,
13
- } from 'vue';
14
- import {
15
- JColumnProps,
16
- ModelEnum,
17
- TypeEnum,
18
- RequestData,
19
- } from './proTableTypes';
20
- import { get, debounce, isArray } from 'lodash-es';
21
-
22
- export interface JTableProps extends TableProps {
23
- request?: (params?: Record<string, any>) => Promise<Partial<RequestData>>;
24
- cardBodyClass?: string;
25
- columns: JColumnProps[];
26
- model?: keyof typeof ModelEnum | undefined; // 显示table还是card
27
-
28
- modelValue?: keyof typeof ModelEnum | undefined;
29
- noPagination?: boolean;
30
- rowSelection?: TableProps['rowSelection'];
31
- dataSource?: Record<string, any>[];
32
- params?: Record<string, any>;
33
- gridColumn?: number;
34
- gridColumns?: number[];
35
- alertRender?: boolean;
36
- type?: keyof typeof TypeEnum;
37
- defaultParams?: Record<string, any>;
38
- bodyStyle?: Record<string, any>;
39
- pageIndex: number;
40
- pageSize: number;
41
- total: number;
42
- column: number;
43
- }
44
-
45
- const tableProps = () => {
46
- return {
47
- ..._tableProps(),
48
- loading: {
49
- type: Boolean,
50
- default: undefined,
51
- },
52
- request: {
53
- type: Function,
54
- default: undefined,
55
- },
56
- cardBodyClass: {
57
- type: String,
58
- default: '',
59
- },
60
- bodyStyle: {
61
- type: Object,
62
- default: {},
63
- },
64
- columns: {
65
- type: Array,
66
- default: () => [],
67
- },
68
- model: {
69
- type: [String, undefined],
70
- default: undefined,
71
- },
72
- modelValue: {
73
- type: String,
74
- default: undefined,
75
- },
76
- noPagination: {
77
- type: Boolean,
78
- default: false,
79
- },
80
- rowSelection: {
81
- type: Object as PropType<TableProps['rowSelection']>,
82
- default: () => undefined,
83
- },
84
- dataSource: {
85
- type: Array,
86
- default: () => [],
87
- },
88
- gridColumns: {
89
- type: Array as PropType<number[]>,
90
- default: () => [],
91
- },
92
- gridColumn: {
93
- type: Number,
94
- default: 4,
95
- },
96
- alertRender: {
97
- type: Boolean,
98
- default: true,
99
- },
100
- params: {
101
- type: Object,
102
- default: () => {
103
- },
104
- },
105
- type: {
106
- type: String,
107
- default: 'PAGE',
108
- },
109
- scroll: {
110
- type: Object,
111
- default: () => {
112
- x: 1366;
113
- },
114
- },
115
- defaultParams: {
116
- type: Object,
117
- default: () => {
118
- },
119
- },
120
- rowKey: {
121
- type: [String, Function],
122
- default: 'id',
123
- },
124
- pagination: {
125
- type: Object, // Boolean,
126
- default: () => {
127
- return {
128
- showSizeChanger: true,
129
- showQuickJumper: false,
130
- size: 'size',
131
- pageSizeOptions: ['12', '24', '48', '96'],
132
- };
133
- },
134
- },
135
- };
136
- };
137
-
138
- const ProTable = defineComponent<JTableProps>({
139
- name: 'ProTable',
140
- slots: [
141
- 'headerTitle', // 顶部左边插槽
142
- 'card', // 卡片内容
143
- 'rightExtraRender',
144
- 'paginationRender', // 分页
145
- ],
146
- props: tableProps() as any,
147
- emits: ['update:modelValue', 'modelChange'],
148
- setup(props: JTableProps, {slots, expose, emit}) {
149
- const _model = ref<keyof typeof ModelEnum>(
150
- props.model ? props.model : ModelEnum.CARD,
151
- ); // 模式切换
152
-
153
- const _dataSource = ref<Record<string, any>[]>([]);
154
- const pageIndex = ref<number>(0);
155
- const pageSize = ref<number>(12);
156
- const total = ref<number>(0);
157
- const _loading = ref<boolean>(false);
158
- const column = ref<number>(props.gridColumn || 4);
159
-
160
- if (
161
- !props.noPagination &&
162
- props.pagination &&
163
- isArray(props.pagination?.pageSizeOptions)
164
- ) {
165
- pageSize.value = props.pagination.pageSizeOptions[0] as number;
166
- }
167
-
168
- /**
169
- * 监听宽度,计算显示卡片个数
170
- */
171
- const windowChange = () => {
172
- if (window.innerWidth <= 1440) {
173
- const _column =
174
- props.gridColumn && props.gridColumn < 2
175
- ? props.gridColumn
176
- : 2;
177
- column.value = props.gridColumns?.[0]
178
- ? props.gridColumns[0]
179
- : _column;
180
- } else if (window.innerWidth > 1440 && window.innerWidth <= 1600) {
181
- const _column =
182
- props.gridColumn && props.gridColumn < 3
183
- ? props.gridColumn
184
- : 3;
185
- column.value = props.gridColumns?.[1]
186
- ? props.gridColumns[1]
187
- : _column;
188
- } else if (window.innerWidth > 1600) {
189
- const _column =
190
- props.gridColumn && props.gridColumn < 4
191
- ? props.gridColumn
192
- : 4;
193
- column.value = props.gridColumns?.[2]
194
- ? props.gridColumns[2]
195
- : _column;
196
- }
197
- };
198
-
199
- const handleSearch = async (_params?: Record<string, any>) => {
200
- _loading.value =
201
- props.loading !== undefined ? (props.loading as boolean) : true;
202
- if (props.request) {
203
- console.log(_params);
204
- const resp: any = await props
205
- .request({
206
- pageIndex: 0,
207
- pageSize: Number(pageSize.value),
208
- ...props.defaultParams,
209
- ..._params,
210
- terms: [
211
- ...(props.defaultParams?.terms || []),
212
- ...(_params?.terms || []),
213
- ],
214
- })
215
- .catch(() => {
216
- _loading.value =
217
- props.loading !== undefined
218
- ? (props.loading as boolean)
219
- : false;
220
- });
221
- if (resp.status === 200) {
222
- if (props.type === 'PAGE') {
223
- // 判断如果是最后一页且最后一页为空,就跳转到前一页
224
- if (
225
- resp?.result?.total &&
226
- resp?.result?.pageSize &&
227
- resp?.result?.pageIndex &&
228
- resp?.result?.data?.length === 0
229
- ) {
230
- pageIndex.value =
231
- pageIndex.value > 0 ? pageIndex.value - 1 : 0;
232
-
233
- handleSearch({
234
- ..._params,
235
- pageSize: pageSize.value,
236
- pageIndex: pageIndex.value,
237
- });
238
- } else {
239
- _dataSource.value = resp?.result?.data || [];
240
- pageIndex.value = resp?.result?.pageIndex || 0;
241
- pageSize.value = resp?.result?.pageSize || 12;
242
- total.value = resp?.result?.total || 0;
243
- }
244
- } else {
245
- _dataSource.value = resp?.result || [];
246
- }
247
- } else {
248
- _dataSource.value = [];
249
- }
250
- } else {
251
- _dataSource.value = props?.dataSource || [];
252
- }
253
- _loading.value =
254
- props.loading !== undefined
255
- ? (props.loading as boolean)
256
- : false;
257
- };
258
-
259
- const _debounceFn = debounce(handleSearch, 300);
260
-
261
- watch(
262
- () => props.params,
263
- (newValue) => {
264
- _debounceFn(newValue || {});
265
- },
266
- {deep: true, immediate: true},
267
- );
268
-
269
- watch(
270
- () => props.dataSource,
271
- (newVal) => {
272
- if (newVal && !props.request) {
273
- handleSearch(props.params);
274
- }
275
- },
276
- {deep: true, immediate: true},
277
- );
278
-
279
- watch(
280
- () => props.modelValue,
281
- () => {
282
- if (props.modelValue) {
283
- _model.value = props.modelValue;
284
- }
285
- },
286
- {immediate: true},
287
- );
288
-
289
- /**
290
- * 刷新数据
291
- * @param _params
292
- */
293
- const reload = (_params?: Record<string, any>) => {
294
- handleSearch({
295
- ...props.params,
296
- ..._params,
297
- pageSize: pageSize.value || 12, // 刷新页面不改变分页情况
298
- pageIndex: pageIndex.value || 0,
299
- });
300
- };
301
-
302
- onMounted(() => {
303
- windowChange(); // 初始化
304
- window.onresize = () => {
305
- windowChange();
306
- };
307
- });
308
-
309
- onUnmounted(() => {
310
- window.onresize = null;
311
- });
312
-
313
- /**
314
- * 导出方法
315
- */
316
- expose({reload, _dataSource});
317
-
318
- return () => (
319
- <div class="jtable-body-spin" style={{...props.bodyStyle}}>
320
- <Spin spinning={_loading.value}>
321
- <div class={'jtable-body'}>
322
- <div class={'jtable-body-header'}>
323
- <div class={'jtable-body-header-left'}>
324
- {/* 顶部左边插槽 */}
325
- {slots.headerTitle && slots.headerTitle()}
326
- </div>
327
- <div class={'jtable-body-header-right'}>
328
- {/* 顶部右边插槽 */}
329
- {slots.rightExtraRender &&
330
- slots.rightExtraRender()}
331
- {!props.model && (
332
- <div
333
- class={
334
- 'jtable-body-header-right-button'
335
- }
336
- >
337
- <RadioGroup
338
- class="jtable-body-header-right-button"
339
- value={_model.value}
340
- onChange={(e: RadioChangeEvent) => {
341
- _model.value = e.target.value;
342
- emit(
343
- 'update:modelValue',
344
- e.target.value,
345
- );
346
- emit(
347
- 'modelChange',
348
- e.target.value,
349
- );
350
- }}
351
- >
352
- <RadioButton
353
- value={ModelEnum.TABLE}
354
- >
355
- <AIcon
356
- class={'right-button-icon'}
357
- type="UnorderedListOutlined"
358
- />
359
- </RadioButton>
360
- <RadioButton value={ModelEnum.CARD}>
361
- <AIcon
362
- class={'right-button-icon'}
363
- type="AppstoreOutlined"
364
- />
365
- </RadioButton>
366
- </RadioGroup>
367
- </div>
368
- )}
369
- </div>
370
- </div>
371
- {/* content */}
372
- <div class={'jtable-content'}>
373
- {props.alertRender &&
374
- props?.rowSelection &&
375
- props?.rowSelection?.selectedRowKeys &&
376
- props.rowSelection.selectedRowKeys?.length ? (
377
- <div class={'jtable-alert'}>
378
- <Alert
379
- message={
380
- '已选择' +
381
- props?.rowSelection?.selectedRowKeys
382
- ?.length +
383
- '项'
384
- }
385
- type="info"
386
- onClose={() => {
387
- // if (props.rowSelection?.onSelectNone) {
388
- // // 取消选择清空被选数据
389
- // }
390
- props.rowSelection?.onChange?.(
391
- [],
392
- [],
393
- );
394
- props.rowSelection?.onSelectNone?.();
395
- }}
396
- closeText={
397
- <Button type="link">
398
- 取消选择
399
- </Button>
400
- }
401
- />
402
- </div>
403
- ) : null}
404
- {_model.value === ModelEnum.CARD ? (
405
- <div
406
- class={'jtable-card'}
407
- style={
408
- props.scroll && props.scroll.y
409
- ? {
410
- maxHeight:
411
- props.scroll.y + 'px',
412
- overflow: 'auto',
413
- }
414
- : undefined
415
- }
416
- >
417
- {_dataSource.value.length ? (
418
- <div
419
- class={'jtable-card-items'}
420
- style={{
421
- gridTemplateColumns: `repeat(${column.value}, 1fr)`,
422
- }}
423
- >
424
- {_dataSource.value.map((item) =>
425
- slots.card ? (
426
- <div
427
- class={[
428
- 'jtable-card-item',
429
- props.cardBodyClass,
430
- ]}
431
- >
432
- {slots.card(item)}
433
- </div>
434
- ) : null,
435
- )}
436
- </div>
437
- ) : (
438
- <div class="j-table-empty">
439
- <Empty/>
440
- </div>
441
- )}
442
- </div>
443
- ) : (
444
- <div>
445
- <Table
446
- {...props}
447
- dataSource={_dataSource.value}
448
- columns={props.columns.filter(
449
- (i) => !i?.hideInTable,
450
- )}
451
- pagination={false}
452
- rowSelection={props.rowSelection}
453
- scroll={props.scroll}
454
- v-slots={{
455
- headerCell: (
456
- dt: Record<string, any>,
457
- ) => {
458
- const {column, title} = dt;
459
- if (column?.headerCell) {
460
- return slots?.[
461
- column?.headerCell
462
- ]!(column.title);
463
- } else {
464
- return title || '';
465
- }
466
- },
467
- bodyCell: (
468
- dt: Record<string, any>,
469
- ) => {
470
- const {column, record} = dt;
471
- if (
472
- (column?.key ||
473
- column?.dataIndex) &&
474
- column?.scopedSlots &&
475
- (slots?.[
476
- column?.dataIndex
477
- ] ||
478
- slots?.[column?.key])
479
- ) {
480
- const _key =
481
- column?.key ||
482
- column?.dataIndex;
483
- return slots?.[_key]!(
484
- record,
485
- );
486
- } else {
487
- const _value = get(
488
- record,
489
- column?.dataIndex,
490
- );
491
- // 获取数据
492
- return _value;
493
- }
494
- },
495
- emptyText: () => <Empty/>,
496
- }}
497
- />
498
- </div>
499
- )}
500
- </div>
501
- {/* 分页 */}
502
- {!!_dataSource.value.length &&
503
- !props.noPagination &&
504
- props.type === 'PAGE' && (
505
- <div class={'jtable-pagination'}>
506
- {slots?.paginationRender ? (
507
- slots.paginationRender()
508
- ) : (
509
- <Pagination
510
- {...props.pagination}
511
- total={total.value}
512
- current={pageIndex.value + 1}
513
- pageSize={pageSize.value}
514
- showTotal={(num) => {
515
- const minSize =
516
- pageIndex.value *
517
- pageSize.value +
518
- 1;
519
- const MaxSize =
520
- (pageIndex.value + 1) *
521
- pageSize.value;
522
- return `第 ${minSize} - ${
523
- MaxSize > num
524
- ? num
525
- : MaxSize
526
- } 条/总共 ${num} 条`;
527
- }}
528
- onChange={(page, size) => {
529
- handleSearch({
530
- ...props.params,
531
- pageSize: size,
532
- pageIndex:
533
- pageSize.value === size
534
- ? page
535
- ? page - 1
536
- : 0
537
- : 0,
538
- });
539
- }}
540
- />
541
- )}
542
- </div>
543
- )}
544
- </div>
545
- </Spin>
546
- </div>
547
- );
548
- },
549
- });
550
-
551
- export default ProTable;
@@ -1,70 +0,0 @@
1
- /**
2
- * 公共类型数据
3
- */
4
- import type { TableProps, ColumnProps } from 'ant-design-vue/es/table';
5
- import type { TooltipProps } from 'ant-design-vue/es/tooltip';
6
- import type { PopconfirmProps } from 'ant-design-vue/es/popconfirm';
7
- import { CSSProperties } from 'vue';
8
-
9
- export enum TypeEnum {
10
- TREE = 'TREE',
11
- PAGE = 'PAGE',
12
- }
13
-
14
- export enum ModelEnum {
15
- TABLE = 'TABLE',
16
- CARD = 'CARD',
17
- }
18
-
19
- export type ModelType = keyof typeof ModelEnum;
20
-
21
- export type RequestData =
22
- | {
23
- code: string;
24
- result: {
25
- data: Record<string, any>[] | undefined;
26
- pageIndex: number;
27
- pageSize: number;
28
- total: number;
29
- };
30
- status: number;
31
- }
32
- | Record<string, any>;
33
-
34
- export type ActionsType = {
35
- key: string;
36
- text?: string;
37
- disabled?: boolean;
38
- permission?: boolean;
39
- onClick?: (data: any) => void;
40
- style?: CSSProperties;
41
- tooltip?: TooltipProps;
42
- popConfirm?: PopconfirmProps;
43
- icon?: string;
44
- };
45
-
46
- export interface JColumnProps extends ColumnProps {
47
- scopedSlots?: boolean; // 是否为插槽 true: 是 false: 否
48
- hideInTable?: boolean; //
49
- }
50
-
51
- export interface CommonProps extends TableProps {
52
- cardBodyClass?: string;
53
- columns: JColumnProps[];
54
- model?: ModelType; // 显示table还是card
55
- noPagination?: boolean;
56
- rowSelection?: TableProps['rowSelection'];
57
- // cardProps?: Record<string, any>;
58
- dataSource?: Record<string, any>[];
59
- gridColumn?: number;
60
- /**
61
- * 用于不同分辨率
62
- * gridColumns[0] 1366 ~ 1440 分辨率;
63
- * gridColumns[1] 1440 ~ 1600 分辨率;
64
- * gridColumns[2] > 1600 分辨率;
65
- */
66
- gridColumns?: number[];
67
- alertRender?: boolean; // 选择提示框
68
- type?: keyof typeof TypeEnum; // 判断表格类型:SCROLL:滑动表格; TREE:树表格; PAGE:分页表格
69
- bodyStyle?: Record<string, any>;
70
- }
@@ -1 +0,0 @@
1
- import './index.less';
@@ -1,75 +0,0 @@
1
- <template>
2
- <thumb :move="moveX" :ratio="ratioX" :size="sizeWidth" :always="always"/>
3
- <thumb
4
- :move="moveY"
5
- :ratio="ratioY"
6
- :size="sizeHeight"
7
- vertical
8
- :always="always"
9
- />
10
- </template>
11
- <script lang="ts" setup>
12
- import { inject, ref } from 'vue'
13
- import { GAP } from './util'
14
- import Thumb from './Thumb.vue'
15
- import { scrollbarContextKey } from './constants'
16
-
17
- const props = defineProps({
18
- always: {
19
- type: Boolean,
20
- default: true,
21
- },
22
- minSize: {
23
- type: Number,
24
- required: true,
25
- }
26
- })
27
-
28
- const scrollbar = inject(scrollbarContextKey)
29
-
30
- const moveX = ref(0)
31
- const moveY = ref(0)
32
- const sizeWidth = ref('')
33
- const sizeHeight = ref('')
34
- const ratioY = ref(1)
35
- const ratioX = ref(1)
36
-
37
- const handleScroll = (wrap: HTMLDivElement) => {
38
- if (wrap) {
39
- const offsetHeight = wrap.offsetHeight - GAP
40
- const offsetWidth = wrap.offsetWidth - GAP
41
-
42
- moveY.value = ((wrap.scrollTop * 100) / offsetHeight) * ratioY.value
43
- moveX.value = ((wrap.scrollLeft * 100) / offsetWidth) * ratioX.value
44
- }
45
- }
46
-
47
- const update = () => {
48
- const wrap = scrollbar?.wrapElement
49
- if (!wrap) return
50
- const offsetHeight = wrap.offsetHeight - GAP
51
- const offsetWidth = wrap.offsetWidth - GAP
52
-
53
- const originalHeight = offsetHeight ** 2 / wrap.scrollHeight
54
- const originalWidth = offsetWidth ** 2 / wrap.scrollWidth
55
- const height = Math.max(originalHeight, props.minSize)
56
- const width = Math.max(originalWidth, props.minSize)
57
-
58
- ratioY.value =
59
- originalHeight /
60
- (offsetHeight - originalHeight) /
61
- (height / (offsetHeight - height))
62
- ratioX.value =
63
- originalWidth /
64
- (offsetWidth - originalWidth) /
65
- (width / (offsetWidth - width))
66
-
67
- sizeHeight.value = height + GAP < offsetHeight ? `${height}px` : ''
68
- sizeWidth.value = width + GAP < offsetWidth ? `${width}px` : ''
69
- }
70
-
71
- defineExpose({
72
- handleScroll,
73
- update,
74
- })
75
- </script>