@dt-frames/ui 2.0.0 → 2.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (220) hide show
  1. package/es/assets/data/icons/actions.d.ts +1 -0
  2. package/es/assets/data/icons/actions.ts +423 -0
  3. package/es/assets/data/icons/code.d.ts +1 -0
  4. package/es/assets/data/icons/code.ts +10 -0
  5. package/es/assets/data/icons/commuticate.d.ts +1 -0
  6. package/es/assets/data/icons/commuticate.ts +182 -0
  7. package/es/assets/data/icons/currency.d.ts +1 -0
  8. package/es/assets/data/icons/currency.ts +44 -0
  9. package/es/assets/data/icons/devices.d.ts +1 -0
  10. package/es/assets/data/icons/devices.ts +126 -0
  11. package/es/assets/data/icons/edit.d.ts +1 -0
  12. package/es/assets/data/icons/edit.ts +163 -0
  13. package/es/assets/data/icons/file.d.ts +1 -0
  14. package/es/assets/data/icons/file.ts +99 -0
  15. package/es/assets/data/icons/math.d.ts +1 -0
  16. package/es/assets/data/icons/math.ts +53 -0
  17. package/es/assets/data/icons/message.d.ts +1 -0
  18. package/es/assets/data/icons/message.ts +68 -0
  19. package/es/assets/data/icons/navigate.d.ts +1 -0
  20. package/es/assets/data/icons/navigate.ts +181 -0
  21. package/es/assets/data/icons/other.d.ts +1 -0
  22. package/es/assets/data/icons/other.ts +324 -0
  23. package/es/assets/data/index.d.ts +4 -0
  24. package/es/assets/data/index.ts +58 -0
  25. package/es/assets/icons/iconfont.css +7266 -0
  26. package/es/assets/icons/iconfont.eot +0 -0
  27. package/es/assets/icons/iconfont.svg +5445 -0
  28. package/es/assets/icons/iconfont.ttf +0 -0
  29. package/es/assets/icons/iconfont.woff +0 -0
  30. package/es/assets/icons/iconfont.woff2 +0 -0
  31. package/es/assets/imgs/header/avatar.png +0 -0
  32. package/es/assets/imgs/logo/logo.png +0 -0
  33. package/es/assets/imgs/table/empty.png +0 -0
  34. package/es/assets/locales/en.d.ts +101 -0
  35. package/es/assets/locales/en.ts +101 -0
  36. package/es/assets/locales/index.d.ts +2 -0
  37. package/es/assets/locales/index.ts +5 -0
  38. package/es/assets/locales/zh.d.ts +103 -0
  39. package/es/assets/locales/zh.ts +103 -0
  40. package/es/components/container/index.d.ts +93 -0
  41. package/es/components/container/index.js +288 -0
  42. package/es/components/container/index.less +64 -0
  43. package/es/components/container/src/components/bar.d.ts +14 -0
  44. package/es/components/container/src/components/scroll-bar.d.ts +70 -0
  45. package/es/components/container/src/hooks/scroll.d.ts +10 -0
  46. package/es/components/container/src/scroll-container.d.ts +76 -0
  47. package/es/components/container/src/slot-container.d.ts +18 -0
  48. package/es/components/container/src/types/scroll.type.d.ts +22 -0
  49. package/es/components/container/src/utils/scroll.d.ts +5 -0
  50. package/es/components/curd/index.d.ts +2 -0
  51. package/es/components/curd/index.js +3098 -0
  52. package/es/components/curd/src/components/Curd.d.ts +1451 -0
  53. package/es/components/curd/src/hooks/useCurd.d.ts +112 -0
  54. package/es/components/curd/src/props.d.ts +188 -0
  55. package/es/components/curd/src/types/curd.type.d.ts +19 -0
  56. package/es/components/drawer/index.d.ts +8041 -0
  57. package/es/components/drawer/index.js +837 -0
  58. package/es/components/drawer/index.less +10 -0
  59. package/es/components/drawer/src/components/DrawerFooter.d.ts +139 -0
  60. package/es/components/drawer/src/components/DrawerHeader.d.ts +13 -0
  61. package/es/components/drawer/src/hooks/useDrawer.d.ts +3 -0
  62. package/es/components/drawer/src/index.d.ts +8043 -0
  63. package/es/components/drawer/src/props.d.ts +64 -0
  64. package/es/components/drawer/src/types/index.type.d.ts +48 -0
  65. package/es/components/form/index.d.ts +3367 -0
  66. package/es/components/form/index.js +1895 -0
  67. package/es/components/form/index.less +141 -0
  68. package/es/components/form/src/components/FormButtons.d.ts +88 -0
  69. package/es/components/form/src/components/FormItem.d.ts +313 -0
  70. package/es/components/form/src/components/componentMap.d.ts +4 -0
  71. package/es/components/form/src/components/formIcon.d.ts +1231 -0
  72. package/es/components/form/src/components/formInputUseDialog.d.ts +911 -0
  73. package/es/components/form/src/components/index.d.ts +4 -0
  74. package/es/components/form/src/components/radioButton.d.ts +34 -0
  75. package/es/components/form/src/enums/index.d.ts +7 -0
  76. package/es/components/form/src/hooks/helper.d.ts +14 -0
  77. package/es/components/form/src/hooks/useForm.d.ts +6 -0
  78. package/es/components/form/src/hooks/useFormActions.d.ts +12 -0
  79. package/es/components/form/src/hooks/useFormEvent.d.ts +25 -0
  80. package/es/components/form/src/hooks/useFormValue.d.ts +3 -0
  81. package/es/components/form/src/hooks/useFormValues.d.ts +11 -0
  82. package/es/components/form/src/hooks/useLabelWidth.d.ts +22 -0
  83. package/es/components/form/src/index.d.ts +3113 -0
  84. package/es/components/form/src/props.d.ts +133 -0
  85. package/es/components/form/src/types/actions.type.d.ts +15 -0
  86. package/es/components/form/src/types/form.type.d.ts +70 -0
  87. package/es/components/icons/index.d.ts +3 -0
  88. package/es/components/icons/index.js +1969 -0
  89. package/es/components/icons/index.less +42 -0
  90. package/es/components/icons/src/pick-icon.d.ts +455 -0
  91. package/es/components/icons/src/svg-icon.d.ts +44 -0
  92. package/es/components/modal/index.d.ts +3 -0
  93. package/es/components/modal/index.js +1192 -0
  94. package/es/components/modal/index.less +54 -0
  95. package/es/components/modal/src/components/CloseIcon.d.ts +40 -0
  96. package/es/components/modal/src/components/Modal.d.ts +215 -0
  97. package/es/components/modal/src/components/ModalFooter.d.ts +139 -0
  98. package/es/components/modal/src/components/ModalWrap.d.ts +153 -0
  99. package/es/components/modal/src/hooks/useDrag.d.ts +7 -0
  100. package/es/components/modal/src/hooks/useFullScreen.d.ts +6 -0
  101. package/es/components/modal/src/hooks/useModal.d.ts +5 -0
  102. package/es/components/modal/src/index.d.ts +881 -0
  103. package/es/components/modal/src/props.d.ts +100 -0
  104. package/es/components/modal/src/types/modal.type.d.ts +17 -0
  105. package/es/components/source/hooks/useDownload.d.ts +8 -0
  106. package/es/components/source/hooks/useSource.d.ts +40 -0
  107. package/es/components/source/index.d.ts +2 -0
  108. package/es/components/source/index.js +331 -0
  109. package/es/components/source/types/source.type.d.ts +37 -0
  110. package/es/components/source/utils/index.d.ts +8 -0
  111. package/es/components/table/index.d.ts +3 -0
  112. package/es/components/table/index.js +4414 -0
  113. package/es/components/table/index.less +183 -0
  114. package/es/components/table/src/components/TableAction.d.ts +70 -0
  115. package/es/components/table/src/components/TableHeader.d.ts +1243 -0
  116. package/es/components/table/src/components/TableRender.d.ts +13 -0
  117. package/es/components/table/src/components/editTable/CellComponent.d.ts +22 -0
  118. package/es/components/table/src/components/editTable/EditTableCell.d.ts +93 -0
  119. package/es/components/table/src/components/editTable/componentMap.d.ts +4 -0
  120. package/es/components/table/src/components/editTable/index.d.ts +9 -0
  121. package/es/components/table/src/components/editTable/props.d.ts +27 -0
  122. package/es/components/table/src/components/tableSetting/Column.d.ts +69 -0
  123. package/es/components/table/src/components/tableSetting/Download.d.ts +1029 -0
  124. package/es/components/table/src/components/tableSetting/DownloadCtrl.d.ts +995 -0
  125. package/es/components/table/src/components/tableSetting/Fullscreen.d.ts +22 -0
  126. package/es/components/table/src/components/tableSetting/index.d.ts +1137 -0
  127. package/es/components/table/src/hooks/useColumns.d.ts +14 -0
  128. package/es/components/table/src/hooks/useCustomRow.d.ts +20 -0
  129. package/es/components/table/src/hooks/useDataSource.d.ts +16 -0
  130. package/es/components/table/src/hooks/useHeader.d.ts +8 -0
  131. package/es/components/table/src/hooks/useHeaderCode.d.ts +3 -0
  132. package/es/components/table/src/hooks/useLoading.d.ts +6 -0
  133. package/es/components/table/src/hooks/usePagination.d.ts +122 -0
  134. package/es/components/table/src/hooks/useRow.d.ts +5 -0
  135. package/es/components/table/src/hooks/useRowSelection.d.ts +12 -0
  136. package/es/components/table/src/hooks/useTable.d.ts +9 -0
  137. package/es/components/table/src/hooks/useTableInstance.d.ts +16 -0
  138. package/es/components/table/src/hooks/useTableScroll.d.ts +13 -0
  139. package/es/components/table/src/index.d.ts +990 -0
  140. package/es/components/table/src/props.d.ts +244 -0
  141. package/es/components/table/src/types/actions.type.d.ts +22 -0
  142. package/es/components/table/src/types/header.type.d.ts +23 -0
  143. package/es/components/table/src/types/table.type.d.ts +92 -0
  144. package/es/directives/icon.d.ts +2 -0
  145. package/es/directives/index.d.ts +7 -0
  146. package/es/directives/index.js +2015 -0
  147. package/es/directives/permission.d.ts +2 -0
  148. package/es/global.d.ts +7 -0
  149. package/es/index.d.ts +1 -0
  150. package/es/index.js +3242 -0
  151. package/es/theme/index.d.ts +10 -0
  152. package/es/theme/index.js +3242 -0
  153. package/es/theme/index.less +603 -0
  154. package/es/theme/src/components/content/index.d.ts +27 -0
  155. package/es/theme/src/components/feature/back-top.d.ts +5 -0
  156. package/es/theme/src/components/feature/index.d.ts +7 -0
  157. package/es/theme/src/components/footer/index.d.ts +31 -0
  158. package/es/theme/src/components/header/components/bread-crumb.d.ts +6 -0
  159. package/es/theme/src/components/header/components/fullscreen.d.ts +5 -0
  160. package/es/theme/src/components/header/components/index.d.ts +11 -0
  161. package/es/theme/src/components/header/components/lang-picker.d.ts +23 -0
  162. package/es/theme/src/components/header/components/logo.d.ts +36 -0
  163. package/es/theme/src/components/header/components/menu-filter.d.ts +22 -0
  164. package/es/theme/src/components/header/components/notify.d.ts +23 -0
  165. package/es/theme/src/components/header/components/setting-theme.d.ts +222 -0
  166. package/es/theme/src/components/header/components/size.d.ts +282 -0
  167. package/es/theme/src/components/header/components/theme-drawer/feature.d.ts +138 -0
  168. package/es/theme/src/components/header/components/theme-drawer/index.d.ts +3 -0
  169. package/es/theme/src/components/header/components/theme-drawer/menu-type.d.ts +16 -0
  170. package/es/theme/src/components/header/components/theme-drawer/select.d.ts +58 -0
  171. package/es/theme/src/components/header/components/theme-drawer/switch.d.ts +49 -0
  172. package/es/theme/src/components/header/components/trigger.d.ts +10 -0
  173. package/es/theme/src/components/header/components/user-info.d.ts +36 -0
  174. package/es/theme/src/components/header/helper/change-theme.d.ts +13 -0
  175. package/es/theme/src/components/header/helper/menu-tree.d.ts +3 -0
  176. package/es/theme/src/components/header/index.d.ts +698 -0
  177. package/es/theme/src/components/header/multiple-header.d.ts +787 -0
  178. package/es/theme/src/components/sider/components/basic-menu/basic-menu-item.d.ts +62 -0
  179. package/es/theme/src/components/sider/components/basic-menu/basic-menu.d.ts +207 -0
  180. package/es/theme/src/components/sider/components/basic-menu/basic-sub-menu-item.d.ts +127 -0
  181. package/es/theme/src/components/sider/components/basic-menu/menu-item-content.d.ts +26 -0
  182. package/es/theme/src/components/sider/components/drag-bar.d.ts +14 -0
  183. package/es/theme/src/components/sider/components/layout-menu.d.ts +22 -0
  184. package/es/theme/src/components/sider/components/props.d.ts +69 -0
  185. package/es/theme/src/components/sider/components/sider-trigger.d.ts +18 -0
  186. package/es/theme/src/components/sider/helper/sider.d.ts +12 -0
  187. package/es/theme/src/components/sider/helper/split-menu.d.ts +10 -0
  188. package/es/theme/src/components/sider/index.d.ts +70 -0
  189. package/es/theme/src/components/tabs/components/TabContent.d.ts +6 -0
  190. package/es/theme/src/components/tabs/components/TabRedo.d.ts +21 -0
  191. package/es/theme/src/components/tabs/components/index.d.ts +3 -0
  192. package/es/theme/src/components/tabs/hooks/useMultifyTabs.d.ts +7 -0
  193. package/es/theme/src/components/tabs/hooks/useTabDropdown.d.ts +6 -0
  194. package/es/theme/src/components/tabs/index.d.ts +63 -0
  195. package/es/theme/src/components/tabs/types/tabs.type.d.ts +7 -0
  196. package/es/theme/src/enums/index.d.ts +1 -0
  197. package/es/theme/src/enums/theme.enum.d.ts +33 -0
  198. package/es/theme/src/hooks/index.d.ts +6 -0
  199. package/es/theme/src/hooks/useDragLine.d.ts +2 -0
  200. package/es/theme/src/hooks/useHeader.d.ts +25 -0
  201. package/es/theme/src/hooks/useMenu.d.ts +27 -0
  202. package/es/theme/src/hooks/useMultifyTab.d.ts +7 -0
  203. package/es/theme/src/hooks/useOpenKeys.d.ts +7 -0
  204. package/es/theme/src/hooks/useTheme.d.ts +9 -0
  205. package/es/theme/src/index.d.ts +1644 -0
  206. package/es/theme/src/setting/theme.setting.d.ts +2 -0
  207. package/es/theme/src/stores/index.d.ts +3 -0
  208. package/es/theme/src/stores/routeReuse.store.d.ts +23 -0
  209. package/es/theme/src/stores/theme.store.d.ts +15 -0
  210. package/es/theme/src/types/index.d.ts +3 -0
  211. package/es/theme/src/types/menu.type.d.ts +15 -0
  212. package/es/theme/src/types/theme.type.d.ts +60 -0
  213. package/es/utils/withInstall.d.ts +4 -0
  214. package/index.d.ts +10 -0
  215. package/index.js +34 -0
  216. package/package.json +1 -5
  217. package/tailwind.config.cjs +11 -0
  218. package/tsconfig.json +41 -0
  219. package/tsconfig.node.json +9 -0
  220. package/vite.config.ts +78 -0
