@meethive/components 0.0.3 → 0.0.4

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 (111) hide show
  1. package/es/AutoComplete/AutoComplete.js +71 -80
  2. package/es/BadgeStatus/Badge.js +38 -47
  3. package/es/CardSelect/CardSelect.js +115 -137
  4. package/es/CheckButton/CheckButton.js +102 -118
  5. package/es/ConfigProvider/ConfigProvider.js +44 -68
  6. package/es/DragModal/DragModal.js +191 -212
  7. package/es/EditTable/Body.js +158 -189
  8. package/es/EditTable/CellRender.js +10 -12
  9. package/es/EditTable/EditTable.js +385 -434
  10. package/es/EditTable/FormItem.js +140 -169
  11. package/es/EditTable/Group.js +171 -204
  12. package/es/EditTable/Header.js +57 -63
  13. package/es/EditTable/HeaderRender.js +10 -12
  14. package/es/EditTable/components/ContextMenu/Menu.js +78 -86
  15. package/es/EditTable/components/Search/Search.js +151 -163
  16. package/es/EditTable/components/Search/Sort.js +104 -119
  17. package/es/Ellipsis/Ellipsis.js +144 -148
  18. package/es/Empty/Empty.js +51 -57
  19. package/es/FullPage/FullPage.js +20 -19
  20. package/es/Icon/Icon.js +42 -49
  21. package/es/LocaleProvider/LocaleProvider.js +32 -38
  22. package/es/Markdown/Markdown.js +101 -118
  23. package/es/PermissionButton/PermissionButton.js +118 -118
  24. package/es/ProLayout/Basic/BasicLayout.js +301 -418
  25. package/es/ProLayout/Basic/Header.js +91 -111
  26. package/es/ProLayout/PageContainer/index.js +267 -344
  27. package/es/ProLayout/SiderMenu/BaseMenu.js +186 -240
  28. package/es/ProTable/Alert.js +39 -40
  29. package/es/ProTable/Content.js +84 -97
  30. package/es/ProTable/Header.js +32 -33
  31. package/es/ProTable/Pagination.js +56 -55
  32. package/es/ProTable/ProTable.js +256 -276
  33. package/es/RadioButton/RadioButton.js +48 -53
  34. package/es/Scrollbar/Bar.js +65 -76
  35. package/es/Scrollbar/Scrollbar.js +129 -161
  36. package/es/Scrollbar/Thumb.js +101 -150
  37. package/es/Search/Item.js +208 -236
  38. package/es/Search/Search.js +90 -90
  39. package/es/Skeleton/Skeleton.js +26 -27
  40. package/es/Skeleton/components/DashBoardCard.js +26 -27
  41. package/es/Skeleton/components/DashBoardChart.js +26 -27
  42. package/es/Skeleton/components/Detail.js +26 -27
  43. package/es/Skeleton/components/Drawer.js +26 -27
  44. package/es/Skeleton/components/Item.js +55 -54
  45. package/es/Skeleton/components/List.js +29 -27
  46. package/es/Skeleton/components/ListCard.js +28 -28
  47. package/es/Skeleton/components/ListCardItem.js +20 -20
  48. package/es/Skeleton/components/ListTable.js +26 -27
  49. package/es/Skeleton/components/Page.js +27 -26
  50. package/es/Skeleton/components/Search.js +16 -16
  51. package/es/Skeleton/components/Tree.js +26 -27
  52. package/es/TimeFormat/TimeFormat.js +32 -36
  53. package/es/Title/Title.js +23 -26
  54. package/es/ValueItem/ValueItem.js +100 -113
  55. package/es/VirtualTable/VirtualTable.js +235 -271
  56. package/lib/AutoComplete/AutoComplete.js +71 -80
  57. package/lib/BadgeStatus/Badge.js +38 -47
  58. package/lib/CardSelect/CardSelect.js +115 -137
  59. package/lib/CheckButton/CheckButton.js +102 -118
  60. package/lib/ConfigProvider/ConfigProvider.js +44 -68
  61. package/lib/DragModal/DragModal.js +191 -212
  62. package/lib/EditTable/Body.js +158 -189
  63. package/lib/EditTable/CellRender.js +10 -12
  64. package/lib/EditTable/EditTable.js +385 -434
  65. package/lib/EditTable/FormItem.js +140 -169
  66. package/lib/EditTable/Group.js +171 -204
  67. package/lib/EditTable/Header.js +57 -63
  68. package/lib/EditTable/HeaderRender.js +10 -12
  69. package/lib/EditTable/components/ContextMenu/Menu.js +78 -86
  70. package/lib/EditTable/components/Search/Search.js +151 -163
  71. package/lib/EditTable/components/Search/Sort.js +104 -119
  72. package/lib/Ellipsis/Ellipsis.js +144 -148
  73. package/lib/Empty/Empty.js +51 -57
  74. package/lib/FullPage/FullPage.js +20 -19
  75. package/lib/Icon/Icon.js +42 -49
  76. package/lib/LocaleProvider/LocaleProvider.js +32 -38
  77. package/lib/Markdown/Markdown.js +101 -118
  78. package/lib/PermissionButton/PermissionButton.js +118 -118
  79. package/lib/ProLayout/Basic/BasicLayout.js +301 -418
  80. package/lib/ProLayout/Basic/Header.js +91 -111
  81. package/lib/ProLayout/PageContainer/index.js +267 -344
  82. package/lib/ProLayout/SiderMenu/BaseMenu.js +186 -240
  83. package/lib/ProTable/Alert.js +39 -40
  84. package/lib/ProTable/Content.js +84 -97
  85. package/lib/ProTable/Header.js +32 -33
  86. package/lib/ProTable/Pagination.js +56 -55
  87. package/lib/ProTable/ProTable.js +256 -276
  88. package/lib/RadioButton/RadioButton.js +48 -53
  89. package/lib/Scrollbar/Bar.js +65 -76
  90. package/lib/Scrollbar/Scrollbar.js +129 -161
  91. package/lib/Scrollbar/Thumb.js +101 -150
  92. package/lib/Search/Item.js +208 -236
  93. package/lib/Search/Search.js +90 -90
  94. package/lib/Skeleton/Skeleton.js +26 -27
  95. package/lib/Skeleton/components/DashBoardCard.js +26 -27
  96. package/lib/Skeleton/components/DashBoardChart.js +26 -27
  97. package/lib/Skeleton/components/Detail.js +26 -27
  98. package/lib/Skeleton/components/Drawer.js +26 -27
  99. package/lib/Skeleton/components/Item.js +55 -54
  100. package/lib/Skeleton/components/List.js +29 -27
  101. package/lib/Skeleton/components/ListCard.js +28 -28
  102. package/lib/Skeleton/components/ListCardItem.js +20 -20
  103. package/lib/Skeleton/components/ListTable.js +26 -27
  104. package/lib/Skeleton/components/Page.js +27 -26
  105. package/lib/Skeleton/components/Search.js +16 -16
  106. package/lib/Skeleton/components/Tree.js +26 -27
  107. package/lib/TimeFormat/TimeFormat.js +32 -36
  108. package/lib/Title/Title.js +23 -26
  109. package/lib/ValueItem/ValueItem.js +100 -113
  110. package/lib/VirtualTable/VirtualTable.js +235 -271
  111. package/package.json +1 -1
