@jetlinks-web/components 1.0.4 → 2.0.0

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 (80) hide show
  1. package/index.ts +54 -15
  2. package/package.json +9 -6
  3. package/src/AMap/Map.vue +110 -107
  4. package/src/BadgeStatus/Badge.vue +41 -40
  5. package/src/BadgeStatus/color.ts +25 -23
  6. package/src/CardSelect/CardSelect.vue +136 -0
  7. package/src/CardSelect/index.ts +3 -0
  8. package/src/CheckButton/CheckButton.vue +146 -0
  9. package/src/CheckButton/index.md +27 -0
  10. package/src/CheckButton/index.ts +3 -0
  11. package/src/ConfigProvider/context.ts +17 -0
  12. package/src/ConfigProvider/index.tsx +42 -0
  13. package/src/Echarts/Echarts.vue +43 -43
  14. package/src/Ellipsis/Ellipsis.vue +182 -0
  15. package/src/Ellipsis/index.ts +3 -0
  16. package/src/Empty/Empty.vue +43 -0
  17. package/src/Empty/image.ts +3 -0
  18. package/src/Empty/index.ts +2 -0
  19. package/src/FullPage/{index.vue → FullPage.vue} +30 -27
  20. package/src/FullPage/index.ts +3 -0
  21. package/src/Icon/icon.tsx +40 -0
  22. package/src/Icon/index.ts +3 -0
  23. package/src/MonacoEditor/Monaco.vue +242 -0
  24. package/src/MonacoEditor/index.md +26 -0
  25. package/src/MonacoEditor/index.ts +2 -0
  26. package/src/PermissionButton/index.tsx +95 -92
  27. package/src/ProLayout/Basic/BasicLayout.less +66 -0
  28. package/src/ProLayout/Basic/BasicLayout.tsx +392 -0
  29. package/src/ProLayout/Basic/Header.less +8 -0
  30. package/src/ProLayout/Basic/Header.tsx +115 -0
  31. package/src/ProLayout/PageContainer/index.less +103 -0
  32. package/src/ProLayout/PageContainer/index.tsx +441 -0
  33. package/src/ProLayout/PageContainer/typings.ts +56 -0
  34. package/src/ProLayout/RouteContext.ts +87 -0
  35. package/src/ProLayout/SiderMenu/BaseMenu.tsx +296 -0
  36. package/src/ProLayout/SiderMenu/SiderMenu.tsx +320 -0
  37. package/src/ProLayout/SiderMenu/index.less +212 -0
  38. package/src/ProLayout/SiderMenu/index.ts +2 -0
  39. package/src/ProLayout/SiderMenu/typings.ts +49 -0
  40. package/src/ProLayout/TopHeader/index.less +174 -0
  41. package/src/ProLayout/TopHeader/index.tsx +210 -0
  42. package/src/ProLayout/defaultSettings.ts +106 -0
  43. package/src/ProLayout/index.ts +6 -0
  44. package/src/ProLayout/style/default.less +4 -0
  45. package/src/ProLayout/style/index.ts +1 -0
  46. package/src/ProLayout/style/style.less +7 -0
  47. package/src/ProLayout/typings.ts +87 -0
  48. package/src/ProLayout/util.ts +64 -0
  49. package/src/ProTable/index.md +53 -0
  50. package/src/ProTable/index.tsx +551 -0
  51. package/src/ProTable/proTableTypes.ts +70 -0
  52. package/src/ProTable/style/index.less +92 -0
  53. package/src/ProTable/style/index.ts +1 -0
  54. package/src/Scrollbar/Bar.vue +75 -0
  55. package/src/Scrollbar/Scrollbar.vue +260 -0
  56. package/src/Scrollbar/Thumb.vue +163 -0
  57. package/src/Scrollbar/constants.ts +10 -0
  58. package/src/Scrollbar/index.ts +4 -0
  59. package/src/Scrollbar/scrollbar.ts +108 -0
  60. package/src/Scrollbar/thumb.ts +16 -0
  61. package/src/Scrollbar/util.ts +38 -0
  62. package/src/Search/Advanced/History.vue +140 -0
  63. package/src/Search/Advanced/SaveHistory.vue +108 -0
  64. package/src/Search/Advanced/index.vue +435 -0
  65. package/src/Search/Item.vue +525 -0
  66. package/src/Search/Search.vue +398 -0
  67. package/src/Search/hooks/index.ts +1 -0
  68. package/src/Search/hooks/useSearchItems.ts +68 -0
  69. package/src/Search/index.md +57 -0
  70. package/src/Search/index.ts +5 -0
  71. package/src/Search/setting.ts +55 -0
  72. package/src/Search/typing.ts +76 -0
  73. package/src/Search/util.ts +263 -0
  74. package/src/ValueItem/ValueItem.vue +50 -35
  75. package/src/ValueItem/util.ts +2 -1
  76. package/src/style/index.ts +3 -0
  77. package/src/style/variable.less +4 -0
  78. package/src/GeoComponent/GeoComponent.vue +0 -139
  79. package/src/GeoComponent/index.ts +0 -3
  80. package/src/PermissionButton/hooks.ts +0 -20
@@ -0,0 +1,551 @@
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/lib/radio';
4
+ import type { TableProps } from 'ant-design-vue/lib/table';
5
+ import { tableProps as _tableProps } from 'ant-design-vue/lib/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;
@@ -0,0 +1,70 @@
1
+ /**
2
+ * 公共类型数据
3
+ */
4
+ import type { TableProps, ColumnProps } from 'ant-design-vue/lib/table';
5
+ import type { TooltipProps } from 'ant-design-vue/lib/tooltip';
6
+ import type { PopconfirmProps } from 'ant-design-vue/lib/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
+ }