@opentiny/vue-search-box 0.1.1-alpha.1 → 0.1.1-alpha.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 (43) hide show
  1. package/README.md +28 -0
  2. package/README.zh-CN.md +28 -0
  3. package/dist/es/index.es.js +11 -3
  4. package/dist/es/index.vue.es2.js +11 -42
  5. package/dist/es/utils/en_US.es.js +37 -37
  6. package/dist/es/utils/zh_CN.es.js +1 -1
  7. package/dist/lib/index.cjs.js +10 -2
  8. package/dist/lib/index.vue.cjs2.js +83 -114
  9. package/dist/lib/utils/en_US.cjs.js +38 -38
  10. package/dist/lib/utils/zh_CN.cjs.js +2 -2
  11. package/dist/types/utils/en_US.d.ts +2 -1
  12. package/dist/types/utils/zh_CN.d.ts +2 -1
  13. package/package.json +24 -20
  14. package/__tests__/search-box.spec.ts +0 -0
  15. package/scripts/pre-release.cjs +0 -8
  16. package/src/composables/use-checkbox.ts +0 -90
  17. package/src/composables/use-custom.ts +0 -53
  18. package/src/composables/use-datepicker.ts +0 -90
  19. package/src/composables/use-dropdown.ts +0 -251
  20. package/src/composables/use-edit.ts +0 -119
  21. package/src/composables/use-init.ts +0 -69
  22. package/src/composables/use-match.ts +0 -193
  23. package/src/composables/use-num-range.ts +0 -86
  24. package/src/composables/use-placeholder.ts +0 -43
  25. package/src/composables/use-tag.ts +0 -54
  26. package/src/index.less +0 -376
  27. package/src/index.ts +0 -13
  28. package/src/index.type.ts +0 -192
  29. package/src/index.vue +0 -1138
  30. package/src/smb-theme.ts +0 -15
  31. package/src/theme.json +0 -135
  32. package/src/utils/clone.ts +0 -37
  33. package/src/utils/date.ts +0 -724
  34. package/src/utils/dropdown.ts +0 -27
  35. package/src/utils/en_US.ts +0 -41
  36. package/src/utils/index.ts +0 -11
  37. package/src/utils/tag.ts +0 -80
  38. package/src/utils/type.ts +0 -6
  39. package/src/utils/validate.ts +0 -234
  40. package/src/utils/zh_CN.ts +0 -41
  41. package/src/vars.less +0 -56
  42. package/vite.config.theme.ts +0 -20
  43. package/vite.config.ts +0 -60
