@dt-frames/ui 2.0.1 → 2.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/assets/data/icons/actions.d.ts +1 -0
- package/es/assets/data/icons/actions.ts +423 -0
- package/es/assets/data/icons/code.d.ts +1 -0
- package/es/assets/data/icons/code.ts +10 -0
- package/es/assets/data/icons/commuticate.d.ts +1 -0
- package/es/assets/data/icons/commuticate.ts +182 -0
- package/es/assets/data/icons/currency.d.ts +1 -0
- package/es/assets/data/icons/currency.ts +44 -0
- package/es/assets/data/icons/devices.d.ts +1 -0
- package/es/assets/data/icons/devices.ts +126 -0
- package/es/assets/data/icons/edit.d.ts +1 -0
- package/es/assets/data/icons/edit.ts +163 -0
- package/es/assets/data/icons/file.d.ts +1 -0
- package/es/assets/data/icons/file.ts +99 -0
- package/es/assets/data/icons/math.d.ts +1 -0
- package/es/assets/data/icons/math.ts +53 -0
- package/es/assets/data/icons/message.d.ts +1 -0
- package/es/assets/data/icons/message.ts +68 -0
- package/es/assets/data/icons/navigate.d.ts +1 -0
- package/es/assets/data/icons/navigate.ts +181 -0
- package/es/assets/data/icons/other.d.ts +1 -0
- package/es/assets/data/icons/other.ts +324 -0
- package/es/assets/data/index.d.ts +4 -0
- package/es/assets/data/index.ts +58 -0
- package/es/assets/icons/iconfont.css +7266 -0
- package/es/assets/icons/iconfont.eot +0 -0
- package/es/assets/icons/iconfont.svg +5445 -0
- package/es/assets/icons/iconfont.ttf +0 -0
- package/es/assets/icons/iconfont.woff +0 -0
- package/es/assets/icons/iconfont.woff2 +0 -0
- package/es/assets/imgs/header/avatar.png +0 -0
- package/es/assets/imgs/logo/logo.png +0 -0
- package/es/assets/imgs/table/empty.png +0 -0
- package/es/assets/locales/en.d.ts +101 -0
- package/es/assets/locales/en.ts +101 -0
- package/es/assets/locales/index.d.ts +2 -0
- package/es/assets/locales/index.ts +5 -0
- package/es/assets/locales/zh.d.ts +103 -0
- package/es/assets/locales/zh.ts +103 -0
- package/es/components/container/index.d.ts +94 -0
- package/es/components/container/index.js +290 -0
- package/es/components/container/index.less +64 -0
- package/es/components/container/src/components/bar.d.ts +14 -0
- package/es/components/container/src/components/scroll-bar.d.ts +70 -0
- package/es/components/container/src/hooks/scroll.d.ts +10 -0
- package/es/components/container/src/scroll-container.d.ts +76 -0
- package/es/components/container/src/slot-container.d.ts +20 -0
- package/es/components/container/src/types/scroll.type.d.ts +22 -0
- package/es/components/container/src/utils/scroll.d.ts +5 -0
- package/es/components/curd/index.d.ts +2 -0
- package/es/components/curd/index.js +3120 -0
- package/es/components/curd/src/components/Curd.d.ts +1246 -0
- package/es/components/curd/src/hooks/useCurd.d.ts +112 -0
- package/es/components/curd/src/props.d.ts +187 -0
- package/es/components/curd/src/types/curd.type.d.ts +19 -0
- package/es/components/drawer/index.d.ts +8039 -0
- package/es/components/drawer/index.js +838 -0
- package/es/components/drawer/index.less +10 -0
- package/es/components/drawer/src/components/DrawerFooter.d.ts +139 -0
- package/es/components/drawer/src/components/DrawerHeader.d.ts +11 -0
- package/es/components/drawer/src/hooks/useDrawer.d.ts +3 -0
- package/es/components/drawer/src/index.d.ts +8041 -0
- package/es/components/drawer/src/props.d.ts +64 -0
- package/es/components/drawer/src/types/index.type.d.ts +48 -0
- package/es/components/form/index.d.ts +3219 -0
- package/es/components/form/index.js +1896 -0
- package/es/components/form/index.less +141 -0
- package/es/components/form/src/components/FormButtons.d.ts +88 -0
- package/es/components/form/src/components/FormItem.d.ts +165 -0
- package/es/components/form/src/components/componentMap.d.ts +4 -0
- package/es/components/form/src/components/formIcon.d.ts +1231 -0
- package/es/components/form/src/components/formInputUseDialog.d.ts +911 -0
- package/es/components/form/src/components/index.d.ts +4 -0
- package/es/components/form/src/components/radioButton.d.ts +34 -0
- package/es/components/form/src/enums/index.d.ts +7 -0
- package/es/components/form/src/hooks/helper.d.ts +14 -0
- package/es/components/form/src/hooks/useForm.d.ts +6 -0
- package/es/components/form/src/hooks/useFormActions.d.ts +12 -0
- package/es/components/form/src/hooks/useFormEvent.d.ts +25 -0
- package/es/components/form/src/hooks/useFormValue.d.ts +3 -0
- package/es/components/form/src/hooks/useFormValues.d.ts +11 -0
- package/es/components/form/src/hooks/useLabelWidth.d.ts +22 -0
- package/es/components/form/src/index.d.ts +2965 -0
- package/es/components/form/src/props.d.ts +133 -0
- package/es/components/form/src/types/actions.type.d.ts +15 -0
- package/es/components/form/src/types/form.type.d.ts +70 -0
- package/es/components/icons/index.d.ts +497 -0
- package/es/components/icons/index.js +1969 -0
- package/es/components/icons/index.less +42 -0
- package/es/components/icons/src/pick-icon.d.ts +455 -0
- package/es/components/icons/src/svg-icon.d.ts +44 -0
- package/es/components/modal/index.d.ts +3 -0
- package/es/components/modal/index.js +1193 -0
- package/es/components/modal/index.less +54 -0
- package/es/components/modal/src/components/CloseIcon.d.ts +40 -0
- package/es/components/modal/src/components/Modal.d.ts +108 -0
- package/es/components/modal/src/components/ModalFooter.d.ts +139 -0
- package/es/components/modal/src/components/ModalWrap.d.ts +153 -0
- package/es/components/modal/src/hooks/useDrag.d.ts +7 -0
- package/es/components/modal/src/hooks/useFullScreen.d.ts +6 -0
- package/es/components/modal/src/hooks/useModal.d.ts +5 -0
- package/es/components/modal/src/index.d.ts +774 -0
- package/es/components/modal/src/props.d.ts +100 -0
- package/es/components/modal/src/types/modal.type.d.ts +17 -0
- package/es/components/source/hooks/useDownload.d.ts +8 -0
- package/es/components/source/hooks/useSource.d.ts +40 -0
- package/es/components/source/index.d.ts +2 -0
- package/es/components/source/index.js +332 -0
- package/es/components/source/types/source.type.d.ts +37 -0
- package/es/components/source/utils/index.d.ts +8 -0
- package/es/components/table/index.d.ts +3 -0
- package/es/components/table/index.js +3983 -0
- package/es/components/table/index.less +192 -0
- package/es/components/table/src/components/TableAction.d.ts +70 -0
- package/es/components/table/src/components/TableHeader.d.ts +1136 -0
- package/es/components/table/src/components/TableRender.d.ts +17 -0
- package/es/components/table/src/components/editTable/CellComponent.d.ts +22 -0
- package/es/components/table/src/components/editTable/EditTableCell.d.ts +93 -0
- package/es/components/table/src/components/editTable/componentMap.d.ts +4 -0
- package/es/components/table/src/components/editTable/index.d.ts +9 -0
- package/es/components/table/src/components/editTable/props.d.ts +27 -0
- package/es/components/table/src/components/tableSetting/Column.d.ts +69 -0
- package/es/components/table/src/components/tableSetting/Download.d.ts +922 -0
- package/es/components/table/src/components/tableSetting/DownloadCtrl.d.ts +888 -0
- package/es/components/table/src/components/tableSetting/Fullscreen.d.ts +22 -0
- package/es/components/table/src/components/tableSetting/index.d.ts +1030 -0
- package/es/components/table/src/hooks/useColumns.d.ts +14 -0
- package/es/components/table/src/hooks/useCustomRow.d.ts +20 -0
- package/es/components/table/src/hooks/useDataSource.d.ts +15 -0
- package/es/components/table/src/hooks/useHeader.d.ts +8 -0
- package/es/components/table/src/hooks/useHeaderCode.d.ts +3 -0
- package/es/components/table/src/hooks/useLoading.d.ts +6 -0
- package/es/components/table/src/hooks/usePagination.d.ts +7 -0
- package/es/components/table/src/hooks/useRow.d.ts +5 -0
- package/es/components/table/src/hooks/useRowSelection.d.ts +12 -0
- package/es/components/table/src/hooks/useTable.d.ts +9 -0
- package/es/components/table/src/hooks/useTableInstance.d.ts +16 -0
- package/es/components/table/src/hooks/useTableScroll.d.ts +13 -0
- package/es/components/table/src/index.d.ts +644 -0
- package/es/components/table/src/props.d.ts +185 -0
- package/es/components/table/src/types/actions.type.d.ts +21 -0
- package/es/components/table/src/types/header.type.d.ts +23 -0
- package/es/components/table/src/types/table.type.d.ts +98 -0
- package/es/directives/icon.d.ts +2 -0
- package/es/directives/index.d.ts +7 -0
- package/es/directives/index.js +2015 -0
- package/es/directives/permission.d.ts +2 -0
- package/es/global.d.ts +7 -0
- package/es/index.d.ts +1 -0
- package/es/index.js +4 -0
- package/es/theme/index.d.ts +10 -0
- package/es/theme/index.js +3255 -0
- package/es/theme/index.less +603 -0
- package/es/theme/src/components/content/index.d.ts +27 -0
- package/es/theme/src/components/feature/back-top.d.ts +5 -0
- package/es/theme/src/components/feature/index.d.ts +7 -0
- package/es/theme/src/components/footer/index.d.ts +31 -0
- package/es/theme/src/components/header/components/bread-crumb.d.ts +6 -0
- package/es/theme/src/components/header/components/fullscreen.d.ts +5 -0
- package/es/theme/src/components/header/components/index.d.ts +11 -0
- package/es/theme/src/components/header/components/lang-picker.d.ts +23 -0
- package/es/theme/src/components/header/components/logo.d.ts +35 -0
- package/es/theme/src/components/header/components/menu-filter.d.ts +22 -0
- package/es/theme/src/components/header/components/notify.d.ts +24 -0
- package/es/theme/src/components/header/components/setting-theme.d.ts +223 -0
- package/es/theme/src/components/header/components/size.d.ts +282 -0
- package/es/theme/src/components/header/components/theme-drawer/feature.d.ts +138 -0
- package/es/theme/src/components/header/components/theme-drawer/index.d.ts +3 -0
- package/es/theme/src/components/header/components/theme-drawer/menu-type.d.ts +16 -0
- package/es/theme/src/components/header/components/theme-drawer/select.d.ts +58 -0
- package/es/theme/src/components/header/components/theme-drawer/switch.d.ts +49 -0
- package/es/theme/src/components/header/components/trigger.d.ts +10 -0
- package/es/theme/src/components/header/components/user-info.d.ts +37 -0
- package/es/theme/src/components/header/helper/change-theme.d.ts +13 -0
- package/es/theme/src/components/header/helper/menu-tree.d.ts +3 -0
- package/es/theme/src/components/header/index.d.ts +699 -0
- package/es/theme/src/components/header/multiple-header.d.ts +785 -0
- package/es/theme/src/components/sider/components/basic-menu/basic-menu-item.d.ts +62 -0
- package/es/theme/src/components/sider/components/basic-menu/basic-menu.d.ts +207 -0
- package/es/theme/src/components/sider/components/basic-menu/basic-sub-menu-item.d.ts +127 -0
- package/es/theme/src/components/sider/components/basic-menu/menu-item-content.d.ts +26 -0
- package/es/theme/src/components/sider/components/drag-bar.d.ts +14 -0
- package/es/theme/src/components/sider/components/layout-menu.d.ts +22 -0
- package/es/theme/src/components/sider/components/props.d.ts +69 -0
- package/es/theme/src/components/sider/components/sider-trigger.d.ts +18 -0
- package/es/theme/src/components/sider/helper/sider.d.ts +12 -0
- package/es/theme/src/components/sider/helper/split-menu.d.ts +10 -0
- package/es/theme/src/components/sider/index.d.ts +70 -0
- package/es/theme/src/components/tabs/components/TabContent.d.ts +6 -0
- package/es/theme/src/components/tabs/components/TabRedo.d.ts +21 -0
- package/es/theme/src/components/tabs/components/index.d.ts +3 -0
- package/es/theme/src/components/tabs/hooks/useMultifyTabs.d.ts +7 -0
- package/es/theme/src/components/tabs/hooks/useTabDropdown.d.ts +6 -0
- package/es/theme/src/components/tabs/index.d.ts +63 -0
- package/es/theme/src/components/tabs/types/tabs.type.d.ts +7 -0
- package/es/theme/src/enums/index.d.ts +1 -0
- package/es/theme/src/enums/theme.enum.d.ts +33 -0
- package/es/theme/src/hooks/index.d.ts +6 -0
- package/es/theme/src/hooks/useDragLine.d.ts +2 -0
- package/es/theme/src/hooks/useHeader.d.ts +25 -0
- package/es/theme/src/hooks/useMenu.d.ts +27 -0
- package/es/theme/src/hooks/useMultifyTab.d.ts +7 -0
- package/es/theme/src/hooks/useOpenKeys.d.ts +7 -0
- package/es/theme/src/hooks/useTheme.d.ts +9 -0
- package/es/theme/src/index.d.ts +1643 -0
- package/es/theme/src/setting/theme.setting.d.ts +2 -0
- package/es/theme/src/stores/index.d.ts +3 -0
- package/es/theme/src/stores/routeReuse.store.d.ts +23 -0
- package/es/theme/src/stores/theme.store.d.ts +15 -0
- package/es/theme/src/types/index.d.ts +3 -0
- package/es/theme/src/types/menu.type.d.ts +15 -0
- package/es/theme/src/types/theme.type.d.ts +60 -0
- package/es/utils/withInstall.d.ts +4 -0
- package/index.d.ts +10 -0
- package/index.js +34 -0
- package/package.json +3 -6
- package/tailwind.config.cjs +11 -0
- package/tsconfig.json +41 -0
- package/tsconfig.node.json +9 -0
- package/vite.config.ts +51 -0
|
@@ -0,0 +1,1896 @@
|
|
|
1
|
+
import { RadioButton, RadioGroup, Button, FormItem as FormItem$1, Col as Col$1, Row, Form as Form$1 } from "ant-design-vue/es";
|
|
2
|
+
import "ant-design-vue/es/form/style";
|
|
3
|
+
import "ant-design-vue/es/row/style";
|
|
4
|
+
import { toRaw as toRaw$1, unref, computed, getCurrentInstance, reactive, readonly, watchEffect, nextTick, defineComponent, useAttrs, openBlock, createBlock, mergeProps, isRef, withCtx, createElementBlock, Fragment, renderList, createTextVNode, toDisplayString, createElementVNode, createVNode, normalizeProps, guardReactiveProps, createCommentVNode, toRefs, isVNode, ref, watch, resolveDirective, normalizeStyle, withDirectives, normalizeClass, onMounted, withKeys, createSlots, renderSlot } from "vue";
|
|
5
|
+
import { DtCache, CacheKey, deepMerge, Pages, useGo, useRedo, Language, useAppStore, isNumber, useI18n, isString, isFunction, error, useSlots, isArray, isBoolean, isNull, dispatchResize, isObject, isNullAndUnDef, isEmpty, useTimeoutFn } from "@dt-frames/core";
|
|
6
|
+
import { isEqual, omit, cloneDeep, upperFirst, uniqBy, set } from "lodash-es";
|
|
7
|
+
import { Input, Select, TreeSelect, Radio, Checkbox, AutoComplete, Cascader, DatePicker, InputNumber, Switch, TimePicker, Slider, Rate, Divider, Col, Tooltip, Form, FormItem } from "ant-design-vue";
|
|
8
|
+
import { defineStore } from "pinia";
|
|
9
|
+
import "ant-design-vue/es/radio/style";
|
|
10
|
+
import "ant-design-vue/es/col/style";
|
|
11
|
+
import "ant-design-vue/es/button/style";
|
|
12
|
+
import dayjs from "dayjs";
|
|
13
|
+
var Theme = /* @__PURE__ */ ((Theme2) => {
|
|
14
|
+
Theme2["DARK"] = "dark";
|
|
15
|
+
Theme2["LIGHT"] = "light";
|
|
16
|
+
return Theme2;
|
|
17
|
+
})(Theme || {});
|
|
18
|
+
var MenuType = /* @__PURE__ */ ((MenuType2) => {
|
|
19
|
+
MenuType2["SIDE"] = "sidebar";
|
|
20
|
+
MenuType2["TOP_MENU"] = "top-menu";
|
|
21
|
+
MenuType2["MIX"] = "mix";
|
|
22
|
+
return MenuType2;
|
|
23
|
+
})(MenuType || {});
|
|
24
|
+
var MenuMode = /* @__PURE__ */ ((MenuMode2) => {
|
|
25
|
+
MenuMode2["INLINE"] = "inline";
|
|
26
|
+
MenuMode2["HORIZONTAL"] = "horizontal";
|
|
27
|
+
MenuMode2["VERTICAL"] = "vertical";
|
|
28
|
+
return MenuMode2;
|
|
29
|
+
})(MenuMode || {});
|
|
30
|
+
var ContentMode = /* @__PURE__ */ ((ContentMode2) => {
|
|
31
|
+
ContentMode2["FULL"] = "full";
|
|
32
|
+
ContentMode2["FIXED"] = "fixed";
|
|
33
|
+
return ContentMode2;
|
|
34
|
+
})(ContentMode || {});
|
|
35
|
+
var UiSize = /* @__PURE__ */ ((UiSize2) => {
|
|
36
|
+
UiSize2["LARGE"] = "large";
|
|
37
|
+
UiSize2["MIDDLE"] = "middle";
|
|
38
|
+
UiSize2["SMALL"] = "small";
|
|
39
|
+
return UiSize2;
|
|
40
|
+
})(UiSize || {});
|
|
41
|
+
const defaultThemeConf = {
|
|
42
|
+
content: {
|
|
43
|
+
contentMode: ContentMode.FULL
|
|
44
|
+
},
|
|
45
|
+
headOptions: {
|
|
46
|
+
fixed: true,
|
|
47
|
+
theme: Theme.LIGHT,
|
|
48
|
+
showLogo: true,
|
|
49
|
+
showBackToTop: true,
|
|
50
|
+
useLockPage: true,
|
|
51
|
+
size: UiSize.SMALL,
|
|
52
|
+
showSize: true,
|
|
53
|
+
showBreadCrumb: true,
|
|
54
|
+
showFullScreen: true,
|
|
55
|
+
showSearch: true,
|
|
56
|
+
showNotice: true,
|
|
57
|
+
showLocaleSwitch: true,
|
|
58
|
+
showSettingTheme: true,
|
|
59
|
+
showLoginOut: true
|
|
60
|
+
},
|
|
61
|
+
menuOptions: {
|
|
62
|
+
fixed: true,
|
|
63
|
+
theme: Theme.DARK,
|
|
64
|
+
collapsed: false,
|
|
65
|
+
collapsedShowTitle: false,
|
|
66
|
+
canDrag: true,
|
|
67
|
+
show: true,
|
|
68
|
+
hidden: false,
|
|
69
|
+
split: false,
|
|
70
|
+
menuWidth: 240,
|
|
71
|
+
trigger: true,
|
|
72
|
+
type: MenuType.SIDE,
|
|
73
|
+
mode: MenuMode.INLINE
|
|
74
|
+
},
|
|
75
|
+
footerOptions: {
|
|
76
|
+
show: false,
|
|
77
|
+
height: 48,
|
|
78
|
+
title: "Copyright(C) 2021 by www.ithinkdt.com. All rights reserved.",
|
|
79
|
+
subTitle: "Privacy Statement"
|
|
80
|
+
},
|
|
81
|
+
routeReuse: {
|
|
82
|
+
show: true,
|
|
83
|
+
cache: true,
|
|
84
|
+
canDrag: true,
|
|
85
|
+
showQuick: true,
|
|
86
|
+
showRedo: true,
|
|
87
|
+
showFold: true
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
const useThemeStore = defineStore({
|
|
91
|
+
id: "dt-theme",
|
|
92
|
+
state: () => ({
|
|
93
|
+
themeConf: DtCache.getLocal(CacheKey.THEME) ?? defaultThemeConf,
|
|
94
|
+
pageLoading: false
|
|
95
|
+
}),
|
|
96
|
+
getters: {
|
|
97
|
+
getThemeConf() {
|
|
98
|
+
return this.themeConf;
|
|
99
|
+
},
|
|
100
|
+
getHeaderConf() {
|
|
101
|
+
return this.themeConf.headOptions;
|
|
102
|
+
},
|
|
103
|
+
getMenuConf() {
|
|
104
|
+
return this.themeConf.menuOptions;
|
|
105
|
+
},
|
|
106
|
+
getFooterConf() {
|
|
107
|
+
return this.themeConf.footerOptions;
|
|
108
|
+
},
|
|
109
|
+
getRouteReuseConf() {
|
|
110
|
+
return this.themeConf.routeReuse;
|
|
111
|
+
},
|
|
112
|
+
getPageLoading() {
|
|
113
|
+
return this.pageLoading;
|
|
114
|
+
}
|
|
115
|
+
},
|
|
116
|
+
actions: {
|
|
117
|
+
setThemeConf(options = {}) {
|
|
118
|
+
let newThemeConf = deepMerge(this.themeConf, options);
|
|
119
|
+
this.themeConf = deepMerge(defaultThemeConf, newThemeConf);
|
|
120
|
+
DtCache.setLocal(CacheKey.THEME, this.themeConf);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
defineStore({
|
|
125
|
+
id: "route-reuse",
|
|
126
|
+
state: () => ({
|
|
127
|
+
cacheTabList: /* @__PURE__ */ new Set(),
|
|
128
|
+
tabList: DtCache.getLocal(CacheKey.THEME)?.routeReuse?.cache ? DtCache.getLocal(CacheKey.ROUTE_REUSE) || [] : [],
|
|
129
|
+
lastDragEndIndex: 0
|
|
130
|
+
}),
|
|
131
|
+
getters: {
|
|
132
|
+
getTabList() {
|
|
133
|
+
return this.tabList;
|
|
134
|
+
},
|
|
135
|
+
getCachedTabList() {
|
|
136
|
+
return Array.from(this.cacheTabList);
|
|
137
|
+
},
|
|
138
|
+
getLastDragEndIndex() {
|
|
139
|
+
return this.lastDragEndIndex;
|
|
140
|
+
}
|
|
141
|
+
},
|
|
142
|
+
actions: {
|
|
143
|
+
async addTab(route) {
|
|
144
|
+
const { path, name, fullPath, params, query, meta } = route;
|
|
145
|
+
if (path === Pages.NOT_FOUND || path === Pages.LOGIN || path === Pages.BASE_PAGE) {
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
let updateIndex = -1;
|
|
149
|
+
const tabHasExits = this.tabList.some((tab, index) => {
|
|
150
|
+
updateIndex = index;
|
|
151
|
+
return (tab.fullPath || tab.path) === (fullPath || path);
|
|
152
|
+
});
|
|
153
|
+
if (tabHasExits) {
|
|
154
|
+
const curTab = toRaw$1(this.tabList)[updateIndex];
|
|
155
|
+
curTab.params = params || curTab.params;
|
|
156
|
+
curTab.query = query || curTab.query;
|
|
157
|
+
curTab.fullPath = fullPath || curTab.fullPath;
|
|
158
|
+
this.tabList.splice(updateIndex, 1, curTab);
|
|
159
|
+
} else {
|
|
160
|
+
this.tabList.push(JSON.parse(JSON.stringify(route)));
|
|
161
|
+
}
|
|
162
|
+
this.updateCacheTab();
|
|
163
|
+
},
|
|
164
|
+
closeTab(path, router) {
|
|
165
|
+
const go = useGo(router);
|
|
166
|
+
const index = this.tabList.findIndex((item) => item.path === path);
|
|
167
|
+
let page;
|
|
168
|
+
if (index === 0) {
|
|
169
|
+
if (this.tabList.length !== 1) {
|
|
170
|
+
page = this.tabList[index + 1];
|
|
171
|
+
}
|
|
172
|
+
} else {
|
|
173
|
+
page = this.tabList[index - 1];
|
|
174
|
+
}
|
|
175
|
+
this.bulkCloseTabs([path]);
|
|
176
|
+
this.updateCacheTab();
|
|
177
|
+
path === router.currentRoute.value.path && go(page.path);
|
|
178
|
+
},
|
|
179
|
+
closeAllTab(currentRoute, router) {
|
|
180
|
+
const go = useGo(router);
|
|
181
|
+
let filterTabList = this.tabList.filter((item) => item?.meta?.affix ?? false);
|
|
182
|
+
const route = filterTabList.length > 0 ? filterTabList[filterTabList.length - 1] : unref(currentRoute);
|
|
183
|
+
this.tabList = [route];
|
|
184
|
+
this.updateCacheTab();
|
|
185
|
+
go(route.path);
|
|
186
|
+
},
|
|
187
|
+
closeLeftTabs(path) {
|
|
188
|
+
const index = this.tabList.findIndex((item) => item.path === path);
|
|
189
|
+
if (index > 0) {
|
|
190
|
+
const leftTabs = this.tabList.slice(0, index);
|
|
191
|
+
const pathList = [];
|
|
192
|
+
for (const item of leftTabs) {
|
|
193
|
+
const affix = item?.meta?.affix ?? false;
|
|
194
|
+
if (!affix) {
|
|
195
|
+
pathList.push(item.fullPath);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
this.bulkCloseTabs(pathList);
|
|
199
|
+
}
|
|
200
|
+
this.updateCacheTab();
|
|
201
|
+
},
|
|
202
|
+
closeRightTabs(path) {
|
|
203
|
+
const index = this.tabList.findIndex((item) => item.path === path);
|
|
204
|
+
if (index >= 0 && index < this.tabList.length - 1) {
|
|
205
|
+
const rightTabs = this.tabList.slice(index + 1, this.tabList.length);
|
|
206
|
+
const pathList = [];
|
|
207
|
+
for (const item of rightTabs) {
|
|
208
|
+
const affix = item?.meta?.affix ?? false;
|
|
209
|
+
if (!affix) {
|
|
210
|
+
pathList.push(item.fullPath);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
this.bulkCloseTabs(pathList);
|
|
214
|
+
}
|
|
215
|
+
this.updateCacheTab();
|
|
216
|
+
},
|
|
217
|
+
closeOtherTabs(path) {
|
|
218
|
+
const pathList = [];
|
|
219
|
+
for (let item of this.tabList) {
|
|
220
|
+
const affix = item?.meta?.affix ?? false;
|
|
221
|
+
if (item.path !== path && !affix) {
|
|
222
|
+
pathList.push(item.path);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
this.bulkCloseTabs(pathList);
|
|
226
|
+
this.updateCacheTab();
|
|
227
|
+
},
|
|
228
|
+
bulkCloseTabs(pathList) {
|
|
229
|
+
this.tabList = this.tabList.filter((item) => !pathList.includes(item.fullPath));
|
|
230
|
+
},
|
|
231
|
+
updateCacheTab() {
|
|
232
|
+
const cacheTab = DtCache.getLocal(CacheKey.THEME)?.routeReuse?.cache;
|
|
233
|
+
cacheTab && DtCache.setLocal(CacheKey.ROUTE_REUSE, this.tabList);
|
|
234
|
+
const cacheMap = /* @__PURE__ */ new Set();
|
|
235
|
+
for (const tab of this.tabList) {
|
|
236
|
+
if (tab.meta?.hideTab) {
|
|
237
|
+
continue;
|
|
238
|
+
}
|
|
239
|
+
const name = tab.name;
|
|
240
|
+
cacheMap.add(name);
|
|
241
|
+
}
|
|
242
|
+
this.cacheTabList = cacheMap;
|
|
243
|
+
},
|
|
244
|
+
async refreshPage(router) {
|
|
245
|
+
const findTab = this.getCachedTabList.find((item) => item === unref(router.currentRoute).name);
|
|
246
|
+
if (findTab) {
|
|
247
|
+
this.cacheTabList.delete(findTab.toString());
|
|
248
|
+
}
|
|
249
|
+
const redo = useRedo(router);
|
|
250
|
+
await redo();
|
|
251
|
+
},
|
|
252
|
+
sortTabs(oldIndex, newIndex) {
|
|
253
|
+
const currentTab = this.tabList[oldIndex];
|
|
254
|
+
this.tabList.splice(oldIndex, 1);
|
|
255
|
+
this.tabList.splice(newIndex, 0, currentTab);
|
|
256
|
+
this.lastDragEndIndex = this.lastDragEndIndex + 1;
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
});
|
|
260
|
+
function useMenu() {
|
|
261
|
+
const { getMenuConf, setThemeConf } = useThemeStore();
|
|
262
|
+
const getCollapsedShowTitle = computed(() => getMenuConf.collapsedShowTitle);
|
|
263
|
+
const getIsSidebarType = computed(() => getMenuConf.type === MenuType.SIDE);
|
|
264
|
+
const getMenuFixed = computed(() => getMenuConf.fixed);
|
|
265
|
+
const getShowMenu = computed(() => getMenuConf.show);
|
|
266
|
+
const getShowSidebar = computed(() => {
|
|
267
|
+
return unref(getSplit) || unref(getShowMenu) && unref(getMenuMode) !== MenuMode.HORIZONTAL;
|
|
268
|
+
});
|
|
269
|
+
const getMenuHidden = computed(() => getMenuConf.hidden);
|
|
270
|
+
const getMenuTheme = computed(() => getMenuConf.theme);
|
|
271
|
+
const getTrigger = computed(() => getMenuConf.trigger);
|
|
272
|
+
const getCanDrag = computed(() => getMenuConf.canDrag);
|
|
273
|
+
const getIsMixMode = computed(() => {
|
|
274
|
+
return unref(getMenuMode) === MenuMode.INLINE && unref(getMenuType) === MenuType.MIX;
|
|
275
|
+
});
|
|
276
|
+
const getMenuWidth = computed(() => unref(getIsMixMode) ? Number(getMenuConf.menuWidth) - 40 : getMenuConf.menuWidth);
|
|
277
|
+
const getLogoWidth = computed(() => getMenuConf.menuWidth);
|
|
278
|
+
const getMenuType = computed(() => getMenuConf.type);
|
|
279
|
+
const getIsTopMenu = computed(() => unref(getMenuType) === MenuType.TOP_MENU);
|
|
280
|
+
const getMenuMode = computed(() => getMenuConf.mode);
|
|
281
|
+
const getSplit = computed(() => getMenuConf.split);
|
|
282
|
+
const getCollapsed = computed(() => getMenuConf.collapsed);
|
|
283
|
+
const getIsHorizontal = computed(() => unref(getMenuMode) === MenuMode.HORIZONTAL);
|
|
284
|
+
const setThemeStore = (conf = {}) => setThemeConf(conf);
|
|
285
|
+
const toggleCollapsed = () => setThemeStore({
|
|
286
|
+
menuOptions: {
|
|
287
|
+
collapsed: !unref(getCollapsed)
|
|
288
|
+
}
|
|
289
|
+
});
|
|
290
|
+
const getMiniWidthNumber = computed(() => getMenuConf.collapsedShowTitle ? 80 : 48);
|
|
291
|
+
const getRealWidth = computed(() => {
|
|
292
|
+
return unref(getCollapsed) ? unref(getMiniWidthNumber) : unref(getMenuWidth);
|
|
293
|
+
});
|
|
294
|
+
const getCalcContentWidth = computed(() => {
|
|
295
|
+
const width = unref(getIsTopMenu) || !unref(getShowMenu) || unref(getSplit) && unref(getMenuHidden) ? 0 : unref(getRealWidth);
|
|
296
|
+
return `calc(100% - ${unref(width)}px)`;
|
|
297
|
+
});
|
|
298
|
+
return {
|
|
299
|
+
getCollapsedShowTitle,
|
|
300
|
+
getIsSidebarType,
|
|
301
|
+
getMenuFixed,
|
|
302
|
+
getShowMenu,
|
|
303
|
+
getShowSidebar,
|
|
304
|
+
getMenuHidden,
|
|
305
|
+
getMenuTheme,
|
|
306
|
+
getTrigger,
|
|
307
|
+
getMenuWidth,
|
|
308
|
+
getLogoWidth,
|
|
309
|
+
getMenuType,
|
|
310
|
+
getIsTopMenu,
|
|
311
|
+
getMenuMode,
|
|
312
|
+
getSplit,
|
|
313
|
+
getCollapsed,
|
|
314
|
+
getIsHorizontal,
|
|
315
|
+
getMiniWidthNumber,
|
|
316
|
+
getRealWidth,
|
|
317
|
+
getCalcContentWidth,
|
|
318
|
+
getIsMixMode,
|
|
319
|
+
getCanDrag,
|
|
320
|
+
toggleCollapsed,
|
|
321
|
+
setThemeStore
|
|
322
|
+
};
|
|
323
|
+
}
|
|
324
|
+
function useMultipleTab() {
|
|
325
|
+
const { getRouteReuseConf } = useThemeStore();
|
|
326
|
+
const getShowMultipleTab = computed(() => getRouteReuseConf.show);
|
|
327
|
+
const getShowQuick = computed(() => getRouteReuseConf.showQuick);
|
|
328
|
+
const getShowRedo = computed(() => getRouteReuseConf.showRedo);
|
|
329
|
+
const getCanCache = computed(() => getRouteReuseConf.cache);
|
|
330
|
+
const getCanDrag = computed(() => getRouteReuseConf.canDrag);
|
|
331
|
+
return {
|
|
332
|
+
getShowMultipleTab,
|
|
333
|
+
getShowQuick,
|
|
334
|
+
getShowRedo,
|
|
335
|
+
getCanCache,
|
|
336
|
+
getCanDrag
|
|
337
|
+
};
|
|
338
|
+
}
|
|
339
|
+
function useHeader() {
|
|
340
|
+
const HEADER_HEIGHT = 48;
|
|
341
|
+
const TABS_HEIGHT = 33;
|
|
342
|
+
const { getHeaderConf = {} } = useThemeStore();
|
|
343
|
+
const {
|
|
344
|
+
getIsSidebarType,
|
|
345
|
+
getMenuType,
|
|
346
|
+
getShowMenu,
|
|
347
|
+
getMenuHidden,
|
|
348
|
+
getTrigger,
|
|
349
|
+
getMenuMode,
|
|
350
|
+
getSplit,
|
|
351
|
+
getIsTopMenu,
|
|
352
|
+
getIsMixMode
|
|
353
|
+
} = useMenu();
|
|
354
|
+
const { getShowMultipleTab } = useMultipleTab();
|
|
355
|
+
const getHeaderTheme = computed(() => getHeaderConf.theme);
|
|
356
|
+
const getFixed = computed(() => getHeaderConf.fixed);
|
|
357
|
+
const getShowHeaderLogo = computed(() => unref(getShowLogo) && !unref(getIsSidebarType));
|
|
358
|
+
const getShowSearch = computed(() => getHeaderConf.showSearch);
|
|
359
|
+
const getShowHeaderTrigger = computed(() => {
|
|
360
|
+
if (unref(getMenuType) === MenuType.TOP_MENU || !unref(getShowMenu) || unref(getMenuHidden)) {
|
|
361
|
+
return false;
|
|
362
|
+
}
|
|
363
|
+
return unref(getTrigger);
|
|
364
|
+
});
|
|
365
|
+
const getShowBreadCrumb = computed(() => getHeaderConf.showBreadCrumb);
|
|
366
|
+
const getShowBread = computed(
|
|
367
|
+
() => unref(getMenuMode) !== MenuMode.HORIZONTAL && !unref(getSplit) && unref(getShowBreadCrumb)
|
|
368
|
+
);
|
|
369
|
+
const getShowTopMenu = computed(() => unref(getMenuMode) === MenuMode.HORIZONTAL || unref(getSplit));
|
|
370
|
+
const getShowNotice = computed(() => getHeaderConf.showNotice);
|
|
371
|
+
const getShowFullScreen = computed(() => getHeaderConf.showFullScreen);
|
|
372
|
+
const getShowLocale = computed(() => getHeaderConf.showLocaleSwitch);
|
|
373
|
+
const getShowSettingTheme = computed(() => getHeaderConf.showSettingTheme);
|
|
374
|
+
const getShowFullHeaderRef = computed(() => {
|
|
375
|
+
return !unref(getIsSidebarType) && !unref(getIsTopMenu);
|
|
376
|
+
});
|
|
377
|
+
const getHeaderHeight = computed(() => {
|
|
378
|
+
let height = 0;
|
|
379
|
+
height += HEADER_HEIGHT;
|
|
380
|
+
if (unref(getShowMultipleTab) && !unref(getSplit)) {
|
|
381
|
+
height += TABS_HEIGHT;
|
|
382
|
+
}
|
|
383
|
+
return height;
|
|
384
|
+
});
|
|
385
|
+
const getTabsHeight = computed(() => TABS_HEIGHT);
|
|
386
|
+
const getShowInsetHeaderRef = computed(() => {
|
|
387
|
+
return unref(getIsSidebarType) || unref(getIsTopMenu);
|
|
388
|
+
});
|
|
389
|
+
const getShowBackToTop = computed(() => getHeaderConf.showBackToTop);
|
|
390
|
+
const getIsZH = computed(() => {
|
|
391
|
+
let local = DtCache.getLocal(CacheKey.LOCALE);
|
|
392
|
+
if (!local)
|
|
393
|
+
return true;
|
|
394
|
+
return local === Language.ZH;
|
|
395
|
+
});
|
|
396
|
+
const getUiSize = computed(() => getHeaderConf?.size ?? UiSize.SMALL);
|
|
397
|
+
const getShowUiSize = computed(() => getHeaderConf?.showSize);
|
|
398
|
+
const getShowLogo = computed(() => getHeaderConf.showLogo);
|
|
399
|
+
const getShowLoginOut = computed(() => getHeaderConf.showLoginOut);
|
|
400
|
+
const loginOutClick = getHeaderConf.logoutClick;
|
|
401
|
+
return {
|
|
402
|
+
getHeaderTheme,
|
|
403
|
+
getFixed,
|
|
404
|
+
getShowSearch,
|
|
405
|
+
getShowHeaderLogo,
|
|
406
|
+
getShowHeaderTrigger,
|
|
407
|
+
getShowBread,
|
|
408
|
+
getShowTopMenu,
|
|
409
|
+
getShowFullScreen,
|
|
410
|
+
getShowLocale,
|
|
411
|
+
getShowSettingTheme,
|
|
412
|
+
getShowNotice,
|
|
413
|
+
getShowFullHeaderRef,
|
|
414
|
+
getHeaderHeight,
|
|
415
|
+
getTabsHeight,
|
|
416
|
+
getShowInsetHeaderRef,
|
|
417
|
+
getShowBackToTop,
|
|
418
|
+
getIsZH,
|
|
419
|
+
getUiSize,
|
|
420
|
+
getShowLogo,
|
|
421
|
+
getShowLoginOut,
|
|
422
|
+
getShowUiSize,
|
|
423
|
+
loginOutClick
|
|
424
|
+
};
|
|
425
|
+
}
|
|
426
|
+
function useLabelWidth(schemaItemRef, propsRef) {
|
|
427
|
+
const { getIsZH } = useHeader();
|
|
428
|
+
const { appConf } = useAppStore();
|
|
429
|
+
return computed(() => {
|
|
430
|
+
const { labelWidth, enLabelWidth, labelCol = {}, wrapperCol = {} } = unref(schemaItemRef);
|
|
431
|
+
const {
|
|
432
|
+
labelWidth: gLabelWidth,
|
|
433
|
+
enLabelWidth: gEnLabelWidth,
|
|
434
|
+
labelCol: glabelCol = {},
|
|
435
|
+
wrapperCol: gwrapperCol = {},
|
|
436
|
+
layout = appConf.ui.form.layout
|
|
437
|
+
} = unref(propsRef);
|
|
438
|
+
let width = (unref(getIsZH) ? labelWidth ?? gLabelWidth : enLabelWidth ?? gEnLabelWidth) ?? labelWidth ?? gLabelWidth ?? 0;
|
|
439
|
+
const labelcol = { ...glabelCol, ...labelCol };
|
|
440
|
+
const wrapcol = { ...gwrapperCol, ...wrapperCol };
|
|
441
|
+
width = isNumber(width) ? `${width}px` : width;
|
|
442
|
+
return {
|
|
443
|
+
labelCol: {
|
|
444
|
+
style: { width },
|
|
445
|
+
...labelcol
|
|
446
|
+
},
|
|
447
|
+
wrapperCol: {
|
|
448
|
+
style: { width: layout === "vertical" ? "100%" : `calc(100% - ${width})` },
|
|
449
|
+
...wrapcol
|
|
450
|
+
}
|
|
451
|
+
};
|
|
452
|
+
});
|
|
453
|
+
}
|
|
454
|
+
const SINGLE_DATA_TYPE = ["DatePicker", "MonthPicker", "WeekPicker", "TimePicker"];
|
|
455
|
+
const MULTIFY_DATA_TYPE = ["RangePicker"];
|
|
456
|
+
const DATE_PICKER_TYPES = [...SINGLE_DATA_TYPE, ...MULTIFY_DATA_TYPE];
|
|
457
|
+
function createPlaceholder(component) {
|
|
458
|
+
const { t } = useI18n("UI");
|
|
459
|
+
if (component.includes("Input") || component.includes("Complete")) {
|
|
460
|
+
return t("PLEASE_INPUT");
|
|
461
|
+
}
|
|
462
|
+
if (component.includes("Picker") || component.includes("Select") || component.includes("Cascader") || component.includes("Checkbox") || component.includes("Radio") || component.includes("Switch")) {
|
|
463
|
+
return t("PLEASE_SELECT");
|
|
464
|
+
}
|
|
465
|
+
if (component.includes("Icon")) {
|
|
466
|
+
return t("PLEASE_SET_ICON");
|
|
467
|
+
}
|
|
468
|
+
return "";
|
|
469
|
+
}
|
|
470
|
+
function setComponentRuleType(rule, component, valueFormat) {
|
|
471
|
+
if (SINGLE_DATA_TYPE.includes(component)) {
|
|
472
|
+
rule.type = valueFormat ? "string" : "object";
|
|
473
|
+
} else if (["RangePicker", "Upload", "CheckboxGroup", "TimePicker"].includes(component)) {
|
|
474
|
+
rule.type = "array";
|
|
475
|
+
} else if (["InputNumber"].includes(component)) {
|
|
476
|
+
rule.type = "number";
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
function handleInputNumberValue(component, val) {
|
|
480
|
+
if (!component)
|
|
481
|
+
return val;
|
|
482
|
+
if ([
|
|
483
|
+
"Input",
|
|
484
|
+
"InputPassword",
|
|
485
|
+
"InputSearch",
|
|
486
|
+
"InputTextArea"
|
|
487
|
+
].includes(component)) {
|
|
488
|
+
return val && isNumber(val) ? `${val}` : val;
|
|
489
|
+
}
|
|
490
|
+
return val;
|
|
491
|
+
}
|
|
492
|
+
function useFormValue(props, key = "value", changeEvent = "change", emitData) {
|
|
493
|
+
const instance = getCurrentInstance();
|
|
494
|
+
const emit = instance?.emit;
|
|
495
|
+
const innerState = reactive({
|
|
496
|
+
value: props[key]
|
|
497
|
+
});
|
|
498
|
+
const defaultState = readonly(innerState);
|
|
499
|
+
const setState = (val) => {
|
|
500
|
+
innerState.value = val;
|
|
501
|
+
nextTick(() => {
|
|
502
|
+
emit?.(changeEvent, val, ...toRaw$1(unref(emitData)) || []);
|
|
503
|
+
});
|
|
504
|
+
};
|
|
505
|
+
watchEffect(() => {
|
|
506
|
+
innerState.value = props[key];
|
|
507
|
+
});
|
|
508
|
+
const state = computed({
|
|
509
|
+
get() {
|
|
510
|
+
return innerState.value;
|
|
511
|
+
},
|
|
512
|
+
set(value) {
|
|
513
|
+
if (isEqual(value, defaultState.value))
|
|
514
|
+
return;
|
|
515
|
+
innerState.value = value;
|
|
516
|
+
nextTick(() => {
|
|
517
|
+
emit?.(changeEvent, value, ...toRaw$1(unref(emitData)) || []);
|
|
518
|
+
});
|
|
519
|
+
}
|
|
520
|
+
});
|
|
521
|
+
return [state, setState, defaultState];
|
|
522
|
+
}
|
|
523
|
+
const _sfc_main$4 = /* @__PURE__ */ defineComponent({
|
|
524
|
+
__name: "radioButton",
|
|
525
|
+
props: {
|
|
526
|
+
value: {
|
|
527
|
+
type: [String, Number, Boolean]
|
|
528
|
+
},
|
|
529
|
+
options: {
|
|
530
|
+
type: Array,
|
|
531
|
+
default: () => []
|
|
532
|
+
}
|
|
533
|
+
},
|
|
534
|
+
setup(__props) {
|
|
535
|
+
const props = __props;
|
|
536
|
+
const attrs = useAttrs();
|
|
537
|
+
const [state] = useFormValue(props);
|
|
538
|
+
const getOptions = computed(() => {
|
|
539
|
+
const { options } = props;
|
|
540
|
+
if (!options || options?.length === 0)
|
|
541
|
+
return [];
|
|
542
|
+
const isStringArr = options.some((item) => isString(item));
|
|
543
|
+
if (!isStringArr)
|
|
544
|
+
return options;
|
|
545
|
+
return options.map((item) => ({ label: item, value: item }));
|
|
546
|
+
});
|
|
547
|
+
return (_ctx, _cache) => {
|
|
548
|
+
const _component_ARadioButton = RadioButton;
|
|
549
|
+
const _component_ARadioGroup = RadioGroup;
|
|
550
|
+
return openBlock(), createBlock(_component_ARadioGroup, mergeProps(unref(attrs), {
|
|
551
|
+
value: unref(state),
|
|
552
|
+
"onUpdate:value": _cache[0] || (_cache[0] = ($event) => isRef(state) ? state.value = $event : null),
|
|
553
|
+
"button-style": "solid"
|
|
554
|
+
}), {
|
|
555
|
+
default: withCtx(() => [
|
|
556
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(unref(getOptions), (item) => {
|
|
557
|
+
return openBlock(), createBlock(_component_ARadioButton, {
|
|
558
|
+
key: `${item.value}`,
|
|
559
|
+
value: item.value,
|
|
560
|
+
disabled: item.disabled
|
|
561
|
+
}, {
|
|
562
|
+
default: withCtx(() => [
|
|
563
|
+
createTextVNode(toDisplayString(item.label), 1)
|
|
564
|
+
]),
|
|
565
|
+
_: 2
|
|
566
|
+
}, 1032, ["value", "disabled"]);
|
|
567
|
+
}), 128))
|
|
568
|
+
]),
|
|
569
|
+
_: 1
|
|
570
|
+
}, 16, ["value"]);
|
|
571
|
+
};
|
|
572
|
+
}
|
|
573
|
+
});
|
|
574
|
+
const _hoisted_1$1 = { class: "input-with-dialog" };
|
|
575
|
+
const _sfc_main$3 = /* @__PURE__ */ defineComponent({
|
|
576
|
+
__name: "formInputUseDialog",
|
|
577
|
+
setup(__props) {
|
|
578
|
+
const { t } = useI18n("UI");
|
|
579
|
+
const attrs = useAttrs();
|
|
580
|
+
const bindProps = computed(() => {
|
|
581
|
+
return {
|
|
582
|
+
...omit(attrs, [
|
|
583
|
+
"formValues"
|
|
584
|
+
]),
|
|
585
|
+
disabled: true
|
|
586
|
+
};
|
|
587
|
+
});
|
|
588
|
+
function onClickInput() {
|
|
589
|
+
const { model, schema = {} } = attrs.formValues;
|
|
590
|
+
if (!schema.openDialog || !isFunction(schema.openDialog)) {
|
|
591
|
+
error(t("MUSE_FUNCTION"));
|
|
592
|
+
return;
|
|
593
|
+
}
|
|
594
|
+
schema.openDialog(model);
|
|
595
|
+
}
|
|
596
|
+
function clearProps() {
|
|
597
|
+
const { model, schema = {} } = attrs.formValues;
|
|
598
|
+
[...schema.linkProps, schema.name].forEach((it) => model[it] = null);
|
|
599
|
+
}
|
|
600
|
+
return (_ctx, _cache) => {
|
|
601
|
+
return openBlock(), createElementBlock("div", _hoisted_1$1, [
|
|
602
|
+
createElementVNode("div", { onClick: onClickInput }, [
|
|
603
|
+
createVNode(unref(Input), normalizeProps(guardReactiveProps(unref(bindProps))), null, 16)
|
|
604
|
+
]),
|
|
605
|
+
unref(attrs).formValues?.schema?.linkProps?.length ? (openBlock(), createElementBlock("i", {
|
|
606
|
+
key: 0,
|
|
607
|
+
class: "i mdi:close-circle",
|
|
608
|
+
onClick: clearProps
|
|
609
|
+
})) : createCommentVNode("", true)
|
|
610
|
+
]);
|
|
611
|
+
};
|
|
612
|
+
}
|
|
613
|
+
});
|
|
614
|
+
const components = {
|
|
615
|
+
Input,
|
|
616
|
+
InputWithDialog: _sfc_main$3,
|
|
617
|
+
InputTextArea: Input.TextArea,
|
|
618
|
+
InputSearch: Input.Search,
|
|
619
|
+
InputGroup: Input.Group,
|
|
620
|
+
InputPassword: Input.Password,
|
|
621
|
+
Select,
|
|
622
|
+
TreeSelect,
|
|
623
|
+
Radio,
|
|
624
|
+
RadioGroup: Radio.Group,
|
|
625
|
+
RadioButtonGroup: _sfc_main$4,
|
|
626
|
+
Checkbox,
|
|
627
|
+
CheckboxGroup: Checkbox.Group,
|
|
628
|
+
AutoComplete,
|
|
629
|
+
Cascader,
|
|
630
|
+
DatePicker,
|
|
631
|
+
MonthPicker: DatePicker.MonthPicker,
|
|
632
|
+
WeekPicker: DatePicker.WeekPicker,
|
|
633
|
+
RangePicker: DatePicker.RangePicker,
|
|
634
|
+
InputNumber,
|
|
635
|
+
Switch,
|
|
636
|
+
TimePicker,
|
|
637
|
+
Slider,
|
|
638
|
+
Rate,
|
|
639
|
+
Divider
|
|
640
|
+
};
|
|
641
|
+
const componentMap = /* @__PURE__ */ new Map();
|
|
642
|
+
for (let item in components) {
|
|
643
|
+
componentMap.set(item, components[item]);
|
|
644
|
+
}
|
|
645
|
+
function _isSlot(s) {
|
|
646
|
+
return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s);
|
|
647
|
+
}
|
|
648
|
+
const _sfc_main$2 = {
|
|
649
|
+
name: "FormItem",
|
|
650
|
+
inheritAttrs: false,
|
|
651
|
+
props: {
|
|
652
|
+
schema: {
|
|
653
|
+
type: Object,
|
|
654
|
+
default: () => ({})
|
|
655
|
+
},
|
|
656
|
+
formProps: {
|
|
657
|
+
type: Object,
|
|
658
|
+
default: () => ({})
|
|
659
|
+
},
|
|
660
|
+
defaultValues: {
|
|
661
|
+
type: Object,
|
|
662
|
+
default: () => ({})
|
|
663
|
+
},
|
|
664
|
+
formModel: {
|
|
665
|
+
type: Object,
|
|
666
|
+
default: () => ({})
|
|
667
|
+
},
|
|
668
|
+
setFormModel: {
|
|
669
|
+
type: Function
|
|
670
|
+
},
|
|
671
|
+
formActionType: {
|
|
672
|
+
type: Object
|
|
673
|
+
}
|
|
674
|
+
},
|
|
675
|
+
setup(props, {
|
|
676
|
+
emit,
|
|
677
|
+
slots
|
|
678
|
+
}) {
|
|
679
|
+
const {
|
|
680
|
+
getSlot
|
|
681
|
+
} = useSlots();
|
|
682
|
+
const {
|
|
683
|
+
t
|
|
684
|
+
} = useI18n("UI");
|
|
685
|
+
const {
|
|
686
|
+
getUiSize
|
|
687
|
+
} = useHeader();
|
|
688
|
+
const {
|
|
689
|
+
appConf
|
|
690
|
+
} = useAppStore();
|
|
691
|
+
const {
|
|
692
|
+
schema,
|
|
693
|
+
formProps
|
|
694
|
+
} = toRefs(props);
|
|
695
|
+
const getValues = computed(() => {
|
|
696
|
+
const {
|
|
697
|
+
defaultValues,
|
|
698
|
+
formModel,
|
|
699
|
+
schema: schema2
|
|
700
|
+
} = props;
|
|
701
|
+
let name = schema2.name;
|
|
702
|
+
return {
|
|
703
|
+
name: isArray(name) ? name.join("-") : name,
|
|
704
|
+
model: formModel,
|
|
705
|
+
schema: schema2,
|
|
706
|
+
values: {
|
|
707
|
+
...defaultValues,
|
|
708
|
+
...formModel
|
|
709
|
+
}
|
|
710
|
+
};
|
|
711
|
+
});
|
|
712
|
+
const getShow = computed(() => {
|
|
713
|
+
const {
|
|
714
|
+
show = true,
|
|
715
|
+
isAdvanced = true
|
|
716
|
+
} = props.schema;
|
|
717
|
+
if (!isAdvanced) {
|
|
718
|
+
return false;
|
|
719
|
+
}
|
|
720
|
+
if (isFunction(show)) {
|
|
721
|
+
return show(unref(getValues).model);
|
|
722
|
+
}
|
|
723
|
+
return show;
|
|
724
|
+
});
|
|
725
|
+
const getComponentProps = computed(() => {
|
|
726
|
+
const {
|
|
727
|
+
schema: schema2
|
|
728
|
+
} = props;
|
|
729
|
+
let {
|
|
730
|
+
props: cProps = {}
|
|
731
|
+
} = schema2;
|
|
732
|
+
if (isFunction(cProps)) {
|
|
733
|
+
cProps = cProps(unref(getValues).model) ?? {};
|
|
734
|
+
}
|
|
735
|
+
if (schema2.component === "Divider") {
|
|
736
|
+
cProps = Object.assign({
|
|
737
|
+
type: "horizontal"
|
|
738
|
+
}, cProps, {
|
|
739
|
+
orientation: "left"
|
|
740
|
+
});
|
|
741
|
+
}
|
|
742
|
+
return cProps;
|
|
743
|
+
});
|
|
744
|
+
function renderItem() {
|
|
745
|
+
const {
|
|
746
|
+
component,
|
|
747
|
+
slot,
|
|
748
|
+
render,
|
|
749
|
+
name,
|
|
750
|
+
colon = appConf.ui.form.colon,
|
|
751
|
+
suffix,
|
|
752
|
+
prefix
|
|
753
|
+
} = props.schema;
|
|
754
|
+
const {
|
|
755
|
+
labelCol,
|
|
756
|
+
wrapperCol
|
|
757
|
+
} = unref(useLabelWidth(schema, formProps));
|
|
758
|
+
const getContent = () => {
|
|
759
|
+
const value = unref(getValues);
|
|
760
|
+
let _con = slot ? getSlot(slots, slot, value.model) : render ? render(value.model) : renderFormItem();
|
|
761
|
+
return component === "InputGroup" || component === "Icon" ? createVNode(FormItem, {
|
|
762
|
+
"class": "m-0"
|
|
763
|
+
}, _isSlot(_con) ? _con : {
|
|
764
|
+
default: () => [_con]
|
|
765
|
+
}) : _con;
|
|
766
|
+
};
|
|
767
|
+
const getSuffix = () => {
|
|
768
|
+
return isFunction(suffix) ? suffix(unref(getValues).model) : suffix;
|
|
769
|
+
};
|
|
770
|
+
const getPrefix = () => {
|
|
771
|
+
return isFunction(prefix) ? prefix(unref(getValues).model) : prefix;
|
|
772
|
+
};
|
|
773
|
+
return createVNode(Form.Item, {
|
|
774
|
+
"name": isArray(name) ? name.join("-") : name,
|
|
775
|
+
"colon": colon,
|
|
776
|
+
"class": [unref(getUiSize), {
|
|
777
|
+
"suffix-item": !!suffix
|
|
778
|
+
}],
|
|
779
|
+
"label": renderLabel(),
|
|
780
|
+
"rules": handleRules(),
|
|
781
|
+
"labelCol": labelCol,
|
|
782
|
+
"wrapperCol": wrapperCol
|
|
783
|
+
}, {
|
|
784
|
+
default: () => [createVNode("div", {
|
|
785
|
+
"style": "display:flex"
|
|
786
|
+
}, [!!prefix && createVNode("span", {
|
|
787
|
+
"class": "prefix px-2"
|
|
788
|
+
}, [getPrefix()]), createVNode("div", {
|
|
789
|
+
"style": "flex:1; width: 100%;"
|
|
790
|
+
}, [getContent()]), !!suffix && createVNode("span", {
|
|
791
|
+
"class": "suffix px-2"
|
|
792
|
+
}, [getSuffix()])])]
|
|
793
|
+
});
|
|
794
|
+
}
|
|
795
|
+
function renderLabel() {
|
|
796
|
+
const {
|
|
797
|
+
label,
|
|
798
|
+
toolTip,
|
|
799
|
+
subLabel,
|
|
800
|
+
toolTipProps = {}
|
|
801
|
+
} = props.schema;
|
|
802
|
+
const renderLabel2 = subLabel ? createVNode("span", null, [createTextVNode(" "), label, createTextVNode(" "), createVNode("span", {
|
|
803
|
+
"class": "text-secondary opacity-50"
|
|
804
|
+
}, [createTextVNode("("), subLabel, createTextVNode(")")])]) : label;
|
|
805
|
+
const _toolTip = isFunction(toolTip) ? toolTip(unref(getValues).model) : toolTip;
|
|
806
|
+
const _toolTipProps = {
|
|
807
|
+
title: renderLabel2,
|
|
808
|
+
autoAdjustOverflow: true,
|
|
809
|
+
placement: "top",
|
|
810
|
+
...toolTipProps
|
|
811
|
+
};
|
|
812
|
+
return _toolTip ? createVNode("span", null, [createVNode(Tooltip, _toolTipProps, _isSlot(renderLabel2) ? renderLabel2 : {
|
|
813
|
+
default: () => [renderLabel2]
|
|
814
|
+
})]) : renderLabel2;
|
|
815
|
+
}
|
|
816
|
+
function renderFormItem() {
|
|
817
|
+
const {
|
|
818
|
+
schema: schema2,
|
|
819
|
+
formModel,
|
|
820
|
+
formActionType
|
|
821
|
+
} = props;
|
|
822
|
+
const {
|
|
823
|
+
component,
|
|
824
|
+
name,
|
|
825
|
+
changeEvent = "change",
|
|
826
|
+
valueField,
|
|
827
|
+
renderComponent,
|
|
828
|
+
props: sProps
|
|
829
|
+
} = props.schema;
|
|
830
|
+
const isCheck = component && ["Switch", "Checkbox"].includes(component);
|
|
831
|
+
const eventKey = `on${upperFirst(changeEvent)}`;
|
|
832
|
+
const _sProps = isFunction(sProps) ? sProps(formModel) : sProps;
|
|
833
|
+
const on = {
|
|
834
|
+
[eventKey]: (...args) => {
|
|
835
|
+
const [e] = args;
|
|
836
|
+
const target = e ? e.target : null;
|
|
837
|
+
const value = target ? isCheck ? target.checked : target.value : e;
|
|
838
|
+
if (isString(name)) {
|
|
839
|
+
props.setFormModel(name, value);
|
|
840
|
+
} else if (isArray(name)) {
|
|
841
|
+
name.map((key) => props.setFormModel(key, value));
|
|
842
|
+
}
|
|
843
|
+
if (_sProps && _sProps[eventKey])
|
|
844
|
+
_sProps[eventKey](...args, formModel);
|
|
845
|
+
}
|
|
846
|
+
};
|
|
847
|
+
for (let it in _sProps) {
|
|
848
|
+
if (it.startsWith("on") && it !== eventKey) {
|
|
849
|
+
on[it] = (...args) => {
|
|
850
|
+
_sProps[it](...args, formModel);
|
|
851
|
+
};
|
|
852
|
+
}
|
|
853
|
+
}
|
|
854
|
+
const getDisable = computed(() => {
|
|
855
|
+
const {
|
|
856
|
+
disabled: gDisabled
|
|
857
|
+
} = props.formProps;
|
|
858
|
+
const {
|
|
859
|
+
disabled
|
|
860
|
+
} = props.schema;
|
|
861
|
+
const {
|
|
862
|
+
disabled: itemDisabled = false
|
|
863
|
+
} = unref(getComponentProps);
|
|
864
|
+
let _disabled = !!gDisabled || itemDisabled;
|
|
865
|
+
if (isBoolean(disabled))
|
|
866
|
+
_disabled = disabled;
|
|
867
|
+
if (isFunction(disabled))
|
|
868
|
+
_disabled = disabled(unref(getValues).model);
|
|
869
|
+
return _disabled;
|
|
870
|
+
});
|
|
871
|
+
const itemProps = {
|
|
872
|
+
allowClear: _sProps?.allowClear ?? appConf.ui.form.allowClear,
|
|
873
|
+
size: unref(getUiSize) === UiSize.MIDDLE ? "default" : unref(getUiSize),
|
|
874
|
+
...unref(getComponentProps),
|
|
875
|
+
disabled: unref(getDisable)
|
|
876
|
+
};
|
|
877
|
+
if (component === "Select") {
|
|
878
|
+
{
|
|
879
|
+
itemProps.showSearch = true;
|
|
880
|
+
itemProps.optionFilterProp = "label";
|
|
881
|
+
}
|
|
882
|
+
}
|
|
883
|
+
if (!itemProps.disabled && component !== "RangePicker") {
|
|
884
|
+
itemProps.placeholder = unref(getComponentProps)?.placeholder || createPlaceholder(component);
|
|
885
|
+
}
|
|
886
|
+
if (["DatePicker", "MonthPicker", "RangePicker"].includes(component)) {
|
|
887
|
+
itemProps.defaultValue = props.formModel[name];
|
|
888
|
+
}
|
|
889
|
+
itemProps.codeName = name;
|
|
890
|
+
itemProps.formValues = unref(getValues);
|
|
891
|
+
if (["Select", "DatePicker", "MonthPicker", "WeekPicker", "RangePicker"].includes(component)) {
|
|
892
|
+
itemProps.dropdownClassName += ` ${unref(getUiSize)}`;
|
|
893
|
+
}
|
|
894
|
+
const bindValue = {
|
|
895
|
+
[valueField || (isCheck ? "checked" : "value")]: props.formModel[name]
|
|
896
|
+
};
|
|
897
|
+
let compAttr = {
|
|
898
|
+
...itemProps,
|
|
899
|
+
...bindValue,
|
|
900
|
+
...on
|
|
901
|
+
};
|
|
902
|
+
const Comp = componentMap.get(component);
|
|
903
|
+
if (!renderComponent) {
|
|
904
|
+
return createVNode(Comp, compAttr, null);
|
|
905
|
+
}
|
|
906
|
+
const compSlot = isFunction(renderComponent) ? {
|
|
907
|
+
...renderComponent(unref(getValues))
|
|
908
|
+
} : {
|
|
909
|
+
default: () => renderComponent
|
|
910
|
+
};
|
|
911
|
+
return createVNode(Comp, compAttr, _isSlot(compSlot) ? compSlot : {
|
|
912
|
+
default: () => [compSlot]
|
|
913
|
+
});
|
|
914
|
+
}
|
|
915
|
+
function handleRules() {
|
|
916
|
+
const {
|
|
917
|
+
rules: defaultRules = [],
|
|
918
|
+
component,
|
|
919
|
+
label,
|
|
920
|
+
dynamicRules,
|
|
921
|
+
required
|
|
922
|
+
} = props.schema;
|
|
923
|
+
if (!component)
|
|
924
|
+
return [];
|
|
925
|
+
if (isFunction(dynamicRules)) {
|
|
926
|
+
return dynamicRules(unref(getValues).model);
|
|
927
|
+
}
|
|
928
|
+
const defaultMsg = createPlaceholder(component) + label;
|
|
929
|
+
let rules = cloneDeep(defaultRules);
|
|
930
|
+
const getRequired = isFunction(required) ? required(unref(getValues).model) : required;
|
|
931
|
+
function validator(rule, value) {
|
|
932
|
+
const msg = rule.message || defaultMsg;
|
|
933
|
+
if (value === void 0 || isNull(value) || Array.isArray(value) && value.length === 0 || typeof value === "string" && value.trim() === "" || typeof value === "object" && Reflect.has(value, "checked") && Reflect.has(value, "halfChecked") && Array.isArray(value.checked) && Array.isArray(value.halfChecked) && value.checked.length === 0 && value.halfChecked.length === 0) {
|
|
934
|
+
return Promise.reject(msg);
|
|
935
|
+
}
|
|
936
|
+
return Promise.resolve();
|
|
937
|
+
}
|
|
938
|
+
if (!rules || !rules.length) {
|
|
939
|
+
let _required = isBoolean(getRequired) ? getRequired : unref(getRequired);
|
|
940
|
+
rules = _required ? [{
|
|
941
|
+
required: _required,
|
|
942
|
+
validator
|
|
943
|
+
}] : [];
|
|
944
|
+
}
|
|
945
|
+
const requiredIndex = rules.findIndex((rule) => Reflect.has(rule, "required") && !Reflect.has(rule, "validator"));
|
|
946
|
+
if (requiredIndex !== -1) {
|
|
947
|
+
const rule = rules[requiredIndex];
|
|
948
|
+
if (!unref(getShow)) {
|
|
949
|
+
rule.required = false;
|
|
950
|
+
}
|
|
951
|
+
if (!Reflect.has(rule, "type")) {
|
|
952
|
+
rule.type = component === "InputNumber" ? "number" : "string";
|
|
953
|
+
}
|
|
954
|
+
rule.message = rule.message || defaultMsg;
|
|
955
|
+
if (component.includes("Input") || component.includes("Textarea")) {
|
|
956
|
+
rule.whitespace = true;
|
|
957
|
+
}
|
|
958
|
+
const valueFormat = unref(getComponentProps)?.valueFormat;
|
|
959
|
+
setComponentRuleType(rule, component, valueFormat);
|
|
960
|
+
}
|
|
961
|
+
const maxIndex = rules.findIndex((val) => val.max);
|
|
962
|
+
if (maxIndex !== -1 && !rules[maxIndex].validator) {
|
|
963
|
+
rules[maxIndex].message = rules[maxIndex].message || `\u6700\u5927\u503C\u4E3A${rules[maxIndex].max}`;
|
|
964
|
+
}
|
|
965
|
+
return rules;
|
|
966
|
+
}
|
|
967
|
+
return () => {
|
|
968
|
+
let _slot2;
|
|
969
|
+
const {
|
|
970
|
+
colSlot,
|
|
971
|
+
renderCol,
|
|
972
|
+
colProps,
|
|
973
|
+
component,
|
|
974
|
+
render,
|
|
975
|
+
slot
|
|
976
|
+
} = props.schema;
|
|
977
|
+
const {
|
|
978
|
+
colProps: gColProps,
|
|
979
|
+
mode
|
|
980
|
+
} = props.formProps;
|
|
981
|
+
let _colProps = colProps || gColProps || (mode === "search" ? appConf.ui.form.searchColspan : appConf.ui.form.dialogColspan);
|
|
982
|
+
const values = unref(getValues);
|
|
983
|
+
if (!component) {
|
|
984
|
+
if (!render && !renderCol && !slot) {
|
|
985
|
+
error(t("NEED_RENDER"));
|
|
986
|
+
return;
|
|
987
|
+
}
|
|
988
|
+
}
|
|
989
|
+
if (component === "Divider") {
|
|
990
|
+
let _slot;
|
|
991
|
+
let cprops = unref(getComponentProps);
|
|
992
|
+
const span = cprops?.span ?? 24;
|
|
993
|
+
return createVNode(Col, {
|
|
994
|
+
"span": span
|
|
995
|
+
}, {
|
|
996
|
+
default: () => [createVNode(Divider, cprops, _isSlot(_slot = renderLabel()) ? _slot : {
|
|
997
|
+
default: () => [_slot]
|
|
998
|
+
})]
|
|
999
|
+
});
|
|
1000
|
+
}
|
|
1001
|
+
const getContent = () => {
|
|
1002
|
+
return colSlot ? getSlot(slots, colSlot, values) : renderCol ? renderCol(values) : renderItem();
|
|
1003
|
+
};
|
|
1004
|
+
return unref(getShow) && createVNode(Col, _colProps, _isSlot(_slot2 = getContent()) ? _slot2 : {
|
|
1005
|
+
default: () => [_slot2]
|
|
1006
|
+
});
|
|
1007
|
+
};
|
|
1008
|
+
}
|
|
1009
|
+
};
|
|
1010
|
+
const _hoisted_1 = {
|
|
1011
|
+
key: 0,
|
|
1012
|
+
className: "preIcon pr-1"
|
|
1013
|
+
};
|
|
1014
|
+
const _hoisted_2 = {
|
|
1015
|
+
key: 0,
|
|
1016
|
+
className: "preIcon pl-1"
|
|
1017
|
+
};
|
|
1018
|
+
const _hoisted_3 = { class: "text" };
|
|
1019
|
+
const _hoisted_4 = /* @__PURE__ */ createElementVNode("i", { class: "text-2xl i ic:baseline-arrow-drop-down" }, null, -1);
|
|
1020
|
+
const _hoisted_5 = [
|
|
1021
|
+
_hoisted_4
|
|
1022
|
+
];
|
|
1023
|
+
const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
1024
|
+
__name: "FormButtons",
|
|
1025
|
+
props: {
|
|
1026
|
+
mode: {
|
|
1027
|
+
type: String,
|
|
1028
|
+
default: "search"
|
|
1029
|
+
},
|
|
1030
|
+
show: {
|
|
1031
|
+
type: Boolean,
|
|
1032
|
+
default: true
|
|
1033
|
+
},
|
|
1034
|
+
showAdvancedButton: {
|
|
1035
|
+
type: Boolean,
|
|
1036
|
+
default: true
|
|
1037
|
+
},
|
|
1038
|
+
minShowColumn: {
|
|
1039
|
+
type: Number,
|
|
1040
|
+
default: 2
|
|
1041
|
+
},
|
|
1042
|
+
buttonList: {
|
|
1043
|
+
type: [Array],
|
|
1044
|
+
default: []
|
|
1045
|
+
},
|
|
1046
|
+
isAdvanced: {
|
|
1047
|
+
type: Boolean,
|
|
1048
|
+
default: true
|
|
1049
|
+
}
|
|
1050
|
+
},
|
|
1051
|
+
emits: ["handle-method"],
|
|
1052
|
+
setup(__props, { emit: emits }) {
|
|
1053
|
+
const props = __props;
|
|
1054
|
+
const { t } = useI18n();
|
|
1055
|
+
const advancedRef = ref(props.isAdvanced);
|
|
1056
|
+
let key = 0;
|
|
1057
|
+
const showAdvanceRef = computed(() => {
|
|
1058
|
+
return props.mode === "search" ? props.showAdvancedButton : false;
|
|
1059
|
+
});
|
|
1060
|
+
const colOpt = computed(() => {
|
|
1061
|
+
let style = {
|
|
1062
|
+
textAlign: "right"
|
|
1063
|
+
};
|
|
1064
|
+
if (props.mode === "dialog") {
|
|
1065
|
+
Object.assign(style, {
|
|
1066
|
+
display: "inline-block"
|
|
1067
|
+
});
|
|
1068
|
+
}
|
|
1069
|
+
return { style };
|
|
1070
|
+
});
|
|
1071
|
+
const getAdvanceClass = computed(() => {
|
|
1072
|
+
return [
|
|
1073
|
+
"basic-arrow",
|
|
1074
|
+
{ "basic-arrow--active": !advancedRef.value }
|
|
1075
|
+
];
|
|
1076
|
+
});
|
|
1077
|
+
const toggleAdvanced = () => {
|
|
1078
|
+
advancedRef.value = !advancedRef.value;
|
|
1079
|
+
dispatchResize();
|
|
1080
|
+
emits("handle-method", advancedRef.value);
|
|
1081
|
+
};
|
|
1082
|
+
function handleBtnClick(button) {
|
|
1083
|
+
if (button.onClick && isFunction(button.onClick)) {
|
|
1084
|
+
button.onClick();
|
|
1085
|
+
} else {
|
|
1086
|
+
emits("handle-method", button);
|
|
1087
|
+
}
|
|
1088
|
+
}
|
|
1089
|
+
watch(() => props.isAdvanced, (v) => {
|
|
1090
|
+
if (v) {
|
|
1091
|
+
nextTick(() => toggleAdvanced());
|
|
1092
|
+
}
|
|
1093
|
+
}, {
|
|
1094
|
+
immediate: true
|
|
1095
|
+
});
|
|
1096
|
+
watch(
|
|
1097
|
+
() => props.buttonList,
|
|
1098
|
+
(v) => key = new Date().getTime(),
|
|
1099
|
+
{
|
|
1100
|
+
immediate: true,
|
|
1101
|
+
deep: true
|
|
1102
|
+
}
|
|
1103
|
+
);
|
|
1104
|
+
return (_ctx, _cache) => {
|
|
1105
|
+
const _component_AButton = Button;
|
|
1106
|
+
const _component_AFormItem = FormItem$1;
|
|
1107
|
+
const _component_ACol = Col$1;
|
|
1108
|
+
const _directive_icon = resolveDirective("icon");
|
|
1109
|
+
const _directive_auth = resolveDirective("auth");
|
|
1110
|
+
return __props.show ? (openBlock(), createBlock(_component_ACol, normalizeProps(mergeProps({ key: 0 }, unref(colOpt))), {
|
|
1111
|
+
default: withCtx(() => [
|
|
1112
|
+
createVNode(_component_AFormItem, {
|
|
1113
|
+
class: "dt-form-btns",
|
|
1114
|
+
style: normalizeStyle({
|
|
1115
|
+
"margin-bottom": __props.mode === "search" ? "16px" : "0px"
|
|
1116
|
+
})
|
|
1117
|
+
}, {
|
|
1118
|
+
default: withCtx(() => [
|
|
1119
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(__props.buttonList, (button) => {
|
|
1120
|
+
return openBlock(), createElementBlock(Fragment, null, [
|
|
1121
|
+
(button.show === void 0 ? true : button.show) ? withDirectives((openBlock(), createBlock(_component_AButton, {
|
|
1122
|
+
type: button.type,
|
|
1123
|
+
class: normalizeClass(button.class),
|
|
1124
|
+
loading: button.loading?.value,
|
|
1125
|
+
disabled: button.disabled,
|
|
1126
|
+
key: unref(key),
|
|
1127
|
+
onClick: ($event) => handleBtnClick(button)
|
|
1128
|
+
}, {
|
|
1129
|
+
icon: withCtx(() => [
|
|
1130
|
+
button.preIcon ? withDirectives((openBlock(), createElementBlock("span", _hoisted_1, null, 512)), [
|
|
1131
|
+
[_directive_icon, button.preIcon]
|
|
1132
|
+
]) : createCommentVNode("", true)
|
|
1133
|
+
]),
|
|
1134
|
+
default: withCtx(() => [
|
|
1135
|
+
createTextVNode(" " + toDisplayString(unref(t)(button.name)) + " ", 1),
|
|
1136
|
+
button.postIcon ? withDirectives((openBlock(), createElementBlock("span", _hoisted_2, null, 512)), [
|
|
1137
|
+
[_directive_icon, button.postIcon]
|
|
1138
|
+
]) : createCommentVNode("", true)
|
|
1139
|
+
]),
|
|
1140
|
+
_: 2
|
|
1141
|
+
}, 1032, ["type", "class", "loading", "disabled", "onClick"])), [
|
|
1142
|
+
[_directive_auth, button.auth]
|
|
1143
|
+
]) : createCommentVNode("", true)
|
|
1144
|
+
], 64);
|
|
1145
|
+
}), 256)),
|
|
1146
|
+
unref(showAdvanceRef) ? (openBlock(), createBlock(_component_AButton, {
|
|
1147
|
+
key: 0,
|
|
1148
|
+
type: "link",
|
|
1149
|
+
class: "advanced",
|
|
1150
|
+
onClick: toggleAdvanced
|
|
1151
|
+
}, {
|
|
1152
|
+
default: withCtx(() => [
|
|
1153
|
+
createElementVNode("span", _hoisted_3, toDisplayString(advancedRef.value ? unref(t)("UI.ADVANCED") : unref(t)("UI.EXPAND")), 1),
|
|
1154
|
+
createElementVNode("span", {
|
|
1155
|
+
class: normalizeClass(unref(getAdvanceClass))
|
|
1156
|
+
}, _hoisted_5, 2)
|
|
1157
|
+
]),
|
|
1158
|
+
_: 1
|
|
1159
|
+
})) : createCommentVNode("", true)
|
|
1160
|
+
]),
|
|
1161
|
+
_: 1
|
|
1162
|
+
}, 8, ["style"])
|
|
1163
|
+
]),
|
|
1164
|
+
_: 1
|
|
1165
|
+
}, 16)) : createCommentVNode("", true);
|
|
1166
|
+
};
|
|
1167
|
+
}
|
|
1168
|
+
});
|
|
1169
|
+
const SEARCH_BTN_NAME = "UI.SEARCH";
|
|
1170
|
+
const RESET_BTN_NAME = "UI.RESET";
|
|
1171
|
+
const SEARCH_BTNS = [
|
|
1172
|
+
{ name: SEARCH_BTN_NAME, preIcon: "mdi:magnify", type: "primary" },
|
|
1173
|
+
{ name: RESET_BTN_NAME, preIcon: "mdi:refresh", type: "default" }
|
|
1174
|
+
];
|
|
1175
|
+
function useFormEvents({
|
|
1176
|
+
emits,
|
|
1177
|
+
getSchema,
|
|
1178
|
+
formModel,
|
|
1179
|
+
defaultValue,
|
|
1180
|
+
formElRef,
|
|
1181
|
+
schemaRef,
|
|
1182
|
+
getProps,
|
|
1183
|
+
handleFormValues
|
|
1184
|
+
}) {
|
|
1185
|
+
function getFormValues() {
|
|
1186
|
+
const formEl = unref(formElRef);
|
|
1187
|
+
if (!formEl)
|
|
1188
|
+
return {};
|
|
1189
|
+
return handleFormValues(toRaw$1(unref(formModel)));
|
|
1190
|
+
}
|
|
1191
|
+
function updateSchema(data) {
|
|
1192
|
+
let updateItems = [];
|
|
1193
|
+
updateItems = isObject(data) ? [data] : [...data];
|
|
1194
|
+
if (updateItems?.length && !updateItems.every((it) => it.component !== "Divider" && it.name)) {
|
|
1195
|
+
console.error("\u6240\u6709\u7684\u5143\u7D20\u90FD\u5FC5\u987B\u8BBE\u7F6Ename\u5C5E\u6027");
|
|
1196
|
+
return;
|
|
1197
|
+
}
|
|
1198
|
+
const schema = [];
|
|
1199
|
+
updateItems.forEach((it) => {
|
|
1200
|
+
unref(getSchema).forEach((val) => {
|
|
1201
|
+
if (val.name === it.name) {
|
|
1202
|
+
const newSchema = deepMerge(val, it);
|
|
1203
|
+
schema.push(newSchema);
|
|
1204
|
+
} else {
|
|
1205
|
+
schema.push(val);
|
|
1206
|
+
}
|
|
1207
|
+
});
|
|
1208
|
+
});
|
|
1209
|
+
let shcemas = uniqBy(schema, "name");
|
|
1210
|
+
_setValue(shcemas);
|
|
1211
|
+
schemaRef.value = shcemas;
|
|
1212
|
+
}
|
|
1213
|
+
function resetSchema(data) {
|
|
1214
|
+
let updateItems = [];
|
|
1215
|
+
updateItems = isObject(data) ? [data] : [...data];
|
|
1216
|
+
_setValue(updateItems, true);
|
|
1217
|
+
schemaRef.value = updateItems;
|
|
1218
|
+
}
|
|
1219
|
+
function _setValue(data, isReset = false) {
|
|
1220
|
+
data = isArray(data) ? data : [data];
|
|
1221
|
+
let obj = {};
|
|
1222
|
+
data.map((it) => {
|
|
1223
|
+
let name = isArray(it.name) ? it.name[0] : it.name;
|
|
1224
|
+
obj[name] = null;
|
|
1225
|
+
if (!isNullAndUnDef(it.defaultValue))
|
|
1226
|
+
return obj[name] = it.defaultValue;
|
|
1227
|
+
let props = isFunction(it.props) ? it.props(toRaw$1(unref(formModel))) : it.props;
|
|
1228
|
+
if (!isNullAndUnDef(props?.defaultValue))
|
|
1229
|
+
obj[name] = props.defaultValue;
|
|
1230
|
+
});
|
|
1231
|
+
if (isReset) {
|
|
1232
|
+
let oldValues = getFormValues();
|
|
1233
|
+
let oldObj = {};
|
|
1234
|
+
Object.keys(oldValues).map((key) => oldObj[key] = null);
|
|
1235
|
+
obj = {
|
|
1236
|
+
...oldObj,
|
|
1237
|
+
...obj
|
|
1238
|
+
};
|
|
1239
|
+
}
|
|
1240
|
+
setFormValues(obj);
|
|
1241
|
+
}
|
|
1242
|
+
async function clearValidate(name) {
|
|
1243
|
+
await unref(formElRef)?.clearValidate(name);
|
|
1244
|
+
}
|
|
1245
|
+
function resetForms() {
|
|
1246
|
+
const { resetFunc } = unref(getProps);
|
|
1247
|
+
resetFunc && isFunction(resetFunc) && resetFunc();
|
|
1248
|
+
if (!unref(formElRef))
|
|
1249
|
+
return;
|
|
1250
|
+
Object.keys(formModel).forEach((key) => {
|
|
1251
|
+
const schema = unref(getSchema).find((item) => item.name === key);
|
|
1252
|
+
const isInput = schema?.component && ["Input", "InputPassword", "InputSearch", "InputTextArea"].includes(schema.component);
|
|
1253
|
+
formModel[key] = isInput ? defaultValue.value[key] || "" : defaultValue.value[key];
|
|
1254
|
+
});
|
|
1255
|
+
nextTick(() => clearValidate());
|
|
1256
|
+
emits("reset", toRaw$1(formModel));
|
|
1257
|
+
}
|
|
1258
|
+
function removeFormByName(names) {
|
|
1259
|
+
if (!names)
|
|
1260
|
+
return;
|
|
1261
|
+
const schemaList = cloneDeep(unref(getSchema));
|
|
1262
|
+
const nameList = isString(names) ? [names] : names;
|
|
1263
|
+
for (const name of nameList) {
|
|
1264
|
+
_removeSchemaByName(name, schemaList);
|
|
1265
|
+
}
|
|
1266
|
+
schemaRef.value = schemaList;
|
|
1267
|
+
}
|
|
1268
|
+
function _removeSchemaByName(name, schemaList) {
|
|
1269
|
+
const index = schemaList.findIndex((schema) => schema.name === name);
|
|
1270
|
+
if (index !== -1) {
|
|
1271
|
+
delete formModel[name];
|
|
1272
|
+
schemaList.splice(index, 1);
|
|
1273
|
+
}
|
|
1274
|
+
}
|
|
1275
|
+
function appendFormItems(schema, prefixName, first = false) {
|
|
1276
|
+
const schemaList = cloneDeep(unref(getSchema));
|
|
1277
|
+
const index = schemaList.findIndex((schema2) => schema2.name === prefixName);
|
|
1278
|
+
if (!prefixName || index === -1 || first) {
|
|
1279
|
+
first ? schemaList.unshift(...schema) : schemaList.push(...schema);
|
|
1280
|
+
schemaRef.value = schemaList;
|
|
1281
|
+
return;
|
|
1282
|
+
}
|
|
1283
|
+
if (index !== -1) {
|
|
1284
|
+
schemaList.splice(index + 1, 0, ...schema);
|
|
1285
|
+
}
|
|
1286
|
+
schemaRef.value = schemaList;
|
|
1287
|
+
}
|
|
1288
|
+
function itemIsDateType(key) {
|
|
1289
|
+
return unref(getSchema).some((item) => {
|
|
1290
|
+
return item.name === key ? ["DatePicker", "MonthPicker", "WeekPicker", "TimePicker", "RangePicker"].includes(item.component) : false;
|
|
1291
|
+
});
|
|
1292
|
+
}
|
|
1293
|
+
async function validateFields(nameList) {
|
|
1294
|
+
return unref(formElRef)?.validateFields(nameList);
|
|
1295
|
+
}
|
|
1296
|
+
function setFormValues(values) {
|
|
1297
|
+
if (!values || !Object.keys(values).length) {
|
|
1298
|
+
for (let it in formModel)
|
|
1299
|
+
formModel[it] = Array.isArray(formModel[it]) ? [] : null;
|
|
1300
|
+
return;
|
|
1301
|
+
}
|
|
1302
|
+
const names = unref(getSchema).map((item) => item.name).filter(Boolean);
|
|
1303
|
+
const validKeys = [];
|
|
1304
|
+
Object.keys(values).forEach((key) => {
|
|
1305
|
+
const schema = unref(getSchema).find((item) => item.name === key);
|
|
1306
|
+
let value = values[key];
|
|
1307
|
+
const hasKey = Reflect.has(values, key);
|
|
1308
|
+
value = handleInputNumberValue(schema?.component, value);
|
|
1309
|
+
if (hasKey && names.includes(key)) {
|
|
1310
|
+
if (itemIsDateType(key)) {
|
|
1311
|
+
if (Array.isArray(value)) {
|
|
1312
|
+
const arr = [];
|
|
1313
|
+
for (const ele of value) {
|
|
1314
|
+
arr.push(ele ? dayjs(ele) : null);
|
|
1315
|
+
}
|
|
1316
|
+
formModel[key] = arr;
|
|
1317
|
+
} else {
|
|
1318
|
+
const { props } = schema || {};
|
|
1319
|
+
let _props = props;
|
|
1320
|
+
if (typeof props === "function") {
|
|
1321
|
+
_props = props({ formModel });
|
|
1322
|
+
}
|
|
1323
|
+
formModel[key] = value ? _props?.valueFormat ? value : dayjs(value) : null;
|
|
1324
|
+
}
|
|
1325
|
+
} else {
|
|
1326
|
+
formModel[key] = value;
|
|
1327
|
+
}
|
|
1328
|
+
validKeys.push(key);
|
|
1329
|
+
} else {
|
|
1330
|
+
formModel[key] = value;
|
|
1331
|
+
}
|
|
1332
|
+
});
|
|
1333
|
+
return validateFields(validKeys);
|
|
1334
|
+
}
|
|
1335
|
+
async function validate(nameList) {
|
|
1336
|
+
return await unref(formElRef)?.validate(nameList);
|
|
1337
|
+
}
|
|
1338
|
+
return {
|
|
1339
|
+
getFormValues,
|
|
1340
|
+
updateSchema,
|
|
1341
|
+
resetSchema,
|
|
1342
|
+
clearValidate,
|
|
1343
|
+
resetForms,
|
|
1344
|
+
removeFormByName,
|
|
1345
|
+
validateFields,
|
|
1346
|
+
setFormValues,
|
|
1347
|
+
validate,
|
|
1348
|
+
appendFormItems
|
|
1349
|
+
};
|
|
1350
|
+
}
|
|
1351
|
+
function useFormValues({
|
|
1352
|
+
defaultValue,
|
|
1353
|
+
getSchema,
|
|
1354
|
+
formModel
|
|
1355
|
+
}) {
|
|
1356
|
+
const getComMap = () => {
|
|
1357
|
+
let comMap = /* @__PURE__ */ new Map();
|
|
1358
|
+
unref(getSchema).map((it) => {
|
|
1359
|
+
if (it.component && it.name) {
|
|
1360
|
+
comMap.set(it.name, it);
|
|
1361
|
+
}
|
|
1362
|
+
});
|
|
1363
|
+
return comMap;
|
|
1364
|
+
};
|
|
1365
|
+
function handleFormValues(model) {
|
|
1366
|
+
if (!isObject(model))
|
|
1367
|
+
return {};
|
|
1368
|
+
const vals = {};
|
|
1369
|
+
let comMap = getComMap();
|
|
1370
|
+
for (let [key, val] of Object.entries(model)) {
|
|
1371
|
+
let component = comMap.get(key)?.component;
|
|
1372
|
+
if (!key || Array.isArray(val) && val.length === 0 || isFunction(val)) {
|
|
1373
|
+
continue;
|
|
1374
|
+
}
|
|
1375
|
+
if (component) {
|
|
1376
|
+
if (SINGLE_DATA_TYPE.includes(component)) {
|
|
1377
|
+
val = dayjs(val).valueOf();
|
|
1378
|
+
} else if (MULTIFY_DATA_TYPE.includes(component)) {
|
|
1379
|
+
val = (val || []).map((it) => dayjs(it).valueOf());
|
|
1380
|
+
if (comMap.get(key).extraName?.length) {
|
|
1381
|
+
comMap.get(key).extraName.map((it, i) => {
|
|
1382
|
+
set(vals, it, val.length > 0 ? val[i] : null);
|
|
1383
|
+
});
|
|
1384
|
+
}
|
|
1385
|
+
}
|
|
1386
|
+
}
|
|
1387
|
+
if (isString(val)) {
|
|
1388
|
+
val = val.trim();
|
|
1389
|
+
}
|
|
1390
|
+
set(vals, key, val);
|
|
1391
|
+
}
|
|
1392
|
+
return vals;
|
|
1393
|
+
}
|
|
1394
|
+
function initDefault() {
|
|
1395
|
+
const schema = unref(getSchema), obj = {};
|
|
1396
|
+
schema.forEach((item) => {
|
|
1397
|
+
const { props = {}, name, component, defaultValue: gDefaultValue, extraName } = item;
|
|
1398
|
+
const { defaultValue: itemDefaultValue, mode, format, treeCheckable } = isFunction(props) ? props(formModel) : props;
|
|
1399
|
+
if (!name)
|
|
1400
|
+
return;
|
|
1401
|
+
let names = [];
|
|
1402
|
+
if (component === "InputWithDialog") {
|
|
1403
|
+
names = [name, ...extraName];
|
|
1404
|
+
} else if (isArray(name)) {
|
|
1405
|
+
names = name;
|
|
1406
|
+
} else {
|
|
1407
|
+
names = [name];
|
|
1408
|
+
}
|
|
1409
|
+
const defaultValue2 = itemDefaultValue ?? gDefaultValue;
|
|
1410
|
+
if (!isNullAndUnDef(defaultValue2)) {
|
|
1411
|
+
if (DATE_PICKER_TYPES.includes(component)) {
|
|
1412
|
+
if (isArray(defaultValue2)) {
|
|
1413
|
+
let vals = defaultValue2.map((it) => format ? dayjs(it, format) : dayjs(it));
|
|
1414
|
+
if (names.length > 1) {
|
|
1415
|
+
names.map((key, index) => obj[key] = vals[index] ?? null);
|
|
1416
|
+
} else {
|
|
1417
|
+
obj[names[0]] = vals;
|
|
1418
|
+
}
|
|
1419
|
+
} else {
|
|
1420
|
+
obj[names[0]] = format ? dayjs(defaultValue2, format) : dayjs(defaultValue2);
|
|
1421
|
+
}
|
|
1422
|
+
} else {
|
|
1423
|
+
if (names.length > 1) {
|
|
1424
|
+
names.forEach((key, index) => {
|
|
1425
|
+
if (!defaultValue2 || defaultValue2.length - 1 < index) {
|
|
1426
|
+
obj[key] = null;
|
|
1427
|
+
} else {
|
|
1428
|
+
obj[key] = defaultValue2[index];
|
|
1429
|
+
}
|
|
1430
|
+
});
|
|
1431
|
+
} else {
|
|
1432
|
+
obj[names[0]] = defaultValue2;
|
|
1433
|
+
}
|
|
1434
|
+
}
|
|
1435
|
+
} else {
|
|
1436
|
+
names.map((it) => {
|
|
1437
|
+
if (component === "TreeSelect" || (mode === "multiple" || treeCheckable) || component === "Select" && mode === "multiple") {
|
|
1438
|
+
obj[it] = [];
|
|
1439
|
+
} else {
|
|
1440
|
+
obj[it] = null;
|
|
1441
|
+
}
|
|
1442
|
+
});
|
|
1443
|
+
}
|
|
1444
|
+
});
|
|
1445
|
+
defaultValue.value = { ...obj };
|
|
1446
|
+
for (let key in obj) {
|
|
1447
|
+
formModel[key] = obj[key];
|
|
1448
|
+
}
|
|
1449
|
+
}
|
|
1450
|
+
return {
|
|
1451
|
+
initDefault,
|
|
1452
|
+
handleFormValues
|
|
1453
|
+
};
|
|
1454
|
+
}
|
|
1455
|
+
function useFormActions(opt) {
|
|
1456
|
+
const { getProps, defaultValue, updateSchema, getFormValues, setFormValues } = opt;
|
|
1457
|
+
const { appConf } = useAppStore();
|
|
1458
|
+
function handleAdvanced(isAdvanced) {
|
|
1459
|
+
const { schemas, minShowColumn = appConf.ui.form?.minShowColumn || 2 } = unref(getProps);
|
|
1460
|
+
let schema = schemas.reduce((t, it, index) => {
|
|
1461
|
+
if (index > minShowColumn - 1)
|
|
1462
|
+
it.isAdvanced = isAdvanced;
|
|
1463
|
+
t.push(it);
|
|
1464
|
+
return t;
|
|
1465
|
+
}, []);
|
|
1466
|
+
updateSchema(schema);
|
|
1467
|
+
}
|
|
1468
|
+
function handleMethod(params) {
|
|
1469
|
+
const { onSearch, onReset } = unref(getProps);
|
|
1470
|
+
if (isBoolean(params)) {
|
|
1471
|
+
handleAdvanced(params);
|
|
1472
|
+
} else if (params.name === SEARCH_BTN_NAME) {
|
|
1473
|
+
console.log(getProps);
|
|
1474
|
+
onSearch(getFormValues());
|
|
1475
|
+
} else if (params.name === RESET_BTN_NAME) {
|
|
1476
|
+
setFormValues(toRaw(defaultValue.value));
|
|
1477
|
+
onReset(getFormValues());
|
|
1478
|
+
} else {
|
|
1479
|
+
params.onClick();
|
|
1480
|
+
}
|
|
1481
|
+
}
|
|
1482
|
+
return [handleMethod];
|
|
1483
|
+
}
|
|
1484
|
+
const BasicProps = {
|
|
1485
|
+
mode: {
|
|
1486
|
+
type: String,
|
|
1487
|
+
default: "search"
|
|
1488
|
+
},
|
|
1489
|
+
autoFetch: {
|
|
1490
|
+
type: Boolean,
|
|
1491
|
+
default: true
|
|
1492
|
+
},
|
|
1493
|
+
model: {
|
|
1494
|
+
type: Object,
|
|
1495
|
+
default: () => ({})
|
|
1496
|
+
},
|
|
1497
|
+
layout: {
|
|
1498
|
+
type: String,
|
|
1499
|
+
default: "horizontal"
|
|
1500
|
+
},
|
|
1501
|
+
labelWidth: {
|
|
1502
|
+
type: [Number, String],
|
|
1503
|
+
default: 100
|
|
1504
|
+
},
|
|
1505
|
+
enLabelWidth: {
|
|
1506
|
+
type: [Number, String],
|
|
1507
|
+
default: 100
|
|
1508
|
+
},
|
|
1509
|
+
labelAlign: {
|
|
1510
|
+
type: String,
|
|
1511
|
+
default: "right"
|
|
1512
|
+
},
|
|
1513
|
+
labelCol: {
|
|
1514
|
+
type: Object,
|
|
1515
|
+
default: () => ({})
|
|
1516
|
+
},
|
|
1517
|
+
wrapperCol: {
|
|
1518
|
+
type: Object,
|
|
1519
|
+
default: () => ({})
|
|
1520
|
+
},
|
|
1521
|
+
rowProps: {
|
|
1522
|
+
type: Object,
|
|
1523
|
+
default: () => ({})
|
|
1524
|
+
},
|
|
1525
|
+
colProps: {
|
|
1526
|
+
type: Object,
|
|
1527
|
+
default: () => ({})
|
|
1528
|
+
},
|
|
1529
|
+
size: {
|
|
1530
|
+
type: String,
|
|
1531
|
+
default: "small"
|
|
1532
|
+
},
|
|
1533
|
+
disabled: {
|
|
1534
|
+
type: Boolean,
|
|
1535
|
+
default: false
|
|
1536
|
+
},
|
|
1537
|
+
compact: {
|
|
1538
|
+
type: Boolean,
|
|
1539
|
+
default: null
|
|
1540
|
+
},
|
|
1541
|
+
schemas: {
|
|
1542
|
+
type: Array,
|
|
1543
|
+
default: () => []
|
|
1544
|
+
},
|
|
1545
|
+
autoSearchOnEnter: {
|
|
1546
|
+
type: Boolean,
|
|
1547
|
+
default: true
|
|
1548
|
+
},
|
|
1549
|
+
alwaysShowLines: {
|
|
1550
|
+
type: Boolean,
|
|
1551
|
+
default: false
|
|
1552
|
+
},
|
|
1553
|
+
minShowColumn: {
|
|
1554
|
+
type: Number,
|
|
1555
|
+
default: 2
|
|
1556
|
+
},
|
|
1557
|
+
showAdvancedButton: {
|
|
1558
|
+
type: Boolean,
|
|
1559
|
+
default: true
|
|
1560
|
+
},
|
|
1561
|
+
allowClear: {
|
|
1562
|
+
type: Boolean,
|
|
1563
|
+
default: true
|
|
1564
|
+
},
|
|
1565
|
+
scrollToFirstError: {
|
|
1566
|
+
type: Boolean,
|
|
1567
|
+
default: true
|
|
1568
|
+
},
|
|
1569
|
+
colon: {
|
|
1570
|
+
type: Boolean,
|
|
1571
|
+
default: true
|
|
1572
|
+
},
|
|
1573
|
+
loading: {
|
|
1574
|
+
type: Object,
|
|
1575
|
+
default: () => {
|
|
1576
|
+
return {
|
|
1577
|
+
onSearch: ref(false),
|
|
1578
|
+
onReset: ref(false)
|
|
1579
|
+
};
|
|
1580
|
+
}
|
|
1581
|
+
},
|
|
1582
|
+
onSearch: {
|
|
1583
|
+
type: Function,
|
|
1584
|
+
default: (params) => {
|
|
1585
|
+
}
|
|
1586
|
+
},
|
|
1587
|
+
onReset: {
|
|
1588
|
+
type: Function,
|
|
1589
|
+
default: (params) => {
|
|
1590
|
+
}
|
|
1591
|
+
},
|
|
1592
|
+
buttons: {
|
|
1593
|
+
type: [Array, null, Boolean],
|
|
1594
|
+
default: false
|
|
1595
|
+
},
|
|
1596
|
+
resetFunc: {
|
|
1597
|
+
type: Function
|
|
1598
|
+
},
|
|
1599
|
+
registerInstance: {
|
|
1600
|
+
type: Function
|
|
1601
|
+
}
|
|
1602
|
+
};
|
|
1603
|
+
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
1604
|
+
__name: "index",
|
|
1605
|
+
props: BasicProps,
|
|
1606
|
+
emits: ["register"],
|
|
1607
|
+
setup(__props, { emit: emits }) {
|
|
1608
|
+
const props = __props;
|
|
1609
|
+
const { getAppConf } = useAppStore();
|
|
1610
|
+
const attrs = useAttrs();
|
|
1611
|
+
const formElRef = ref(null);
|
|
1612
|
+
const formModel = reactive({});
|
|
1613
|
+
const defaultValue = ref({});
|
|
1614
|
+
const propsRef = ref();
|
|
1615
|
+
const schemaRef = ref(null);
|
|
1616
|
+
const getProps = computed(() => {
|
|
1617
|
+
let colProps = props.colProps;
|
|
1618
|
+
if (isEmpty(props.colProps)) {
|
|
1619
|
+
colProps = props.mode === "search" ? getAppConf.ui.form.searchColspan || { span: 8 } : getAppConf.ui.form.dialogColspan || { span: 12 };
|
|
1620
|
+
}
|
|
1621
|
+
return {
|
|
1622
|
+
...props,
|
|
1623
|
+
...getAppConf.ui.form,
|
|
1624
|
+
colProps,
|
|
1625
|
+
...unref(propsRef)
|
|
1626
|
+
};
|
|
1627
|
+
});
|
|
1628
|
+
const getBindValue = computed(() => {
|
|
1629
|
+
return {
|
|
1630
|
+
...attrs,
|
|
1631
|
+
...unref(getProps)
|
|
1632
|
+
};
|
|
1633
|
+
});
|
|
1634
|
+
const getSchema = computed(() => {
|
|
1635
|
+
return unref(schemaRef) || unref(getProps).schemas;
|
|
1636
|
+
});
|
|
1637
|
+
const getFormClass = computed(() => {
|
|
1638
|
+
const { compact, mode } = unref(getProps);
|
|
1639
|
+
const getCompact = compact === null ? mode === "dialog" ? false : true : compact;
|
|
1640
|
+
return [
|
|
1641
|
+
"basic-form",
|
|
1642
|
+
`basic-form__${mode}`,
|
|
1643
|
+
{
|
|
1644
|
+
"basic-form__compact": getCompact
|
|
1645
|
+
}
|
|
1646
|
+
];
|
|
1647
|
+
});
|
|
1648
|
+
function setProps(formProps) {
|
|
1649
|
+
propsRef.value = deepMerge(unref(propsRef) || {}, formProps);
|
|
1650
|
+
return null;
|
|
1651
|
+
}
|
|
1652
|
+
function setFormModel(key, value) {
|
|
1653
|
+
formModel[key] = value;
|
|
1654
|
+
const { validateTrigger } = unref(getBindValue);
|
|
1655
|
+
if (!validateTrigger || validateTrigger === "change") {
|
|
1656
|
+
validateFields([key]);
|
|
1657
|
+
}
|
|
1658
|
+
}
|
|
1659
|
+
function handleEnterPress() {
|
|
1660
|
+
}
|
|
1661
|
+
const { initDefault, handleFormValues } = useFormValues({
|
|
1662
|
+
defaultValue,
|
|
1663
|
+
getSchema,
|
|
1664
|
+
formModel
|
|
1665
|
+
});
|
|
1666
|
+
const {
|
|
1667
|
+
updateSchema,
|
|
1668
|
+
resetSchema,
|
|
1669
|
+
clearValidate,
|
|
1670
|
+
resetForms,
|
|
1671
|
+
removeFormByName,
|
|
1672
|
+
setFormValues,
|
|
1673
|
+
appendFormItems,
|
|
1674
|
+
validate,
|
|
1675
|
+
validateFields,
|
|
1676
|
+
getFormValues
|
|
1677
|
+
} = useFormEvents({
|
|
1678
|
+
emits,
|
|
1679
|
+
getSchema,
|
|
1680
|
+
formModel,
|
|
1681
|
+
formElRef,
|
|
1682
|
+
defaultValue,
|
|
1683
|
+
schemaRef,
|
|
1684
|
+
getProps,
|
|
1685
|
+
handleFormValues
|
|
1686
|
+
});
|
|
1687
|
+
const formActionMethods = {
|
|
1688
|
+
setProps,
|
|
1689
|
+
updateSchema,
|
|
1690
|
+
resetSchema,
|
|
1691
|
+
clearValidate,
|
|
1692
|
+
resetForms,
|
|
1693
|
+
removeFormByName,
|
|
1694
|
+
setFormValues,
|
|
1695
|
+
appendFormItems,
|
|
1696
|
+
validate,
|
|
1697
|
+
validateFields,
|
|
1698
|
+
getFormValues
|
|
1699
|
+
};
|
|
1700
|
+
const getActionsProps = computed(() => {
|
|
1701
|
+
const {
|
|
1702
|
+
mode,
|
|
1703
|
+
minShowColumn = getAppConf.ui.form.minShowColumn || 2,
|
|
1704
|
+
schemas = [],
|
|
1705
|
+
showAdvancedButton: advanced,
|
|
1706
|
+
loading,
|
|
1707
|
+
buttons
|
|
1708
|
+
} = unref(getProps);
|
|
1709
|
+
let showAdvancedButton = mode === "search" ? true : false;
|
|
1710
|
+
if (advanced !== void 0) {
|
|
1711
|
+
showAdvancedButton = advanced;
|
|
1712
|
+
}
|
|
1713
|
+
if (schemas.length <= minShowColumn) {
|
|
1714
|
+
showAdvancedButton = false;
|
|
1715
|
+
}
|
|
1716
|
+
let buttonList = [];
|
|
1717
|
+
if (isArray(buttons)) {
|
|
1718
|
+
buttonList = [...buttons];
|
|
1719
|
+
} else if (mode === "search" && !buttons) {
|
|
1720
|
+
SEARCH_BTNS.forEach((it) => {
|
|
1721
|
+
it.loading = it.name === SEARCH_BTN_NAME ? loading?.onSearch : loading?.onReset;
|
|
1722
|
+
buttonList.push(it);
|
|
1723
|
+
});
|
|
1724
|
+
}
|
|
1725
|
+
let colspan = mode === "search" ? getAppConf.ui.form.searchColspan : getAppConf.ui.form.dialogColspan;
|
|
1726
|
+
return {
|
|
1727
|
+
...colspan,
|
|
1728
|
+
...{
|
|
1729
|
+
showAdvancedButton,
|
|
1730
|
+
buttonList
|
|
1731
|
+
}
|
|
1732
|
+
};
|
|
1733
|
+
});
|
|
1734
|
+
const [handleMethod] = useFormActions({
|
|
1735
|
+
getProps,
|
|
1736
|
+
defaultValue,
|
|
1737
|
+
updateSchema,
|
|
1738
|
+
getFormValues,
|
|
1739
|
+
setFormValues
|
|
1740
|
+
});
|
|
1741
|
+
onMounted(() => {
|
|
1742
|
+
setFormValues(null);
|
|
1743
|
+
emits("register", formActionMethods);
|
|
1744
|
+
initDefault();
|
|
1745
|
+
});
|
|
1746
|
+
watch(
|
|
1747
|
+
() => unref(getProps).onSearch,
|
|
1748
|
+
() => {
|
|
1749
|
+
useTimeoutFn(() => {
|
|
1750
|
+
const { onSearch, autoFetch } = unref(getProps);
|
|
1751
|
+
if (autoFetch && onSearch && isFunction(onSearch)) {
|
|
1752
|
+
onSearch(toRaw(defaultValue.value));
|
|
1753
|
+
}
|
|
1754
|
+
}, 1);
|
|
1755
|
+
}
|
|
1756
|
+
);
|
|
1757
|
+
watch(
|
|
1758
|
+
() => unref(getProps).model,
|
|
1759
|
+
(v) => {
|
|
1760
|
+
const { model } = unref(getProps);
|
|
1761
|
+
if (!model || !Object.keys(model).length)
|
|
1762
|
+
return;
|
|
1763
|
+
setFormValues(model);
|
|
1764
|
+
},
|
|
1765
|
+
{
|
|
1766
|
+
immediate: true,
|
|
1767
|
+
deep: true
|
|
1768
|
+
}
|
|
1769
|
+
);
|
|
1770
|
+
return (_ctx, _cache) => {
|
|
1771
|
+
const _component_ARow = Row;
|
|
1772
|
+
const _component_AForm = Form$1;
|
|
1773
|
+
return openBlock(), createBlock(_component_AForm, mergeProps(unref(getBindValue), {
|
|
1774
|
+
ref_key: "formElRef",
|
|
1775
|
+
ref: formElRef,
|
|
1776
|
+
class: unref(getFormClass),
|
|
1777
|
+
model: formModel,
|
|
1778
|
+
layout: unref(getProps).layout,
|
|
1779
|
+
onKeypress: withKeys(handleEnterPress, ["enter"])
|
|
1780
|
+
}), {
|
|
1781
|
+
default: withCtx(() => [
|
|
1782
|
+
createVNode(_component_ARow, mergeProps(unref(getProps).rowProps, { style: {
|
|
1783
|
+
margin: 0
|
|
1784
|
+
} }), {
|
|
1785
|
+
default: withCtx(() => [
|
|
1786
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(unref(getSchema), (schema) => {
|
|
1787
|
+
return openBlock(), createBlock(unref(_sfc_main$2), {
|
|
1788
|
+
key: schema.name,
|
|
1789
|
+
schema,
|
|
1790
|
+
formProps: unref(getProps),
|
|
1791
|
+
formModel,
|
|
1792
|
+
defaultValues: defaultValue.value,
|
|
1793
|
+
setFormModel,
|
|
1794
|
+
formActionType: formActionMethods
|
|
1795
|
+
}, createSlots({ _: 2 }, [
|
|
1796
|
+
renderList(Object.keys(_ctx.$slots), (item) => {
|
|
1797
|
+
return {
|
|
1798
|
+
name: item,
|
|
1799
|
+
fn: withCtx((data) => [
|
|
1800
|
+
renderSlot(_ctx.$slots, item, normalizeProps(guardReactiveProps(data || {})))
|
|
1801
|
+
])
|
|
1802
|
+
};
|
|
1803
|
+
})
|
|
1804
|
+
]), 1032, ["schema", "formProps", "formModel", "defaultValues"]);
|
|
1805
|
+
}), 128)),
|
|
1806
|
+
unref(getActionsProps).buttonList?.length ? (openBlock(), createBlock(unref(_sfc_main$1), mergeProps({ key: 0 }, unref(getActionsProps), { onHandleMethod: unref(handleMethod) }), null, 16, ["onHandleMethod"])) : createCommentVNode("", true)
|
|
1807
|
+
]),
|
|
1808
|
+
_: 3
|
|
1809
|
+
}, 16)
|
|
1810
|
+
]),
|
|
1811
|
+
_: 3
|
|
1812
|
+
}, 16, ["class", "model", "layout", "onKeypress"]);
|
|
1813
|
+
};
|
|
1814
|
+
}
|
|
1815
|
+
});
|
|
1816
|
+
function useForm(props) {
|
|
1817
|
+
const formRef = ref(null);
|
|
1818
|
+
const loadedRef = ref(false);
|
|
1819
|
+
function register(instance) {
|
|
1820
|
+
if (unref(loadedRef) && instance === unref(formRef))
|
|
1821
|
+
return;
|
|
1822
|
+
formRef.value = instance;
|
|
1823
|
+
loadedRef.value = true;
|
|
1824
|
+
watch(
|
|
1825
|
+
() => props,
|
|
1826
|
+
() => props && instance.setProps(props),
|
|
1827
|
+
{
|
|
1828
|
+
immediate: true,
|
|
1829
|
+
deep: true
|
|
1830
|
+
}
|
|
1831
|
+
);
|
|
1832
|
+
}
|
|
1833
|
+
async function getForm() {
|
|
1834
|
+
const form = unref(formRef);
|
|
1835
|
+
if (!form)
|
|
1836
|
+
console.error("\u8868\u5355\u672A\u7533\u660E!");
|
|
1837
|
+
await nextTick();
|
|
1838
|
+
return form;
|
|
1839
|
+
}
|
|
1840
|
+
const methods = {
|
|
1841
|
+
setProps: async (props2) => {
|
|
1842
|
+
const form = await getForm();
|
|
1843
|
+
form.setProps(props2);
|
|
1844
|
+
},
|
|
1845
|
+
updateSchema: async (data) => {
|
|
1846
|
+
const form = await getForm();
|
|
1847
|
+
form.updateSchema(data);
|
|
1848
|
+
},
|
|
1849
|
+
resetSchema: async (data) => {
|
|
1850
|
+
const form = await getForm();
|
|
1851
|
+
form.resetSchema(data);
|
|
1852
|
+
},
|
|
1853
|
+
clearValidate: async (name) => {
|
|
1854
|
+
const form = await getForm();
|
|
1855
|
+
form.clearValidate(name);
|
|
1856
|
+
},
|
|
1857
|
+
resetForms: async () => {
|
|
1858
|
+
const form = await getForm();
|
|
1859
|
+
form.resetForms();
|
|
1860
|
+
},
|
|
1861
|
+
removeFormByName: async (name) => {
|
|
1862
|
+
unref(formRef)?.removeFormByName(name);
|
|
1863
|
+
},
|
|
1864
|
+
setFormValues: async (values) => {
|
|
1865
|
+
const form = await getForm();
|
|
1866
|
+
form.setFormValues(values);
|
|
1867
|
+
},
|
|
1868
|
+
appendFormItems: async (schema, prefixName, first) => {
|
|
1869
|
+
const form = await getForm();
|
|
1870
|
+
form.appendFormItems(schema, prefixName, first);
|
|
1871
|
+
},
|
|
1872
|
+
validate: async (nameList) => {
|
|
1873
|
+
const form = await getForm();
|
|
1874
|
+
return form.validate(nameList);
|
|
1875
|
+
},
|
|
1876
|
+
validateFields: async (nameList) => {
|
|
1877
|
+
const form = await getForm();
|
|
1878
|
+
return form.validateFields(nameList);
|
|
1879
|
+
},
|
|
1880
|
+
getFormValues: () => {
|
|
1881
|
+
return unref(formRef)?.getFormValues();
|
|
1882
|
+
}
|
|
1883
|
+
};
|
|
1884
|
+
return [register, methods];
|
|
1885
|
+
}
|
|
1886
|
+
const withInstall = (comp) => {
|
|
1887
|
+
comp.install = (app) => {
|
|
1888
|
+
app.component(comp.name, comp);
|
|
1889
|
+
};
|
|
1890
|
+
return comp;
|
|
1891
|
+
};
|
|
1892
|
+
const DtForm = withInstall(_sfc_main);
|
|
1893
|
+
export {
|
|
1894
|
+
DtForm,
|
|
1895
|
+
useForm
|
|
1896
|
+
};
|