vome-core 0.3.65 → 0.3.67
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/dist/admin/api/client.js +7 -2
- package/dist/admin/components/ui/avatar/Avatar.vue +18 -18
- package/dist/admin/components/ui/avatar/AvatarFallback.vue +21 -21
- package/dist/admin/components/ui/avatar/AvatarImage.vue +16 -16
- package/dist/admin/components/ui/avatar/index.js +1 -1
- package/dist/admin/components/ui/badge/Badge.vue +26 -26
- package/dist/admin/components/ui/button/Button.vue +31 -31
- package/dist/admin/components/ui/checkbox/Checkbox.vue +35 -35
- package/dist/admin/components/ui/checkbox/index.js +1 -1
- package/dist/admin/components/ui/dialog/Dialog.vue +19 -19
- package/dist/admin/components/ui/dialog/DialogClose.vue +15 -15
- package/dist/admin/components/ui/dialog/DialogContent.vue +267 -267
- package/dist/admin/components/ui/dialog/DialogDescription.vue +23 -23
- package/dist/admin/components/ui/dialog/DialogFooter.vue +27 -27
- package/dist/admin/components/ui/dialog/DialogHeader.vue +17 -17
- package/dist/admin/components/ui/dialog/DialogOverlay.vue +21 -21
- package/dist/admin/components/ui/dialog/DialogScrollContent.vue +60 -60
- package/dist/admin/components/ui/dialog/DialogTitle.vue +23 -23
- package/dist/admin/components/ui/dialog/DialogTrigger.vue +15 -15
- package/dist/admin/components/ui/dialog/index.js +1 -1
- package/dist/admin/components/ui/dropdown-menu/DropdownMenu.vue +19 -19
- package/dist/admin/components/ui/dropdown-menu/DropdownMenuCheckboxItem.vue +39 -39
- package/dist/admin/components/ui/dropdown-menu/DropdownMenuContent.vue +39 -39
- package/dist/admin/components/ui/dropdown-menu/DropdownMenuGroup.vue +15 -15
- package/dist/admin/components/ui/dropdown-menu/DropdownMenuItem.vue +31 -31
- package/dist/admin/components/ui/dropdown-menu/DropdownMenuLabel.vue +23 -23
- package/dist/admin/components/ui/dropdown-menu/DropdownMenuRadioGroup.vue +21 -21
- package/dist/admin/components/ui/dropdown-menu/DropdownMenuRadioItem.vue +40 -40
- package/dist/admin/components/ui/dropdown-menu/DropdownMenuSeparator.vue +23 -23
- package/dist/admin/components/ui/dropdown-menu/DropdownMenuShortcut.vue +17 -17
- package/dist/admin/components/ui/dropdown-menu/DropdownMenuSub.vue +18 -18
- package/dist/admin/components/ui/dropdown-menu/DropdownMenuSubContent.vue +27 -27
- package/dist/admin/components/ui/dropdown-menu/DropdownMenuSubTrigger.vue +31 -31
- package/dist/admin/components/ui/dropdown-menu/DropdownMenuTrigger.vue +17 -17
- package/dist/admin/components/ui/dropdown-menu/index.js +1 -1
- package/dist/admin/components/ui/input/Input.vue +183 -183
- package/dist/admin/components/ui/input/index.js +1 -1
- package/dist/admin/components/ui/label/Label.vue +26 -26
- package/dist/admin/components/ui/label/index.js +1 -1
- package/dist/admin/components/ui/scroll-area/ScrollArea.vue +33 -33
- package/dist/admin/components/ui/scroll-area/ScrollBar.vue +32 -32
- package/dist/admin/components/ui/scroll-area/index.js +1 -1
- package/dist/admin/components/ui/select/Select.vue +19 -19
- package/dist/admin/components/ui/select/SelectContent.vue +51 -51
- package/dist/admin/components/ui/select/SelectGroup.vue +15 -15
- package/dist/admin/components/ui/select/SelectItem.vue +53 -53
- package/dist/admin/components/ui/select/SelectItemText.vue +15 -15
- package/dist/admin/components/ui/select/SelectLabel.vue +17 -17
- package/dist/admin/components/ui/select/SelectScrollDownButton.vue +26 -26
- package/dist/admin/components/ui/select/SelectScrollUpButton.vue +26 -26
- package/dist/admin/components/ui/select/SelectSeparator.vue +19 -19
- package/dist/admin/components/ui/select/SelectTrigger.vue +44 -44
- package/dist/admin/components/ui/select/SelectValue.vue +15 -15
- package/dist/admin/components/ui/select/index.js +1 -1
- package/dist/admin/components/ui/separator/Separator.vue +29 -29
- package/dist/admin/components/ui/separator/index.js +1 -1
- package/dist/admin/components/ui/sheet/Sheet.vue +19 -19
- package/dist/admin/components/ui/sheet/SheetClose.vue +15 -15
- package/dist/admin/components/ui/sheet/SheetContent.vue +63 -63
- package/dist/admin/components/ui/sheet/SheetDescription.vue +21 -21
- package/dist/admin/components/ui/sheet/SheetFooter.vue +16 -16
- package/dist/admin/components/ui/sheet/SheetHeader.vue +15 -15
- package/dist/admin/components/ui/sheet/SheetOverlay.vue +21 -21
- package/dist/admin/components/ui/sheet/SheetTitle.vue +21 -21
- package/dist/admin/components/ui/sheet/SheetTrigger.vue +15 -15
- package/dist/admin/components/ui/sheet/index.js +1 -1
- package/dist/admin/components/ui/sonner/Toaster.vue +117 -117
- package/dist/admin/components/ui/sonner/index.js +1 -1
- package/dist/admin/components/ui/table/Table.vue +16 -16
- package/dist/admin/components/ui/table/TableBody.vue +17 -17
- package/dist/admin/components/ui/table/TableCaption.vue +17 -17
- package/dist/admin/components/ui/table/TableCell.vue +22 -22
- package/dist/admin/components/ui/table/TableEmpty.vue +34 -34
- package/dist/admin/components/ui/table/TableFooter.vue +17 -17
- package/dist/admin/components/ui/table/TableHead.vue +17 -17
- package/dist/admin/components/ui/table/TableHeader.vue +17 -17
- package/dist/admin/components/ui/table/TableRow.vue +17 -17
- package/dist/admin/components/ui/table/index.js +1 -1
- package/dist/admin/components/ui/tabs/Tabs.vue +24 -24
- package/dist/admin/components/ui/tabs/TabsContent.vue +21 -21
- package/dist/admin/components/ui/tabs/TabsList.vue +24 -24
- package/dist/admin/components/ui/tabs/TabsTrigger.vue +26 -26
- package/dist/admin/components/ui/tabs/index.js +1 -1
- package/dist/admin/components/ui/tooltip/Tooltip.vue +19 -19
- package/dist/admin/components/ui/tooltip/TooltipContent.vue +34 -34
- package/dist/admin/components/ui/tooltip/TooltipProvider.vue +14 -14
- package/dist/admin/components/ui/tooltip/TooltipTrigger.vue +15 -15
- package/dist/admin/components/ui/tooltip/index.js +1 -1
- package/dist/admin/components/vm-action-btn.vue +136 -136
- package/dist/admin/components/vm-aside-list-item.vue +136 -136
- package/dist/admin/components/vm-aside.vue +229 -229
- package/dist/admin/components/vm-auto-perm-dialog.vue +371 -371
- package/dist/admin/components/vm-card-grid.vue +37 -37
- package/dist/admin/components/vm-card-head.vue +45 -45
- package/dist/admin/components/vm-card-meta.vue +22 -22
- package/dist/admin/components/vm-card-title.vue +56 -56
- package/dist/admin/components/vm-card.vue +176 -176
- package/dist/admin/components/vm-check-tree.vue +340 -340
- package/dist/admin/components/vm-clamp-text.vue +39 -39
- package/dist/admin/components/vm-dept-tree.vue +497 -497
- package/dist/admin/components/vm-empty.vue +68 -68
- package/dist/admin/components/vm-eps-perm-picker.vue +123 -123
- package/dist/admin/components/vm-form-dialog.vue +632 -632
- package/dist/admin/components/vm-group-cascader.vue +560 -560
- package/dist/admin/components/vm-icon-btn.vue +88 -88
- package/dist/admin/components/vm-icon-picker.vue +647 -647
- package/dist/admin/components/vm-inline-search.vue +61 -61
- package/dist/admin/components/vm-loading.vue +114 -114
- package/dist/admin/components/vm-markdown.vue +405 -405
- package/dist/admin/components/vm-marquee.vue +265 -265
- package/dist/admin/components/vm-page-tabs.vue +94 -94
- package/dist/admin/components/vm-perm-section.vue +57 -57
- package/dist/admin/components/vm-ri-icon.vue +23 -23
- package/dist/admin/components/vm-role-picker.vue +314 -314
- package/dist/admin/components/vm-split-layout.vue +106 -106
- package/dist/admin/components/vm-thumb.vue +49 -49
- package/dist/admin/components/vm-view-path-picker.vue +59 -59
- package/dist/admin/crud/auto-fields.js +1 -1
- package/dist/admin/crud/components/vm-avatar.vue +104 -104
- package/dist/admin/crud/components/vm-color-picker.vue +1626 -1626
- package/dist/admin/crud/components/vm-column-custom.vue +193 -193
- package/dist/admin/crud/components/vm-context-menu.vue +105 -105
- package/dist/admin/crud/components/vm-copy-btn.vue +102 -102
- package/dist/admin/crud/components/vm-date-calendar-panel.vue +537 -537
- package/dist/admin/crud/components/vm-date-picker.vue +75 -75
- package/dist/admin/crud/components/vm-date-range.vue +88 -88
- package/dist/admin/crud/components/vm-date-text.vue +42 -42
- package/dist/admin/crud/components/vm-datetime-field.vue +215 -215
- package/dist/admin/crud/components/vm-datetime-picker.vue +9 -9
- package/dist/admin/crud/components/vm-dict-tag.vue +112 -112
- package/dist/admin/crud/components/vm-ellipsis-text.vue +34 -34
- package/dist/admin/crud/components/vm-form-hint.vue +81 -81
- package/dist/admin/crud/components/vm-json-code.vue +41 -41
- package/dist/admin/crud/components/vm-json-editor.vue +161 -161
- package/dist/admin/crud/components/vm-json-kv-editor.vue +318 -318
- package/dist/admin/crud/components/vm-kv-row.vue +51 -51
- package/dist/admin/crud/components/vm-multi-select.vue +279 -279
- package/dist/admin/crud/components/vm-number-range.vue +204 -204
- package/dist/admin/crud/components/vm-preview-viewer.vue +894 -894
- package/dist/admin/crud/components/vm-radio.vue +87 -87
- package/dist/admin/crud/components/vm-richtext.vue +313 -313
- package/dist/admin/crud/components/vm-select.vue +570 -570
- package/dist/admin/crud/components/vm-status-tag.vue +158 -158
- package/dist/admin/crud/components/vm-switch.vue +158 -158
- package/dist/admin/crud/components/vm-tag-list.vue +108 -108
- package/dist/admin/crud/components/vm-text-link.vue +52 -52
- package/dist/admin/crud/components/vm-toggle-switch.vue +84 -84
- package/dist/admin/crud/components/vm-tree-select.vue +450 -450
- package/dist/admin/crud/components/vm-upload-item.vue +298 -298
- package/dist/admin/crud/components/vm-upload.vue +436 -436
- package/dist/admin/crud/config.js +1 -1
- package/dist/admin/crud/confirm.js +1 -1
- package/dist/admin/crud/crud-page-request.js +1 -1
- package/dist/admin/crud/data-i18n.js +1 -1
- package/dist/admin/crud/dict.js +1 -1
- package/dist/admin/crud/export-fetch.js +1 -1
- package/dist/admin/crud/index.js +1 -0
- package/dist/admin/crud/key.js +1 -1
- package/dist/admin/crud/plugins.js +1 -1
- package/dist/admin/crud/span.js +1 -1
- package/dist/admin/crud/style.js +1 -1
- package/dist/admin/crud/useCrud.js +3 -0
- package/dist/admin/crud/validate.js +1 -1
- package/dist/admin/crud/vm-add-btn.vue +70 -70
- package/dist/admin/crud/vm-adv-search.vue +83 -83
- package/dist/admin/crud/vm-crud.vue +711 -711
- package/dist/admin/crud/vm-data-i18n-btn.vue +456 -456
- package/dist/admin/crud/vm-data-i18n-lang.vue +183 -183
- package/dist/admin/crud/vm-export-btn.vue +183 -183
- package/dist/admin/crud/vm-flex.vue +14 -14
- package/dist/admin/crud/vm-form.vue +33 -15
- package/dist/admin/crud/vm-import-btn.vue +747 -747
- package/dist/admin/crud/vm-multi-delete-btn.vue +49 -49
- package/dist/admin/crud/vm-pagination.vue +212 -212
- package/dist/admin/crud/vm-refresh-btn.vue +35 -35
- package/dist/admin/crud/vm-row.vue +55 -55
- package/dist/admin/crud/vm-search-key.vue +78 -78
- package/dist/admin/crud/vm-search.vue +466 -466
- package/dist/admin/crud/vm-table.vue +1390 -1390
- package/dist/admin/crud/vm-tabs.vue +94 -94
- package/dist/admin/crud/vm-toolbar.vue +357 -357
- package/dist/admin/crud/vm-upsert.vue +765 -765
- package/dist/admin/directives/perm.js +1 -1
- package/dist/admin/env.d.ts +1 -1
- package/dist/admin/hooks/useUpload.js +1 -1
- package/dist/admin/index.d.ts +1 -31
- package/dist/admin/lib/browser.js +1 -1
- package/dist/admin/lib/cn.js +1 -1
- package/dist/admin/lib/dialog-float.js +1 -1
- package/dist/admin/lib/export-excel.js +1 -1
- package/dist/admin/lib/import-excel.js +1 -1
- package/dist/admin/lib/json.js +1 -1
- package/dist/admin/lib/menu.js +1 -1
- package/dist/admin/lib/micro-locale.js +1 -1
- package/dist/admin/lib/micro-theme.js +1 -1
- package/dist/admin/lib/shell.js +1 -1
- package/dist/admin/lib/theme-color-options.js +1 -1
- package/dist/admin/lib/tree.js +1 -1
- package/dist/admin/lib/upload.js +1 -1
- package/dist/admin/lib/video-frame.js +1 -1
- package/dist/admin/router/create.js +1 -1
- package/dist/admin/router/guards.js +1 -1
- package/dist/admin/router/index.d.ts +1 -5
- package/dist/admin/service/index.d.ts +1 -11
- package/dist/admin/styles/base.css +121 -121
- package/dist/admin/vendor/browser-image-compression.js +1144 -1144
- package/dist/admin/vendor/decimal-js.js +12 -12
- package/dist/admin/vendor/xlsx.js +263 -263
- package/dist/ai/index.js +1 -1
- package/dist/client/admin-vendor.d.ts +1 -13
- package/dist/client/ai-model-registry.js +1 -1
- package/dist/client/base.js +1 -1
- package/dist/client/configure.js +1 -1
- package/dist/client/dict.js +1 -1
- package/dist/client/eps-payload.js +1 -1
- package/dist/client/eps.js +1 -1
- package/dist/client/index.d.ts +1 -7
- package/dist/client/index.js +1 -1
- package/dist/client/locale-change.js +1 -1
- package/dist/client/locale-store.js +1 -1
- package/dist/client/service.js +1 -1
- package/dist/client/vite-admin.d.ts +1 -40
- package/dist/client/vite-admin.js +1 -1
- package/dist/client/vite-auto-import.d.ts +1 -2
- package/dist/client/vite-auto-import.js +1 -1
- package/dist/client/vite-micro-proxy.d.ts +1 -20
- package/dist/client/vite-micro-proxy.js +1 -1
- package/dist/client/vite-plugin-eps.d.ts +1 -20
- package/dist/client/vite-plugin-eps.js +1 -1
- package/dist/client/vite-resolve.d.ts +1 -16
- package/dist/client/vite-resolve.js +1 -1
- package/dist/config/index.js +1 -1
- package/dist/index.js +1 -1
- package/dist/server/index.js +1 -1
- package/dist/shared/datetime-picker.js +1 -1
- package/dist/shared/decimal.js +1 -1
- package/dist/shared/excel.js +1 -1
- package/dist/shared/index.js +1 -1
- package/dist/shared/locale-json.js +1 -1
- package/dist/shared/tree.js +1 -1
- package/package.json +1 -1
- package/typings/admin/base/auth.ts +24 -24
- package/typings/admin/base/permission.ts +19 -19
- package/typings/admin/comm/cascader.ts +7 -7
- package/typings/admin/comm/check-tree.ts +7 -7
- package/typings/admin/comm/crud.ts +427 -427
- package/typings/admin/comm/eps.ts +86 -86
- package/typings/admin/comm/request.ts +16 -16
- package/typings/admin/comm/service.ts +43 -43
- package/typings/admin/comm/upload.ts +39 -39
- package/typings/admin/theme.ts +10 -10
- package/typings/admin/vome/browser.ts +11 -11
- package/typings/admin/vome/module.ts +13 -13
- package/typings/admin/vome/tags.ts +9 -9
- package/typings/comm/crud.ts +83 -83
- package/typings/comm/page.ts +18 -18
- package/typings/comm/scan.ts +6 -6
- package/typings/common.ts +4 -4
- package/typings/context/data.ts +10 -10
- package/typings/ext/market-seat.ts +42 -42
- package/typings/ext/market.ts +55 -55
- package/typings/ext/module.ts +64 -64
- package/typings/ext/plugin.ts +38 -38
- package/typings/ioc/metadata.ts +34 -34
- package/typings/logger/config.ts +6 -6
- package/typings/routing/crud.ts +199 -199
- package/typings/routing/eps.ts +88 -88
- package/typings/routing/meta.ts +63 -63
- package/typings/routing/register.ts +21 -21
- package/typings/routing/scan-context.ts +7 -7
- package/dist/admin/api/client.d.ts +0 -50
- package/dist/admin/components/ui/avatar/index.d.ts +0 -3
- package/dist/admin/components/ui/badge/index.d.ts +0 -6
- package/dist/admin/components/ui/button/index.d.ts +0 -7
- package/dist/admin/components/ui/checkbox/index.d.ts +0 -1
- package/dist/admin/components/ui/dialog/index.d.ts +0 -10
- package/dist/admin/components/ui/dropdown-menu/index.d.ts +0 -15
- package/dist/admin/components/ui/input/index.d.ts +0 -1
- package/dist/admin/components/ui/label/index.d.ts +0 -1
- package/dist/admin/components/ui/scroll-area/index.d.ts +0 -2
- package/dist/admin/components/ui/select/index.d.ts +0 -11
- package/dist/admin/components/ui/separator/index.d.ts +0 -1
- package/dist/admin/components/ui/sheet/index.d.ts +0 -8
- package/dist/admin/components/ui/sonner/index.d.ts +0 -1
- package/dist/admin/components/ui/table/index.d.ts +0 -9
- package/dist/admin/components/ui/tabs/index.d.ts +0 -4
- package/dist/admin/components/ui/tooltip/index.d.ts +0 -4
- package/dist/admin/crud/auto-fields.d.ts +0 -68
- package/dist/admin/crud/config.d.ts +0 -5
- package/dist/admin/crud/confirm.d.ts +0 -19
- package/dist/admin/crud/crud-page-request.d.ts +0 -21
- package/dist/admin/crud/data-i18n.d.ts +0 -62
- package/dist/admin/crud/dict.d.ts +0 -4
- package/dist/admin/crud/export-fetch.d.ts +0 -22
- package/dist/admin/crud/index.d.ts +0 -60
- package/dist/admin/crud/json-kv.d.ts +0 -9
- package/dist/admin/crud/key.d.ts +0 -22
- package/dist/admin/crud/paging.d.ts +0 -2
- package/dist/admin/crud/plugins.d.ts +0 -63
- package/dist/admin/crud/registry.d.ts +0 -3
- package/dist/admin/crud/span.d.ts +0 -17
- package/dist/admin/crud/style.d.ts +0 -82
- package/dist/admin/crud/useCrud.d.ts +0 -21
- package/dist/admin/crud/validate.d.ts +0 -7
- package/dist/admin/directives/perm.d.ts +0 -3
- package/dist/admin/hooks/useBrowser.d.ts +0 -6
- package/dist/admin/hooks/useUpload.d.ts +0 -8
- package/dist/admin/hooks/useVome.d.ts +0 -10
- package/dist/admin/lib/browser.d.ts +0 -3
- package/dist/admin/lib/cn.d.ts +0 -2
- package/dist/admin/lib/compress-image.d.ts +0 -12
- package/dist/admin/lib/dialog-float.d.ts +0 -8
- package/dist/admin/lib/eps.d.ts +0 -2
- package/dist/admin/lib/export-excel.d.ts +0 -9
- package/dist/admin/lib/file-preview.d.ts +0 -9
- package/dist/admin/lib/import-excel.d.ts +0 -21
- package/dist/admin/lib/json.d.ts +0 -11
- package/dist/admin/lib/menu.d.ts +0 -3
- package/dist/admin/lib/micro-locale.d.ts +0 -5
- package/dist/admin/lib/micro-theme.d.ts +0 -14
- package/dist/admin/lib/module.d.ts +0 -21
- package/dist/admin/lib/scarce-assets.d.ts +0 -5
- package/dist/admin/lib/shell.d.ts +0 -8
- package/dist/admin/lib/theme-color-options.d.ts +0 -15
- package/dist/admin/lib/tree.d.ts +0 -2
- package/dist/admin/lib/upload.d.ts +0 -17
- package/dist/admin/lib/video-frame.d.ts +0 -6
- package/dist/admin/router/create.d.ts +0 -16
- package/dist/admin/router/guards.d.ts +0 -6
- package/dist/admin/router/menu-routes.d.ts +0 -13
- package/dist/admin/stores/app.d.ts +0 -13
- package/dist/admin/stores/tags.d.ts +0 -14
- package/dist/admin/stores/user.d.ts +0 -48
- package/dist/client/ai-model-registry.d.ts +0 -16
- package/dist/client/base.d.ts +0 -28
- package/dist/client/configure.d.ts +0 -33
- package/dist/client/dict.d.ts +0 -31
- package/dist/client/eps-payload.d.ts +0 -3
- package/dist/client/eps.d.ts +0 -17
- package/dist/client/locale-change.d.ts +0 -16
- package/dist/client/locale-store.d.ts +0 -105
- package/dist/client/service.d.ts +0 -29
|
@@ -1,215 +1,215 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div
|
|
3
|
-
ref="rootRef"
|
|
4
|
-
class="vm-dt-field"
|
|
5
|
-
:class="{ 'is-disabled': disabled }"
|
|
6
|
-
@click="onRootClick"
|
|
7
|
-
>
|
|
8
|
-
<div class="vm-dt-field__box">
|
|
9
|
-
<span v-if="!displayText" class="vm-dt-field__ph">{{
|
|
10
|
-
placeholder ?? crudLabel('pickDateTime')
|
|
11
|
-
}}</span>
|
|
12
|
-
<span class="vm-dt-field__val">{{ displayText }}</span>
|
|
13
|
-
</div>
|
|
14
|
-
<i class="ri-calendar-line vm-dt-field__icon" aria-hidden="true" />
|
|
15
|
-
|
|
16
|
-
<Teleport to="body">
|
|
17
|
-
<!-- FocusScope:暂停宿主 Dialog 焦点陷阱,否则 Teleport 内时分秒 input 无法聚焦手输 -->
|
|
18
|
-
<FocusScope
|
|
19
|
-
v-if="open"
|
|
20
|
-
as-child
|
|
21
|
-
loop
|
|
22
|
-
:trapped="true"
|
|
23
|
-
@unmount-auto-focus="onPanelUnmountAutoFocus"
|
|
24
|
-
>
|
|
25
|
-
<div
|
|
26
|
-
ref="panelWrapRef"
|
|
27
|
-
class="vm-dialog-float"
|
|
28
|
-
:style="panelStyle"
|
|
29
|
-
@pointerdown.stop
|
|
30
|
-
@mousedown.stop
|
|
31
|
-
>
|
|
32
|
-
<VmDateCalendarPanel
|
|
33
|
-
:model-value="modelValue"
|
|
34
|
-
:precision="precision"
|
|
35
|
-
@update:model-value="onPick"
|
|
36
|
-
@clear="onClear"
|
|
37
|
-
/>
|
|
38
|
-
</div>
|
|
39
|
-
</FocusScope>
|
|
40
|
-
</Teleport>
|
|
41
|
-
</div>
|
|
42
|
-
</template>
|
|
43
|
-
|
|
44
|
-
<script setup lang="ts">
|
|
45
|
-
import { crudLabel } from '../style'
|
|
46
|
-
import { computed, onBeforeUnmount, onMounted, ref } from 'vue'
|
|
47
|
-
import { FocusScope } from 'reka-ui'
|
|
48
|
-
import VmDateCalendarPanel from './vm-date-calendar-panel.vue'
|
|
49
|
-
import { POPUP_TRIGGER_GAP } from '../../lib/dialog-float'
|
|
50
|
-
import {
|
|
51
|
-
dateTimeDisplayText,
|
|
52
|
-
normalizeDateTimePrecision,
|
|
53
|
-
type DateTimePrecision,
|
|
54
|
-
} from '../../../shared/datetime-picker'
|
|
55
|
-
|
|
56
|
-
defineOptions({ name: 'vm-datetime-field' })
|
|
57
|
-
|
|
58
|
-
const props = withDefaults(
|
|
59
|
-
defineProps<{
|
|
60
|
-
modelValue?: string | null
|
|
61
|
-
precision?: DateTimePrecision | string
|
|
62
|
-
placeholder?: string
|
|
63
|
-
disabled?: boolean
|
|
64
|
-
}>(),
|
|
65
|
-
{
|
|
66
|
-
modelValue: null,
|
|
67
|
-
precision: 'day',
|
|
68
|
-
placeholder: undefined,
|
|
69
|
-
disabled: false,
|
|
70
|
-
},
|
|
71
|
-
)
|
|
72
|
-
|
|
73
|
-
const emit = defineEmits<{
|
|
74
|
-
'update:modelValue': [v: string | null]
|
|
75
|
-
change: [v: string | null]
|
|
76
|
-
}>()
|
|
77
|
-
|
|
78
|
-
const rootRef = ref<HTMLElement | null>(null)
|
|
79
|
-
const panelWrapRef = ref<HTMLElement | null>(null)
|
|
80
|
-
const open = ref(false)
|
|
81
|
-
const panelStyle = ref<Record<string, string>>({})
|
|
82
|
-
|
|
83
|
-
const precision = computed(() => normalizeDateTimePrecision(props.precision))
|
|
84
|
-
const displayText = computed(() =>
|
|
85
|
-
dateTimeDisplayText(props.modelValue, precision.value),
|
|
86
|
-
)
|
|
87
|
-
|
|
88
|
-
function syncPanelPos() {
|
|
89
|
-
const el = rootRef.value
|
|
90
|
-
if (!el) return
|
|
91
|
-
const r = el.getBoundingClientRect()
|
|
92
|
-
panelStyle.value = {
|
|
93
|
-
position: 'fixed',
|
|
94
|
-
left: `${r.left}px`,
|
|
95
|
-
top: `${r.bottom + POPUP_TRIGGER_GAP}px`,
|
|
96
|
-
zIndex: '10050',
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
function close() {
|
|
101
|
-
open.value = false
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
/** 面板卸载时勿把焦点强行打回触发器(否则会立刻再次 toggle) */
|
|
105
|
-
function onPanelUnmountAutoFocus(e: Event) {
|
|
106
|
-
e.preventDefault()
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
function onRootClick() {
|
|
110
|
-
if (props.disabled) return
|
|
111
|
-
if (open.value) {
|
|
112
|
-
close()
|
|
113
|
-
return
|
|
114
|
-
}
|
|
115
|
-
open.value = true
|
|
116
|
-
syncPanelPos()
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
function onPick(v: string) {
|
|
120
|
-
emit('update:modelValue', v)
|
|
121
|
-
emit('change', v)
|
|
122
|
-
if (precision.value !== 'datetime') close()
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
function onClear() {
|
|
126
|
-
emit('update:modelValue', null)
|
|
127
|
-
emit('change', null)
|
|
128
|
-
close()
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
function onDocPointer(e: PointerEvent) {
|
|
132
|
-
if (!open.value) return
|
|
133
|
-
const t = e.target as Node
|
|
134
|
-
if (rootRef.value?.contains(t) || panelWrapRef.value?.contains(t)) return
|
|
135
|
-
close()
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
function onViewportChange() {
|
|
139
|
-
if (open.value) syncPanelPos()
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
onMounted(() => {
|
|
143
|
-
document.addEventListener('pointerdown', onDocPointer, true)
|
|
144
|
-
window.addEventListener('resize', onViewportChange)
|
|
145
|
-
window.addEventListener('scroll', onViewportChange, true)
|
|
146
|
-
})
|
|
147
|
-
|
|
148
|
-
onBeforeUnmount(() => {
|
|
149
|
-
document.removeEventListener('pointerdown', onDocPointer, true)
|
|
150
|
-
window.removeEventListener('resize', onViewportChange)
|
|
151
|
-
window.removeEventListener('scroll', onViewportChange, true)
|
|
152
|
-
})
|
|
153
|
-
</script>
|
|
154
|
-
|
|
155
|
-
<style lang="scss" scoped>
|
|
156
|
-
.vm-dt-field {
|
|
157
|
-
box-sizing: border-box;
|
|
158
|
-
display: flex;
|
|
159
|
-
width: 100%;
|
|
160
|
-
height: var(--vm-control-height, 38px);
|
|
161
|
-
align-items: center;
|
|
162
|
-
gap: 6px;
|
|
163
|
-
padding: 0 10px;
|
|
164
|
-
border: 1px solid transparent;
|
|
165
|
-
border-radius: 12px;
|
|
166
|
-
background: var(--muted, #f4f6fb);
|
|
167
|
-
cursor: pointer;
|
|
168
|
-
outline: none;
|
|
169
|
-
|
|
170
|
-
&.is-disabled {
|
|
171
|
-
opacity: 0.55;
|
|
172
|
-
pointer-events: none;
|
|
173
|
-
cursor: not-allowed;
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
.vm-dt-field__box {
|
|
178
|
-
position: relative;
|
|
179
|
-
flex: 1 1 auto;
|
|
180
|
-
min-width: 0;
|
|
181
|
-
height: 100%;
|
|
182
|
-
display: flex;
|
|
183
|
-
align-items: center;
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
.vm-dt-field__ph {
|
|
187
|
-
position: absolute;
|
|
188
|
-
left: 0;
|
|
189
|
-
right: 0;
|
|
190
|
-
overflow: hidden;
|
|
191
|
-
color: var(--muted-foreground, #94a3b8);
|
|
192
|
-
font-size: inherit;
|
|
193
|
-
text-overflow: ellipsis;
|
|
194
|
-
white-space: nowrap;
|
|
195
|
-
pointer-events: none;
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
.vm-dt-field__val {
|
|
199
|
-
position: relative;
|
|
200
|
-
z-index: 1;
|
|
201
|
-
overflow: hidden;
|
|
202
|
-
color: var(--foreground, #1f2937);
|
|
203
|
-
font-size: inherit;
|
|
204
|
-
text-overflow: ellipsis;
|
|
205
|
-
white-space: nowrap;
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
.vm-dt-field__icon {
|
|
209
|
-
flex: none;
|
|
210
|
-
font-size: 16px;
|
|
211
|
-
color: var(--muted-foreground, #94a3b8);
|
|
212
|
-
line-height: 1;
|
|
213
|
-
pointer-events: none;
|
|
214
|
-
}
|
|
215
|
-
</style>
|
|
1
|
+
<template>
|
|
2
|
+
<div
|
|
3
|
+
ref="rootRef"
|
|
4
|
+
class="vm-dt-field"
|
|
5
|
+
:class="{ 'is-disabled': disabled }"
|
|
6
|
+
@click="onRootClick"
|
|
7
|
+
>
|
|
8
|
+
<div class="vm-dt-field__box">
|
|
9
|
+
<span v-if="!displayText" class="vm-dt-field__ph">{{
|
|
10
|
+
placeholder ?? crudLabel('pickDateTime')
|
|
11
|
+
}}</span>
|
|
12
|
+
<span class="vm-dt-field__val">{{ displayText }}</span>
|
|
13
|
+
</div>
|
|
14
|
+
<i class="ri-calendar-line vm-dt-field__icon" aria-hidden="true" />
|
|
15
|
+
|
|
16
|
+
<Teleport to="body">
|
|
17
|
+
<!-- FocusScope:暂停宿主 Dialog 焦点陷阱,否则 Teleport 内时分秒 input 无法聚焦手输 -->
|
|
18
|
+
<FocusScope
|
|
19
|
+
v-if="open"
|
|
20
|
+
as-child
|
|
21
|
+
loop
|
|
22
|
+
:trapped="true"
|
|
23
|
+
@unmount-auto-focus="onPanelUnmountAutoFocus"
|
|
24
|
+
>
|
|
25
|
+
<div
|
|
26
|
+
ref="panelWrapRef"
|
|
27
|
+
class="vm-dialog-float"
|
|
28
|
+
:style="panelStyle"
|
|
29
|
+
@pointerdown.stop
|
|
30
|
+
@mousedown.stop
|
|
31
|
+
>
|
|
32
|
+
<VmDateCalendarPanel
|
|
33
|
+
:model-value="modelValue"
|
|
34
|
+
:precision="precision"
|
|
35
|
+
@update:model-value="onPick"
|
|
36
|
+
@clear="onClear"
|
|
37
|
+
/>
|
|
38
|
+
</div>
|
|
39
|
+
</FocusScope>
|
|
40
|
+
</Teleport>
|
|
41
|
+
</div>
|
|
42
|
+
</template>
|
|
43
|
+
|
|
44
|
+
<script setup lang="ts">
|
|
45
|
+
import { crudLabel } from '../style'
|
|
46
|
+
import { computed, onBeforeUnmount, onMounted, ref } from 'vue'
|
|
47
|
+
import { FocusScope } from 'reka-ui'
|
|
48
|
+
import VmDateCalendarPanel from './vm-date-calendar-panel.vue'
|
|
49
|
+
import { POPUP_TRIGGER_GAP } from '../../lib/dialog-float'
|
|
50
|
+
import {
|
|
51
|
+
dateTimeDisplayText,
|
|
52
|
+
normalizeDateTimePrecision,
|
|
53
|
+
type DateTimePrecision,
|
|
54
|
+
} from '../../../shared/datetime-picker'
|
|
55
|
+
|
|
56
|
+
defineOptions({ name: 'vm-datetime-field' })
|
|
57
|
+
|
|
58
|
+
const props = withDefaults(
|
|
59
|
+
defineProps<{
|
|
60
|
+
modelValue?: string | null
|
|
61
|
+
precision?: DateTimePrecision | string
|
|
62
|
+
placeholder?: string
|
|
63
|
+
disabled?: boolean
|
|
64
|
+
}>(),
|
|
65
|
+
{
|
|
66
|
+
modelValue: null,
|
|
67
|
+
precision: 'day',
|
|
68
|
+
placeholder: undefined,
|
|
69
|
+
disabled: false,
|
|
70
|
+
},
|
|
71
|
+
)
|
|
72
|
+
|
|
73
|
+
const emit = defineEmits<{
|
|
74
|
+
'update:modelValue': [v: string | null]
|
|
75
|
+
change: [v: string | null]
|
|
76
|
+
}>()
|
|
77
|
+
|
|
78
|
+
const rootRef = ref<HTMLElement | null>(null)
|
|
79
|
+
const panelWrapRef = ref<HTMLElement | null>(null)
|
|
80
|
+
const open = ref(false)
|
|
81
|
+
const panelStyle = ref<Record<string, string>>({})
|
|
82
|
+
|
|
83
|
+
const precision = computed(() => normalizeDateTimePrecision(props.precision))
|
|
84
|
+
const displayText = computed(() =>
|
|
85
|
+
dateTimeDisplayText(props.modelValue, precision.value),
|
|
86
|
+
)
|
|
87
|
+
|
|
88
|
+
function syncPanelPos() {
|
|
89
|
+
const el = rootRef.value
|
|
90
|
+
if (!el) return
|
|
91
|
+
const r = el.getBoundingClientRect()
|
|
92
|
+
panelStyle.value = {
|
|
93
|
+
position: 'fixed',
|
|
94
|
+
left: `${r.left}px`,
|
|
95
|
+
top: `${r.bottom + POPUP_TRIGGER_GAP}px`,
|
|
96
|
+
zIndex: '10050',
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function close() {
|
|
101
|
+
open.value = false
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/** 面板卸载时勿把焦点强行打回触发器(否则会立刻再次 toggle) */
|
|
105
|
+
function onPanelUnmountAutoFocus(e: Event) {
|
|
106
|
+
e.preventDefault()
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
function onRootClick() {
|
|
110
|
+
if (props.disabled) return
|
|
111
|
+
if (open.value) {
|
|
112
|
+
close()
|
|
113
|
+
return
|
|
114
|
+
}
|
|
115
|
+
open.value = true
|
|
116
|
+
syncPanelPos()
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
function onPick(v: string) {
|
|
120
|
+
emit('update:modelValue', v)
|
|
121
|
+
emit('change', v)
|
|
122
|
+
if (precision.value !== 'datetime') close()
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
function onClear() {
|
|
126
|
+
emit('update:modelValue', null)
|
|
127
|
+
emit('change', null)
|
|
128
|
+
close()
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
function onDocPointer(e: PointerEvent) {
|
|
132
|
+
if (!open.value) return
|
|
133
|
+
const t = e.target as Node
|
|
134
|
+
if (rootRef.value?.contains(t) || panelWrapRef.value?.contains(t)) return
|
|
135
|
+
close()
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
function onViewportChange() {
|
|
139
|
+
if (open.value) syncPanelPos()
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
onMounted(() => {
|
|
143
|
+
document.addEventListener('pointerdown', onDocPointer, true)
|
|
144
|
+
window.addEventListener('resize', onViewportChange)
|
|
145
|
+
window.addEventListener('scroll', onViewportChange, true)
|
|
146
|
+
})
|
|
147
|
+
|
|
148
|
+
onBeforeUnmount(() => {
|
|
149
|
+
document.removeEventListener('pointerdown', onDocPointer, true)
|
|
150
|
+
window.removeEventListener('resize', onViewportChange)
|
|
151
|
+
window.removeEventListener('scroll', onViewportChange, true)
|
|
152
|
+
})
|
|
153
|
+
</script>
|
|
154
|
+
|
|
155
|
+
<style lang="scss" scoped>
|
|
156
|
+
.vm-dt-field {
|
|
157
|
+
box-sizing: border-box;
|
|
158
|
+
display: flex;
|
|
159
|
+
width: 100%;
|
|
160
|
+
height: var(--vm-control-height, 38px);
|
|
161
|
+
align-items: center;
|
|
162
|
+
gap: 6px;
|
|
163
|
+
padding: 0 10px;
|
|
164
|
+
border: 1px solid transparent;
|
|
165
|
+
border-radius: 12px;
|
|
166
|
+
background: var(--muted, #f4f6fb);
|
|
167
|
+
cursor: pointer;
|
|
168
|
+
outline: none;
|
|
169
|
+
|
|
170
|
+
&.is-disabled {
|
|
171
|
+
opacity: 0.55;
|
|
172
|
+
pointer-events: none;
|
|
173
|
+
cursor: not-allowed;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
.vm-dt-field__box {
|
|
178
|
+
position: relative;
|
|
179
|
+
flex: 1 1 auto;
|
|
180
|
+
min-width: 0;
|
|
181
|
+
height: 100%;
|
|
182
|
+
display: flex;
|
|
183
|
+
align-items: center;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
.vm-dt-field__ph {
|
|
187
|
+
position: absolute;
|
|
188
|
+
left: 0;
|
|
189
|
+
right: 0;
|
|
190
|
+
overflow: hidden;
|
|
191
|
+
color: var(--muted-foreground, #94a3b8);
|
|
192
|
+
font-size: inherit;
|
|
193
|
+
text-overflow: ellipsis;
|
|
194
|
+
white-space: nowrap;
|
|
195
|
+
pointer-events: none;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
.vm-dt-field__val {
|
|
199
|
+
position: relative;
|
|
200
|
+
z-index: 1;
|
|
201
|
+
overflow: hidden;
|
|
202
|
+
color: var(--foreground, #1f2937);
|
|
203
|
+
font-size: inherit;
|
|
204
|
+
text-overflow: ellipsis;
|
|
205
|
+
white-space: nowrap;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
.vm-dt-field__icon {
|
|
209
|
+
flex: none;
|
|
210
|
+
font-size: 16px;
|
|
211
|
+
color: var(--muted-foreground, #94a3b8);
|
|
212
|
+
line-height: 1;
|
|
213
|
+
pointer-events: none;
|
|
214
|
+
}
|
|
215
|
+
</style>
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<vm-date-picker v-bind="$attrs" type="datetime" />
|
|
3
|
-
</template>
|
|
4
|
-
|
|
5
|
-
<script setup lang="ts">
|
|
6
|
-
import VmDatePicker from './vm-date-picker.vue'
|
|
7
|
-
|
|
8
|
-
defineOptions({ name: 'vm-datetime-picker', inheritAttrs: false })
|
|
9
|
-
</script>
|
|
1
|
+
<template>
|
|
2
|
+
<vm-date-picker v-bind="$attrs" type="datetime" />
|
|
3
|
+
</template>
|
|
4
|
+
|
|
5
|
+
<script setup lang="ts">
|
|
6
|
+
import VmDatePicker from './vm-date-picker.vue'
|
|
7
|
+
|
|
8
|
+
defineOptions({ name: 'vm-datetime-picker', inheritAttrs: false })
|
|
9
|
+
</script>
|
|
@@ -1,112 +1,112 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<span v-if="!hits.length" class="vm-dict-tag is-empty">—</span>
|
|
3
|
-
<span v-else class="vm-dict-tag-list">
|
|
4
|
-
<span
|
|
5
|
-
v-for="(item, i) in hits"
|
|
6
|
-
:key="`${String(item.value)}-${i}`"
|
|
7
|
-
class="vm-dict-tag"
|
|
8
|
-
:style="item.style"
|
|
9
|
-
>
|
|
10
|
-
{{ item.label }}
|
|
11
|
-
</span>
|
|
12
|
-
</span>
|
|
13
|
-
</template>
|
|
14
|
-
|
|
15
|
-
<script setup lang="ts">
|
|
16
|
-
import { computed } from 'vue'
|
|
17
|
-
import { getCrudStyle } from '../style'
|
|
18
|
-
|
|
19
|
-
defineOptions({ name: 'vm-dict-tag' })
|
|
20
|
-
|
|
21
|
-
type DictOpt = {
|
|
22
|
-
label: string
|
|
23
|
-
value: string | number | boolean
|
|
24
|
-
type?: string
|
|
25
|
-
color?: string
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
const props = defineProps<{
|
|
29
|
-
/** 单值或字典 value 数组(多选列) */
|
|
30
|
-
modelValue?:
|
|
31
|
-
| string
|
|
32
|
-
| number
|
|
33
|
-
| boolean
|
|
34
|
-
| null
|
|
35
|
-
| Array<string | number | boolean | null | undefined>
|
|
36
|
-
options?: DictOpt[]
|
|
37
|
-
}>()
|
|
38
|
-
|
|
39
|
-
function valuesOf(
|
|
40
|
-
raw: unknown,
|
|
41
|
-
): Array<string | number | boolean> {
|
|
42
|
-
if (raw == null || raw === '') return []
|
|
43
|
-
if (Array.isArray(raw)) {
|
|
44
|
-
return raw.filter(
|
|
45
|
-
(v): v is string | number | boolean =>
|
|
46
|
-
v != null && v !== '',
|
|
47
|
-
)
|
|
48
|
-
}
|
|
49
|
-
return [raw as string | number | boolean]
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
function matchOpt(
|
|
53
|
-
options: DictOpt[] | undefined,
|
|
54
|
-
v: string | number | boolean,
|
|
55
|
-
): DictOpt | undefined {
|
|
56
|
-
return options?.find(
|
|
57
|
-
(d) => d.value === v || String(d.value) === String(v),
|
|
58
|
-
)
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
function styleOf(opt: DictOpt, idx: number) {
|
|
62
|
-
if (opt.color) {
|
|
63
|
-
return { background: `${opt.color}22`, color: opt.color }
|
|
64
|
-
}
|
|
65
|
-
const colors = getCrudStyle().colors
|
|
66
|
-
const c = colors[idx % colors.length] || 'var(--brand)'
|
|
67
|
-
return { background: `${c}22`, color: c }
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
const hits = computed(() => {
|
|
71
|
-
const opts = props.options || []
|
|
72
|
-
const out: Array<{
|
|
73
|
-
label: string
|
|
74
|
-
value: string | number | boolean
|
|
75
|
-
style: Record<string, string>
|
|
76
|
-
}> = []
|
|
77
|
-
for (const v of valuesOf(props.modelValue)) {
|
|
78
|
-
const hit = matchOpt(opts, v)
|
|
79
|
-
if (!hit) continue
|
|
80
|
-
const idx = opts.findIndex((d) => d === hit)
|
|
81
|
-
out.push({
|
|
82
|
-
label: hit.label,
|
|
83
|
-
value: hit.value,
|
|
84
|
-
style: styleOf(hit, idx < 0 ? 0 : idx),
|
|
85
|
-
})
|
|
86
|
-
}
|
|
87
|
-
return out
|
|
88
|
-
})
|
|
89
|
-
</script>
|
|
90
|
-
|
|
91
|
-
<style lang="scss" scoped>
|
|
92
|
-
.vm-dict-tag-list {
|
|
93
|
-
display: inline-flex;
|
|
94
|
-
flex-wrap: wrap;
|
|
95
|
-
align-items: center;
|
|
96
|
-
gap: 4px;
|
|
97
|
-
max-width: 100%;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
.vm-dict-tag {
|
|
101
|
-
display: inline-flex;
|
|
102
|
-
padding: 2px 8px;
|
|
103
|
-
border-radius: 8px;
|
|
104
|
-
font-size: 12px;
|
|
105
|
-
font-weight: 600;
|
|
106
|
-
|
|
107
|
-
&.is-empty {
|
|
108
|
-
color: var(--muted-foreground);
|
|
109
|
-
background: transparent;
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
</style>
|
|
1
|
+
<template>
|
|
2
|
+
<span v-if="!hits.length" class="vm-dict-tag is-empty">—</span>
|
|
3
|
+
<span v-else class="vm-dict-tag-list">
|
|
4
|
+
<span
|
|
5
|
+
v-for="(item, i) in hits"
|
|
6
|
+
:key="`${String(item.value)}-${i}`"
|
|
7
|
+
class="vm-dict-tag"
|
|
8
|
+
:style="item.style"
|
|
9
|
+
>
|
|
10
|
+
{{ item.label }}
|
|
11
|
+
</span>
|
|
12
|
+
</span>
|
|
13
|
+
</template>
|
|
14
|
+
|
|
15
|
+
<script setup lang="ts">
|
|
16
|
+
import { computed } from 'vue'
|
|
17
|
+
import { getCrudStyle } from '../style'
|
|
18
|
+
|
|
19
|
+
defineOptions({ name: 'vm-dict-tag' })
|
|
20
|
+
|
|
21
|
+
type DictOpt = {
|
|
22
|
+
label: string
|
|
23
|
+
value: string | number | boolean
|
|
24
|
+
type?: string
|
|
25
|
+
color?: string
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const props = defineProps<{
|
|
29
|
+
/** 单值或字典 value 数组(多选列) */
|
|
30
|
+
modelValue?:
|
|
31
|
+
| string
|
|
32
|
+
| number
|
|
33
|
+
| boolean
|
|
34
|
+
| null
|
|
35
|
+
| Array<string | number | boolean | null | undefined>
|
|
36
|
+
options?: DictOpt[]
|
|
37
|
+
}>()
|
|
38
|
+
|
|
39
|
+
function valuesOf(
|
|
40
|
+
raw: unknown,
|
|
41
|
+
): Array<string | number | boolean> {
|
|
42
|
+
if (raw == null || raw === '') return []
|
|
43
|
+
if (Array.isArray(raw)) {
|
|
44
|
+
return raw.filter(
|
|
45
|
+
(v): v is string | number | boolean =>
|
|
46
|
+
v != null && v !== '',
|
|
47
|
+
)
|
|
48
|
+
}
|
|
49
|
+
return [raw as string | number | boolean]
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function matchOpt(
|
|
53
|
+
options: DictOpt[] | undefined,
|
|
54
|
+
v: string | number | boolean,
|
|
55
|
+
): DictOpt | undefined {
|
|
56
|
+
return options?.find(
|
|
57
|
+
(d) => d.value === v || String(d.value) === String(v),
|
|
58
|
+
)
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function styleOf(opt: DictOpt, idx: number) {
|
|
62
|
+
if (opt.color) {
|
|
63
|
+
return { background: `${opt.color}22`, color: opt.color }
|
|
64
|
+
}
|
|
65
|
+
const colors = getCrudStyle().colors
|
|
66
|
+
const c = colors[idx % colors.length] || 'var(--brand)'
|
|
67
|
+
return { background: `${c}22`, color: c }
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const hits = computed(() => {
|
|
71
|
+
const opts = props.options || []
|
|
72
|
+
const out: Array<{
|
|
73
|
+
label: string
|
|
74
|
+
value: string | number | boolean
|
|
75
|
+
style: Record<string, string>
|
|
76
|
+
}> = []
|
|
77
|
+
for (const v of valuesOf(props.modelValue)) {
|
|
78
|
+
const hit = matchOpt(opts, v)
|
|
79
|
+
if (!hit) continue
|
|
80
|
+
const idx = opts.findIndex((d) => d === hit)
|
|
81
|
+
out.push({
|
|
82
|
+
label: hit.label,
|
|
83
|
+
value: hit.value,
|
|
84
|
+
style: styleOf(hit, idx < 0 ? 0 : idx),
|
|
85
|
+
})
|
|
86
|
+
}
|
|
87
|
+
return out
|
|
88
|
+
})
|
|
89
|
+
</script>
|
|
90
|
+
|
|
91
|
+
<style lang="scss" scoped>
|
|
92
|
+
.vm-dict-tag-list {
|
|
93
|
+
display: inline-flex;
|
|
94
|
+
flex-wrap: wrap;
|
|
95
|
+
align-items: center;
|
|
96
|
+
gap: 4px;
|
|
97
|
+
max-width: 100%;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
.vm-dict-tag {
|
|
101
|
+
display: inline-flex;
|
|
102
|
+
padding: 2px 8px;
|
|
103
|
+
border-radius: 8px;
|
|
104
|
+
font-size: 12px;
|
|
105
|
+
font-weight: 600;
|
|
106
|
+
|
|
107
|
+
&.is-empty {
|
|
108
|
+
color: var(--muted-foreground);
|
|
109
|
+
background: transparent;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
</style>
|