@@ -0,0 +1,1895 @@
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 { toRaw as toRaw$1, unref as unref$1, computed as computed$1, getCurrentInstance, reactive as reactive$1, readonly, watchEffect, nextTick as nextTick$1, defineComponent as defineComponent$1, openBlock, createBlock, mergeProps, isRef, withCtx, createElementBlock, Fragment, renderList, createTextVNode, toDisplayString, useAttrs as useAttrs$1, createElementVNode, createVNode, normalizeProps, guardReactiveProps, createCommentVNode, isVNode, resolveDirective, normalizeStyle, withDirectives, normalizeClass, withKeys, createSlots, renderSlot } from "vue";
4
+ import { DtCache, CacheKey, deepMerge, Pages, useGo, useRedo, Language, useAppStore, isNumber, useI18n, isString, isFunction, error, useSlots, isArray, isBoolean, isNull, dispatchResize, isObject, isNullAndUnDef, useTimeoutFn } from "@dt-frames/core";
5
+ import { isEqual, omit, cloneDeep, upperFirst, uniqBy, set } from "lodash-es";
6
+ import { Input, Select, TreeSelect, Radio, Checkbox, AutoComplete, Cascader, DatePicker, InputNumber, Switch, TimePicker, Slider, Rate, Divider, Col, Tooltip, Form, FormItem } from "ant-design-vue";
7
+ import { defineStore } from "pinia";
8
+ import "ant-design-vue/es/button/style";
9
+ import dayjs from "dayjs";
10
+ const _default = "";
11
+ const index$1 = "";
12
+ var Theme = /* @__PURE__ */ ((Theme2) => {
13
+ Theme2["DARK"] = "dark";
14
+ Theme2["LIGHT"] = "light";
15
+ return Theme2;
16
+ })(Theme || {});
17
+ var MenuType = /* @__PURE__ */ ((MenuType2) => {
18
+ MenuType2["SIDE"] = "sidebar";
19
+ MenuType2["TOP_MENU"] = "top-menu";
20
+ MenuType2["MIX"] = "mix";
21
+ return MenuType2;
22
+ })(MenuType || {});
23
+ var MenuMode = /* @__PURE__ */ ((MenuMode2) => {
24
+ MenuMode2["INLINE"] = "inline";
25
+ MenuMode2["HORIZONTAL"] = "horizontal";
26
+ MenuMode2["VERTICAL"] = "vertical";
27
+ return MenuMode2;
28
+ })(MenuMode || {});
29
+ var ContentMode = /* @__PURE__ */ ((ContentMode2) => {
30
+ ContentMode2["FULL"] = "full";
31
+ ContentMode2["FIXED"] = "fixed";
32
+ return ContentMode2;
33
+ })(ContentMode || {});
34
+ var UiSize = /* @__PURE__ */ ((UiSize2) => {
35
+ UiSize2["LARGE"] = "large";
36
+ UiSize2["MIDDLE"] = "middle";
37
+ UiSize2["SMALL"] = "small";
38
+ return UiSize2;
39
+ })(UiSize || {});
40
+ const defaultThemeConf = {
41
+ content: {
42
+ contentMode: ContentMode.FULL
43
+ },
44
+ headOptions: {
45
+ fixed: true,
46
+ theme: Theme.LIGHT,
47
+ showLogo: true,
48
+ showBackToTop: true,
49
+ useLockPage: true,
50
+ size: UiSize.SMALL,
51
+ showSize: true,
52
+ showBreadCrumb: true,
53
+ showFullScreen: true,
54
+ showSearch: true,
55
+ showNotice: true,
56
+ showLocaleSwitch: true,
57
+ showSettingTheme: true,
58
+ showLoginOut: true
59
+ },
60
+ menuOptions: {
61
+ fixed: true,
62
+ theme: Theme.DARK,
63
+ collapsed: false,
64
+ collapsedShowTitle: false,
65
+ canDrag: true,
66
+ show: true,
67
+ hidden: false,
68
+ split: false,
69
+ menuWidth: 240,
70
+ trigger: true,
71
+ type: MenuType.SIDE,
72
+ mode: MenuMode.INLINE
73
+ },
74
+ footerOptions: {
75
+ show: false,
76
+ height: 48,
77
+ title: "Copyright(C) 2021 by www.ithinkdt.com. All rights reserved.",
78
+ subTitle: "Privacy Statement"
79
+ },
80
+ routeReuse: {
81
+ show: true,
82
+ cache: true,
83
+ canDrag: true,
84
+ showQuick: true,
85
+ showRedo: true,
86
+ showFold: true
87
+ }
88
+ };
89
+ const useThemeStore = defineStore({
90
+ id: "dt-theme",
91
+ state: () => ({
92
+ themeConf: DtCache.getLocal(CacheKey.THEME) ?? defaultThemeConf,
93
+ pageLoading: false
94
+ }),
95
+ getters: {
96
+ getThemeConf() {
97
+ return this.themeConf;
98
+ },
99
+ getHeaderConf() {
100
+ return this.themeConf.headOptions;
101
+ },
102
+ getMenuConf() {
103
+ return this.themeConf.menuOptions;
104
+ },
105
+ getFooterConf() {
106
+ return this.themeConf.footerOptions;
107
+ },
108
+ getRouteReuseConf() {
109
+ return this.themeConf.routeReuse;
110
+ },
111
+ getPageLoading() {
112
+ return this.pageLoading;
113
+ }
114
+ },
115
+ actions: {
116
+ setThemeConf(options = {}) {
117
+ let newThemeConf = deepMerge(this.themeConf, options);
118
+ this.themeConf = deepMerge(defaultThemeConf, newThemeConf);
119
+ DtCache.setLocal(CacheKey.THEME, this.themeConf);
120
+ }
121
+ }
122
+ });
123
+ defineStore({
124
+ id: "route-reuse",
125
+ state: () => ({
126
+ cacheTabList: /* @__PURE__ */ new Set(),
127
+ tabList: DtCache.getLocal(CacheKey.THEME)?.routeReuse?.cache ? DtCache.getLocal(CacheKey.ROUTE_REUSE) || [] : [],
128
+ lastDragEndIndex: 0
129
+ }),
130
+ getters: {
131
+ getTabList() {
132
+ return this.tabList;
133
+ },
134
+ getCachedTabList() {
135
+ return Array.from(this.cacheTabList);
136
+ },
137
+ getLastDragEndIndex() {
138
+ return this.lastDragEndIndex;
139
+ }
140
+ },
141
+ actions: {
142
+ async addTab(route) {
143
+ const { path, name, fullPath, params, query, meta } = route;
144
+ if (path === Pages.NOT_FOUND || path === Pages.LOGIN || path === Pages.BASE_PAGE) {
145
+ return;
146
+ }
147
+ let updateIndex = -1;
148
+ const tabHasExits = this.tabList.some((tab, index2) => {
149
+ updateIndex = index2;
150
+ return (tab.fullPath || tab.path) === (fullPath || path);
151
+ });
152
+ if (tabHasExits) {
153
+ const curTab = toRaw$1(this.tabList)[updateIndex];
154
+ curTab.params = params || curTab.params;
155
+ curTab.query = query || curTab.query;
156
+ curTab.fullPath = fullPath || curTab.fullPath;
157
+ this.tabList.splice(updateIndex, 1, curTab);
158
+ } else {
159
+ this.tabList.push(JSON.parse(JSON.stringify(route)));
160
+ }
161
+ this.updateCacheTab();
162
+ },
163
+ closeTab(path, router) {
164
+ const go = useGo(router);
165
+ const index2 = this.tabList.findIndex((item) => item.path === path);
166
+ let page;
167
+ if (index2 === 0) {
168
+ if (this.tabList.length !== 1) {
169
+ page = this.tabList[index2 + 1];
170
+ }
171
+ } else {
172
+ page = this.tabList[index2 - 1];
173
+ }
174
+ this.bulkCloseTabs([path]);
175
+ this.updateCacheTab();
176
+ path === router.currentRoute.value.path && go(page.path);
177
+ },
178
+ closeAllTab(currentRoute, router) {
179
+ const go = useGo(router);
180
+ let filterTabList = this.tabList.filter((item) => item?.meta?.affix ?? false);
181
+ const route = filterTabList.length > 0 ? filterTabList[filterTabList.length - 1] : unref$1(currentRoute);
182
+ this.tabList = [route];
183
+ this.updateCacheTab();
184
+ go(route.path);
185
+ },
186
+ closeLeftTabs(path) {
187
+ const index2 = this.tabList.findIndex((item) => item.path === path);
188
+ if (index2 > 0) {
189
+ const leftTabs = this.tabList.slice(0, index2);
190
+ const pathList = [];
191
+ for (const item of leftTabs) {
192
+ const affix = item?.meta?.affix ?? false;
193
+ if (!affix) {
194
+ pathList.push(item.fullPath);
195
+ }
196
+ }
197
+ this.bulkCloseTabs(pathList);
198
+ }
199
+ this.updateCacheTab();
200
+ },
201
+ closeRightTabs(path) {
202
+ const index2 = this.tabList.findIndex((item) => item.path === path);
203
+ if (index2 >= 0 && index2 < this.tabList.length - 1) {
204
+ const rightTabs = this.tabList.slice(index2 + 1, this.tabList.length);
205
+ const pathList = [];
206
+ for (const item of rightTabs) {
207
+ const affix = item?.meta?.affix ?? false;
208
+ if (!affix) {
209
+ pathList.push(item.fullPath);
210
+ }
211
+ }
212
+ this.bulkCloseTabs(pathList);
213
+ }
214
+ this.updateCacheTab();
215
+ },
216
+ closeOtherTabs(path) {
217
+ const pathList = [];
218
+ for (let item of this.tabList) {
219
+ const affix = item?.meta?.affix ?? false;
220
+ if (item.path !== path && !affix) {
221
+ pathList.push(item.path);
222
+ }
223
+ }
224
+ this.bulkCloseTabs(pathList);
225
+ this.updateCacheTab();
226
+ },
227
+ bulkCloseTabs(pathList) {
228
+ this.tabList = this.tabList.filter((item) => !pathList.includes(item.fullPath));
229
+ },
230
+ updateCacheTab() {
231
+ const cacheTab = DtCache.getLocal(CacheKey.THEME)?.routeReuse?.cache;
232
+ cacheTab && DtCache.setLocal(CacheKey.ROUTE_REUSE, this.tabList);
233
+ const cacheMap = /* @__PURE__ */ new Set();
234
+ for (const tab of this.tabList) {
235
+ if (tab.meta?.hideTab) {
236
+ continue;
237
+ }
238
+ const name = tab.name;
239
+ cacheMap.add(name);
240
+ }
241
+ this.cacheTabList = cacheMap;
242
+ },
243
+ async refreshPage(router) {
244
+ const findTab = this.getCachedTabList.find((item) => item === unref$1(router.currentRoute).name);
245
+ if (findTab) {
246
+ this.cacheTabList.delete(findTab.toString());
247
+ }
248
+ const redo = useRedo(router);
249
+ await redo();
250
+ },
251
+ sortTabs(oldIndex, newIndex) {
252
+ const currentTab = this.tabList[oldIndex];
253
+ this.tabList.splice(oldIndex, 1);
254
+ this.tabList.splice(newIndex, 0, currentTab);
255
+ this.lastDragEndIndex = this.lastDragEndIndex + 1;
256
+ }
257
+ }
258
+ });
259
+ function useMenu() {
260
+ const { getMenuConf, setThemeConf } = useThemeStore();
261
+ const getCollapsedShowTitle = computed$1(() => getMenuConf.collapsedShowTitle);
262
+ const getIsSidebarType = computed$1(() => getMenuConf.type === MenuType.SIDE);
263
+ const getMenuFixed = computed$1(() => getMenuConf.fixed);
264
+ const getShowMenu = computed$1(() => getMenuConf.show);
265
+ const getShowSidebar = computed$1(() => {
266
+ return unref$1(getSplit) || unref$1(getShowMenu) && unref$1(getMenuMode) !== MenuMode.HORIZONTAL;
267
+ });
268
+ const getMenuHidden = computed$1(() => getMenuConf.hidden);
269
+ const getMenuTheme = computed$1(() => getMenuConf.theme);
270
+ const getTrigger = computed$1(() => getMenuConf.trigger);
271
+ const getCanDrag = computed$1(() => getMenuConf.canDrag);
272
+ const getIsMixMode = computed$1(() => {
273
+ return unref$1(getMenuMode) === MenuMode.INLINE && unref$1(getMenuType) === MenuType.MIX;
274
+ });
275
+ const getMenuWidth = computed$1(() => unref$1(getIsMixMode) ? Number(getMenuConf.menuWidth) - 40 : getMenuConf.menuWidth);
276
+ const getLogoWidth = computed$1(() => getMenuConf.menuWidth);
277
+ const getMenuType = computed$1(() => getMenuConf.type);
278
+ const getIsTopMenu = computed$1(() => unref$1(getMenuType) === MenuType.TOP_MENU);
279
+ const getMenuMode = computed$1(() => getMenuConf.mode);
280
+ const getSplit = computed$1(() => getMenuConf.split);
281
+ const getCollapsed = computed$1(() => getMenuConf.collapsed);
282
+ const getIsHorizontal = computed$1(() => unref$1(getMenuMode) === MenuMode.HORIZONTAL);
283
+ const setThemeStore = (conf = {}) => setThemeConf(conf);
284
+ const toggleCollapsed = () => setThemeStore({
285
+ menuOptions: {
286
+ collapsed: !unref$1(getCollapsed)
287
+ }
288
+ });
289
+ const getMiniWidthNumber = computed$1(() => getMenuConf.collapsedShowTitle ? 80 : 48);
290
+ const getRealWidth = computed$1(() => {
291
+ return unref$1(getCollapsed) ? unref$1(getMiniWidthNumber) : unref$1(getMenuWidth);
292
+ });
293
+ const getCalcContentWidth = computed$1(() => {
294
+ const width = unref$1(getIsTopMenu) || !unref$1(getShowMenu) || unref$1(getSplit) && unref$1(getMenuHidden) ? 0 : unref$1(getRealWidth);
295
+ return `calc(100% - ${unref$1(width)}px)`;
296
+ });
297
+ return {
298
+ getCollapsedShowTitle,
299
+ getIsSidebarType,
300
+ getMenuFixed,
301
+ getShowMenu,
302
+ getShowSidebar,
303
+ getMenuHidden,
304
+ getMenuTheme,
305
+ getTrigger,
306
+ getMenuWidth,
307
+ getLogoWidth,
308
+ getMenuType,
309
+ getIsTopMenu,
310
+ getMenuMode,
311
+ getSplit,
312
+ getCollapsed,
313
+ getIsHorizontal,
314
+ getMiniWidthNumber,
315
+ getRealWidth,
316
+ getCalcContentWidth,
317
+ getIsMixMode,
318
+ getCanDrag,
319
+ toggleCollapsed,
320
+ setThemeStore
321
+ };
322
+ }
323
+ function useMultipleTab() {
324
+ const { getRouteReuseConf } = useThemeStore();
325
+ const getShowMultipleTab = computed(() => getRouteReuseConf.show);
326
+ const getShowQuick = computed(() => getRouteReuseConf.showQuick);
327
+ const getShowRedo = computed(() => getRouteReuseConf.showRedo);
328
+ const getCanCache = computed(() => getRouteReuseConf.cache);
329
+ const getCanDrag = computed(() => getRouteReuseConf.canDrag);
330
+ return {
331
+ getShowMultipleTab,
332
+ getShowQuick,
333
+ getShowRedo,
334
+ getCanCache,
335
+ getCanDrag
336
+ };
337
+ }
338
+ function useHeader() {
339
+ const HEADER_HEIGHT = 48;
340
+ const TABS_HEIGHT = 33;
341
+ const { getHeaderConf = {} } = useThemeStore();
342
+ const {
343
+ getIsSidebarType,
344
+ getMenuType,
345
+ getShowMenu,
346
+ getMenuHidden,
347
+ getTrigger,
348
+ getMenuMode,
349
+ getSplit,
350
+ getIsTopMenu,
351
+ getIsMixMode
352
+ } = useMenu();
353
+ const { getShowMultipleTab } = useMultipleTab();
354
+ const getHeaderTheme = computed$1(() => getHeaderConf.theme);
355
+ const getFixed = computed$1(() => getHeaderConf.fixed);
356
+ const getShowHeaderLogo = computed$1(() => unref$1(getShowLogo) && !unref$1(getIsSidebarType));
357
+ const getShowSearch = computed$1(() => getHeaderConf.showSearch);
358
+ const getShowHeaderTrigger = computed$1(() => {
359
+ if (unref$1(getMenuType) === MenuType.TOP_MENU || !unref$1(getShowMenu) || unref$1(getMenuHidden)) {
360
+ return false;
361
+ }
362
+ return unref$1(getTrigger);
363
+ });
364
+ const getShowBreadCrumb = computed$1(() => getHeaderConf.showBreadCrumb);
365
+ const getShowBread = computed$1(
366
+ () => unref$1(getMenuMode) !== MenuMode.HORIZONTAL && !unref$1(getSplit) && unref$1(getShowBreadCrumb)
367
+ );
368
+ const getShowTopMenu = computed$1(() => unref$1(getMenuMode) === MenuMode.HORIZONTAL || unref$1(getSplit));
369
+ const getShowNotice = computed$1(() => getHeaderConf.showNotice);
370
+ const getShowFullScreen = computed$1(() => getHeaderConf.showFullScreen);
371
+ const getShowLocale = computed$1(() => getHeaderConf.showLocaleSwitch);
372
+ const getShowSettingTheme = computed$1(() => getHeaderConf.showSettingTheme);
373
+ const getShowFullHeaderRef = computed$1(() => {
374
+ return !unref$1(getIsSidebarType) && !unref$1(getIsTopMenu);
375
+ });
376
+ const getHeaderHeight = computed$1(() => {
377
+ let height = 0;
378
+ height += HEADER_HEIGHT;
379
+ if (unref$1(getShowMultipleTab) && !unref$1(getSplit)) {
380
+ height += TABS_HEIGHT;
381
+ }
382
+ return height;
383
+ });
384
+ const getTabsHeight = computed$1(() => TABS_HEIGHT);
385
+ const getShowInsetHeaderRef = computed$1(() => {
386
+ return unref$1(getIsSidebarType) || unref$1(getIsTopMenu);
387
+ });
388
+ const getShowBackToTop = computed$1(() => getHeaderConf.showBackToTop);
389
+ const getIsZH = computed$1(() => {
390
+ let local = DtCache.getLocal(CacheKey.LOCALE);
391
+ if (!local)
392
+ return true;
393
+ return local === Language.ZH;
394
+ });
395
+ const getUiSize = computed$1(() => getHeaderConf?.size ?? UiSize.SMALL);
396
+ const getShowUiSize = computed$1(() => getHeaderConf?.showSize);
397
+ const getShowLogo = computed$1(() => getHeaderConf.showLogo);
398
+ const getShowLoginOut = computed$1(() => getHeaderConf.showLoginOut);
399
+ const loginOutClick = getHeaderConf.logoutClick;
400
+ return {
401
+ getHeaderTheme,
402
+ getFixed,
403
+ getShowSearch,
404
+ getShowHeaderLogo,
405
+ getShowHeaderTrigger,
406
+ getShowBread,
407
+ getShowTopMenu,
408
+ getShowFullScreen,
409
+ getShowLocale,
410
+ getShowSettingTheme,
411
+ getShowNotice,
412
+ getShowFullHeaderRef,
413
+ getHeaderHeight,
414
+ getTabsHeight,
415
+ getShowInsetHeaderRef,
416
+ getShowBackToTop,
417
+ getIsZH,
418
+ getUiSize,
419
+ getShowLogo,
420
+ getShowLoginOut,
421
+ getShowUiSize,
422
+ loginOutClick
423
+ };
424
+ }
425
+ function useLabelWidth(schemaItemRef, propsRef) {
426
+ const { getIsZH } = useHeader();
427
+ const { appConf } = useAppStore();
428
+ return computed(() => {
429
+ const { labelWidth, enLabelWidth, labelCol = {}, wrapperCol = {} } = unref(schemaItemRef);
430
+ const {
431
+ labelWidth: gLabelWidth,
432
+ enLabelWidth: gEnLabelWidth,
433
+ labelCol: glabelCol = {},
434
+ wrapperCol: gwrapperCol = {},
435
+ layout = appConf.ui.form.layout
436
+ } = unref(propsRef);
437
+ let width = (unref(getIsZH) ? labelWidth ?? gLabelWidth : enLabelWidth ?? gEnLabelWidth) ?? labelWidth ?? gLabelWidth ?? 0;
438
+ const labelcol = { ...glabelCol, ...labelCol };
439
+ const wrapcol = { ...gwrapperCol, ...wrapperCol };
440
+ width = isNumber(width) ? `${width}px` : width;
441
+ return {
442
+ labelCol: {
443
+ style: { width },
444
+ ...labelcol
445
+ },
446
+ wrapperCol: {
447
+ style: { width: layout === "vertical" ? "100%" : `calc(100% - ${width})` },
448
+ ...wrapcol
449
+ }
450
+ };
451
+ });
452
+ }
453
+ const SINGLE_DATA_TYPE = ["DatePicker", "MonthPicker", "WeekPicker", "TimePicker"];
454
+ const MULTIFY_DATA_TYPE = ["RangePicker"];
455
+ const DATE_PICKER_TYPES = [...SINGLE_DATA_TYPE, ...MULTIFY_DATA_TYPE];
456
+ function createPlaceholder(component) {
457
+ const { t } = useI18n("UI");
458
+ if (component.includes("Input") || component.includes("Complete")) {
459
+ return t("PLEASE_INPUT");
460
+ }
461
+ if (component.includes("Picker") || component.includes("Select") || component.includes("Cascader") || component.includes("Checkbox") || component.includes("Radio") || component.includes("Switch")) {
462
+ return t("PLEASE_SELECT");
463
+ }
464
+ if (component.includes("Icon")) {
465
+ return t("PLEASE_SET_ICON");
466
+ }
467
+ return "";
468
+ }
469
+ function setComponentRuleType(rule, component, valueFormat) {
470
+ if (SINGLE_DATA_TYPE.includes(component)) {
471
+ rule.type = valueFormat ? "string" : "object";
472
+ } else if (["RangePicker", "Upload", "CheckboxGroup", "TimePicker"].includes(component)) {
473
+ rule.type = "array";
474
+ } else if (["InputNumber"].includes(component)) {
475
+ rule.type = "number";
476
+ }
477
+ }
478
+ function handleInputNumberValue(component, val) {
479
+ if (!component)
480
+ return val;
481
+ if ([
482
+ "Input",
483
+ "InputPassword",
484
+ "InputSearch",
485
+ "InputTextArea"
486
+ ].includes(component)) {
487
+ return val && isNumber(val) ? `${val}` : val;
488
+ }
489
+ return val;
490
+ }
491
+ const index = "";
492
+ function useFormValue(props, key = "value", changeEvent = "change", emitData) {
493
+ const instance = getCurrentInstance();
494
+ const emit = instance?.emit;
495
+ const innerState = reactive$1({
496
+ value: props[key]
497
+ });
498
+ const defaultState = readonly(innerState);
499
+ const setState = (val) => {
500
+ innerState.value = val;
501
+ nextTick$1(() => {
502
+ emit?.(changeEvent, val, ...toRaw$1(unref$1(emitData)) || []);
503
+ });
504
+ };
505
+ watchEffect(() => {
506
+ innerState.value = props[key];
507
+ });
508
+ const state = computed$1({
509
+ get() {
510
+ return innerState.value;
511
+ },
512
+ set(value) {
513
+ if (isEqual(value, defaultState.value))
514
+ return;
515
+ innerState.value = value;
516
+ nextTick$1(() => {
517
+ emit?.(changeEvent, value, ...toRaw$1(unref$1(emitData)) || []);
518
+ });
519
+ }
520
+ });
521
+ return [state, setState, defaultState];
522
+ }
523
+ const _sfc_main$4 = /* @__PURE__ */ defineComponent$1({
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$1(() => {
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$1(attrs), {
551
+ value: unref$1(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$1(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$1({
576
+ __name: "formInputUseDialog",
577
+ setup(__props) {
578
+ const { t } = useI18n("UI");
579
+ const attrs = useAttrs$1();
580
+ const bindProps = computed$1(() => {
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$1(Input), normalizeProps(guardReactiveProps(unref$1(bindProps))), null, 16)
604
+ ]),
605
+ unref$1(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 = defineComponent({
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$1({
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$1(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,
1125
+ disabled: button.disabled,
1126
+ key: unref$1(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$1(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$1(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(unref$1(advancedRef) ? unref$1(t)("UI.ADVANCED") : unref$1(t)("UI.EXPAND")), 1),
1154
+ createElementVNode("span", {
1155
+ class: normalizeClass(unref$1(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(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(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(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 index2 = schemaList.findIndex((schema) => schema.name === name);
1270
+ if (index2 !== -1) {
1271
+ delete formModel[name];
1272
+ schemaList.splice(index2, 1);
1273
+ }
1274
+ }
1275
+ function appendFormItems(schema, prefixName, first = false) {
1276
+ const schemaList = cloneDeep(unref(getSchema));
1277
+ const index2 = schemaList.findIndex((schema2) => schema2.name === prefixName);
1278
+ if (!prefixName || index2 === -1 || first) {
1279
+ first ? schemaList.unshift(...schema) : schemaList.push(...schema);
1280
+ schemaRef.value = schemaList;
1281
+ return;
1282
+ }
1283
+ if (index2 !== -1) {
1284
+ schemaList.splice(index2 + 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$1(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$1(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, index2) => obj[key] = vals[index2] ?? 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, index2) => {
1425
+ if (!defaultValue2 || defaultValue2.length - 1 < index2) {
1426
+ obj[key] = null;
1427
+ } else {
1428
+ obj[key] = defaultValue2[index2];
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, index2) => {
1461
+ if (index2 > 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
+ },
1518
+ wrapperCol: {
1519
+ type: Object,
1520
+ default: () => {
1521
+ }
1522
+ },
1523
+ rowProps: {
1524
+ type: Object,
1525
+ default: () => {
1526
+ }
1527
+ },
1528
+ colProps: {
1529
+ type: Object,
1530
+ default: () => {
1531
+ }
1532
+ },
1533
+ size: {
1534
+ type: String,
1535
+ default: "small"
1536
+ },
1537
+ disabled: {
1538
+ type: Boolean,
1539
+ default: false
1540
+ },
1541
+ compact: {
1542
+ type: Boolean,
1543
+ default: null
1544
+ },
1545
+ schemas: {
1546
+ type: Array,
1547
+ default: () => []
1548
+ },
1549
+ autoSearchOnEnter: {
1550
+ type: Boolean,
1551
+ default: true
1552
+ },
1553
+ alwaysShowLines: {
1554
+ type: Boolean,
1555
+ default: false
1556
+ },
1557
+ minShowColumn: {
1558
+ type: Number,
1559
+ default: 2
1560
+ },
1561
+ showAdvancedButton: {
1562
+ type: Boolean,
1563
+ default: true
1564
+ },
1565
+ allowClear: {
1566
+ type: Boolean,
1567
+ default: true
1568
+ },
1569
+ scrollToFirstError: {
1570
+ type: Boolean,
1571
+ default: true
1572
+ },
1573
+ colon: {
1574
+ type: Boolean,
1575
+ default: true
1576
+ },
1577
+ loading: {
1578
+ type: Object,
1579
+ default: () => {
1580
+ return {
1581
+ onSearch: ref(false),
1582
+ onReset: ref(false)
1583
+ };
1584
+ }
1585
+ },
1586
+ onSearch: {
1587
+ type: Function,
1588
+ default: (params) => {
1589
+ }
1590
+ },
1591
+ onReset: {
1592
+ type: Function,
1593
+ default: (params) => {
1594
+ }
1595
+ },
1596
+ buttons: {
1597
+ type: [Array, null, Boolean],
1598
+ default: false
1599
+ },
1600
+ resetFunc: {
1601
+ type: Function
1602
+ },
1603
+ registerInstance: {
1604
+ type: Function
1605
+ }
1606
+ };
1607
+ const _sfc_main = /* @__PURE__ */ defineComponent$1({
1608
+ __name: "index",
1609
+ props: BasicProps,
1610
+ emits: ["register"],
1611
+ setup(__props, { emit: emits }) {
1612
+ const props = __props;
1613
+ const { getAppConf } = useAppStore();
1614
+ const attrs = useAttrs();
1615
+ const formElRef = ref(null);
1616
+ const formModel = reactive({});
1617
+ const defaultValue = ref({});
1618
+ const propsRef = ref();
1619
+ const schemaRef = ref(null);
1620
+ const getProps = computed(() => {
1621
+ return {
1622
+ ...props,
1623
+ ...getAppConf.ui.form,
1624
+ ...unref(propsRef)
1625
+ };
1626
+ });
1627
+ const getBindValue = computed(() => {
1628
+ return {
1629
+ ...attrs,
1630
+ ...unref(getProps)
1631
+ };
1632
+ });
1633
+ const getSchema = computed(() => {
1634
+ return unref(schemaRef) || unref(getProps).schemas;
1635
+ });
1636
+ const getFormClass = computed(() => {
1637
+ const { compact, mode } = unref(getProps);
1638
+ const getCompact = compact === null ? mode === "dialog" ? false : true : compact;
1639
+ return [
1640
+ "basic-form",
1641
+ `basic-form__${mode}`,
1642
+ {
1643
+ "basic-form__compact": getCompact
1644
+ }
1645
+ ];
1646
+ });
1647
+ function setProps(formProps) {
1648
+ propsRef.value = deepMerge(unref(propsRef) || {}, formProps);
1649
+ return null;
1650
+ }
1651
+ function setFormModel(key, value) {
1652
+ formModel[key] = value;
1653
+ const { validateTrigger } = unref(getBindValue);
1654
+ if (!validateTrigger || validateTrigger === "change") {
1655
+ validateFields([key]);
1656
+ }
1657
+ }
1658
+ function handleEnterPress() {
1659
+ }
1660
+ const { initDefault, handleFormValues } = useFormValues({
1661
+ defaultValue,
1662
+ getSchema,
1663
+ formModel
1664
+ });
1665
+ const {
1666
+ updateSchema,
1667
+ resetSchema,
1668
+ clearValidate,
1669
+ resetForms,
1670
+ removeFormByName,
1671
+ setFormValues,
1672
+ appendFormItems,
1673
+ validate,
1674
+ validateFields,
1675
+ getFormValues
1676
+ } = useFormEvents({
1677
+ emits,
1678
+ getSchema,
1679
+ formModel,
1680
+ formElRef,
1681
+ defaultValue,
1682
+ schemaRef,
1683
+ getProps,
1684
+ handleFormValues
1685
+ });
1686
+ const formActionMethods = {
1687
+ setProps,
1688
+ updateSchema,
1689
+ resetSchema,
1690
+ clearValidate,
1691
+ resetForms,
1692
+ removeFormByName,
1693
+ setFormValues,
1694
+ appendFormItems,
1695
+ validate,
1696
+ validateFields,
1697
+ getFormValues
1698
+ };
1699
+ const getActionsProps = computed(() => {
1700
+ const {
1701
+ mode,
1702
+ minShowColumn = getAppConf.ui.form.minShowColumn || 2,
1703
+ schemas = [],
1704
+ showAdvancedButton: advanced,
1705
+ loading,
1706
+ buttons
1707
+ } = unref(getProps);
1708
+ let showAdvancedButton = mode === "search" ? true : false;
1709
+ if (advanced !== void 0) {
1710
+ showAdvancedButton = advanced;
1711
+ }
1712
+ if (schemas.length <= minShowColumn) {
1713
+ showAdvancedButton = false;
1714
+ }
1715
+ let buttonList = [];
1716
+ if (isArray(buttons)) {
1717
+ buttonList = [...buttons];
1718
+ } else if (mode === "search" && !buttons) {
1719
+ SEARCH_BTNS.forEach((it) => {
1720
+ it.loading = it.name === SEARCH_BTN_NAME ? loading?.onSearch : loading?.onReset;
1721
+ buttonList.push(it);
1722
+ });
1723
+ }
1724
+ let colspan = mode === "search" ? getAppConf.ui.form.searchColspan : getAppConf.ui.form.dialogColspan;
1725
+ return {
1726
+ ...colspan,
1727
+ ...{
1728
+ showAdvancedButton,
1729
+ buttonList
1730
+ }
1731
+ };
1732
+ });
1733
+ const [handleMethod] = useFormActions({
1734
+ getProps,
1735
+ defaultValue,
1736
+ updateSchema,
1737
+ getFormValues,
1738
+ setFormValues
1739
+ });
1740
+ onMounted(() => {
1741
+ setFormValues(null);
1742
+ emits("register", formActionMethods);
1743
+ initDefault();
1744
+ });
1745
+ watch(
1746
+ () => unref(getProps).onSearch,
1747
+ () => {
1748
+ useTimeoutFn(() => {
1749
+ const { onSearch, autoFetch } = unref(getProps);
1750
+ if (autoFetch && onSearch && isFunction(onSearch)) {
1751
+ onSearch(toRaw(defaultValue.value));
1752
+ }
1753
+ }, 1);
1754
+ }
1755
+ );
1756
+ watch(
1757
+ () => unref(getProps).model,
1758
+ (v) => {
1759
+ const { model } = unref(getProps);
1760
+ if (!model || !Object.keys(model).length)
1761
+ return;
1762
+ setFormValues(model);
1763
+ },
1764
+ {
1765
+ immediate: true,
1766
+ deep: true
1767
+ }
1768
+ );
1769
+ return (_ctx, _cache) => {
1770
+ const _component_ARow = Row;
1771
+ const _component_AForm = Form$1;
1772
+ return openBlock(), createBlock(_component_AForm, mergeProps(unref$1(getBindValue), {
1773
+ ref_key: "formElRef",
1774
+ ref: formElRef,
1775
+ class: unref$1(getFormClass),
1776
+ model: unref$1(formModel),
1777
+ layout: unref$1(getProps).layout,
1778
+ onKeypress: withKeys(handleEnterPress, ["enter"])
1779
+ }), {
1780
+ default: withCtx(() => [
1781
+ createVNode(_component_ARow, mergeProps(unref$1(getProps).rowProps, { style: {
1782
+ margin: 0
1783
+ } }), {
1784
+ default: withCtx(() => [
1785
+ (openBlock(true), createElementBlock(Fragment, null, renderList(unref$1(getSchema), (schema) => {
1786
+ return openBlock(), createBlock(unref$1(_sfc_main$2), {
1787
+ key: schema.name,
1788
+ schema,
1789
+ formProps: unref$1(getProps),
1790
+ formModel: unref$1(formModel),
1791
+ defaultValues: unref$1(defaultValue),
1792
+ setFormModel,
1793
+ formActionType: formActionMethods
1794
+ }, createSlots({ _: 2 }, [
1795
+ renderList(Object.keys(_ctx.$slots), (item) => {
1796
+ return {
1797
+ name: item,
1798
+ fn: withCtx((data) => [
1799
+ renderSlot(_ctx.$slots, item, normalizeProps(guardReactiveProps(data || {})))
1800
+ ])
1801
+ };
1802
+ })
1803
+ ]), 1032, ["schema", "formProps", "formModel", "defaultValues"]);
1804
+ }), 128)),
1805
+ unref$1(getActionsProps).buttonList?.length ? (openBlock(), createBlock(unref$1(_sfc_main$1), mergeProps({ key: 0 }, unref$1(getActionsProps), { onHandleMethod: unref$1(handleMethod) }), null, 16, ["onHandleMethod"])) : createCommentVNode("", true)
1806
+ ]),
1807
+ _: 3
1808
+ }, 16)
1809
+ ]),
1810
+ _: 3
1811
+ }, 16, ["class", "model", "layout", "onKeypress"]);
1812
+ };
1813
+ }
1814
+ });
1815
+ function useForm(props) {
1816
+ const formRef = ref(null);
1817
+ const loadedRef = ref(false);
1818
+ function register(instance) {
1819
+ if (unref(loadedRef) && instance === unref(formRef))
1820
+ return;
1821
+ formRef.value = instance;
1822
+ loadedRef.value = true;
1823
+ watch(
1824
+ () => props,
1825
+ () => props && instance.setProps(props),
1826
+ {
1827
+ immediate: true,
1828
+ deep: true
1829
+ }
1830
+ );
1831
+ }
1832
+ async function getForm() {
1833
+ const form = unref(formRef);
1834
+ if (!form)
1835
+ console.error("\u8868\u5355\u672A\u7533\u660E!");
1836
+ await nextTick();
1837
+ return form;
1838
+ }
1839
+ const methods = {
1840
+ setProps: async (props2) => {
1841
+ const form = await getForm();
1842
+ form.setProps(props2);
1843
+ },
1844
+ updateSchema: async (data) => {
1845
+ const form = await getForm();
1846
+ form.updateSchema(data);
1847
+ },
1848
+ resetSchema: async (data) => {
1849
+ const form = await getForm();
1850
+ form.resetSchema(data);
1851
+ },
1852
+ clearValidate: async (name) => {
1853
+ const form = await getForm();
1854
+ form.clearValidate(name);
1855
+ },
1856
+ resetForms: async () => {
1857
+ const form = await getForm();
1858
+ form.resetForms();
1859
+ },
1860
+ removeFormByName: async (name) => {
1861
+ unref(formRef)?.removeFormByName(name);
1862
+ },
1863
+ setFormValues: async (values) => {
1864
+ const form = await getForm();
1865
+ form.setFormValues(values);
1866
+ },
1867
+ appendFormItems: async (schema, prefixName, first) => {
1868
+ const form = await getForm();
1869
+ form.appendFormItems(schema, prefixName, first);
1870
+ },
1871
+ validate: async (nameList) => {
1872
+ const form = await getForm();
1873
+ return form.validate(nameList);
1874
+ },
1875
+ validateFields: async (nameList) => {
1876
+ const form = await getForm();
1877
+ return form.validateFields(nameList);
1878
+ },
1879
+ getFormValues: () => {
1880
+ return unref(formRef)?.getFormValues();
1881
+ }
1882
+ };
1883
+ return [register, methods];
1884
+ }
1885
+ const withInstall = (comp) => {
1886
+ comp.install = (app) => {
1887
+ app.component(comp.name, comp);
1888
+ };
1889
+ return comp;
1890
+ };
1891
+ const DtForm = withInstall(_sfc_main);
1892
+ export {
1893
+ DtForm,
1894
+ useForm
1895
+ };