@@ -1,279 +1,259 @@
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
-
1
+ import { defineComponent, useSlots, watch, onMounted, onUnmounted, computed, ref, reactive, inject } from 'vue';
2
+ import { Spin } from 'ant-design-vue';
3
+ import { debounce } from 'lodash-es';
4
+ import Header from './Header.js';
5
+ import Alert from './Alert.js';
6
+ import Content from './Content.js';
7
+ import JPagination from './Pagination.js';
8
+ import { proTableProps } from './setting';
9
+ import { TableConfig } from '../utils/constants';
10
+ import { useTableInject } from './hooks';
11
+ import useProTableStyle from './style';
12
+ import { onlyMessage } from '@meethive/utils';
13
+ import { useLocaleReceiver } from '../LocaleReciver';
14
+ export default defineComponent({
15
+ name: 'JProTable',
16
+ components: {
17
+ Spin,
18
+ Header,
19
+ Alert,
20
+ Content,
21
+ JPagination
22
+ },
23
+ props: {
24
+ ...proTableProps
25
+ },
26
+ setup(props, {
27
+ expose
28
+ }) {
29
+ const tableConfig = inject(TableConfig, {
30
+ pagination: {}
31
+ });
32
+ const slots = useSlots();
33
+ const myPagination = computed(() => {
34
+ const globalPagination = tableConfig.pagination || {};
35
+ let showQuickJumper = globalPagination.showQuickJumper ?? props.pagination.showQuickJumper ?? false;
36
+ return {
37
+ showSizeChanger: true,
38
+ size: 'size',
39
+ pageSizeOptions: ['12', '24', '48', '96'],
40
+ ...globalPagination,
41
+ ...props.pagination,
42
+ showQuickJumper
43
+ };
44
+ });
45
+ const loading = ref(false);
46
+ const _dataSource = ref([]);
47
+ const _mode = ref(props.mode || props.modeValue || 'CARD');
48
+ const column = ref(4);
49
+ const page = reactive({
50
+ pageIndex: 0,
51
+ pageSize: 12,
52
+ total: 0,
53
+ loading: false
54
+ });
55
+ const prefixCls = computed(() => 'pro-table');
56
+ const [wrapSSR, hashId] = useProTableStyle(prefixCls);
57
+ const [contextLocale] = useLocaleReceiver('ProTable');
58
+ let currentRequestId = 0;
59
+ const extraSlots = ['headerRightRender', 'headerLeftRender', 'paginationRender', 'alertRender'];
60
+ const _rowSelection = useTableInject();
61
+ const showAlert = computed(() => {
62
+ return props.alertShow && (props.rowSelection?.selectedRowKeys?.length || _rowSelection?.value?.selectedRowKeys?.length);
63
+ });
64
+ const showPagination = computed(() => {
65
+ return !!_dataSource.value.length && !props.noPagination && props.type === 'PAGE';
66
+ });
67
+ const onCheck = e => {
68
+ _mode.value = e.target.value;
69
+ };
70
+ const handleData = (result, _params) => {
71
+ if (props.type === 'PAGE') {
72
+ // 判断如果是最后一页且最后一页为空,就跳转到前一页
73
+ // 判断条件:如果是total分开查询,判断result的长度;如果不分开查询就判断result.data的长度
74
+ if (props.totalRequest) {
75
+ if (result.length === 0) {
76
+ return true;
77
+ } else {
78
+ _dataSource.value = result || [];
79
+ page.pageIndex = _params?.pageIndex || 0;
80
+ page.pageSize = _params?.pageSize || 12;
81
+ page.total = page.pageSize * (page.pageIndex + 1) + 1;
82
+ }
83
+ } else {
84
+ if (result?.total && result?.pageSize && result?.pageIndex && result?.data?.length === 0) {
85
+ return true;
86
+ } else {
87
+ _dataSource.value = result?.data || [];
88
+ page.pageIndex = result?.pageIndex || 0;
89
+ page.pageSize = result?.pageSize || 12;
90
+ page.total = result?.total || 0;
91
+ }
92
+ }
93
+ } else {
94
+ _dataSource.value = result || [];
95
+ }
96
+ return false;
97
+ };
98
+ const handleSearch = async _params => {
99
+ if (Array.isArray(props.dataSource)) {
100
+ _dataSource.value = props.dataSource;
101
+ } else if (props.request) {
102
+ const __params = {
103
+ pageIndex: page.pageIndex,
104
+ pageSize: Number(page.pageSize),
105
+ ...props.defaultParams,
106
+ ..._params,
107
+ terms: [...(props.defaultParams?.terms || []), ...(_params?.terms || [])]
108
+ };
109
+ loading.value = true;
110
+ const resp = await props.request(__params).finally(() => {
111
+ loading.value = false;
112
+ });
113
+ if (resp.success) {
114
+ const flag = handleData(resp.result || {}, _params);
115
+ if (flag) {
116
+ // 判断如果是最后一页且最后一页为空,就跳转到前一页
117
+ if (props.totalRequest) {
118
+ onlyMessage(contextLocale.value.pagination?.lastPage || '', 'error');
119
+ // 置灰下一页
120
+ page.total = page.pageSize * (page.pageIndex > 0 ? page.pageIndex : 1);
121
+ } else {
122
+ page.pageIndex = page.pageIndex > 0 ? page.pageIndex - 1 : 0;
123
+ handleSearch({
124
+ ..._params,
125
+ pageSize: page.pageSize,
126
+ pageIndex: page.pageIndex
127
+ });
128
+ }
129
+ }
130
+ } else {
131
+ _dataSource.value = [];
132
+ }
133
+ if (props.totalRequest) {
134
+ currentRequestId++;
135
+ const requestId = currentRequestId;
136
+ page.loading = true;
137
+ props.totalRequest(__params).then(res => {
138
+ if (res.success) {
139
+ page.total = res.result || 0;
140
+ }
141
+ }).finally(() => {
142
+ if (requestId === currentRequestId) {
143
+ page.loading = false;
144
+ }
145
+ });
146
+ }
147
+ } else {
148
+ _dataSource.value = [];
149
+ }
150
+ };
151
+ const _debounceFn = debounce(handleSearch, 300);
152
+ const onPageChange = (_page, size) => {
153
+ handleSearch({
154
+ ...props.params,
155
+ pageSize: size,
156
+ pageIndex: page.pageSize === size ? _page ? _page - 1 : 0 : 0
157
+ });
158
+ };
159
+ const onClose = () => {
160
+ if (props.rowSelection) {
161
+ props.rowSelection.onChange?.([], []);
162
+ props.rowSelection.onSelectNone?.();
163
+ } else if (_rowSelection?.value) {
164
+ _rowSelection.value?.onSelectNone?.();
165
+ }
166
+ };
167
+
190
168
  /**
191
169
  * 刷新数据
192
170
  * @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
- })
171
+ */
172
+ const reload = _params => {
173
+ handleSearch({
174
+ ...props.params,
175
+ ..._params,
176
+ pageSize: page.pageSize || 12,
177
+ pageIndex: page.pageIndex || 0
178
+ });
179
+ };
180
+ const _gridColumns = computed(() => {
181
+ if (props.gridColumns?.length) {
182
+ const arr = props.gridColumns;
183
+ const lastValue = arr.slice(-1)?.[0];
184
+ if (arr?.length < 4) {
185
+ while (arr.length < 4) {
186
+ arr.push(lastValue);
187
+ }
188
+ return arr;
189
+ } else {
190
+ return props.gridColumns.slice(0, 4);
191
+ }
192
+ } else {
193
+ return [1, 2, 3, 4];
194
+ }
195
+ });
196
+
197
+ // 监听宽度,计算显示卡片个数
198
+ const windowChange = () => {
199
+ const ele = document.getElementById('jtable-body-spin');
200
+ if (ele) {
201
+ const styles = window.getComputedStyle(ele);
202
+ const width = parseFloat(styles.width);
203
+ if (width <= 992) {
204
+ column.value = _gridColumns.value?.[0] || 1;
205
+ } else if (width > 992 && width <= 1440) {
206
+ column.value = _gridColumns.value?.[1] || 2;
207
+ } else if (width > 1440 && width <= 1600) {
208
+ column.value = _gridColumns.value?.[2] || 3;
209
+ } else if (width > 1600) {
210
+ column.value = _gridColumns.value?.[3] || 4;
211
+ }
212
+ }
213
+ };
214
+ watch(() => props.params, newValue => {
215
+ _debounceFn(newValue || {});
216
+ }, {
217
+ deep: true,
218
+ immediate: true
219
+ });
220
+ watch(() => props.dataSource, newVal => {
221
+ if (newVal && !props.request) {
222
+ handleSearch(props.params);
223
+ }
224
+ }, {
225
+ deep: true,
226
+ immediate: true
227
+ });
228
+ onMounted(() => {
229
+ windowChange(); // 初始化
230
+ window.onresize = () => {
231
+ windowChange();
232
+ };
233
+ });
234
+ onUnmounted(() => {
235
+ window.onresize = null;
236
+ });
237
+ expose({
238
+ reload,
239
+ dataSource: _dataSource
240
+ });
241
+ return {
242
+ slots,
243
+ hashId,
244
+ loading,
245
+ _dataSource,
246
+ _mode,
247
+ column,
248
+ page,
249
+ myPagination,
250
+ showAlert,
251
+ showPagination,
252
+ extraSlots,
253
+ _rowSelection,
254
+ onCheck,
255
+ onPageChange,
256
+ onClose
257
+ };
258
+ }
259
+ });
@@ -1,53 +1,48 @@
1
-
2
- import { defineComponent, ref, computed, watch } from 'vue'
3
- import useRadioButtonStyle from './style'
4
-
5
- export default defineComponent({
6
- name: 'JRadioButton',
7
- props: {
8
- value: {
9
- type: [String, Number],
10
- default: undefined
11
- },
12
- options: {
13
- type: Array,
14
- default: () => []
15
- },
16
- columns: {
17
- type: Number,
18
- default: 3
19
- }
20
- },
21
- emits: ['update:value'],
22
- setup(props, { emit }) {
23
- const prefixCls = computed(() => 'j-radio-button')
24
- const [wrapSSR, hashId] = useRadioButtonStyle(prefixCls)
25
-
26
- const myValue = ref(props.value)
27
-
28
- const styles = computed(() => {
29
- return {
30
- 'grid-template-columns': `repeat(${props.columns}, 1fr)`
31
- }
32
- })
33
-
34
- const onClick = (record) => {
35
- if (myValue.value !== record.value) {
36
- myValue.value = record.value
37
- emit('update:value', record.value)
38
- emit('select', record.value)
39
- }
40
- }
41
-
42
- watch(() => props.value, () => {
43
- myValue.value = props.value
44
- })
45
-
46
- return {
47
- hashId,
48
- myValue,
49
- styles,
50
- onClick
51
- }
52
- }
53
- })
1
+ import { defineComponent, ref, computed, watch } from 'vue';
2
+ import useRadioButtonStyle from './style';
3
+ export default defineComponent({
4
+ name: 'JRadioButton',
5
+ props: {
6
+ value: {
7
+ type: [String, Number],
8
+ default: undefined
9
+ },
10
+ options: {
11
+ type: Array,
12
+ default: () => []
13
+ },
14
+ columns: {
15
+ type: Number,
16
+ default: 3
17
+ }
18
+ },
19
+ emits: ['update:value'],
20
+ setup(props, {
21
+ emit
22
+ }) {
23
+ const prefixCls = computed(() => 'j-radio-button');
24
+ const [wrapSSR, hashId] = useRadioButtonStyle(prefixCls);
25
+ const myValue = ref(props.value);
26
+ const styles = computed(() => {
27
+ return {
28
+ 'grid-template-columns': `repeat(${props.columns}, 1fr)`
29
+ };
30
+ });
31
+ const onClick = record => {
32
+ if (myValue.value !== record.value) {
33
+ myValue.value = record.value;
34
+ emit('update:value', record.value);
35
+ emit('select', record.value);
36
+ }
37
+ };
38
+ watch(() => props.value, () => {
39
+ myValue.value = props.value;
40
+ });
41
+ return {
42
+ hashId,
43
+ myValue,
44
+ styles,
45
+ onClick
46
+ };
47
+ }
48
+ });