@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.
- package/index.ts +54 -15
- package/package.json +9 -6
- package/src/AMap/Map.vue +110 -107
- package/src/BadgeStatus/Badge.vue +41 -40
- package/src/BadgeStatus/color.ts +25 -23
- package/src/CardSelect/CardSelect.vue +136 -0
- package/src/CardSelect/index.ts +3 -0
- package/src/CheckButton/CheckButton.vue +146 -0
- package/src/CheckButton/index.md +27 -0
- package/src/CheckButton/index.ts +3 -0
- package/src/ConfigProvider/context.ts +17 -0
- package/src/ConfigProvider/index.tsx +42 -0
- package/src/Echarts/Echarts.vue +43 -43
- package/src/Ellipsis/Ellipsis.vue +182 -0
- package/src/Ellipsis/index.ts +3 -0
- package/src/Empty/Empty.vue +43 -0
- package/src/Empty/image.ts +3 -0
- package/src/Empty/index.ts +2 -0
- package/src/FullPage/{index.vue → FullPage.vue} +30 -27
- package/src/FullPage/index.ts +3 -0
- package/src/Icon/icon.tsx +40 -0
- package/src/Icon/index.ts +3 -0
- package/src/MonacoEditor/Monaco.vue +242 -0
- package/src/MonacoEditor/index.md +26 -0
- package/src/MonacoEditor/index.ts +2 -0
- package/src/PermissionButton/index.tsx +95 -92
- package/src/ProLayout/Basic/BasicLayout.less +66 -0
- package/src/ProLayout/Basic/BasicLayout.tsx +392 -0
- package/src/ProLayout/Basic/Header.less +8 -0
- package/src/ProLayout/Basic/Header.tsx +115 -0
- package/src/ProLayout/PageContainer/index.less +103 -0
- package/src/ProLayout/PageContainer/index.tsx +441 -0
- package/src/ProLayout/PageContainer/typings.ts +56 -0
- package/src/ProLayout/RouteContext.ts +87 -0
- package/src/ProLayout/SiderMenu/BaseMenu.tsx +296 -0
- package/src/ProLayout/SiderMenu/SiderMenu.tsx +320 -0
- package/src/ProLayout/SiderMenu/index.less +212 -0
- package/src/ProLayout/SiderMenu/index.ts +2 -0
- package/src/ProLayout/SiderMenu/typings.ts +49 -0
- package/src/ProLayout/TopHeader/index.less +174 -0
- package/src/ProLayout/TopHeader/index.tsx +210 -0
- package/src/ProLayout/defaultSettings.ts +106 -0
- package/src/ProLayout/index.ts +6 -0
- package/src/ProLayout/style/default.less +4 -0
- package/src/ProLayout/style/index.ts +1 -0
- package/src/ProLayout/style/style.less +7 -0
- package/src/ProLayout/typings.ts +87 -0
- package/src/ProLayout/util.ts +64 -0
- package/src/ProTable/index.md +53 -0
- package/src/ProTable/index.tsx +551 -0
- package/src/ProTable/proTableTypes.ts +70 -0
- package/src/ProTable/style/index.less +92 -0
- package/src/ProTable/style/index.ts +1 -0
- package/src/Scrollbar/Bar.vue +75 -0
- package/src/Scrollbar/Scrollbar.vue +260 -0
- package/src/Scrollbar/Thumb.vue +163 -0
- package/src/Scrollbar/constants.ts +10 -0
- package/src/Scrollbar/index.ts +4 -0
- package/src/Scrollbar/scrollbar.ts +108 -0
- package/src/Scrollbar/thumb.ts +16 -0
- package/src/Scrollbar/util.ts +38 -0
- package/src/Search/Advanced/History.vue +140 -0
- package/src/Search/Advanced/SaveHistory.vue +108 -0
- package/src/Search/Advanced/index.vue +435 -0
- package/src/Search/Item.vue +525 -0
- package/src/Search/Search.vue +398 -0
- package/src/Search/hooks/index.ts +1 -0
- package/src/Search/hooks/useSearchItems.ts +68 -0
- package/src/Search/index.md +57 -0
- package/src/Search/index.ts +5 -0
- package/src/Search/setting.ts +55 -0
- package/src/Search/typing.ts +76 -0
- package/src/Search/util.ts +263 -0
- package/src/ValueItem/ValueItem.vue +50 -35
- package/src/ValueItem/util.ts +2 -1
- package/src/style/index.ts +3 -0
- package/src/style/variable.less +4 -0
- package/src/GeoComponent/GeoComponent.vue +0 -139
- package/src/GeoComponent/index.ts +0 -3
- package/src/PermissionButton/hooks.ts +0 -20
|
@@ -0,0 +1,398 @@
|
|
|
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>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './useSearchItems';
|
|
@@ -0,0 +1,68 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1,57 @@
|
|
|
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` |
|
|
@@ -0,0 +1,55 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import type { ColumnType } from 'ant-design-vue/lib/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
|
+
}
|