@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,398 +0,0 @@
1
- <template>
2
- <Form :model="terms" @finish="searchSubmit">
3
- <div :class="['JSearch-warp', props.class]" :style="style">
4
- <div class="JSearch-content simple">
5
- <div class="JSearch-items">
6
- <Row :gutter="[16, 16]">
7
- <Col
8
- v-for="(item, index) in searchItems"
9
- :key="index + '_' + item.column"
10
- :span="item.span || 24 / column"
11
- >
12
- <SearchItem
13
- :only-value="true"
14
- :expand="false"
15
- :index="index + 1"
16
- :columns="searchItems"
17
- :component-props="item.componentProps"
18
- :terms-item="terms.terms[index]"
19
- :reset="resetNumber"
20
- :label-width="labelWidth"
21
- @change="(v) => itemValueChange(v, index)"
22
- />
23
- </Col>
24
- <Col :span="24 / column">
25
- <slot
26
- name="footerRender"
27
- :reset="reset"
28
- :submit="searchSubmit"
29
- >
30
- <div
31
- class="JSearch-footer--btns"
32
- :style="{
33
- paddingLeft: `${labelWidth + 8}px`,
34
- }"
35
- >
36
- <Button type="stroke" @click="reset">
37
- {{ resetText }}
38
- </Button>
39
- <FormItemRest>
40
- <Button
41
- html-type="submit"
42
- type="primary"
43
- >
44
- {{ submitText }}
45
- </Button>
46
- </FormItemRest>
47
- </div>
48
- </slot>
49
- </Col>
50
- </Row>
51
- </div>
52
- </div>
53
- </div>
54
- </Form>
55
- </template>
56
-
57
- <script setup lang="ts">
58
- import { JColumnsProps, SearchItemData, SearchProps, Terms } from './typing';
59
- import {
60
- Button,
61
- Row,
62
- Col,
63
- Form,
64
- FormItemRest,
65
- } from 'ant-design-vue';
66
- import { set } from 'lodash-es';
67
- import { reactive, ref, provide } from 'vue';
68
- import type { PropType } from 'vue';
69
- import { termsParamsFormat } from './util';
70
- import SearchItem from './Item.vue';
71
- import { optionsMapKey } from './setting';
72
-
73
- interface Emit {
74
- (e: 'search', data: Terms[] | {}): void;
75
- }
76
-
77
- type SearchType = 'terms' | 'object';
78
-
79
- const props = defineProps({
80
- columns: {
81
- type: Array as PropType<JColumnsProps[]>,
82
- default: () => [],
83
- required: true,
84
- },
85
- type: {
86
- type: String as PropType<SearchType>,
87
- default: 'terms',
88
- required: true,
89
- },
90
- column: {
91
- type: Number,
92
- default: 4,
93
- },
94
- style: {
95
- type: [String, Object],
96
- default: undefined,
97
- },
98
- class: {
99
- type: String,
100
- default: '',
101
- },
102
- labelWidth: {
103
- type: Number,
104
- default: 40,
105
- },
106
- resetText: {
107
- type: String,
108
- default: '重置',
109
- },
110
- submitText: {
111
- type: String,
112
- default: '搜索',
113
- },
114
- });
115
-
116
- const columnOptionMap = ref(new Map());
117
-
118
- const emit = defineEmits<Emit>();
119
- // 当前查询条件
120
- const terms = reactive<Terms>({terms: []});
121
-
122
- const searchItems = ref<SearchProps[]>([]); // 当前查询条件列表
123
-
124
- provide(optionsMapKey, columnOptionMap);
125
- const itemValueChange = (value: SearchItemData, index: number) => {
126
- set(terms.terms, [index], value);
127
- };
128
-
129
- const handleItems = (reset: boolean = false) => {
130
- searchItems.value = [];
131
- terms.terms = [];
132
- columnOptionMap.value.clear();
133
- let hasSearch = false;
134
- props.columns!.forEach((item, index) => {
135
- if (item.search && Object.keys(item.search).length) {
136
- columnOptionMap.value.set(item.dataIndex, item.search);
137
- // 默认值
138
- const {search} = item;
139
- let defaultTerms = null;
140
- // 包含defaultValue 或者 defaultOnceValue
141
- if (
142
- search.defaultValue !== undefined ||
143
- search.defaultTermType ||
144
- search.defaultOnceValue
145
- ) {
146
- const _value =
147
- search.defaultValue || reset
148
- ? search.defaultValue
149
- : search.defaultOnceValue;
150
-
151
- defaultTerms = {
152
- type: 'and',
153
- value: _value,
154
- termType: search.defaultTermType || 'like',
155
- column: item.dataIndex,
156
- };
157
- }
158
-
159
- if (
160
- search.defaultValue !== undefined ||
161
- search.defaultOnceValue !== undefined
162
- ) {
163
- hasSearch = true;
164
- }
165
-
166
- terms.terms.push(defaultTerms);
167
- searchItems.value.push({
168
- ...item.search,
169
- sortIndex: item.search.first ? 0 : index + 1,
170
- title: item.title as any,
171
- column: item.dataIndex,
172
- });
173
- }
174
- });
175
-
176
- if (hasSearch) {
177
- searchSubmit();
178
- }
179
- };
180
-
181
- /**
182
- * 提交
183
- */
184
- const searchSubmit = () => {
185
- emit(
186
- 'search',
187
- termsParamsFormat(
188
- terms.terms,
189
- columnOptionMap.value,
190
- 'low',
191
- props.type,
192
- ),
193
- );
194
- };
195
-
196
- /**
197
- * 重置查询
198
- */
199
- const resetNumber = ref(1);
200
- const reset = () => {
201
- resetNumber.value += 1;
202
- handleItems(true);
203
- if (props.type == 'object') {
204
- emit('search', {});
205
- } else if (props.type == 'terms') {
206
- emit('search', []);
207
- }
208
- };
209
-
210
- handleItems();
211
- </script>
212
-
213
- <style scoped lang="less">
214
- .JSearch-warp {
215
- padding: 24px;
216
- background-color: #fff;
217
- margin-bottom: 24px;
218
-
219
- .pack-up {
220
- .JSearch-items {
221
- flex: 1 1 auto;
222
-
223
- .left {
224
- min-width: 380px;
225
- max-width: 580px;
226
- }
227
- }
228
- }
229
-
230
- &.senior {
231
- > .JSearch-content {
232
- display: flex;
233
-
234
- .JSearch-footer {
235
- display: flex;
236
- gap: 64px;
237
- position: relative;
238
-
239
- .more-btn {
240
- .more-text {
241
- padding-right: 24px;
242
- }
243
-
244
- .more-icon {
245
- transition: transform 0.3s;
246
- transform: rotateZ(90deg);
247
- font-size: 14px;
248
-
249
- &.more-up {
250
- transform: rotateZ(-90deg);
251
- }
252
- }
253
- }
254
-
255
- &.expand {
256
- margin-top: 16px;
257
- width: 100%;
258
- justify-content: space-between;
259
- }
260
-
261
- .JSearch-footer--btns {
262
- display: flex;
263
- gap: 12px;
264
- }
265
- }
266
-
267
- .items-expand {
268
- display: flex;
269
- gap: 16px;
270
-
271
- .left,
272
- & .right {
273
- min-width: 0;
274
- flex: 1 1 0;
275
- }
276
-
277
- .left-items,
278
- & .right-items {
279
- display: flex;
280
- gap: 16px;
281
- flex-direction: column;
282
- }
283
-
284
- .center {
285
- display: flex;
286
- flex-direction: column;
287
- justify-content: center;
288
- }
289
-
290
- &.vertical {
291
- flex-direction: column;
292
-
293
- .center {
294
- flex-direction: row;
295
- justify-content: center;
296
- }
297
- }
298
- }
299
-
300
- &.senior-expand {
301
- flex-direction: column;
302
- }
303
-
304
- &.small {
305
- gap: 12px;
306
-
307
- .JSearch-footer {
308
- gap: 4px;
309
- }
310
- }
311
- }
312
- }
313
-
314
- .JSearch-content {
315
- &.simple {
316
- .JSearch-footer--btns {
317
- display: flex;
318
- gap: 12px;
319
- }
320
-
321
- .JSearch-item {
322
- gap: 8px;
323
-
324
- .JSearch-item--label {
325
- text-align: right;
326
- }
327
- }
328
- }
329
- }
330
-
331
- .no-radius {
332
- border-radius: 0;
333
- border-color: #f1f1f1;
334
- }
335
-
336
- .search-history-warp {
337
- position: relative;
338
-
339
- .search-history-button {
340
- padding-right: 32px;
341
- }
342
-
343
- .search-history-button-icon {
344
- position: absolute;
345
- width: 24px;
346
- height: 18px;
347
- right: 6px;
348
- top: 8px;
349
- color: #fff;
350
- line-height: 18px;
351
- text-align: center;
352
- font-weight: bold;
353
-
354
- > span {
355
- font-size: 14px;
356
- }
357
- }
358
- }
359
- }
360
-
361
- .search-history-empty {
362
- padding: 12px 12px 6px 12px;
363
- background-color: #fff;
364
- }
365
-
366
- .search-history-items {
367
- width: 120px;
368
- max-height: 300px;
369
- overflow-y: auto;
370
-
371
- .search-history-item {
372
- display: flex;
373
- padding: 4px 0px 4px 4px;
374
- align-items: center;
375
- gap: 4px;
376
-
377
- &:hover {
378
- background-color: #f1f1f1;
379
- }
380
-
381
- .history-item--title {
382
- width: calc(100% - 30px);
383
- cursor: pointer;
384
- }
385
-
386
- .delete {
387
- padding: 0 6px;
388
- flex: 0 0 28px;
389
- }
390
- }
391
- }
392
-
393
- .search-history-list-pop {
394
- .ant-popover-inner-content {
395
- padding: 0;
396
- }
397
- }
398
- </style>
@@ -1 +0,0 @@
1
- export * from './useSearchItems';
@@ -1,68 +0,0 @@
1
- import { ref } from 'vue';
2
- import type { Ref } from 'vue';
3
- import type {
4
- JColumnsProps,
5
- SearchItemData,
6
- SearchProps,
7
- SearchItemProps,
8
- } from '../typing';
9
- import { sortBy } from 'lodash-es';
10
-
11
- type OptionsType = {
12
- getDefaultValue: (terms: SearchItemData[]) => void;
13
- };
14
- const hasDefaultValue = (item: SearchProps) => {
15
- return (
16
- item.defaultValue !== undefined ||
17
- item.defaultTermType ||
18
- item.defaultOnceValue
19
- );
20
- };
21
- export const useSearchItems = (
22
- columns: JColumnsProps[],
23
- options: OptionsType,
24
- ): {
25
- searchItems: Ref<SearchProps[]>;
26
- searchOptionsMap: Ref<Map<string, SearchItemProps>>;
27
- } => {
28
- const items = ref<SearchProps[]>([]);
29
- const optionsMap = ref(new Map());
30
- const handleColumns = () => {
31
- const _items = [];
32
- const values: SearchItemData[] = [];
33
- columns.forEach((item, index) => {
34
- const { search } = item;
35
- if (search && Object.keys(search).length) {
36
- optionsMap.value.set(item.dataIndex, search);
37
-
38
- if (hasDefaultValue(search)) {
39
- const _value =
40
- search.defaultValue || search.defaultOnceValue;
41
-
42
- values.push({
43
- type: 'and',
44
- value: _value,
45
- termType: search.defaultTermType || 'like',
46
- column: item.dataIndex,
47
- });
48
- }
49
-
50
- _items.push({
51
- ...item.search,
52
- sortIndex: item.search.first ? 0 : index + 1,
53
- column: item.dataIndex,
54
- });
55
- }
56
- });
57
- items.value = sortBy(_items, 'sortIndex');
58
-
59
- options?.getDefaultValue(values);
60
- };
61
-
62
- handleColumns();
63
-
64
- return {
65
- searchItems: items,
66
- searchOptionsMap: optionsMap,
67
- };
68
- };
@@ -1,57 +0,0 @@
1
- ---
2
- category: Components
3
- subtitle: 搜索
4
- cols: 1
5
- type: 高阶组件
6
- title: Search
7
- cover:
8
- ---
9
-
10
- ## API
11
-
12
- ```html
13
- <j-search></j-search>
14
- ```
15
-
16
- 可结合 ProTable 使用
17
-
18
- | Property | Description | Type | Default Value |
19
- | -------- | ------------------- | --------- | ------------- |
20
- | columns | 同`Table` `columns` | Columns[] | [] |
21
- | labelWidth | label最小宽度 | Number | 40 |
22
-
23
- ### Columns
24
-
25
- | Property | Description | Type | Default Value |
26
- | --------- | ------------------------------------ | -------- | ------------- |
27
- | dataIndex | 同`Table` `columns`中的 dataIndex | |
28
- | title | 同`Table` `columns`中的 title | |
29
- | search | 查询属性, 不传则不会出现在查询组件中 | Search[] |
30
-
31
- ### Search
32
-
33
- | Property | Description | Type | Default Value |
34
- | --------------- | -------------------------------------------- | -------------------------------------------- | --------------------- |
35
- | first | 是否提升为第一个查询字段 | Boolean | '' |
36
- | rename | 重命名查询字段,可以覆盖 Terms.column 中的值 | |
37
- | type | 组件类型 | `select` `number` `treeSelect` `date` `time` | `string` |
38
- | componentProps | 组件的 props | `{}` | {} |
39
- | format | `date` `time` 时生效 | String | `YYYY-MM-DD HH:mm:ss` |
40
- | options | `treeSelect` `select` 时生效 | `Option[]` `Promise` | [] |
41
- | defaultTermType | 修改 Terms.termType 的默认值 | String | 'eq' |
42
- | handleValue | 处理 Terms.value | Function | Function(item) |
43
-
44
- ### 事件
45
-
46
- | Property | Description | 回调参数 |
47
- | -------- | ----------- | --------------------------------------------------------------------------------------------- |
48
- | search | 搜索事件 | `AdvancedSearch`组件 Function({ terms: [{ terms: Terms[]] }); `Search`组件 Function(Terms[]) |
49
-
50
- ### Terms
51
-
52
- | Property | Description | Type |
53
- | -------- | ---------------- | -------------------------- |
54
- | column | 查询字段 | string |
55
- | type | 两组查询间的关系 | `and` `or` |
56
- | termType | 查询条件 | `eq` `like` `btw` 等 |
57
- | value | 查询值 | `string` `number` `Object` |
@@ -1,5 +0,0 @@
1
- import AdvancedSearch from './Advanced/index.vue';
2
- import Search from './Search.vue';
3
-
4
- export { AdvancedSearch };
5
- export default Search;
@@ -1,55 +0,0 @@
1
- import { PropType } from 'vue';
2
- import { JColumnsProps } from './typing';
3
-
4
- export const optionsMapKey = Symbol('searchOptionsMap');
5
- export const basicSearch = {
6
- columns: {
7
- type: Array as PropType<JColumnsProps[]>,
8
- default: () => [],
9
- required: true,
10
- },
11
- type: {
12
- type: String,
13
- default: 'advanced',
14
- },
15
- };
16
-
17
- export const typeOptions = [
18
- { label: '或者', value: 'or' },
19
- { label: '并且', value: 'and' },
20
- ];
21
-
22
- export const TermTypeMap = {
23
- EQ: { label: '=', value: 'eq' },
24
- NOT: { label: '!=', value: 'not' },
25
- LIKE: { label: '包含', value: 'like' },
26
- NLIKE: { label: '不包含', value: 'nlike' },
27
- GT: { label: '>', value: 'gt' },
28
- GTE: { label: '>=', value: 'gte' },
29
- LT: { label: '<', value: 'lt' },
30
- LTE: { label: '<=', value: 'lte' },
31
- IN: { label: '在...之中', value: 'in' },
32
- NIN: { label: '不在...之中', value: 'nin' },
33
- BTW: { label: '在...之间', value: 'btw' },
34
- NBTW: { label: '不在...之间', value: 'nbtw' },
35
- };
36
-
37
- export const termType = Object.values(TermTypeMap);
38
-
39
- export const componentType = {
40
- input: 'input',
41
- inputNumber: 'inputNumber',
42
- password: 'password',
43
- switch: 'switch',
44
- radio: 'radio',
45
- checkbox: 'checkbox',
46
- time: 'time',
47
- date: 'date',
48
- timeRange: 'timeRange',
49
- rangePicker: 'rangePicker',
50
- treeSelect: 'treeSelect',
51
- upload: 'upload',
52
- tree: 'tree',
53
- select: 'select',
54
- component: 'component',
55
- };
@@ -1,76 +0,0 @@
1
- import type { ColumnType } from 'ant-design-vue/es/table';
2
-
3
- export interface SearchBaseProps {
4
- rename?: string;
5
- type?:
6
- | 'select'
7
- | 'number'
8
- | 'string'
9
- | 'treeSelect'
10
- | 'date'
11
- | 'time'
12
- | 'rangePicker'
13
- | 'component'
14
- | 'timeRange';
15
- format?: string;
16
- options?: any[] | Function;
17
- first?: boolean;
18
- defaultTermType?: string; // 默认 eq
19
- defaultValue?: any; // 默认值
20
- defaultOnceValue?: any; // 会被重置掉的默认值
21
- title?: ColumnType['title'];
22
- sortIndex?: number;
23
-
24
- span?: number;
25
- componentProps?: any;
26
-
27
- termFilter?: string[];
28
-
29
- termOptions?: Array<{ label: string; value: string }>;
30
-
31
- handleValue?: (value: SearchItemData) => any;
32
- }
33
-
34
- export interface SearchItemProps {
35
- rename?: SearchBaseProps['rename'];
36
- title: string;
37
- column: string | number | ColumnType['dataIndex'];
38
- }
39
-
40
- export interface SearchItemData {
41
- column: string | number | ColumnType['dataIndex'];
42
- value: any;
43
- termType: string;
44
- type?: string;
45
- }
46
-
47
- export interface TermsItem {
48
- terms: SearchItemData[];
49
- type?: string;
50
- }
51
-
52
- export interface Terms {
53
- terms: TermsItem[];
54
- }
55
-
56
- export interface SortItem {
57
- name: string;
58
- order?: 'desc' | 'asc';
59
- value?: any;
60
- }
61
-
62
- export interface SearchHistoryList {
63
- content?: string;
64
- name: string;
65
- id: string;
66
- key: string;
67
- }
68
-
69
- export interface SearchProps
70
- extends Omit<SearchBaseProps, 'title'>,
71
- SearchItemProps {}
72
-
73
- export interface JColumnsProps extends ColumnType {
74
- scopedSlots?: boolean;
75
- search: SearchProps;
76
- }