@dt-frames/ui 2.0.1 → 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,3098 @@
1
+ import { toRaw as toRaw$1, unref as unref$1, computed as computed$1, getCurrentInstance as getCurrentInstance$1, reactive as reactive$1, readonly, watchEffect as watchEffect$1, 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, ref as ref$1, inject, onUnmounted as onUnmounted$1, h as h$1, resolveDynamicComponent } from "vue";
2
+ import { RadioButton, RadioGroup, Button, FormItem as FormItem$1, Col as Col$1, Row, Form as Form$1, Tooltip as Tooltip$1, Spin } from "ant-design-vue/es";
3
+ import "ant-design-vue/es/form/style";
4
+ import { DtCache, CacheKey, deepMerge, Pages, useGo, useRedo, Language, useAppStore, isNumber, useI18n, isString, isFunction, error, useSlots, isArray, isBoolean, isNull, dispatchResize, isObject, isNullAndUnDef, useTimeoutFn, useApp, off, on, windowResizeFn, useMessage } 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, Modal as Modal$1 } 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$3 = "";
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$2 = "";
492
+ function useFormValue(props, key = "value", changeEvent = "change", emitData) {
493
+ const instance = getCurrentInstance$1();
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$1(() => {
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$c = /* @__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$2 = { class: "input-with-dialog" };
575
+ const _sfc_main$b = /* @__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$2, [
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$b,
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$c,
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$1(s) {
646
+ return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s);
647
+ }
648
+ const _sfc_main$a = 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$1(_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$1(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 on2 = {
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
+ on2[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
+ ...on2
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$1(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$1(_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$1(_slot2 = getContent()) ? _slot2 : {
1005
+ default: () => [_slot2]
1006
+ });
1007
+ };
1008
+ }
1009
+ });
1010
+ const _hoisted_1$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$9 = /* @__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$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$8 = /* @__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$a), {
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$9), 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$8);
1892
+ const orgDialogProp = reactive({});
1893
+ const cbTransfer = reactive({});
1894
+ const dataTransfer = reactive({});
1895
+ function useModalOut() {
1896
+ const modal = ref(null);
1897
+ const loaded = ref(true);
1898
+ const uid = ref(null);
1899
+ const { isProd } = useApp();
1900
+ function register(modalMethod, uuid) {
1901
+ if (!getCurrentInstance()) {
1902
+ throw new Error("useModal\u53EA\u80FD\u5728setup()\u6216\u8005\u51FD\u6570\u4E2D\u4F7F\u7528");
1903
+ }
1904
+ uid.value = uuid;
1905
+ onUnmounted(() => {
1906
+ if (unref(isProd)) {
1907
+ modal.value = null;
1908
+ loaded.value = false;
1909
+ dataTransfer[unref(uid)] = null;
1910
+ orgDialogProp[unref(uid)] = null;
1911
+ cbTransfer[unref(uid)] = (res) => {
1912
+ };
1913
+ }
1914
+ });
1915
+ if (unref(loaded) && modalMethod === unref(modal))
1916
+ return;
1917
+ modal.value = modalMethod;
1918
+ loaded.value = true;
1919
+ }
1920
+ const getInstance = () => {
1921
+ const instance = unref(modal);
1922
+ if (!instance) {
1923
+ error("useModalOut \u5B9E\u4F8B\u672A\u5B9A\u4E49");
1924
+ }
1925
+ return instance;
1926
+ };
1927
+ const methods = {
1928
+ setModalProps: (props) => {
1929
+ getInstance()?.setModalProps(props);
1930
+ },
1931
+ redoModalHeight: () => {
1932
+ getInstance()?.redoModalHeight?.();
1933
+ },
1934
+ openModal: (params, afterClose) => {
1935
+ const id = unref(uid);
1936
+ dataTransfer[id] = isObject(params) ? { ...toRaw(params) } : params;
1937
+ getInstance()?.setModalProps({
1938
+ footer: [],
1939
+ defaultFullscreen: false,
1940
+ ...orgDialogProp[id],
1941
+ visible: true
1942
+ });
1943
+ cbTransfer[id] = (res) => {
1944
+ if (afterClose && isFunction(afterClose)) {
1945
+ afterClose(res);
1946
+ }
1947
+ };
1948
+ },
1949
+ closeModal: () => {
1950
+ getInstance()?.setModalProps({ visible: false });
1951
+ }
1952
+ };
1953
+ return [register, methods];
1954
+ }
1955
+ function useModal(props, setModalData) {
1956
+ const modalInstanceRef = ref(null);
1957
+ const currentInstance = getCurrentInstance();
1958
+ const uidRef = ref(null);
1959
+ const { isProd } = useApp();
1960
+ const getInstance = () => {
1961
+ const instance = unref(modalInstanceRef);
1962
+ if (!instance) {
1963
+ error("useModal \u5B9E\u4F8B\u672A\u5B9A\u4E49");
1964
+ }
1965
+ return instance;
1966
+ };
1967
+ const register = (modalInstance, uuid) => {
1968
+ if (unref(isProd)) {
1969
+ modalInstanceRef.value = null;
1970
+ }
1971
+ uidRef.value = uuid;
1972
+ modalInstanceRef.value = modalInstance;
1973
+ currentInstance?.emit("register", modalInstance, uuid);
1974
+ orgDialogProp[uuid] = toRaw(props);
1975
+ modalInstance.setModalProps(props);
1976
+ };
1977
+ watchEffect(() => {
1978
+ const data = dataTransfer[unref(uidRef)];
1979
+ if (!data)
1980
+ return;
1981
+ if (!setModalData || !isFunction(setModalData))
1982
+ return;
1983
+ nextTick(() => {
1984
+ setModalData(data);
1985
+ });
1986
+ });
1987
+ const methods = {
1988
+ setLoading: (loading = true) => {
1989
+ getInstance()?.setModalProps({ loading });
1990
+ },
1991
+ closeModal: (rsp) => {
1992
+ if (cbTransfer[unref(uidRef)])
1993
+ cbTransfer[unref(uidRef)](rsp);
1994
+ getInstance()?.setModalProps({ visible: false });
1995
+ },
1996
+ setModalProps: (props2) => {
1997
+ getInstance()?.setModalProps(props2);
1998
+ },
1999
+ redoModalHeight: () => {
2000
+ const callRedo = getInstance()?.redoModalHeight;
2001
+ callRedo && callRedo();
2002
+ }
2003
+ };
2004
+ return [register, methods];
2005
+ }
2006
+ const index$1 = "";
2007
+ const basicProps$1 = {
2008
+ t: {
2009
+ type: String
2010
+ },
2011
+ visible: {
2012
+ type: Boolean
2013
+ },
2014
+ closable: {
2015
+ type: Boolean,
2016
+ default: true
2017
+ },
2018
+ destroyOnClose: {
2019
+ type: Boolean
2020
+ },
2021
+ scrollTop: {
2022
+ type: Boolean,
2023
+ default: true
2024
+ },
2025
+ height: { type: Number },
2026
+ minHeight: { type: Number },
2027
+ width: { type: [String, Number] },
2028
+ draggable: {
2029
+ type: Boolean,
2030
+ default: true
2031
+ },
2032
+ defaultFullscreen: {
2033
+ type: Boolean
2034
+ },
2035
+ canFullscreen: {
2036
+ type: Boolean,
2037
+ default: true
2038
+ },
2039
+ title: {
2040
+ type: String
2041
+ },
2042
+ loading: { type: Boolean, default: false },
2043
+ loadingTip: { type: String, default: "\u52A0\u8F7D\u4E2D..." },
2044
+ useWrapper: {
2045
+ type: Boolean,
2046
+ default: true
2047
+ },
2048
+ wrapClassName: { type: String },
2049
+ zIndex: { type: Number },
2050
+ centered: { type: Boolean },
2051
+ showOkBtn: {
2052
+ type: Boolean,
2053
+ default: true
2054
+ },
2055
+ showCancelBtn: {
2056
+ type: Boolean,
2057
+ default: true
2058
+ },
2059
+ okText: {
2060
+ type: String
2061
+ },
2062
+ cancelText: {
2063
+ type: String
2064
+ },
2065
+ mask: { type: Boolean, default: true },
2066
+ maskClosable: { type: Boolean, default: true },
2067
+ keyboard: { type: Boolean, default: true },
2068
+ maskStyle: Object,
2069
+ footer: {
2070
+ type: Object
2071
+ },
2072
+ bodyStyle: Object,
2073
+ wrapperProps: Object,
2074
+ getContainer: Function,
2075
+ closeFunc: Function,
2076
+ afterClose: Function
2077
+ };
2078
+ function useDragMove(context) {
2079
+ const getStyle = (dom, attr) => {
2080
+ return getComputedStyle(dom)[attr];
2081
+ };
2082
+ const drag = (wrap) => {
2083
+ if (!wrap)
2084
+ return;
2085
+ wrap.setAttribute("data-drag", unref(context.draggable));
2086
+ const dialogHeaderEl = wrap.querySelector(".ant-modal-header");
2087
+ const dragDom = wrap.querySelector(".ant-modal");
2088
+ if (!dialogHeaderEl || !dragDom || !unref(context.draggable))
2089
+ return;
2090
+ dialogHeaderEl.style.cursor = "move";
2091
+ dialogHeaderEl.onmousedown = (e) => {
2092
+ if (!e)
2093
+ return;
2094
+ const disX = e.clientX;
2095
+ const disY = e.clientY;
2096
+ const screenWidth = document.body.clientWidth;
2097
+ const screenHeight = document.documentElement.clientHeight;
2098
+ const dragDomWidth = dragDom.offsetWidth;
2099
+ const dragDomheight = dragDom.offsetHeight;
2100
+ console.log(dragDomWidth, dragDomheight, screenHeight, screenWidth);
2101
+ const minDragDomLeft = dragDom.offsetLeft;
2102
+ const maxDragDomLeft = screenWidth - dragDom.offsetLeft - dragDomWidth;
2103
+ const minDragDomTop = dragDom.offsetTop;
2104
+ const maxDragDomTop = screenHeight - dragDom.offsetTop - dragDomheight;
2105
+ const domLeft = getStyle(dragDom, "left");
2106
+ const domTop = getStyle(dragDom, "top");
2107
+ let styL = +domLeft;
2108
+ let styT = +domTop;
2109
+ if (domLeft.includes("%")) {
2110
+ styL = +document.body.clientWidth * (+domLeft.replace(/%/g, "") / 100);
2111
+ styT = +document.body.clientHeight * (+domTop.replace(/%/g, "") / 100);
2112
+ } else {
2113
+ styL = +domLeft.replace(/px/g, "");
2114
+ styT = +domTop.replace(/px/g, "");
2115
+ }
2116
+ document.onmousemove = function(e2) {
2117
+ let left = e2.clientX - disX;
2118
+ let top = e2.clientY - disY;
2119
+ if (-left > minDragDomLeft) {
2120
+ left = -minDragDomLeft;
2121
+ } else if (left > maxDragDomLeft) {
2122
+ left = maxDragDomLeft;
2123
+ }
2124
+ if (-top > minDragDomTop) {
2125
+ top = -minDragDomTop;
2126
+ } else if (top > maxDragDomTop) {
2127
+ top = maxDragDomTop;
2128
+ }
2129
+ dragDom.style.cssText += `;left:${left + styL}px;top:${top + styT}px;`;
2130
+ };
2131
+ document.onmouseup = () => {
2132
+ document.onmousemove = null;
2133
+ document.onmouseup = null;
2134
+ };
2135
+ };
2136
+ };
2137
+ const handleDrag = () => {
2138
+ const dragWraps = document.querySelectorAll(".ant-modal-wrap");
2139
+ for (const wrap of Array.from(dragWraps)) {
2140
+ if (!wrap)
2141
+ continue;
2142
+ const display = getStyle(wrap, "display");
2143
+ const draggable = wrap.getAttribute("data-drag");
2144
+ if (display !== "none") {
2145
+ if (draggable === null || unref(context.destroyOnClose)) {
2146
+ drag(wrap);
2147
+ }
2148
+ }
2149
+ }
2150
+ };
2151
+ watchEffect(() => {
2152
+ if (!unref(context.visible) || !unref(context.draggable)) {
2153
+ return;
2154
+ }
2155
+ useTimeoutFn(() => {
2156
+ handleDrag();
2157
+ }, 30);
2158
+ });
2159
+ }
2160
+ function _isSlot(s) {
2161
+ return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s);
2162
+ }
2163
+ const Modal = defineComponent({
2164
+ name: "Modal",
2165
+ inheritAttrs: false,
2166
+ props: basicProps$1,
2167
+ emits: ["cancel"],
2168
+ setup(props, {
2169
+ slots,
2170
+ emit
2171
+ }) {
2172
+ const {
2173
+ visible,
2174
+ draggable,
2175
+ destroyOnClose
2176
+ } = toRefs(props);
2177
+ const attrs = useAttrs();
2178
+ useDragMove({
2179
+ visible,
2180
+ destroyOnClose,
2181
+ draggable
2182
+ });
2183
+ const {
2184
+ extendSlots
2185
+ } = useSlots();
2186
+ const onCancel = (e) => emit("cancel", e);
2187
+ return () => {
2188
+ let _slot;
2189
+ const propsData = {
2190
+ ...unref(attrs),
2191
+ ...props,
2192
+ destroyOnClose: true,
2193
+ onCancel
2194
+ };
2195
+ if (!propsData?.visible)
2196
+ return null;
2197
+ return createVNode(Modal$1, propsData, _isSlot(_slot = extendSlots(slots)) ? _slot : {
2198
+ default: () => [_slot]
2199
+ });
2200
+ };
2201
+ }
2202
+ });
2203
+ const index = "";
2204
+ const _sfc_main$7 = /* @__PURE__ */ defineComponent$1({
2205
+ __name: "CloseIcon",
2206
+ props: {
2207
+ canFullscreen: { type: Boolean, default: true },
2208
+ fullScreen: { type: Boolean }
2209
+ },
2210
+ emits: ["cancel", "fullscreen"],
2211
+ setup(__props, { emit }) {
2212
+ const props = __props;
2213
+ const { t } = useI18n("UI");
2214
+ const getClass = computed(() => {
2215
+ return [
2216
+ "dt-basic-modal-close",
2217
+ `dt-basic-modal-close--custom`,
2218
+ {
2219
+ [`dt-basic-modal-close--can-full`]: props.canFullscreen
2220
+ }
2221
+ ];
2222
+ });
2223
+ function handleCancel(e) {
2224
+ emit("cancel", e);
2225
+ }
2226
+ function handleFullScreen(e) {
2227
+ e?.stopPropagation();
2228
+ e?.preventDefault();
2229
+ emit("fullscreen");
2230
+ }
2231
+ return (_ctx, _cache) => {
2232
+ const _component_ATooltip = Tooltip$1;
2233
+ return openBlock(), createElementBlock("div", {
2234
+ class: normalizeClass(["flex h-14 items-center justify-center", unref$1(getClass)])
2235
+ }, [
2236
+ __props.canFullscreen ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
2237
+ __props.fullScreen ? (openBlock(), createBlock(_component_ATooltip, {
2238
+ key: 0,
2239
+ title: unref$1(t)("EXIT_FULLSCREEN"),
2240
+ placement: "bottom"
2241
+ }, {
2242
+ default: withCtx(() => [
2243
+ createElementVNode("i", {
2244
+ class: "i ic:baseline-fullscreen-exit hover:font-bold inline-block w-10 h-14 pr-4",
2245
+ onClick: handleFullScreen
2246
+ })
2247
+ ]),
2248
+ _: 1
2249
+ }, 8, ["title"])) : (openBlock(), createBlock(_component_ATooltip, {
2250
+ key: 1,
2251
+ title: unref$1(t)("FULLSCREEN"),
2252
+ placement: "bottom"
2253
+ }, {
2254
+ default: withCtx(() => [
2255
+ createElementVNode("i", {
2256
+ class: "i ic:baseline-fullscreen hover:font-bold inline-block h-14 w-10 pr-4",
2257
+ onClick: handleFullScreen
2258
+ })
2259
+ ]),
2260
+ _: 1
2261
+ }, 8, ["title"]))
2262
+ ], 64)) : createCommentVNode("", true),
2263
+ createElementVNode("i", {
2264
+ class: "i mdi:close h-14 w-10 pr-4",
2265
+ onClick: handleCancel
2266
+ })
2267
+ ], 2);
2268
+ };
2269
+ }
2270
+ });
2271
+ const isServer = typeof window === "undefined";
2272
+ const BAR_MAP = {
2273
+ vertical: {
2274
+ offset: "offsetHeight",
2275
+ scroll: "scrollTop",
2276
+ scrollSize: "scrollHeight",
2277
+ size: "height",
2278
+ key: "vertical",
2279
+ axis: "Y",
2280
+ client: "clientY",
2281
+ direction: "top"
2282
+ },
2283
+ horizontal: {
2284
+ offset: "offsetWidth",
2285
+ scroll: "scrollLeft",
2286
+ scrollSize: "scrollWidth",
2287
+ size: "width",
2288
+ key: "horizontal",
2289
+ axis: "X",
2290
+ client: "clientX",
2291
+ direction: "left"
2292
+ }
2293
+ };
2294
+ function renderThumbStyle({ move, size, bar }) {
2295
+ const style = {};
2296
+ const translate = `translate${bar.axis}(${move}%)`;
2297
+ style[bar.size] = size;
2298
+ style.transform = translate;
2299
+ style.msTransform = translate;
2300
+ style.webkitTransform = translate;
2301
+ return style;
2302
+ }
2303
+ function resizeHandler(entries) {
2304
+ for (const entry of entries) {
2305
+ const listeners = entry.target.__resizeListeners__ || [];
2306
+ if (listeners.length) {
2307
+ listeners.forEach((fn) => {
2308
+ fn();
2309
+ });
2310
+ }
2311
+ }
2312
+ }
2313
+ function addResizeListener(element, fn) {
2314
+ if (isServer)
2315
+ return;
2316
+ if (!element.__resizeListeners__) {
2317
+ element.__resizeListeners__ = [];
2318
+ element.__ro__ = new ResizeObserver(resizeHandler);
2319
+ element.__ro__.observe(element);
2320
+ }
2321
+ element.__resizeListeners__.push(fn);
2322
+ }
2323
+ function removeResizeListener(element, fn) {
2324
+ if (!element || !element.__resizeListeners__)
2325
+ return;
2326
+ element.__resizeListeners__.splice(element.__resizeListeners__.indexOf(fn), 1);
2327
+ if (!element.__resizeListeners__.length) {
2328
+ element.__ro__.disconnect();
2329
+ }
2330
+ }
2331
+ const Bar = defineComponent$1({
2332
+ name: "Bar",
2333
+ props: {
2334
+ vertical: Boolean,
2335
+ size: String,
2336
+ move: Number
2337
+ },
2338
+ setup(props) {
2339
+ const instance = getCurrentInstance$1();
2340
+ const thumb = ref$1();
2341
+ const wrap = inject("scroll-bar-wrap", {});
2342
+ const bar = computed$1(() => {
2343
+ return BAR_MAP[props.vertical ? "vertical" : "horizontal"];
2344
+ });
2345
+ const barStore = ref$1({});
2346
+ const cursorDown = ref$1();
2347
+ const clickThumbHandler = (e) => {
2348
+ if (e.ctrlKey || e.button === 2) {
2349
+ return;
2350
+ }
2351
+ window.getSelection()?.removeAllRanges();
2352
+ startDrag(e);
2353
+ barStore.value[bar.value.axis] = e.currentTarget[bar.value.offset] - (e[bar.value.client] - e.currentTarget.getBoundingClientRect()[bar.value.direction]);
2354
+ };
2355
+ const clickTrackHandler = (e) => {
2356
+ const offset = Math.abs(
2357
+ e.target.getBoundingClientRect()[bar.value.direction] - e[bar.value.client]
2358
+ );
2359
+ const thumbHalf = thumb.value[bar.value.offset] / 2;
2360
+ const thumbPositionPercentage = (offset - thumbHalf) * 100 / instance?.vnode.el?.[bar.value.offset];
2361
+ wrap.value[bar.value.scroll] = thumbPositionPercentage * wrap.value[bar.value.scrollSize] / 100;
2362
+ };
2363
+ const startDrag = (e) => {
2364
+ e.stopImmediatePropagation();
2365
+ cursorDown.value = true;
2366
+ on(document, "mousemove", mouseMoveDocumentHandler);
2367
+ on(document, "mouseup", mouseUpDocumentHandler);
2368
+ document.onselectstart = () => false;
2369
+ };
2370
+ const mouseMoveDocumentHandler = (e) => {
2371
+ if (cursorDown.value === false)
2372
+ return;
2373
+ const prevPage = barStore.value[bar.value.axis];
2374
+ if (!prevPage)
2375
+ return;
2376
+ const offset = (instance?.vnode.el?.getBoundingClientRect()[bar.value.direction] - e[bar.value.client]) * -1;
2377
+ const thumbClickPosition = thumb.value[bar.value.offset] - prevPage;
2378
+ const thumbPositionPercentage = (offset - thumbClickPosition) * 100 / instance?.vnode.el?.[bar.value.offset];
2379
+ wrap.value[bar.value.scroll] = thumbPositionPercentage * wrap.value[bar.value.scrollSize] / 100;
2380
+ };
2381
+ function mouseUpDocumentHandler() {
2382
+ cursorDown.value = false;
2383
+ barStore.value[bar.value.axis] = 0;
2384
+ off(document, "mousemove", mouseMoveDocumentHandler);
2385
+ document.onselectstart = null;
2386
+ }
2387
+ onUnmounted$1(() => {
2388
+ off(document, "mouseup", mouseUpDocumentHandler);
2389
+ });
2390
+ return () => h$1(
2391
+ "div",
2392
+ {
2393
+ class: ["scrollbar__bar", "is-" + bar.value.key],
2394
+ onMousedown: clickTrackHandler
2395
+ },
2396
+ h$1("div", {
2397
+ ref: thumb,
2398
+ class: "scrollbar__thumb",
2399
+ onMousedown: clickThumbHandler,
2400
+ style: renderThumbStyle({
2401
+ size: props.size,
2402
+ move: props.move,
2403
+ bar: bar.value
2404
+ })
2405
+ })
2406
+ );
2407
+ }
2408
+ });
2409
+ const _hoisted_1 = { class: "scrollbar relative h-full overflow-hidden" };
2410
+ const _sfc_main$6 = /* @__PURE__ */ defineComponent$1({
2411
+ __name: "scroll-bar",
2412
+ props: {
2413
+ wrapClass: {
2414
+ type: [String, Array],
2415
+ default: ""
2416
+ },
2417
+ wrapStyle: Array,
2418
+ viewClass: {
2419
+ type: [String, Array],
2420
+ default: ""
2421
+ },
2422
+ viewStyle: {
2423
+ type: [String, Array],
2424
+ default: ""
2425
+ },
2426
+ noresize: Boolean,
2427
+ tag: {
2428
+ type: String,
2429
+ default: "div"
2430
+ }
2431
+ },
2432
+ setup(__props) {
2433
+ const props = __props;
2434
+ const sizeWidth = ref("0");
2435
+ const sizeHeight = ref("0");
2436
+ const moveX = ref(0);
2437
+ const moveY = ref(0);
2438
+ const wrap = ref();
2439
+ const resize = ref();
2440
+ provide("scroll-bar-wrap", wrap);
2441
+ const style = computed(() => {
2442
+ let rsStyle = {};
2443
+ if (Array.isArray(props.wrapStyle)) {
2444
+ props.wrapStyle.forEach((it) => {
2445
+ if (it)
2446
+ rsStyle = Object.assign({}, rsStyle, it);
2447
+ });
2448
+ }
2449
+ return rsStyle;
2450
+ });
2451
+ const handleScroll = () => {
2452
+ moveY.value = unref(wrap).scrollTop * 100 / unref(wrap).clientHeight;
2453
+ moveX.value = unref(wrap).scrollLeft * 100 / unref(wrap).clientWidth;
2454
+ };
2455
+ const update = () => {
2456
+ if (!unref(wrap))
2457
+ return;
2458
+ const heightPercentage = unref(wrap).clientHeight * 100 / unref(wrap).scrollHeight;
2459
+ const widthPercentage = unref(wrap).clientWidth * 100 / unref(wrap).scrollWidth;
2460
+ sizeHeight.value = heightPercentage < 100 ? heightPercentage + "%" : "";
2461
+ sizeWidth.value = widthPercentage < 100 ? widthPercentage + "%" : "";
2462
+ };
2463
+ onMounted(() => {
2464
+ nextTick(update);
2465
+ if (!props.noresize) {
2466
+ addResizeListener(unref(resize), update);
2467
+ addResizeListener(unref(wrap), update);
2468
+ addEventListener("resize", update);
2469
+ }
2470
+ });
2471
+ onBeforeUnmount(() => {
2472
+ if (!props.noresize) {
2473
+ removeResizeListener(unref(resize), update);
2474
+ removeResizeListener(unref(wrap), update);
2475
+ removeEventListener("resize", update);
2476
+ }
2477
+ });
2478
+ return (_ctx, _cache) => {
2479
+ return openBlock(), createElementBlock("div", _hoisted_1, [
2480
+ createElementVNode("div", {
2481
+ ref_key: "wrap",
2482
+ ref: wrap,
2483
+ class: normalizeClass([[__props.wrapClass, "scrollbar__wrap--hidden-default"], "h-full overflow-auto"]),
2484
+ style: normalizeStyle(unref$1(style)),
2485
+ onScroll: handleScroll
2486
+ }, [
2487
+ (openBlock(), createBlock(resolveDynamicComponent(__props.tag), {
2488
+ class: normalizeClass(["box-border", __props.viewClass]),
2489
+ ref_key: "resize",
2490
+ ref: resize,
2491
+ style: normalizeStyle(__props.viewStyle)
2492
+ }, {
2493
+ default: withCtx(() => [
2494
+ renderSlot(_ctx.$slots, "default")
2495
+ ]),
2496
+ _: 3
2497
+ }, 8, ["class", "style"]))
2498
+ ], 38),
2499
+ createVNode(unref$1(Bar), {
2500
+ move: unref$1(moveX),
2501
+ size: unref$1(sizeWidth)
2502
+ }, null, 8, ["move", "size"]),
2503
+ createVNode(unref$1(Bar), {
2504
+ vertical: "",
2505
+ move: unref$1(moveY),
2506
+ size: unref$1(sizeHeight)
2507
+ }, null, 8, ["move", "size"])
2508
+ ]);
2509
+ };
2510
+ }
2511
+ });
2512
+ const _sfc_main$5 = /* @__PURE__ */ defineComponent$1({
2513
+ __name: "scroll-container",
2514
+ setup(__props) {
2515
+ const scrollbarRef = ref(null);
2516
+ return (_ctx, _cache) => {
2517
+ return openBlock(), createBlock(_sfc_main$6, mergeProps({
2518
+ ref_key: "scrollbarRef",
2519
+ ref: scrollbarRef
2520
+ }, _ctx.$attrs, { class: "w-full h-full" }), {
2521
+ default: withCtx(() => [
2522
+ renderSlot(_ctx.$slots, "default")
2523
+ ]),
2524
+ _: 3
2525
+ }, 16);
2526
+ };
2527
+ }
2528
+ });
2529
+ const _sfc_main$4 = defineComponent({
2530
+ name: "slot-container",
2531
+ props: {
2532
+ template: {
2533
+ type: Function
2534
+ },
2535
+ data: {
2536
+ type: Object
2537
+ }
2538
+ },
2539
+ setup(props) {
2540
+ return () => {
2541
+ return h("div", [props.template(props.data)]);
2542
+ };
2543
+ }
2544
+ });
2545
+ const DtScrollContainer = withInstall(_sfc_main$5);
2546
+ withInstall(_sfc_main$4);
2547
+ const _sfc_main$3 = /* @__PURE__ */ defineComponent$1({
2548
+ __name: "ModalWrap",
2549
+ props: {
2550
+ useWrapper: { type: Boolean, default: true },
2551
+ modalHeaderHeight: { type: Number, default: 55 },
2552
+ modalFooterHeight: { type: Number, default: 58 },
2553
+ minHeight: { type: Number, default: 200 },
2554
+ height: { type: Number },
2555
+ visible: { type: Boolean },
2556
+ fullScreen: { type: Boolean }
2557
+ },
2558
+ emits: ["ext-height", "height-change"],
2559
+ setup(__props, { emit: emits }) {
2560
+ const props = __props;
2561
+ const wrapperRef = ref(null);
2562
+ const wrapRef = ref(null);
2563
+ const realHeightRef = ref(0);
2564
+ const minRealHeightRef = ref(0);
2565
+ let realHeight = 0;
2566
+ const wrapStyle = computed(() => {
2567
+ return {
2568
+ minHeight: `${props.minHeight}px`,
2569
+ [props.fullScreen ? "height" : "maxHeight"]: `${unref(realHeightRef)}px`
2570
+ };
2571
+ });
2572
+ onMounted(() => {
2573
+ const { modalHeaderHeight, modalFooterHeight } = props;
2574
+ emits("ext-height", modalHeaderHeight + modalFooterHeight);
2575
+ });
2576
+ async function getModalDom() {
2577
+ const wrapperRefDom = unref(wrapperRef);
2578
+ if (!wrapperRefDom)
2579
+ return;
2580
+ const bodyDom = wrapperRefDom.$el.parentElement;
2581
+ if (!bodyDom)
2582
+ return;
2583
+ bodyDom.style.padding = "0";
2584
+ await nextTick();
2585
+ const modalDom = bodyDom.parentElement && bodyDom.parentElement.parentElement;
2586
+ return modalDom;
2587
+ }
2588
+ async function setModalHeight() {
2589
+ if (!props.visible)
2590
+ return;
2591
+ try {
2592
+ const modalDom = await getModalDom();
2593
+ if (!modalDom)
2594
+ return;
2595
+ const modalRect = getComputedStyle(modalDom).top;
2596
+ const modalTop = Number.parseInt(modalRect);
2597
+ let maxHeight = window.innerHeight - props.modalFooterHeight - props.modalHeaderHeight - 100;
2598
+ if (modalTop < 40) {
2599
+ maxHeight -= 26;
2600
+ }
2601
+ await nextTick();
2602
+ const warpEl = unref(wrapRef);
2603
+ if (!warpEl)
2604
+ return;
2605
+ await nextTick();
2606
+ realHeight = warpEl.scrollHeight;
2607
+ if (props.fullScreen) {
2608
+ realHeightRef.value = window.innerHeight - props.modalFooterHeight - props.modalHeaderHeight;
2609
+ } else {
2610
+ realHeightRef.value = props.height ? props.height : realHeight > maxHeight ? maxHeight : realHeight;
2611
+ }
2612
+ emits("height-change", unref(realHeightRef));
2613
+ const _modalDom = await getModalDom();
2614
+ _modalDom.style.top = (window.innerHeight - _modalDom.offsetHeight) / 2 + "px";
2615
+ } catch (error2) {
2616
+ console.log(error2);
2617
+ }
2618
+ }
2619
+ windowResizeFn(setModalHeight.bind(null, false));
2620
+ watchEffect(() => {
2621
+ props.useWrapper && setModalHeight();
2622
+ });
2623
+ watch(
2624
+ () => props.fullScreen,
2625
+ (v) => {
2626
+ setModalHeight();
2627
+ if (!v) {
2628
+ realHeightRef.value = minRealHeightRef.value;
2629
+ } else {
2630
+ minRealHeightRef.value = realHeightRef.value;
2631
+ }
2632
+ }
2633
+ );
2634
+ return (_ctx, _cache) => {
2635
+ return openBlock(), createBlock(unref$1(DtScrollContainer), {
2636
+ ref_key: "wrapperRef",
2637
+ ref: wrapperRef
2638
+ }, {
2639
+ default: withCtx(() => [
2640
+ createElementVNode("div", {
2641
+ ref_key: "wrapRef",
2642
+ ref: wrapRef,
2643
+ style: normalizeStyle(unref$1(wrapStyle))
2644
+ }, [
2645
+ renderSlot(_ctx.$slots, "default")
2646
+ ], 4)
2647
+ ]),
2648
+ _: 3
2649
+ }, 512);
2650
+ };
2651
+ }
2652
+ });
2653
+ const _sfc_main$2 = /* @__PURE__ */ defineComponent$1({
2654
+ __name: "ModalFooter",
2655
+ props: {
2656
+ buttons: Object,
2657
+ showSave: { type: Boolean, default: true },
2658
+ showCancel: { type: Boolean, default: true },
2659
+ okText: { type: String },
2660
+ cancelText: { type: String }
2661
+ },
2662
+ emits: [
2663
+ "handleSave",
2664
+ "handleCancel"
2665
+ ],
2666
+ setup(__props, { emit: emits }) {
2667
+ const props = __props;
2668
+ const { t } = useI18n("UI");
2669
+ const buttonList = computed$1(() => {
2670
+ if (props.buttons && props.buttons.length)
2671
+ return props.buttons;
2672
+ let buttonActions = [
2673
+ { t: "\u4FDD\u5B58", name: props.okText || t("SAVE"), preIcon: "mdi:content-save", type: "primary", flag: "OK" },
2674
+ { t: "\u5173\u95ED", name: props.cancelText || t("CLOSE"), preIcon: "mdi:close", flag: "CANCEL" }
2675
+ ];
2676
+ if (!props.showSave)
2677
+ buttonActions = buttonActions.filter((btn) => btn.flag !== "OK");
2678
+ if (!props.showCancel)
2679
+ buttonActions = buttonActions.filter((btn) => btn.flag !== "CANCEL");
2680
+ return buttonActions;
2681
+ });
2682
+ function handleMethod(item) {
2683
+ switch (item.flag) {
2684
+ case "OK":
2685
+ emits("handleSave");
2686
+ break;
2687
+ case "CANCEL":
2688
+ emits("handleCancel");
2689
+ break;
2690
+ }
2691
+ }
2692
+ return (_ctx, _cache) => {
2693
+ return openBlock(), createElementBlock(Fragment, null, [
2694
+ renderSlot(_ctx.$slots, "appendFooter"),
2695
+ createVNode(_sfc_main$9, {
2696
+ mode: "dialog",
2697
+ buttonList: unref$1(buttonList),
2698
+ onHandleMethod: _cache[0] || (_cache[0] = ($event) => handleMethod($event))
2699
+ }, null, 8, ["buttonList"])
2700
+ ], 64);
2701
+ };
2702
+ }
2703
+ });
2704
+ function useFullScreen(wrapClassName) {
2705
+ const fullScreenRef = ref(false);
2706
+ const getWrapClassName = computed(() => {
2707
+ const clsName = unref(wrapClassName) || "";
2708
+ const cls = unref(fullScreenRef) ? `fullscreen-modal ${clsName} ` : unref(clsName);
2709
+ return `dt-modal ${cls}`;
2710
+ });
2711
+ function toggleFullScreen(e) {
2712
+ e && e.stopPropagation();
2713
+ fullScreenRef.value = !unref(fullScreenRef);
2714
+ dispatchResize();
2715
+ }
2716
+ return {
2717
+ fullScreenRef,
2718
+ getWrapClassName,
2719
+ toggleFullScreen
2720
+ };
2721
+ }
2722
+ const _sfc_main$1 = /* @__PURE__ */ defineComponent$1({
2723
+ __name: "index",
2724
+ props: basicProps$1,
2725
+ emits: ["visible-change", "height-change", "cancel", "save", "register", "update:visible"],
2726
+ setup(__props, { emit: emits }) {
2727
+ const props = __props;
2728
+ const visibleRef = ref(false);
2729
+ const propsRef = ref();
2730
+ const modalWrapperRef = ref(null);
2731
+ const { getWrapClassName, toggleFullScreen, fullScreenRef } = useFullScreen(computed(() => unref(propsRef)?.wrapClassName));
2732
+ const getMergeProps = computed(() => {
2733
+ return {
2734
+ ...props,
2735
+ ...unref(propsRef)
2736
+ };
2737
+ });
2738
+ const getBindValue = computed(() => {
2739
+ const bindValue = {
2740
+ ...unref(getMergeProps),
2741
+ ...unref(propsRef),
2742
+ visible: unref(visibleRef),
2743
+ wrapClassName: unref(getWrapClassName)
2744
+ };
2745
+ let omitArr = unref(fullScreenRef) ? ["height", "title"] : ["title"];
2746
+ if (isArray(unref(propsRef)?.footer)) {
2747
+ omitArr.push("footer");
2748
+ }
2749
+ return omit(bindValue, omitArr);
2750
+ });
2751
+ const getWrapperHeight = computed(() => {
2752
+ if (unref(fullScreenRef))
2753
+ return void 0;
2754
+ return unref(getBindValue).height;
2755
+ });
2756
+ const modalFooterHeight = computed(() => {
2757
+ if (isArray(props.footer)) {
2758
+ return (unref(propsRef)?.footer).length ? 0 : void 0;
2759
+ }
2760
+ return props?.footer !== void 0 && !props.footer ? 0 : void 0;
2761
+ });
2762
+ const modalMethods = {
2763
+ setModalProps,
2764
+ redoModalHeight: () => {
2765
+ nextTick(() => {
2766
+ if (unref(modalWrapperRef)) {
2767
+ unref(modalWrapperRef).setModalHeight();
2768
+ }
2769
+ });
2770
+ }
2771
+ };
2772
+ const instance = getCurrentInstance();
2773
+ if (instance) {
2774
+ emits("register", modalMethods, instance.uid);
2775
+ }
2776
+ function handleHeightChange(height) {
2777
+ emits("height-change", height);
2778
+ }
2779
+ function setModalProps(props2) {
2780
+ propsRef.value = deepMerge(unref(propsRef) || {}, props2);
2781
+ if (Reflect.has(props2, "visible")) {
2782
+ visibleRef.value = !!props2.visible;
2783
+ }
2784
+ if (Reflect.has(props2, "defaultFullscreen")) {
2785
+ fullScreenRef.value = !!props2.defaultFullscreen;
2786
+ }
2787
+ }
2788
+ function handleSave() {
2789
+ emits("save");
2790
+ }
2791
+ async function handleCancel(e = null) {
2792
+ if (e) {
2793
+ e?.stopPropagation();
2794
+ if (e.target?.classList?.contains("dt-basic-modal-close--custom"))
2795
+ return;
2796
+ if (props.closeFunc && isFunction(props.closeFunc)) {
2797
+ const isClose = await props.closeFunc();
2798
+ visibleRef.value = !isClose;
2799
+ return;
2800
+ }
2801
+ }
2802
+ const { afterClose } = unref(getBindValue);
2803
+ if (afterClose && isFunction(afterClose)) {
2804
+ afterClose();
2805
+ }
2806
+ visibleRef.value = false;
2807
+ emits("cancel", e);
2808
+ }
2809
+ watch(() => unref(visibleRef), (v) => {
2810
+ emits("visible-change", v);
2811
+ emits("update:visible", v);
2812
+ nextTick(() => {
2813
+ if (props.scrollTop && v && unref(modalWrapperRef)) {
2814
+ unref(modalWrapperRef).$el.scrollTop = 0;
2815
+ }
2816
+ });
2817
+ }, {
2818
+ immediate: false
2819
+ });
2820
+ return (_ctx, _cache) => {
2821
+ const _component_ASpin = Spin;
2822
+ return openBlock(), createBlock(unref$1(Modal), mergeProps(unref$1(getBindValue), { onCancel: handleCancel }), createSlots({
2823
+ default: withCtx(() => [
2824
+ createVNode(_component_ASpin, {
2825
+ spinning: unref$1(getBindValue).loading,
2826
+ tip: unref$1(getBindValue).loadingTip
2827
+ }, {
2828
+ default: withCtx(() => [
2829
+ createVNode(_sfc_main$3, mergeProps({
2830
+ useWrapper: unref$1(getBindValue).useWrapper,
2831
+ fullScreen: unref$1(fullScreenRef),
2832
+ ref_key: "modalWrapperRef",
2833
+ ref: modalWrapperRef,
2834
+ minHeight: unref$1(getBindValue).minHeight,
2835
+ height: unref$1(getWrapperHeight),
2836
+ visible: unref$1(visibleRef),
2837
+ modalFooterHeight: unref$1(modalFooterHeight)
2838
+ }, unref$1(omit)(unref$1(getBindValue).wrapperProps, "visible", "height", "modalFooterHeight"), { onHeightChange: handleHeightChange }), {
2839
+ default: withCtx(() => [
2840
+ renderSlot(_ctx.$slots, "default")
2841
+ ]),
2842
+ _: 3
2843
+ }, 16, ["useWrapper", "fullScreen", "minHeight", "height", "visible", "modalFooterHeight"])
2844
+ ]),
2845
+ _: 3
2846
+ }, 8, ["spinning", "tip"])
2847
+ ]),
2848
+ _: 2
2849
+ }, [
2850
+ !_ctx.$slots.closeIcon ? {
2851
+ name: "closeIcon",
2852
+ fn: withCtx(() => [
2853
+ createVNode(_sfc_main$7, {
2854
+ canFullscreen: unref$1(getBindValue).canFullscreen,
2855
+ fullScreen: unref$1(fullScreenRef),
2856
+ onCancel: handleCancel,
2857
+ onFullscreen: unref$1(toggleFullScreen)
2858
+ }, null, 8, ["canFullscreen", "fullScreen", "onFullscreen"])
2859
+ ]),
2860
+ key: "0"
2861
+ } : void 0,
2862
+ !_ctx.$slots.title ? {
2863
+ name: "title",
2864
+ fn: withCtx(() => [
2865
+ createTextVNode(toDisplayString(unref$1(getMergeProps).title), 1)
2866
+ ]),
2867
+ key: "1"
2868
+ } : void 0,
2869
+ !_ctx.$slots.footer ? {
2870
+ name: "footer",
2871
+ fn: withCtx(() => [
2872
+ createVNode(_sfc_main$2, {
2873
+ buttons: unref$1(propsRef)?.footer,
2874
+ showSave: unref$1(getBindValue).showOkBtn,
2875
+ showCancel: unref$1(getBindValue).showCancelBtn,
2876
+ okText: unref$1(getBindValue).okText,
2877
+ cancelText: unref$1(getBindValue).cancelText,
2878
+ onHandleSave: handleSave,
2879
+ onHandleCancel: handleCancel
2880
+ }, createSlots({ _: 2 }, [
2881
+ renderList(Object.keys(_ctx.$slots), (item) => {
2882
+ return {
2883
+ name: item,
2884
+ fn: withCtx((data) => [
2885
+ renderSlot(_ctx.$slots, item, normalizeProps(guardReactiveProps(data || {})))
2886
+ ])
2887
+ };
2888
+ })
2889
+ ]), 1032, ["buttons", "showSave", "showCancel", "okText", "cancelText"])
2890
+ ]),
2891
+ key: "2"
2892
+ } : void 0,
2893
+ renderList(Object.keys(unref$1(omit)(_ctx.$slots, "default")), (item) => {
2894
+ return {
2895
+ name: item,
2896
+ fn: withCtx((data) => [
2897
+ renderSlot(_ctx.$slots, item, normalizeProps(guardReactiveProps(data || {})))
2898
+ ])
2899
+ };
2900
+ })
2901
+ ]), 1040);
2902
+ };
2903
+ }
2904
+ });
2905
+ const basicProps = {
2906
+ title: {
2907
+ type: Object
2908
+ },
2909
+ width: {
2910
+ type: [String, Number],
2911
+ default: "50%"
2912
+ },
2913
+ schemas: {
2914
+ type: Array,
2915
+ default: []
2916
+ },
2917
+ footer: {
2918
+ type: Array,
2919
+ default: void 0
2920
+ },
2921
+ showFullscreen: {
2922
+ type: Boolean,
2923
+ default: true
2924
+ },
2925
+ showClosable: {
2926
+ type: Boolean,
2927
+ default: true
2928
+ },
2929
+ formProps: {
2930
+ type: Object,
2931
+ default: () => ({})
2932
+ },
2933
+ primaryKey: {
2934
+ type: String,
2935
+ default: "id"
2936
+ },
2937
+ actType: {
2938
+ type: Object
2939
+ },
2940
+ onSave: {
2941
+ type: Function,
2942
+ default: () => {
2943
+ }
2944
+ },
2945
+ onDeletes: {
2946
+ type: Function,
2947
+ default: (keys) => {
2948
+ }
2949
+ },
2950
+ onQueryById: {
2951
+ type: Function,
2952
+ default: (id) => {
2953
+ }
2954
+ },
2955
+ onRegister: {
2956
+ type: Object
2957
+ },
2958
+ registerInstance: {
2959
+ type: Function
2960
+ }
2961
+ };
2962
+ const _sfc_main = /* @__PURE__ */ defineComponent$1({
2963
+ __name: "Curd",
2964
+ props: basicProps,
2965
+ setup(__props) {
2966
+ const props = __props;
2967
+ const [registerDialog, { setModalProps }] = useModal({
2968
+ ...omit(toRaw(props), [
2969
+ "curd",
2970
+ "formProps",
2971
+ "schemas"
2972
+ ]),
2973
+ destroyOnClose: true
2974
+ });
2975
+ function handleSave() {
2976
+ props?.onSave();
2977
+ }
2978
+ return (_ctx, _cache) => {
2979
+ return openBlock(), createBlock(unref$1(_sfc_main$1), {
2980
+ onRegister: unref$1(registerDialog),
2981
+ onSave: _cache[0] || (_cache[0] = ($event) => handleSave())
2982
+ }, {
2983
+ default: withCtx(() => [
2984
+ renderSlot(_ctx.$slots, "default")
2985
+ ]),
2986
+ _: 3
2987
+ }, 8, ["onRegister"]);
2988
+ };
2989
+ }
2990
+ });
2991
+ function useCurd(curdOpt) {
2992
+ const [register, {
2993
+ openModal,
2994
+ closeModal,
2995
+ setModalProps
2996
+ }] = useModalOut();
2997
+ const {
2998
+ confirm,
2999
+ message
3000
+ } = useMessage();
3001
+ const {
3002
+ t
3003
+ } = useI18n("UI");
3004
+ const {
3005
+ formProps,
3006
+ schemas
3007
+ } = curdOpt;
3008
+ const oriTitle = isFunction(curdOpt.title) ? curdOpt.title() : unref(curdOpt.title);
3009
+ const title = ref(oriTitle);
3010
+ const [registerForm, curdFormMethods] = useForm({
3011
+ ...formProps || {},
3012
+ schemas,
3013
+ mode: "dialog"
3014
+ });
3015
+ const DtCurdModal = () => {
3016
+ return h(createVNode("div", {
3017
+ "class": "dt-curd-modal"
3018
+ }, [createVNode(_sfc_main, mergeProps(curdOpt, {
3019
+ "title": title,
3020
+ "onRegister": register
3021
+ }), {
3022
+ default: () => [createVNode(DtForm, {
3023
+ "onRegister": registerForm
3024
+ }, null)]
3025
+ })]));
3026
+ };
3027
+ function add() {
3028
+ title.value = t("ADD") + " - " + oriTitle;
3029
+ openModal();
3030
+ }
3031
+ function del({
3032
+ row
3033
+ }) {
3034
+ const {
3035
+ primaryKey = "id",
3036
+ onDeletes
3037
+ } = curdOpt;
3038
+ if (onDeletes && isFunction(onDeletes)) {
3039
+ onDeletes([row[primaryKey]]);
3040
+ }
3041
+ }
3042
+ function update({
3043
+ row
3044
+ }) {
3045
+ const {
3046
+ primaryKey = "id",
3047
+ onQueryById
3048
+ } = curdOpt;
3049
+ title.value = t("EDIT") + " - " + oriTitle;
3050
+ openModal();
3051
+ if (onQueryById && isFunction(onQueryById)) {
3052
+ onQueryById(row[primaryKey]).then((rsp) => {
3053
+ curdFormMethods.setFormValues(rsp);
3054
+ nextTick(() => dispatchResize());
3055
+ });
3056
+ }
3057
+ }
3058
+ function dels(ids = []) {
3059
+ if (!ids.length) {
3060
+ message.error(t("EMPTY"));
3061
+ return;
3062
+ }
3063
+ const {
3064
+ curd
3065
+ } = curdOpt;
3066
+ if (curd && curd.onDeletes && isFunction(curd.onDeletes)) {
3067
+ confirm({
3068
+ title: t("MULTIFY_DELETE_CONFIRM"),
3069
+ content: t("CONFIRM_MULTIFY_DELETE", {
3070
+ length: ids.length
3071
+ }),
3072
+ iconType: "warning",
3073
+ onOk() {
3074
+ curd.onDeletes(ids);
3075
+ }
3076
+ });
3077
+ } else {
3078
+ error(t("NEED_CURD"));
3079
+ }
3080
+ }
3081
+ const instance = {
3082
+ add,
3083
+ del,
3084
+ update,
3085
+ dels,
3086
+ closeModal,
3087
+ setModalProps,
3088
+ curdFormMethods
3089
+ };
3090
+ curdOpt.registerInstance && curdOpt.registerInstance(instance);
3091
+ return {
3092
+ DtCurdModal,
3093
+ ...instance
3094
+ };
3095
+ }
3096
+ export {
3097
+ useCurd
3098
+ };