@jetlinks-web/components 1.0.5 → 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,435 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<Form :model="termsData" @finish="searchSubmit">
|
|
3
|
+
<div
|
|
4
|
+
ref="searchRef"
|
|
5
|
+
:class="['JSearch-warp', 'senior', props.class]"
|
|
6
|
+
:style="style"
|
|
7
|
+
>
|
|
8
|
+
<!-- 高级模式 -->
|
|
9
|
+
<div
|
|
10
|
+
v-if="props.type === 'advanced'"
|
|
11
|
+
ref="searchRefContentRef"
|
|
12
|
+
:class="[
|
|
13
|
+
'JSearch-content',
|
|
14
|
+
expand || compatible ? 'senior-expand' : 'pack-up',
|
|
15
|
+
screenSize ? 'big' : 'small',
|
|
16
|
+
]"
|
|
17
|
+
>
|
|
18
|
+
<div
|
|
19
|
+
:class="[
|
|
20
|
+
'JSearch-items',
|
|
21
|
+
expand ? 'items-expand' : '',
|
|
22
|
+
layout,
|
|
23
|
+
]"
|
|
24
|
+
>
|
|
25
|
+
<div class="left">
|
|
26
|
+
<div class="left-items">
|
|
27
|
+
<SearchItem
|
|
28
|
+
:expand="expand"
|
|
29
|
+
:index="1"
|
|
30
|
+
:columns="searchItems"
|
|
31
|
+
:terms-item="termsData.terms[0].terms[0]"
|
|
32
|
+
:reset="resetNumber"
|
|
33
|
+
@change="(v) => itemValueChange(v, 1)"
|
|
34
|
+
/>
|
|
35
|
+
<SearchItem
|
|
36
|
+
v-if="expand"
|
|
37
|
+
:expand="expand"
|
|
38
|
+
:index="2"
|
|
39
|
+
:columns="searchItems"
|
|
40
|
+
:terms-item="termsData.terms[0].terms[1]"
|
|
41
|
+
:reset="resetNumber"
|
|
42
|
+
@change="(v) => itemValueChange(v, 2)"
|
|
43
|
+
/>
|
|
44
|
+
<SearchItem
|
|
45
|
+
v-if="expand"
|
|
46
|
+
:expand="expand"
|
|
47
|
+
:index="3"
|
|
48
|
+
:columns="searchItems"
|
|
49
|
+
:terms-item="termsData.terms[0].terms[2]"
|
|
50
|
+
:reset="resetNumber"
|
|
51
|
+
@change="(v) => itemValueChange(v, 3)"
|
|
52
|
+
/>
|
|
53
|
+
</div>
|
|
54
|
+
</div>
|
|
55
|
+
<div v-if="expand" class="center">
|
|
56
|
+
<Select
|
|
57
|
+
v-model:value="termsData.terms[1].type"
|
|
58
|
+
class="center-select"
|
|
59
|
+
style="width: 100px"
|
|
60
|
+
:options="typeOptions"
|
|
61
|
+
/>
|
|
62
|
+
</div>
|
|
63
|
+
<div v-if="expand" class="right">
|
|
64
|
+
<div class="right-items">
|
|
65
|
+
<SearchItem
|
|
66
|
+
v-for="item in [4, 5, 6]"
|
|
67
|
+
:key="`search_item_${item}`"
|
|
68
|
+
:expand="expand"
|
|
69
|
+
:index="item"
|
|
70
|
+
:columns="searchItems"
|
|
71
|
+
:terms-item="termsData.terms[1].terms[item - 4]"
|
|
72
|
+
:reset="resetNumber"
|
|
73
|
+
@change="(v) => itemValueChange(v, item)"
|
|
74
|
+
/>
|
|
75
|
+
</div>
|
|
76
|
+
</div>
|
|
77
|
+
</div>
|
|
78
|
+
<div
|
|
79
|
+
:class="[
|
|
80
|
+
'JSearch-footer',
|
|
81
|
+
expand || compatible ? 'expand' : '',
|
|
82
|
+
]"
|
|
83
|
+
>
|
|
84
|
+
<div class="JSearch-footer--btns">
|
|
85
|
+
<Button type="stroke" @click="reset"> 重置</Button>
|
|
86
|
+
<SaveHistory
|
|
87
|
+
:terms="termsData"
|
|
88
|
+
:target="target"
|
|
89
|
+
:request="request"
|
|
90
|
+
/>
|
|
91
|
+
<History
|
|
92
|
+
:target="target"
|
|
93
|
+
:request="historyRequest"
|
|
94
|
+
:delete-request="deleteRequest"
|
|
95
|
+
:delete-key="deleteKey"
|
|
96
|
+
@click="searchSubmit"
|
|
97
|
+
@itemClick="historyItemClick"
|
|
98
|
+
/>
|
|
99
|
+
</div>
|
|
100
|
+
<Button
|
|
101
|
+
type="link"
|
|
102
|
+
class="more-btn"
|
|
103
|
+
@click="expandChange"
|
|
104
|
+
>
|
|
105
|
+
<span class="more-text"> 更多筛选 </span>
|
|
106
|
+
<AIcon
|
|
107
|
+
type="DoubleRightOutlined"
|
|
108
|
+
:class="[
|
|
109
|
+
'more-icon',
|
|
110
|
+
expand ? 'more-up' : 'more-down',
|
|
111
|
+
]"
|
|
112
|
+
/>
|
|
113
|
+
</Button>
|
|
114
|
+
</div>
|
|
115
|
+
</div>
|
|
116
|
+
<!-- 简单模式 -->
|
|
117
|
+
<div v-else class="JSearch-content single big pack-up">
|
|
118
|
+
<div class="JSearch-items">
|
|
119
|
+
<div class="left">
|
|
120
|
+
<SearchItem
|
|
121
|
+
:expand="false"
|
|
122
|
+
:index="1"
|
|
123
|
+
:columns="searchItems"
|
|
124
|
+
:terms-item="termsData.terms[0].terms[0]"
|
|
125
|
+
:reset="resetNumber"
|
|
126
|
+
@change="(v) => itemValueChange(v, 1)"
|
|
127
|
+
/>
|
|
128
|
+
</div>
|
|
129
|
+
</div>
|
|
130
|
+
<div class="JSearch-footer">
|
|
131
|
+
<div class="JSearch-footer--btns">
|
|
132
|
+
<FormItemRest>
|
|
133
|
+
<Button type="stroke" @click="reset">
|
|
134
|
+
重置
|
|
135
|
+
</Button>
|
|
136
|
+
<Button html-type="submit" type="primary">
|
|
137
|
+
搜索
|
|
138
|
+
</Button>
|
|
139
|
+
</FormItemRest>
|
|
140
|
+
</div>
|
|
141
|
+
</div>
|
|
142
|
+
</div>
|
|
143
|
+
</div>
|
|
144
|
+
</Form>
|
|
145
|
+
</template>
|
|
146
|
+
|
|
147
|
+
<script setup lang="ts">
|
|
148
|
+
import SearchItem from '../Item.vue';
|
|
149
|
+
import { optionsMapKey, typeOptions } from '../setting';
|
|
150
|
+
import { useElementSize } from '@vueuse/core';
|
|
151
|
+
import { useRouteQuery } from '@vueuse/router';
|
|
152
|
+
import { PropType, ref, reactive, watch, provide } from 'vue';
|
|
153
|
+
import SaveHistory from './SaveHistory.vue';
|
|
154
|
+
import History from './History.vue';
|
|
155
|
+
import type {
|
|
156
|
+
SearchItemData,
|
|
157
|
+
SearchProps,
|
|
158
|
+
Terms,
|
|
159
|
+
JColumnsProps,
|
|
160
|
+
} from '../typing';
|
|
161
|
+
import {
|
|
162
|
+
compatibleOldTerms,
|
|
163
|
+
getTermTypeFn,
|
|
164
|
+
handleQData,
|
|
165
|
+
hasExpand,
|
|
166
|
+
termsParamsFormat,
|
|
167
|
+
} from '../util';
|
|
168
|
+
import { Select, Button, Form, FormItemRest } from 'ant-design-vue'
|
|
169
|
+
import { AIcon } from '../../../'
|
|
170
|
+
import { cloneDeep } from 'lodash-es';
|
|
171
|
+
|
|
172
|
+
type UrlParam = {
|
|
173
|
+
q: string | null;
|
|
174
|
+
target: string | null;
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
interface Emit {
|
|
178
|
+
(e: 'search', data: Terms): void;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
const props = defineProps({
|
|
182
|
+
columns: {
|
|
183
|
+
type: Array as PropType<JColumnsProps[]>,
|
|
184
|
+
default: () => [],
|
|
185
|
+
required: true,
|
|
186
|
+
},
|
|
187
|
+
type: {
|
|
188
|
+
type: String,
|
|
189
|
+
default: 'advanced',
|
|
190
|
+
},
|
|
191
|
+
target: {
|
|
192
|
+
type: String,
|
|
193
|
+
default: '',
|
|
194
|
+
required: true,
|
|
195
|
+
},
|
|
196
|
+
class: {
|
|
197
|
+
type: String,
|
|
198
|
+
default: '',
|
|
199
|
+
},
|
|
200
|
+
request: {
|
|
201
|
+
type: Function as PropType<(data: any, target: string) => Promise<any>>,
|
|
202
|
+
default: undefined,
|
|
203
|
+
},
|
|
204
|
+
historyRequest: {
|
|
205
|
+
type: Function as PropType<(target: string) => Promise<any>>,
|
|
206
|
+
default: undefined,
|
|
207
|
+
},
|
|
208
|
+
deleteRequest: {
|
|
209
|
+
type: Function as PropType<
|
|
210
|
+
(target: string, id: string) => Promise<any>
|
|
211
|
+
>,
|
|
212
|
+
default: null,
|
|
213
|
+
},
|
|
214
|
+
deleteKey: {
|
|
215
|
+
type: String,
|
|
216
|
+
default: 'key',
|
|
217
|
+
},
|
|
218
|
+
routerMode: {
|
|
219
|
+
type: String,
|
|
220
|
+
default: 'hash',
|
|
221
|
+
},
|
|
222
|
+
style: {
|
|
223
|
+
type: [String, Object],
|
|
224
|
+
default: undefined,
|
|
225
|
+
},
|
|
226
|
+
});
|
|
227
|
+
|
|
228
|
+
const searchRef = ref(null);
|
|
229
|
+
const searchRefContentRef = ref(null);
|
|
230
|
+
const {width} = useElementSize(searchRef);
|
|
231
|
+
|
|
232
|
+
const q = useRouteQuery('q');
|
|
233
|
+
const target = useRouteQuery('target');
|
|
234
|
+
const hasOnceSearch = ref(false);
|
|
235
|
+
|
|
236
|
+
// 是否展开更多筛选
|
|
237
|
+
const expand = ref(false);
|
|
238
|
+
|
|
239
|
+
// 组件方向
|
|
240
|
+
const layout = ref('horizontal');
|
|
241
|
+
const compatible = ref(false);
|
|
242
|
+
// 当前组件宽度 true 大于1000
|
|
243
|
+
const screenSize = ref(true);
|
|
244
|
+
const resetNumber = ref(1);
|
|
245
|
+
|
|
246
|
+
const searchItems = ref<SearchProps[]>([]); // 当前查询条件
|
|
247
|
+
|
|
248
|
+
const termsData = reactive<Terms>({
|
|
249
|
+
terms: [
|
|
250
|
+
{terms: [null, null, null]},
|
|
251
|
+
{terms: [null, null, null], type: 'and'},
|
|
252
|
+
],
|
|
253
|
+
});
|
|
254
|
+
|
|
255
|
+
const columnOptionMap = ref(new Map());
|
|
256
|
+
|
|
257
|
+
provide(optionsMapKey, columnOptionMap);
|
|
258
|
+
|
|
259
|
+
const emit = defineEmits<Emit>();
|
|
260
|
+
|
|
261
|
+
const expandChange = () => {
|
|
262
|
+
expand.value = !expand.value;
|
|
263
|
+
if (!expand.value) {
|
|
264
|
+
// 收起
|
|
265
|
+
const firstItem = termsData.terms[0].terms[0];
|
|
266
|
+
termsData.terms = [
|
|
267
|
+
{terms: [firstItem, null, null]},
|
|
268
|
+
{type: 'or', terms: [null, null, null]},
|
|
269
|
+
];
|
|
270
|
+
}
|
|
271
|
+
};
|
|
272
|
+
|
|
273
|
+
const itemValueChange = (value: SearchItemData, index: number) => {
|
|
274
|
+
if (index < 4) {
|
|
275
|
+
// 第一组数据
|
|
276
|
+
termsData.terms[0].terms[index - 1] = value;
|
|
277
|
+
} else {
|
|
278
|
+
// 第二组数据
|
|
279
|
+
termsData.terms[1].terms[index - 4] = value;
|
|
280
|
+
}
|
|
281
|
+
};
|
|
282
|
+
|
|
283
|
+
const addUrlParams = () => {
|
|
284
|
+
q.value = encodeURI(JSON.stringify(termsData));
|
|
285
|
+
target.value = props.target;
|
|
286
|
+
};
|
|
287
|
+
|
|
288
|
+
const submitData = () => {
|
|
289
|
+
emit('search', termsParamsFormat(termsData, columnOptionMap.value));
|
|
290
|
+
};
|
|
291
|
+
|
|
292
|
+
/**
|
|
293
|
+
* 提交
|
|
294
|
+
*/
|
|
295
|
+
const searchSubmit = () => {
|
|
296
|
+
submitData();
|
|
297
|
+
if (props.type === 'advanced') {
|
|
298
|
+
addUrlParams();
|
|
299
|
+
}
|
|
300
|
+
};
|
|
301
|
+
|
|
302
|
+
/**
|
|
303
|
+
* 重置查询
|
|
304
|
+
*/
|
|
305
|
+
const reset = () => {
|
|
306
|
+
termsData.terms = [
|
|
307
|
+
{terms: [null, null, null]},
|
|
308
|
+
{terms: [null, null, null], type: 'and'},
|
|
309
|
+
];
|
|
310
|
+
expand.value = false;
|
|
311
|
+
if (props.type === 'advanced') {
|
|
312
|
+
q.value = null;
|
|
313
|
+
target.value = null;
|
|
314
|
+
}
|
|
315
|
+
resetNumber.value += 1;
|
|
316
|
+
emit('search', {terms: []});
|
|
317
|
+
};
|
|
318
|
+
|
|
319
|
+
watch(
|
|
320
|
+
width,
|
|
321
|
+
(value) => {
|
|
322
|
+
if (value < 1000) {
|
|
323
|
+
layout.value = 'vertical';
|
|
324
|
+
screenSize.value = false;
|
|
325
|
+
compatible.value = value < 760;
|
|
326
|
+
} else {
|
|
327
|
+
layout.value = 'horizontal';
|
|
328
|
+
screenSize.value = true;
|
|
329
|
+
compatible.value = false;
|
|
330
|
+
}
|
|
331
|
+
},
|
|
332
|
+
{immediate: true},
|
|
333
|
+
);
|
|
334
|
+
|
|
335
|
+
const historyItemClick = (content: string) => {
|
|
336
|
+
try {
|
|
337
|
+
termsData.terms = handleQData(compatibleOldTerms(content))?.terms || [];
|
|
338
|
+
expand.value = hasExpand(termsData.terms);
|
|
339
|
+
searchSubmit();
|
|
340
|
+
} catch (e) {
|
|
341
|
+
console.warn(`Search组件中handleUrlParams处理JSON时异常:【${e}】`);
|
|
342
|
+
}
|
|
343
|
+
};
|
|
344
|
+
|
|
345
|
+
/**
|
|
346
|
+
* 处理URL中的查询参数
|
|
347
|
+
* @param _params
|
|
348
|
+
*/
|
|
349
|
+
const handleUrlParams = (_params: UrlParam) => {
|
|
350
|
+
// URL中的target和props的一致,则还原查询参数
|
|
351
|
+
if (props.target && _params.target === props.target && _params.q) {
|
|
352
|
+
const qStr = decodeURI(_params.q);
|
|
353
|
+
termsData.terms = handleQData(compatibleOldTerms(qStr))?.terms || [];
|
|
354
|
+
expand.value = hasExpand(termsData.terms);
|
|
355
|
+
emit('search', termsParamsFormat(termsData, columnOptionMap.value));
|
|
356
|
+
}
|
|
357
|
+
};
|
|
358
|
+
|
|
359
|
+
/**
|
|
360
|
+
* 处理每项的key为Item组件所需要的key
|
|
361
|
+
*/
|
|
362
|
+
const handleItems = () => {
|
|
363
|
+
searchItems.value = [];
|
|
364
|
+
columnOptionMap.value.clear();
|
|
365
|
+
props.columns!.forEach((item, index) => {
|
|
366
|
+
const _item = cloneDeep(item);
|
|
367
|
+
if (_item.search && Object.keys(_item.search).length) {
|
|
368
|
+
columnOptionMap.value.set(
|
|
369
|
+
// _item.search?.rename || _item.dataIndex,
|
|
370
|
+
_item.dataIndex,
|
|
371
|
+
_item.search,
|
|
372
|
+
);
|
|
373
|
+
|
|
374
|
+
// 默认值
|
|
375
|
+
const {search} = _item;
|
|
376
|
+
let defaultTerms = null;
|
|
377
|
+
// 包含defaultValue 或者 defaultOnceValue
|
|
378
|
+
if (search.defaultValue !== undefined || search.defaultOnceValue) {
|
|
379
|
+
const _value = search.defaultValue || search.defaultOnceValue;
|
|
380
|
+
defaultTerms = {
|
|
381
|
+
type: 'and',
|
|
382
|
+
value: _value,
|
|
383
|
+
termType:
|
|
384
|
+
search.defaultTermType || getTermTypeFn(search.type),
|
|
385
|
+
column: _item.dataIndex,
|
|
386
|
+
};
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
if (
|
|
390
|
+
search.defaultValue !== undefined ||
|
|
391
|
+
search.defaultOnceValue !== undefined
|
|
392
|
+
) {
|
|
393
|
+
hasOnceSearch.value = true;
|
|
394
|
+
}
|
|
395
|
+
searchItems.value.push({
|
|
396
|
+
..._item.search,
|
|
397
|
+
sortIndex: _item.search.first ? 0 : index + 1,
|
|
398
|
+
title: _item.title as any,
|
|
399
|
+
// column: _item.search?.rename || _item.dataIndex,
|
|
400
|
+
column: _item.dataIndex,
|
|
401
|
+
});
|
|
402
|
+
if (defaultTerms) {
|
|
403
|
+
itemValueChange(defaultTerms, search.first ? 1 : index + 1);
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
});
|
|
407
|
+
|
|
408
|
+
submitData();
|
|
409
|
+
|
|
410
|
+
handleUrlParams({q: q.value, target: target.value});
|
|
411
|
+
};
|
|
412
|
+
|
|
413
|
+
watch(
|
|
414
|
+
() => props.columns,
|
|
415
|
+
() => {
|
|
416
|
+
termsData.terms = [
|
|
417
|
+
{terms: [null, null, null]},
|
|
418
|
+
{terms: [null, null, null], type: 'and'},
|
|
419
|
+
];
|
|
420
|
+
expand.value = false;
|
|
421
|
+
if (props.type === 'advanced') {
|
|
422
|
+
q.value = null;
|
|
423
|
+
target.value = null;
|
|
424
|
+
}
|
|
425
|
+
handleItems();
|
|
426
|
+
},
|
|
427
|
+
{
|
|
428
|
+
deep: true,
|
|
429
|
+
},
|
|
430
|
+
);
|
|
431
|
+
|
|
432
|
+
handleItems();
|
|
433
|
+
</script>
|
|
434
|
+
|
|
435
|
+
<style scoped lang="less"></style>
|