package/src/index.vue DELETED
@@ -1,1138 +0,0 @@
1
- <script setup lang="ts">
2
- import type { PropType } from "vue";
3
- import {
4
- reactive,
5
- getCurrentInstance,
6
- watch,
7
- nextTick,
8
- onMounted,
9
- computed,
10
- onBeforeUnmount,
11
- } from "vue";
12
- import TinyTag from "@opentiny/vue-tag";
13
- import TinyInput from "@opentiny/vue-input";
14
- import TinyDropdown from "@opentiny/vue-dropdown";
15
- import TinyDropdownMenu from "@opentiny/vue-dropdown-menu";
16
- import TinyDropdownItem from "@opentiny/vue-dropdown-item";
17
- import TinyCheckbox from "@opentiny/vue-checkbox";
18
- import TinyCheckboxGroup from "@opentiny/vue-checkbox-group";
19
- import TinyButton from "@opentiny/vue-button";
20
- import TinyTooltip from "@opentiny/vue-tooltip";
21
- import TinyDatePicker from "@opentiny/vue-date-picker";
22
- import TinyForm from "@opentiny/vue-form";
23
- import TinyFormItem from "@opentiny/vue-form-item";
24
- import TinyPopover from "@opentiny/vue-popover";
25
- import TinySelect from "@opentiny/vue-select";
26
- import TinyOption from "@opentiny/vue-option";
27
- import { iconSearch, iconClose, iconHelpQuery } from "@opentiny/vue-icon";
28
- import { t } from "@opentiny/vue-locale";
29
- import { useTag } from "./composables/use-tag";
30
- import { useDropdown } from "./composables/use-dropdown";
31
- import { useMatch } from "./composables/use-match";
32
- import { useCheckbox } from "./composables/use-checkbox";
33
- import { useDatePicker } from "./composables/use-datepicker";
34
- import { useNumRange } from "./composables/use-num-range";
35
- import { useEdit } from "./composables/use-edit";
36
- import { useCustom } from "./composables/use-custom";
37
- import { useInit } from "./composables/use-init";
38
- import { usePlaceholder } from "./composables/use-placeholder";
39
- import type {
40
- ISearchBoxItem,
41
- ISearchBoxTag,
42
- ISearchBoxMatchOptions,
43
- } from "./index.type";
44
- import { showDropdown, showPopover } from "./utils/dropdown";
45
- import "./index.less";
46
- import { deepClone } from "./utils/clone";
47
- import { format } from "./utils/date";
48
-
49
- defineOptions({
50
- name: "TinySearchBox",
51
- });
52
-
53
- const props = defineProps({
54
- modelValue: {
55
- type: Array as PropType<ISearchBoxTag[]>,
56
- default() {
57
- return [];
58
- },
59
- },
60
- items: {
61
- type: Array as PropType<ISearchBoxItem[]>,
62
- default: () => [],
63
- },
64
- emptyPlaceholder: {
65
- type: String,
66
- default: t("tvp.tvpSearchbox.defaultPlaceholder"),
67
- },
68
- potentialOptions: {
69
- type: Object as PropType<ISearchBoxMatchOptions>,
70
- default() {
71
- return null;
72
- },
73
- },
74
- // 是否显示帮助图标,新规范默认显示
75
- showHelp: {
76
- type: Boolean as PropType<boolean>,
77
- default: true,
78
- },
79
- // 标签标识键
80
- idMapKey: {
81
- type: String,
82
- default: "id",
83
- },
84
- // 自定义默认搜索项
85
- defaultField: {
86
- type: String,
87
- default: "",
88
- },
89
- editable: {
90
- type: Boolean,
91
- default: false,
92
- },
93
- maxlength: {
94
- type: Number,
95
- },
96
- // 3.18.0新增
97
- panelMaxHeight: {
98
- type: String,
99
- default: "999px",
100
- },
101
- // 3.18.0新增
102
- splitInputValue: {
103
- type: String,
104
- default: ",",
105
- },
106
- // 3.18.0新增
107
- showNoDataTip: {
108
- type: Boolean,
109
- default: true,
110
- },
111
- });
112
-
113
- const emits = defineEmits([
114
- "update:modelValue",
115
- "change",
116
- "search",
117
- "exceed",
118
- "first-level-select",
119
- ]);
120
-
121
- const state = reactive({
122
- innerModelValue: [...props.modelValue],
123
- recordItems: [] as ISearchBoxItem[],
124
- groupItems: {},
125
- inputValue: "",
126
- matchItems: {},
127
- propItem: {},
128
- backupList: [],
129
- filterList: [],
130
- checkboxGroup: [],
131
- prevItem: {},
132
- backupPrevItem: "",
133
- formRules: null,
134
- validType: "text",
135
- numberShowMessage: true,
136
- startDate: null,
137
- startDateTime: null,
138
- endDate: null,
139
- endDateTime: null,
140
- isShowTagKey: true,
141
- potentialOptions: null,
142
- hiden: true,
143
- dateRangeFormat: "yyyy/MM/dd",
144
- datetimeRangeFormat: "yyyy/MM/dd HH:mm:ss",
145
- indexMap: new Map(),
146
- valueMap: new Map(),
147
- popoverVisible: false,
148
- selectValue: "",
149
- allTypeAttri: {
150
- label: t("tvp.tvpSearchbox.rulekeyword1"),
151
- field: "tvpKeyword",
152
- type: "radio",
153
- },
154
- operatorValue: ":", // 当前操作符值
155
- inputEditValue: "",
156
- currentOperators: "",
157
- currentEditValue: "",
158
- isShowDropdown: true, // 控制有匹配数据展示开关
159
- isShowPanel: true, // 控制面板显隐
160
- currentModelValueIndex: -1, // 当前编辑的标签索引
161
- curMinNumVar: "", // numRange最小值变量
162
- curMaxNumVar: "", // numRange最大值变量
163
- instance: getCurrentInstance(),
164
- isMouseDown: false,
165
- isResetFlag: true, // 输入框触发源重置
166
- currentEditSelectTags: [], // 当前编辑多选的标签值
167
- });
168
- state.isShowPanel = computed(
169
- () =>
170
- state.isResetFlag &&
171
- (props.showNoDataTip || (!props.showNoDataTip && state.isShowDropdown)) &&
172
- (state.prevItem.type ||
173
- !state.propItem.label ||
174
- state.backupList.length ||
175
- state.currentOperators?.length)
176
- );
177
-
178
- const TinyIconSearch = iconSearch();
179
- const TinyIconClose = iconClose();
180
- const TinyIconHelpQuery = iconHelpQuery();
181
-
182
- const { selectPropItem, selectRadioItem, createTag, helpClick, setOperator } =
183
- useDropdown({
184
- props,
185
- emits,
186
- state,
187
- t,
188
- format,
189
- });
190
-
191
- const { deleteTag, clearTag, backspaceDeleteTag } = useTag({
192
- props,
193
- state,
194
- emits,
195
- });
196
-
197
- const { editTag, confirmEditTag, selectPropChange, selectItemIsDisable } =
198
- useEdit({
199
- props,
200
- state,
201
- t,
202
- nextTick,
203
- format,
204
- emits,
205
- });
206
-
207
- const { handleInput, selectFirstMap } = useMatch({
208
- props,
209
- state,
210
- emits,
211
- });
212
-
213
- const { placeholder, setPlaceholder } = usePlaceholder({ props, state, t });
214
-
215
- const { selectCheckbox, isIndeterminate, checkAll, isShowClose } = useCheckbox({
216
- props,
217
- state,
218
- emits,
219
- });
220
-
221
- const { onConfirmDate, handleDateShow, pickerOptions } = useDatePicker({
222
- props,
223
- state,
224
- emits,
225
- });
226
-
227
- const { sizeChange, initFormRule } = useNumRange({
228
- props,
229
- state,
230
- t,
231
- emits,
232
- });
233
-
234
- const { handleConfirm, handleEditConfirm } = useCustom({ state, emits });
235
-
236
- const {
237
- initItems,
238
- watchOutsideClick,
239
- watchMouseDown,
240
- watchMouseMove,
241
- handleClick,
242
- } = useInit({
243
- props,
244
- state,
245
- });
246
-
247
- // 处理异步items数据渲染
248
- watch(
249
- () => props.items,
250
- (newVal: ISearchBoxItem[]) => {
251
- state.recordItems = deepClone(newVal);
252
- initItems();
253
- initFormRule();
254
- },
255
- {
256
- deep: true,
257
- immediate: true,
258
- }
259
- );
260
-
261
- watch(
262
- () => state.popoverVisible,
263
- (newVal) => {
264
- if (!newVal && !state.inputEditValue.length) {
265
- state.inputEditValue = state.currentEditSelectTags;
266
- }
267
- },
268
- {
269
- immediate: true,
270
- }
271
- );
272
-
273
- watch(
274
- () => props.modelValue,
275
- (newVal) => {
276
- if (newVal) {
277
- state.indexMap.clear();
278
- state.valueMap.clear();
279
- newVal.forEach((item, index) => {
280
- const value = `${item.label}${item.value}`;
281
- state.indexMap.set(item.label, index);
282
- state.valueMap.set(value, index);
283
- if (item.options?.length > 0) {
284
- item.options.forEach((option) => {
285
- const optionValue = `${item.label}${option.label}`;
286
- state.valueMap.set(optionValue, index);
287
- });
288
- }
289
- });
290
- showPopover(state, false);
291
- if (newVal.length === 0) {
292
- setPlaceholder(props.emptyPlaceholder);
293
- }
294
-
295
- if (props.editable && !state.inputEditValue.length && newVal[0]) {
296
- state.inputEditValue = newVal[0].value;
297
- }
298
- }
299
- state.innerModelValue = [...newVal];
300
- },
301
- {
302
- deep: true,
303
- immediate: true,
304
- }
305
- );
306
-
307
- onMounted(() => {
308
- document.addEventListener("click", watchOutsideClick);
309
- document.addEventListener("mousedown", watchMouseDown);
310
- document.addEventListener("mousemove", watchMouseMove);
311
- });
312
-
313
- onBeforeUnmount(() => {
314
- document.removeEventListener("click", watchOutsideClick);
315
- document.removeEventListener("mousedown", watchMouseDown);
316
- document.removeEventListener("mousemove", watchMouseMove);
317
- });
318
-
319
- defineExpose({
320
- state,
321
- });
322
- </script>
323
-
324
- <template>
325
- <div class="tvp-search-box" @click.stop="showPopover(state, false)">
326
- <tiny-icon-search class="tvp-search-box__prefix" />
327
- <tiny-tag
328
- v-for="(tag, index) in modelValue"
329
- :key="tag.field + index"
330
- closable
331
- :class="[
332
- 'tvp-search-box__tag',
333
- editable && tag.type !== 'map' ? 'tvp-search-box__tag-editor' : '',
334
- ]"
335
- :title="`${tag.label} ${tag.operator || ':'} ${tag.value}`"
336
- @close="deleteTag(tag)"
337
- @click.stop="editTag(tag, index, $event)"
338
- >
339
- <span class="tvp-search-box__tag-value"
340
- >{{ tag.label }} {{ tag.operator || ":" }} {{ tag.value }}
341
- </span>
342
- </tiny-tag>
343
- <span v-if="modelValue.length" class="tvp-search-box__placeholder"></span>
344
-
345
- <tiny-form
346
- ref="formRef"
347
- :model="state"
348
- :rules="state.formRules"
349
- :validate-type="state.validType"
350
- label-width="0px"
351
- message-type="block"
352
- class="tvp-search-box__form"
353
- >
354
- <div class="tvp-search-box__input-wrapper">
355
- <section class="tvp-search-box__prop">
356
- <span v-show="state.propItem.label"
357
- >{{ state.propItem.label }}&nbsp;{{
358
- `${state.operatorValue ? state.operatorValue : ""}&nbsp;`
359
- }}</span
360
- >
361
- <span v-show="state.propItem.value">{{ state.propItem.value }}</span>
362
- </section>
363
- <tiny-dropdown
364
- ref="dropdownRef"
365
- trigger="click"
366
- class="tvp-search-box__dropdown"
367
- :hide-on-click="state.hiden"
368
- :show-icon="false"
369
- lazy-show-popper
370
- >
371
- <tiny-input
372
- ref="inputRef"
373
- v-model="state.inputValue"
374
- class="tvp-search-box__input"
375
- :placeholder="placeholder"
376
- :maxlength="maxlength && maxlength + 1"
377
- @keydown.delete.stop="backspaceDeleteTag"
378
- @keydown.enter.stop="createTag"
379
- @input="handleInput"
380
- @focus="showPopover(state, false)"
381
- @click="handleClick"
382
- >
383
- <template #suffix>
384
- <tiny-icon-close
385
- v-show="isShowClose"
386
- class="tvp-search-box__input-close"
387
- @click.stop="clearTag"
388
- />
389
- <span
390
- v-show="isShowClose"
391
- class="tvp-search-box__input-separator"
392
- ></span>
393
- <tiny-tooltip
394
- v-if="showHelp"
395
- effect="dark"
396
- :content="t('tvp.tvpSearchbox.help')"
397
- placement="top"
398
- >
399
- <tiny-icon-help-query
400
- class="tvp-search-box__input-help"
401
- @click.stop="helpClick"
402
- />
403
- </tiny-tooltip>
404
- <tiny-icon-search
405
- class="tvp-search-box__input-search"
406
- @click.stop="createTag"
407
- />
408
- </template>
409
- </tiny-input>
410
- <template #dropdown>
411
- <tiny-dropdown-menu
412
- placement="bottom-start"
413
- popper-class="tvp-search-box__dropdown-menu"
414
- :style="{ 'max-height': panelMaxHeight }"
415
- @mouseup.stop="() => {}"
416
- >
417
- <div
418
- v-show="
419
- state.isResetFlag &&
420
- !state.propItem.label &&
421
- state.inputValue.trim()
422
- "
423
- >
424
- <template v-for="(value, key) in state.matchItems" :key="key">
425
- <template v-if="value['attr'].length">
426
- <span class="tvp-search-box__filter-type">{{
427
- key === "0" ? t("tvp.tvpSearchbox.attributeType") : key
428
- }}</span>
429
- <tiny-dropdown-item
430
- v-for="(item, index) in value['attr']"
431
- :key="item.label + index"
432
- class="tvp-search-box__filter-item tvp-search-box__dropdown-item"
433
- @click="selectPropItem(item)"
434
- >
435
- <span>
436
- <template v-for="text in item.match" :key="text">
437
- <span
438
- v-if="Array.isArray(text)"
439
- class="tvp-search-box__text-highlight"
440
- >{{ text[0] }}</span
441
- >
442
- <template v-else>{{ text }}</template>
443
- </template>
444
- </span>
445
- </tiny-dropdown-item>
446
- </template>
447
- <template v-if="value['attrValue'].length">
448
- <span class="tvp-search-box__filter-type">{{
449
- t("tvp.tvpSearchbox.propertyValue", [
450
- key === "0" ? t("tvp.tvpSearchbox.attributeType") : key,
451
- ])
452
- }}</span>
453
- <tiny-dropdown-item
454
- v-for="(item, index) in value['attrValue']"
455
- :key="item.label + index"
456
- :disabled="item.isChecked"
457
- class="tvp-search-box__filter-item tvp-search-box__dropdown-item"
458
- @click="selectRadioItem(item, true)"
459
- >
460
- <span>
461
- <template v-for="text in item.match" :key="text">
462
- <span
463
- v-if="Array.isArray(text)"
464
- class="tvp-search-box__text-highlight"
465
- >{{ text[0] }}</span
466
- >
467
- <template v-else>{{ text }}</template>
468
- </template>
469
- </span>
470
- </tiny-dropdown-item>
471
- </template>
472
- </template>
473
- <tiny-dropdown-item
474
- v-if="showNoDataTip && !state.isShowDropdown"
475
- >
476
- <div>{{ t("tvp.tvpSearchbox.noData") }}</div>
477
- </tiny-dropdown-item>
478
- <div v-show="props.potentialOptions">
479
- <span class="tvp-search-box__filter-type">{{
480
- t("tvp.tvpSearchbox.matched")
481
- }}</span>
482
- <div
483
- id="potential-loading"
484
- class="tvp-search-box__potential-box"
485
- >
486
- <div v-if="state.potentialOptions">
487
- <tiny-dropdown-item
488
- v-for="(item, index) in state.potentialOptions"
489
- :key="item.label + index"
490
- class="tvp-search-box__filter-item tvp-search-box__dropdown-item"
491
- @click="selectRadioItem(item, true)"
492
- >
493
- {{ item.label }}:
494
- <span class="tvp-search-box__text-highlight">{{
495
- item.value
496
- }}</span>
497
- </tiny-dropdown-item>
498
- </div>
499
- </div>
500
- </div>
501
- </div>
502
- <div
503
- v-show="
504
- state.isResetFlag &&
505
- !state.propItem.label &&
506
- !state.inputValue.trim()
507
- "
508
- class="tvp-search-box__first-panel"
509
- >
510
- <template v-for="(group, key) in state.groupItems" :key="key">
511
- <span
512
- v-if="group.length"
513
- class="tvp-search-box__filter-type"
514
- >{{
515
- key === "0" ? t("tvp.tvpSearchbox.attributeType") : key
516
- }}</span
517
- >
518
- <tiny-dropdown-item
519
- v-for="(item, index) in group"
520
- :key="(item.field || item.label) + index"
521
- class="tvp-search-box__dropdown-item"
522
- @click="selectPropItem(item)"
523
- >
524
- <span :title="item.label">{{ item.label }}</span>
525
- </tiny-dropdown-item>
526
- </template>
527
- </div>
528
- <!-- 有label的情况 -->
529
- <div v-show="state.isResetFlag && state.propItem.label">
530
- <div v-if="state.currentOperators?.length">
531
- <span class="tvp-search-box__filter-type">{{
532
- t("tvp.tvpSearchbox.operator")
533
- }}</span>
534
- <tiny-dropdown-item
535
- v-for="(item, index) in state.currentOperators"
536
- v-show="item.includes(state.inputValue)"
537
- :key="item + index"
538
- class="tvp-search-box__dropdown-item"
539
- @click="setOperator(item)"
540
- >
541
- {{ item }}
542
- </tiny-dropdown-item>
543
- </div>
544
- <div
545
- v-else-if="
546
- !state.prevItem.type || state.prevItem.type === 'radio'
547
- "
548
- class="tvp-search-box__radio-wrap"
549
- >
550
- <tiny-dropdown-item
551
- v-for="(item, index) in state.backupList"
552
- v-show="!item.isFilter || !state.inputValue"
553
- :key="index + (item.field || item.label)"
554
- :disabled="item.isChecked"
555
- class="tvp-search-box__dropdown-item"
556
- @click="selectRadioItem(item)"
557
- >
558
- <span v-if="item.match" :title="item.label">
559
- <template v-for="text in item.match" :key="text">
560
- <span
561
- v-if="Array.isArray(text)"
562
- class="tvp-search-box__text-highlight"
563
- >{{ text[0] }}</span
564
- >
565
- <template v-else>{{ text }}</template></template
566
- >
567
- </span>
568
- <span v-else :title="item.label">{{ item.label }}</span>
569
- </tiny-dropdown-item>
570
- </div>
571
- <div
572
- v-else-if="
573
- state.isResetFlag && state.prevItem.type === 'checkbox'
574
- "
575
- >
576
- <div class="tvp-search-box__checkbox-wrap">
577
- <tiny-checkbox-group
578
- v-model="checkAll"
579
- class="tvp-search-box__checkbox"
580
- >
581
- <tiny-dropdown-item
582
- class="tvp-search-box__dropdown-item tvp-search-box__checkbox-item"
583
- >
584
- <tiny-checkbox
585
- v-model="checkAll"
586
- :indeterminate="isIndeterminate"
587
- >
588
- {{ t("tvp.tvpSearchbox.selectAll") }}
589
- </tiny-checkbox>
590
- </tiny-dropdown-item>
591
- </tiny-checkbox-group>
592
- <tiny-checkbox-group
593
- v-model="state.checkboxGroup"
594
- class="tvp-search-box__checkbox"
595
- >
596
- <tiny-dropdown-item
597
- v-for="(item, index) in state.backupList"
598
- v-show="!item.isFilter"
599
- :key="(item.field || item.label) + index"
600
- class="tvp-search-box__dropdown-item tvp-search-box__checkbox-item"
601
- >
602
- <tiny-checkbox
603
- :label="state.prevItem.label + item.label"
604
- :title="item.label"
605
- class="tvp-search-box__checkbox-item-label"
606
- >
607
- {{ item.label }}
608
- </tiny-checkbox>
609
- </tiny-dropdown-item>
610
- </tiny-checkbox-group>
611
- </div>
612
- <div class="tvp-search-box__checkbox-btn">
613
- <tiny-button size="mini" @click="selectCheckbox(true)">
614
- {{ t("tvp.tvpSearchbox.confirm") }}
615
- </tiny-button>
616
- <tiny-button size="mini" @click="selectCheckbox(false)">
617
- {{ t("tvp.tvpSearchbox.cancel") }}
618
- </tiny-button>
619
- </div>
620
- </div>
621
- <div
622
- v-else-if="state.prevItem.type === 'numRange'"
623
- class="tvp-search-box__panel-box"
624
- >
625
- <div class="tvp-search-box__number">
626
- <div class="tvp-search-box__dropdown-title">
627
- {{ t("tvp.tvpSearchbox.rangeNumberTitle") }}
628
- </div>
629
- <div class="tvp-search-box__dropdown-start">
630
- {{ t("tvp.tvpSearchbox.minValueText") }}({{
631
- state.prevItem.unit
632
- }})
633
- </div>
634
- <tiny-form-item
635
- :prop="state.curMinNumVar"
636
- class="tvp-search-box__number-item"
637
- :show-message="state.numberShowMessage"
638
- >
639
- <tiny-input
640
- v-model="state[state.curMinNumVar]"
641
- type="number"
642
- class="tvp-search-box__number-input"
643
- ></tiny-input>
644
- </tiny-form-item>
645
- <div class="tvp-search-box__dropdown-end">
646
- {{ t("tvp.tvpSearchbox.maxValueText") }}({{
647
- state.prevItem.unit
648
- }})
649
- </div>
650
- <tiny-form-item
651
- :prop="state.curMaxNumVar"
652
- class="tvp-search-box__number-item"
653
- >
654
- <tiny-input
655
- v-model="state[state.curMaxNumVar]"
656
- type="number"
657
- class="tvp-search-box__number-input"
658
- ></tiny-input>
659
- </tiny-form-item>
660
- </div>
661
- <div class="tvp-search-box__bottom-btn">
662
- <tiny-button size="mini" @click.stop="sizeChange(true)">
663
- {{ t("tvp.tvpSearchbox.confirm") }}
664
- </tiny-button>
665
- <tiny-button size="mini" @click="sizeChange(false)">{{
666
- t("tvp.tvpSearchbox.cancel")
667
- }}</tiny-button>
668
- </div>
669
- </div>
670
-
671
- <div
672
- v-else-if="state.prevItem.type === 'dateRange'"
673
- class="tvp-search-box__panel-box"
674
- >
675
- <div class="tvp-search-box__date-wrap">
676
- <div class="tvp-search-box__dropdown-title">
677
- {{
678
- state.prevItem.maxTimeLength > 0
679
- ? t("tvp.tvpSearchbox.timeLengthTitle", {
680
- value: (
681
- state.prevItem.maxTimeLength / 86400000
682
- ).toFixed(1),
683
- })
684
- : t("tvp.tvpSearchbox.rangeDateTitle")
685
- }}
686
- </div>
687
- <div class="tvp-search-box__dropdown-start">
688
- {{ t("tvp.tvpSearchbox.rangeBeginLabel") }}
689
- </div>
690
- <tiny-form-item
691
- prop="startDate"
692
- :show-message="Boolean(state.prevItem.maxTimeLength)"
693
- class="tvp-search-box__date-item"
694
- >
695
- <tiny-date-picker
696
- v-model="state.startDate"
697
- :format="state.prevItem.format || state.dateRangeFormat"
698
- :value-format="
699
- state.prevItem.format || state.dateRangeFormat
700
- "
701
- :picker-options="
702
- pickerOptions(state.startDate, 'endDate')
703
- "
704
- class="tvp-search-box__date-picker"
705
- @change="handleDateShow"
706
- @blur="handleDateShow"
707
- ></tiny-date-picker>
708
- </tiny-form-item>
709
- <div class="tvp-search-box__dropdown-end">
710
- {{ t("tvp.tvpSearchbox.rangeEndLabel") }}
711
- </div>
712
- <tiny-form-item
713
- prop="endDate"
714
- class="tvp-search-box__date-item"
715
- >
716
- <tiny-date-picker
717
- v-model="state.endDate"
718
- :format="state.prevItem.format || state.dateRangeFormat"
719
- :value-format="
720
- state.prevItem.format || state.dateRangeFormat
721
- "
722
- :picker-options="pickerOptions(state.startDate)"
723
- class="tvp-search-box__date-picker"
724
- @change="handleDateShow"
725
- @blur="handleDateShow"
726
- ></tiny-date-picker>
727
- </tiny-form-item>
728
- </div>
729
- <div class="tvp-search-box__bottom-btn">
730
- <tiny-button size="mini" @click="onConfirmDate(true)">
731
- {{ t("tvp.tvpSearchbox.confirm") }}
732
- </tiny-button>
733
- <tiny-button size="mini" @click="onConfirmDate(false)">
734
- {{ t("tvp.tvpSearchbox.cancel") }}
735
- </tiny-button>
736
- </div>
737
- </div>
738
-
739
- <div
740
- v-else-if="state.prevItem.type === 'datetimeRange'"
741
- class="tvp-search-box__panel-box"
742
- >
743
- <div class="tvp-search-box__date-wrap">
744
- <div class="tvp-search-box__dropdown-title">
745
- {{
746
- state.prevItem.maxTimeLength > 0
747
- ? t("tvp.tvpSearchbox.timeLengthTitle", {
748
- value: (
749
- state.prevItem.maxTimeLength / 86400000
750
- ).toFixed(1),
751
- })
752
- : t("tvp.tvpSearchbox.rangeDateTitle")
753
- }}
754
- </div>
755
- <div class="tvp-search-box__dropdown-start">
756
- {{ t("tvp.tvpSearchbox.rangeBeginLabel") }}
757
- </div>
758
- <tiny-form-item
759
- prop="startDateTime"
760
- :show-message="Boolean(state.prevItem.maxTimeLength)"
761
- class="tvp-search-box__date-item"
762
- >
763
- <tiny-date-picker
764
- v-model="state.startDateTime"
765
- type="datetime"
766
- :isutc8="true"
767
- :format="
768
- state.prevItem.format || state.datetimeRangeFormat
769
- "
770
- :value-format="
771
- state.prevItem.format || state.datetimeRangeFormat
772
- "
773
- :picker-options="
774
- pickerOptions(state.startDateTime, 'endDateTime')
775
- "
776
- class="tvp-search-box__date-picker"
777
- @change="handleDateShow"
778
- @blur="handleDateShow"
779
- ></tiny-date-picker>
780
- </tiny-form-item>
781
- <div class="tvp-search-box__dropdown-end">
782
- {{ t("tvp.tvpSearchbox.rangeEndLabel") }}
783
- </div>
784
- <tiny-form-item
785
- prop="endDateTime"
786
- class="tvp-search-box__date-item"
787
- >
788
- <tiny-date-picker
789
- v-model="state.endDateTime"
790
- type="datetime"
791
- :isutc8="true"
792
- :format="
793
- state.prevItem.format || state.datetimeRangeFormat
794
- "
795
- :value-format="
796
- state.prevItem.format || state.datetimeRangeFormat
797
- "
798
- :picker-options="pickerOptions(state.startDateTime)"
799
- class="tvp-search-box__date-picker"
800
- @change="handleDateShow"
801
- @blur="handleDateShow"
802
- ></tiny-date-picker>
803
- </tiny-form-item>
804
- </div>
805
- <div class="tvp-search-box__bottom-btn">
806
- <tiny-button size="mini" @click="onConfirmDate(true, true)">
807
- {{ t("tvp.tvpSearchbox.confirm") }}
808
- </tiny-button>
809
- <tiny-button
810
- size="mini"
811
- @click="onConfirmDate(false, true)"
812
- >
813
- {{ t("tvp.tvpSearchbox.cancel") }}
814
- </tiny-button>
815
- </div>
816
- </div>
817
-
818
- <div v-else-if="state.prevItem.type === 'map'">
819
- <span
820
- v-if="state.isShowTagKey"
821
- class="tvp-search-box__filter-type"
822
- >{{ t("tvp.tvpSearchbox.tagKey") }}</span
823
- >
824
- <span v-else class="tvp-search-box__filter-type">{{
825
- t("tvp.tvpSearchbox.tagValue")
826
- }}</span>
827
- <tiny-dropdown-item
828
- v-for="(item, index) in state.backupList"
829
- v-show="!item.isFilter"
830
- :key="item.label + item.value + index"
831
- :disabled="item.isChecked"
832
- class="tvp-search-box__dropdown-item"
833
- @click="selectFirstMap(item, state.isShowTagKey)"
834
- >
835
- <span :title="item.label">{{ item.label }}</span>
836
- </tiny-dropdown-item>
837
- </div>
838
- <div
839
- v-else-if="state.prevItem.type === 'custom'"
840
- class="tvp-search-box__panel-box"
841
- @click="showDropdown(state)"
842
- >
843
- <slot
844
- :name="state.prevItem.slotName"
845
- v-bind="{
846
- showDropdown: () => showDropdown(state),
847
- onConfirm: handleConfirm,
848
- }"
849
- @click.stop
850
- ></slot>
851
- </div>
852
- <tiny-dropdown-item
853
- v-if="showNoDataTip && !state.isShowDropdown"
854
- >
855
- <div>{{ t("tvp.tvpSearchbox.noData") }}</div>
856
- </tiny-dropdown-item>
857
- </div>
858
- </tiny-dropdown-menu>
859
- </template>
860
- </tiny-dropdown>
861
- </div>
862
-
863
- <template v-if="editable">
864
- <tiny-popover
865
- ref="popoverRef"
866
- v-model="state.popoverVisible"
867
- placement="bottom-start"
868
- :visible-arrow="false"
869
- trigger="manual"
870
- popper-class="tvp-search-box__popover"
871
- class="tvp-search-box__form-popover"
872
- >
873
- <template v-if="state.prevItem.type !== 'custom'">
874
- <div class="tvp-search-box__date-wrap">
875
- <div class="tvp-search-box__dropdown-start">
876
- {{ t("tvp.tvpSearchbox.attributeType") }}
877
- </div>
878
- <tiny-form-item class="tvp-search-box__number-item">
879
- <tiny-select
880
- v-model="state.selectValue"
881
- searchable
882
- :disabled="state.prevItem.editAttrDisabled"
883
- >
884
- <tiny-option
885
- :key="state.allTypeAttri.label"
886
- :label="t('tvp.tvpSearchbox.allProperty')"
887
- :value="state.allTypeAttri.label"
888
- :disabled="selectItemIsDisable(state.allTypeAttri)"
889
- @click="
890
- selectPropChange(
891
- state.allTypeAttri,
892
- selectItemIsDisable(state.allTypeAttri)
893
- )
894
- "
895
- >
896
- </tiny-option>
897
- <tiny-option
898
- v-for="item in state.recordItems"
899
- :key="item.label"
900
- :label="item.label"
901
- :value="item.label"
902
- :disabled="selectItemIsDisable(item)"
903
- @click="selectPropChange(item, selectItemIsDisable(item))"
904
- >
905
- </tiny-option>
906
- </tiny-select>
907
- </tiny-form-item>
908
- <div
909
- v-if="state.prevItem.operators"
910
- class="tvp-search-box__dropdown-end"
911
- >
912
- {{ t("tvp.tvpSearchbox.operator") }}
913
- </div>
914
- <tiny-form-item
915
- v-if="state.prevItem.operators"
916
- class="tvp-search-box__number-item"
917
- >
918
- <tiny-select v-model="state.operatorValue">
919
- <tiny-option
920
- v-for="item in state.currentOperators"
921
- :key="item"
922
- :label="item"
923
- :value="item"
924
- >
925
- </tiny-option>
926
- </tiny-select>
927
- </tiny-form-item>
928
- <div
929
- v-if="state.prevItem.type !== 'numRange'"
930
- class="tvp-search-box__dropdown-end"
931
- >
932
- {{ t("tvp.tvpSearchbox.tagValue") }}
933
- </div>
934
- <tiny-form-item
935
- v-if="
936
- ![
937
- 'numRange',
938
- 'dateRange',
939
- 'datetimeRange',
940
- 'custom',
941
- ].includes(state.prevItem.type)
942
- "
943
- prop="inputEditValue"
944
- class="tvp-search-box__number-item"
945
- >
946
- <tiny-select
947
- v-if="state.currentEditValue?.length > 0"
948
- v-model="state.inputEditValue"
949
- class="tvp-search-box-select"
950
- :multiple="Boolean(state.prevItem.mergeTag)"
951
- allow-create
952
- filterable
953
- default-first-option
954
- clearable
955
- >
956
- <tiny-option
957
- v-for="item in state.currentEditValue"
958
- :key="item.label"
959
- :label="item.label"
960
- :value="item.label"
961
- >
962
- </tiny-option>
963
- </tiny-select>
964
- <tiny-input
965
- v-else
966
- v-model="state.inputEditValue"
967
- clearable
968
- ></tiny-input>
969
- </tiny-form-item>
970
- <div
971
- v-if="state.prevItem.type === 'numRange'"
972
- class="tvp-search-box__number"
973
- >
974
- <div class="tvp-search-box__dropdown-start">
975
- {{ t("tvp.tvpSearchbox.minValueText") }}({{
976
- state.prevItem.unit
977
- }})
978
- </div>
979
- <tiny-form-item
980
- :prop="state.curMinNumVar"
981
- class="tvp-search-box__number-item"
982
- :show-message="state.numberShowMessage"
983
- >
984
- <tiny-input
985
- v-model="state[state.curMinNumVar]"
986
- type="number"
987
- class="tvp-search-box__number-input"
988
- ></tiny-input>
989
- </tiny-form-item>
990
- <div class="tvp-search-box__dropdown-end">
991
- {{ t("tvp.tvpSearchbox.maxValueText") }}({{
992
- state.prevItem.unit
993
- }})
994
- </div>
995
- <tiny-form-item
996
- :prop="state.curMaxNumVar"
997
- class="tvp-search-box__number-item"
998
- >
999
- <tiny-input
1000
- v-model="state[state.curMaxNumVar]"
1001
- type="number"
1002
- class="tvp-search-box__number-input"
1003
- ></tiny-input>
1004
- </tiny-form-item>
1005
- </div>
1006
- <div
1007
- v-if="state.prevItem.type === 'dateRange'"
1008
- class="tvp-search-box__date-wrap"
1009
- >
1010
- <div class="tvp-search-box__dropdown-title">
1011
- {{
1012
- state.prevItem.maxTimeLength > 0
1013
- ? t("tvp.tvpSearchbox.timeLengthTitle", {
1014
- value: (
1015
- state.prevItem.maxTimeLength / 86400000
1016
- ).toFixed(1),
1017
- })
1018
- : t("tvp.tvpSearchbox.rangeDateTitle")
1019
- }}
1020
- </div>
1021
- <div class="tvp-search-box__dropdown-start">
1022
- {{ t("tvp.tvpSearchbox.rangeBeginLabel") }}
1023
- </div>
1024
- <tiny-form-item
1025
- prop="startDate"
1026
- :show-message="Boolean(state.prevItem.maxTimeLength)"
1027
- class="tvp-search-box__date-item"
1028
- >
1029
- <tiny-date-picker
1030
- v-model="state.startDate"
1031
- :format="state.prevItem.format || state.dateRangeFormat"
1032
- :value-format="
1033
- state.prevItem.format || state.dateRangeFormat
1034
- "
1035
- :picker-options="pickerOptions(state.startDate, 'endDate')"
1036
- class="tvp-search-box__date-picker"
1037
- ></tiny-date-picker>
1038
- </tiny-form-item>
1039
- <div class="tvp-search-box__dropdown-end">
1040
- {{ t("tvp.tvpSearchbox.rangeEndLabel") }}
1041
- </div>
1042
- <tiny-form-item
1043
- prop="endDate"
1044
- class="tvp-search-box__date-item"
1045
- >
1046
- <tiny-date-picker
1047
- v-model="state.endDate"
1048
- :format="state.prevItem.format || state.dateRangeFormat"
1049
- :value-format="
1050
- state.prevItem.format || state.dateRangeFormat
1051
- "
1052
- :picker-options="pickerOptions(state.startDate)"
1053
- class="tvp-search-box__date-picker"
1054
- ></tiny-date-picker>
1055
- </tiny-form-item>
1056
- </div>
1057
- <div
1058
- v-if="state.prevItem.type === 'datetimeRange'"
1059
- class="tvp-search-box__date-wrap"
1060
- >
1061
- <div class="tvp-search-box__dropdown-title">
1062
- {{
1063
- state.prevItem.maxTimeLength > 0
1064
- ? t("tvp.tvpSearchbox.timeLengthTitle", {
1065
- value: (
1066
- state.prevItem.maxTimeLength / 86400000
1067
- ).toFixed(1),
1068
- })
1069
- : t("tvp.tvpSearchbox.rangeDateTitle")
1070
- }}
1071
- </div>
1072
- <div class="tvp-search-box__dropdown-start">
1073
- {{ t("tvp.tvpSearchbox.rangeBeginLabel") }}
1074
- </div>
1075
- <tiny-form-item
1076
- prop="startDateTime"
1077
- :show-message="Boolean(state.prevItem.maxTimeLength)"
1078
- class="tvp-search-box__date-item"
1079
- >
1080
- <tiny-date-picker
1081
- v-model="state.startDateTime"
1082
- type="datetime"
1083
- :isutc8="true"
1084
- :format="state.prevItem.format || state.datetimeRangeFormat"
1085
- :value-format="
1086
- state.prevItem.format || state.datetimeRangeFormat
1087
- "
1088
- :picker-options="
1089
- pickerOptions(state.startDateTime, 'endDateTime')
1090
- "
1091
- class="tvp-search-box__date-picker"
1092
- ></tiny-date-picker>
1093
- </tiny-form-item>
1094
- <div class="tvp-search-box__dropdown-end">
1095
- {{ t("tvp.tvpSearchbox.rangeEndLabel") }}
1096
- </div>
1097
- <tiny-form-item
1098
- prop="endDateTime"
1099
- class="tvp-search-box__date-item"
1100
- >
1101
- <tiny-date-picker
1102
- v-model="state.endDateTime"
1103
- type="datetime"
1104
- :isutc8="true"
1105
- :format="state.prevItem.format || state.datetimeRangeFormat"
1106
- :value-format="
1107
- state.prevItem.format || state.datetimeRangeFormat
1108
- "
1109
- :picker-options="pickerOptions(state.startDateTime)"
1110
- class="tvp-search-box__date-picker"
1111
- ></tiny-date-picker>
1112
- </tiny-form-item>
1113
- </div>
1114
- </div>
1115
- <div class="tvp-search-box__bottom-btn">
1116
- <tiny-button size="mini" @click="confirmEditTag(true)">
1117
- {{ t("tvp.tvpSearchbox.confirm") }}
1118
- </tiny-button>
1119
- <tiny-button size="mini" @click="confirmEditTag(false)">
1120
- {{ t("tvp.tvpSearchbox.cancel") }}
1121
- </tiny-button>
1122
- </div>
1123
- </template>
1124
- <div v-else class="tvp-search-box__panel-box">
1125
- <slot
1126
- :name="`${state.prevItem.slotName}-edit`"
1127
- v-bind="{
1128
- showDropdown: () => showPopover(state),
1129
- onConfirm: handleEditConfirm,
1130
- }"
1131
- @click.stop
1132
- ></slot>
1133
- </div>
1134
- </tiny-popover>
1135
- </template>
1136
- </tiny-form>
1137
- </div>
1138
- </template>