@dt-frames/ui 2.0.1 → 2.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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 +94 -0
  41. package/es/components/container/index.js +290 -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 +20 -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 +3120 -0
  52. package/es/components/curd/src/components/Curd.d.ts +1246 -0
  53. package/es/components/curd/src/hooks/useCurd.d.ts +112 -0
  54. package/es/components/curd/src/props.d.ts +187 -0
  55. package/es/components/curd/src/types/curd.type.d.ts +19 -0
  56. package/es/components/drawer/index.d.ts +8039 -0
  57. package/es/components/drawer/index.js +838 -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 +11 -0
  61. package/es/components/drawer/src/hooks/useDrawer.d.ts +3 -0
  62. package/es/components/drawer/src/index.d.ts +8041 -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 +3219 -0
  66. package/es/components/form/index.js +1896 -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 +165 -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 +2965 -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 +497 -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 +1193 -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 +108 -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 +774 -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 +332 -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 +3983 -0
  113. package/es/components/table/index.less +192 -0
  114. package/es/components/table/src/components/TableAction.d.ts +70 -0
  115. package/es/components/table/src/components/TableHeader.d.ts +1136 -0
  116. package/es/components/table/src/components/TableRender.d.ts +17 -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 +922 -0
  124. package/es/components/table/src/components/tableSetting/DownloadCtrl.d.ts +888 -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 +1030 -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 +15 -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 +7 -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 +644 -0
  140. package/es/components/table/src/props.d.ts +185 -0
  141. package/es/components/table/src/types/actions.type.d.ts +21 -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 +98 -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 +4 -0
  151. package/es/theme/index.d.ts +10 -0
  152. package/es/theme/index.js +3255 -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 +35 -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 +24 -0
  165. package/es/theme/src/components/header/components/setting-theme.d.ts +223 -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 +37 -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 +699 -0
  177. package/es/theme/src/components/header/multiple-header.d.ts +785 -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 +1643 -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 +3 -6
  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 +51 -0
@@ -0,0 +1,3120 @@
1
+ import { toRaw as toRaw$1, unref as unref$1, computed, getCurrentInstance as getCurrentInstance$1, reactive, readonly, watchEffect, nextTick as nextTick$1, defineComponent, useAttrs, openBlock, createBlock, mergeProps, isRef, withCtx, createElementBlock, Fragment, renderList, createTextVNode, toDisplayString, createElementVNode, createVNode, normalizeProps, guardReactiveProps, createCommentVNode, toRefs, isVNode, ref as ref$1, watch, resolveDirective, normalizeStyle, withDirectives, normalizeClass, onMounted as onMounted$1, withKeys, createSlots, renderSlot, onUnmounted, inject, h, provide, onBeforeUnmount, 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, isEmpty, 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(() => getMenuConf.collapsedShowTitle);
262
+ const getIsSidebarType = computed(() => getMenuConf.type === MenuType.SIDE);
263
+ const getMenuFixed = computed(() => getMenuConf.fixed);
264
+ const getShowMenu = computed(() => getMenuConf.show);
265
+ const getShowSidebar = computed(() => {
266
+ return unref$1(getSplit) || unref$1(getShowMenu) && unref$1(getMenuMode) !== MenuMode.HORIZONTAL;
267
+ });
268
+ const getMenuHidden = computed(() => getMenuConf.hidden);
269
+ const getMenuTheme = computed(() => getMenuConf.theme);
270
+ const getTrigger = computed(() => getMenuConf.trigger);
271
+ const getCanDrag = computed(() => getMenuConf.canDrag);
272
+ const getIsMixMode = computed(() => {
273
+ return unref$1(getMenuMode) === MenuMode.INLINE && unref$1(getMenuType) === MenuType.MIX;
274
+ });
275
+ const getMenuWidth = computed(() => unref$1(getIsMixMode) ? Number(getMenuConf.menuWidth) - 40 : getMenuConf.menuWidth);
276
+ const getLogoWidth = computed(() => getMenuConf.menuWidth);
277
+ const getMenuType = computed(() => getMenuConf.type);
278
+ const getIsTopMenu = computed(() => unref$1(getMenuType) === MenuType.TOP_MENU);
279
+ const getMenuMode = computed(() => getMenuConf.mode);
280
+ const getSplit = computed(() => getMenuConf.split);
281
+ const getCollapsed = computed(() => getMenuConf.collapsed);
282
+ const getIsHorizontal = computed(() => 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(() => getMenuConf.collapsedShowTitle ? 80 : 48);
290
+ const getRealWidth = computed(() => {
291
+ return unref$1(getCollapsed) ? unref$1(getMiniWidthNumber) : unref$1(getMenuWidth);
292
+ });
293
+ const getCalcContentWidth = computed(() => {
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(() => getHeaderConf.theme);
355
+ const getFixed = computed(() => getHeaderConf.fixed);
356
+ const getShowHeaderLogo = computed(() => unref$1(getShowLogo) && !unref$1(getIsSidebarType));
357
+ const getShowSearch = computed(() => getHeaderConf.showSearch);
358
+ const getShowHeaderTrigger = computed(() => {
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(() => getHeaderConf.showBreadCrumb);
365
+ const getShowBread = computed(
366
+ () => unref$1(getMenuMode) !== MenuMode.HORIZONTAL && !unref$1(getSplit) && unref$1(getShowBreadCrumb)
367
+ );
368
+ const getShowTopMenu = computed(() => unref$1(getMenuMode) === MenuMode.HORIZONTAL || unref$1(getSplit));
369
+ const getShowNotice = computed(() => getHeaderConf.showNotice);
370
+ const getShowFullScreen = computed(() => getHeaderConf.showFullScreen);
371
+ const getShowLocale = computed(() => getHeaderConf.showLocaleSwitch);
372
+ const getShowSettingTheme = computed(() => getHeaderConf.showSettingTheme);
373
+ const getShowFullHeaderRef = computed(() => {
374
+ return !unref$1(getIsSidebarType) && !unref$1(getIsTopMenu);
375
+ });
376
+ const getHeaderHeight = computed(() => {
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(() => TABS_HEIGHT);
385
+ const getShowInsetHeaderRef = computed(() => {
386
+ return unref$1(getIsSidebarType) || unref$1(getIsTopMenu);
387
+ });
388
+ const getShowBackToTop = computed(() => getHeaderConf.showBackToTop);
389
+ const getIsZH = computed(() => {
390
+ let local = DtCache.getLocal(CacheKey.LOCALE);
391
+ if (!local)
392
+ return true;
393
+ return local === Language.ZH;
394
+ });
395
+ const getUiSize = computed(() => getHeaderConf?.size ?? UiSize.SMALL);
396
+ const getShowUiSize = computed(() => getHeaderConf?.showSize);
397
+ const getShowLogo = computed(() => getHeaderConf.showLogo);
398
+ const getShowLoginOut = computed(() => 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$1(schemaItemRef);
430
+ const {
431
+ labelWidth: gLabelWidth,
432
+ enLabelWidth: gEnLabelWidth,
433
+ labelCol: glabelCol = {},
434
+ wrapperCol: gwrapperCol = {},
435
+ layout = appConf.ui.form.layout
436
+ } = unref$1(propsRef);
437
+ let width = (unref$1(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({
496
+ value: props[key]
497
+ });
498
+ const defaultState = readonly(innerState);
499
+ const setState = (val) => {
500
+ innerState.value = val;
501
+ nextTick$1(() => {
502
+ emit?.(changeEvent, val, ...toRaw$1(unref$1(emitData)) || []);
503
+ });
504
+ };
505
+ watchEffect(() => {
506
+ innerState.value = props[key];
507
+ });
508
+ const state = computed({
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$d = /* @__PURE__ */ defineComponent({
524
+ __name: "radioButton",
525
+ props: {
526
+ value: {
527
+ type: [String, Number, Boolean]
528
+ },
529
+ options: {
530
+ type: Array,
531
+ default: () => []
532
+ }
533
+ },
534
+ setup(__props) {
535
+ const props = __props;
536
+ const attrs = useAttrs();
537
+ const [state] = useFormValue(props);
538
+ const getOptions = computed(() => {
539
+ const { options } = props;
540
+ if (!options || options?.length === 0)
541
+ return [];
542
+ const isStringArr = options.some((item) => isString(item));
543
+ if (!isStringArr)
544
+ return options;
545
+ return options.map((item) => ({ label: item, value: item }));
546
+ });
547
+ return (_ctx, _cache) => {
548
+ const _component_ARadioButton = RadioButton;
549
+ const _component_ARadioGroup = RadioGroup;
550
+ return openBlock(), createBlock(_component_ARadioGroup, mergeProps(unref$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 _export_sfc = (sfc, props) => {
575
+ const target = sfc.__vccOpts || sfc;
576
+ for (const [key, val] of props) {
577
+ target[key] = val;
578
+ }
579
+ return target;
580
+ };
581
+ const RadioButtonGroup = /* @__PURE__ */ _export_sfc(_sfc_main$d, [["__file", "D:/dt/dt-frame-front/dt-frames/frames/packages/ui/src/components/form/src/components/radioButton.vue"]]);
582
+ const _hoisted_1$2 = { class: "input-with-dialog" };
583
+ const _sfc_main$c = /* @__PURE__ */ defineComponent({
584
+ __name: "formInputUseDialog",
585
+ setup(__props) {
586
+ const { t } = useI18n("UI");
587
+ const attrs = useAttrs();
588
+ const bindProps = computed(() => {
589
+ return {
590
+ ...omit(attrs, [
591
+ "formValues"
592
+ ]),
593
+ disabled: true
594
+ };
595
+ });
596
+ function onClickInput() {
597
+ const { model, schema = {} } = attrs.formValues;
598
+ if (!schema.openDialog || !isFunction(schema.openDialog)) {
599
+ error(t("MUSE_FUNCTION"));
600
+ return;
601
+ }
602
+ schema.openDialog(model);
603
+ }
604
+ function clearProps() {
605
+ const { model, schema = {} } = attrs.formValues;
606
+ [...schema.linkProps, schema.name].forEach((it) => model[it] = null);
607
+ }
608
+ return (_ctx, _cache) => {
609
+ return openBlock(), createElementBlock("div", _hoisted_1$2, [
610
+ createElementVNode("div", { onClick: onClickInput }, [
611
+ createVNode(unref$1(Input), normalizeProps(guardReactiveProps(unref$1(bindProps))), null, 16)
612
+ ]),
613
+ unref$1(attrs).formValues?.schema?.linkProps?.length ? (openBlock(), createElementBlock("i", {
614
+ key: 0,
615
+ class: "i mdi:close-circle",
616
+ onClick: clearProps
617
+ })) : createCommentVNode("v-if", true)
618
+ ]);
619
+ };
620
+ }
621
+ });
622
+ const DtFormInputDialog = /* @__PURE__ */ _export_sfc(_sfc_main$c, [["__file", "D:/dt/dt-frame-front/dt-frames/frames/packages/ui/src/components/form/src/components/formInputUseDialog.vue"]]);
623
+ const components = {
624
+ Input,
625
+ InputWithDialog: DtFormInputDialog,
626
+ InputTextArea: Input.TextArea,
627
+ InputSearch: Input.Search,
628
+ InputGroup: Input.Group,
629
+ InputPassword: Input.Password,
630
+ Select,
631
+ TreeSelect,
632
+ Radio,
633
+ RadioGroup: Radio.Group,
634
+ RadioButtonGroup,
635
+ Checkbox,
636
+ CheckboxGroup: Checkbox.Group,
637
+ AutoComplete,
638
+ Cascader,
639
+ DatePicker,
640
+ MonthPicker: DatePicker.MonthPicker,
641
+ WeekPicker: DatePicker.WeekPicker,
642
+ RangePicker: DatePicker.RangePicker,
643
+ InputNumber,
644
+ Switch,
645
+ TimePicker,
646
+ Slider,
647
+ Rate,
648
+ Divider
649
+ };
650
+ const componentMap = /* @__PURE__ */ new Map();
651
+ for (let item in components) {
652
+ componentMap.set(item, components[item]);
653
+ }
654
+ function _isSlot$1(s) {
655
+ return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s);
656
+ }
657
+ const _sfc_main$b = {
658
+ name: "FormItem",
659
+ inheritAttrs: false,
660
+ props: {
661
+ schema: {
662
+ type: Object,
663
+ default: () => ({})
664
+ },
665
+ formProps: {
666
+ type: Object,
667
+ default: () => ({})
668
+ },
669
+ defaultValues: {
670
+ type: Object,
671
+ default: () => ({})
672
+ },
673
+ formModel: {
674
+ type: Object,
675
+ default: () => ({})
676
+ },
677
+ setFormModel: {
678
+ type: Function
679
+ },
680
+ formActionType: {
681
+ type: Object
682
+ }
683
+ },
684
+ setup(props, {
685
+ emit,
686
+ slots
687
+ }) {
688
+ const {
689
+ getSlot
690
+ } = useSlots();
691
+ const {
692
+ t
693
+ } = useI18n("UI");
694
+ const {
695
+ getUiSize
696
+ } = useHeader();
697
+ const {
698
+ appConf
699
+ } = useAppStore();
700
+ const {
701
+ schema,
702
+ formProps
703
+ } = toRefs(props);
704
+ const getValues = computed(() => {
705
+ const {
706
+ defaultValues,
707
+ formModel,
708
+ schema: schema2
709
+ } = props;
710
+ let name = schema2.name;
711
+ return {
712
+ name: isArray(name) ? name.join("-") : name,
713
+ model: formModel,
714
+ schema: schema2,
715
+ values: {
716
+ ...defaultValues,
717
+ ...formModel
718
+ }
719
+ };
720
+ });
721
+ const getShow = computed(() => {
722
+ const {
723
+ show = true,
724
+ isAdvanced = true
725
+ } = props.schema;
726
+ if (!isAdvanced) {
727
+ return false;
728
+ }
729
+ if (isFunction(show)) {
730
+ return show(unref$1(getValues).model);
731
+ }
732
+ return show;
733
+ });
734
+ const getComponentProps = computed(() => {
735
+ const {
736
+ schema: schema2
737
+ } = props;
738
+ let {
739
+ props: cProps = {}
740
+ } = schema2;
741
+ if (isFunction(cProps)) {
742
+ cProps = cProps(unref$1(getValues).model) ?? {};
743
+ }
744
+ if (schema2.component === "Divider") {
745
+ cProps = Object.assign({
746
+ type: "horizontal"
747
+ }, cProps, {
748
+ orientation: "left"
749
+ });
750
+ }
751
+ return cProps;
752
+ });
753
+ function renderItem() {
754
+ const {
755
+ component,
756
+ slot,
757
+ render,
758
+ name,
759
+ colon = appConf.ui.form.colon,
760
+ suffix,
761
+ prefix
762
+ } = props.schema;
763
+ const {
764
+ labelCol,
765
+ wrapperCol
766
+ } = unref$1(useLabelWidth(schema, formProps));
767
+ const getContent = () => {
768
+ const value = unref$1(getValues);
769
+ let _con = slot ? getSlot(slots, slot, value.model) : render ? render(value.model) : renderFormItem();
770
+ return component === "InputGroup" || component === "Icon" ? createVNode(FormItem, {
771
+ "class": "m-0"
772
+ }, _isSlot$1(_con) ? _con : {
773
+ default: () => [_con]
774
+ }) : _con;
775
+ };
776
+ const getSuffix = () => {
777
+ return isFunction(suffix) ? suffix(unref$1(getValues).model) : suffix;
778
+ };
779
+ const getPrefix = () => {
780
+ return isFunction(prefix) ? prefix(unref$1(getValues).model) : prefix;
781
+ };
782
+ return createVNode(Form.Item, {
783
+ "name": isArray(name) ? name.join("-") : name,
784
+ "colon": colon,
785
+ "class": [unref$1(getUiSize), {
786
+ "suffix-item": !!suffix
787
+ }],
788
+ "label": renderLabel(),
789
+ "rules": handleRules(),
790
+ "labelCol": labelCol,
791
+ "wrapperCol": wrapperCol
792
+ }, {
793
+ default: () => [createVNode("div", {
794
+ "style": "display:flex"
795
+ }, [!!prefix && createVNode("span", {
796
+ "class": "prefix px-2"
797
+ }, [getPrefix()]), createVNode("div", {
798
+ "style": "flex:1; width: 100%;"
799
+ }, [getContent()]), !!suffix && createVNode("span", {
800
+ "class": "suffix px-2"
801
+ }, [getSuffix()])])]
802
+ });
803
+ }
804
+ function renderLabel() {
805
+ const {
806
+ label,
807
+ toolTip,
808
+ subLabel,
809
+ toolTipProps = {}
810
+ } = props.schema;
811
+ const renderLabel2 = subLabel ? createVNode("span", null, [createTextVNode(" "), label, createTextVNode(" "), createVNode("span", {
812
+ "class": "text-secondary opacity-50"
813
+ }, [createTextVNode("("), subLabel, createTextVNode(")")])]) : label;
814
+ const _toolTip = isFunction(toolTip) ? toolTip(unref$1(getValues).model) : toolTip;
815
+ const _toolTipProps = {
816
+ title: renderLabel2,
817
+ autoAdjustOverflow: true,
818
+ placement: "top",
819
+ ...toolTipProps
820
+ };
821
+ return _toolTip ? createVNode("span", null, [createVNode(Tooltip, _toolTipProps, _isSlot$1(renderLabel2) ? renderLabel2 : {
822
+ default: () => [renderLabel2]
823
+ })]) : renderLabel2;
824
+ }
825
+ function renderFormItem() {
826
+ const {
827
+ schema: schema2,
828
+ formModel,
829
+ formActionType
830
+ } = props;
831
+ const {
832
+ component,
833
+ name,
834
+ changeEvent = "change",
835
+ valueField,
836
+ renderComponent,
837
+ props: sProps
838
+ } = props.schema;
839
+ const isCheck = component && ["Switch", "Checkbox"].includes(component);
840
+ const eventKey = `on${upperFirst(changeEvent)}`;
841
+ const _sProps = isFunction(sProps) ? sProps(formModel) : sProps;
842
+ const on2 = {
843
+ [eventKey]: (...args) => {
844
+ const [e] = args;
845
+ const target = e ? e.target : null;
846
+ const value = target ? isCheck ? target.checked : target.value : e;
847
+ if (isString(name)) {
848
+ props.setFormModel(name, value);
849
+ } else if (isArray(name)) {
850
+ name.map((key) => props.setFormModel(key, value));
851
+ }
852
+ if (_sProps && _sProps[eventKey])
853
+ _sProps[eventKey](...args, formModel);
854
+ }
855
+ };
856
+ for (let it in _sProps) {
857
+ if (it.startsWith("on") && it !== eventKey) {
858
+ on2[it] = (...args) => {
859
+ _sProps[it](...args, formModel);
860
+ };
861
+ }
862
+ }
863
+ const getDisable = computed(() => {
864
+ const {
865
+ disabled: gDisabled
866
+ } = props.formProps;
867
+ const {
868
+ disabled
869
+ } = props.schema;
870
+ const {
871
+ disabled: itemDisabled = false
872
+ } = unref$1(getComponentProps);
873
+ let _disabled = !!gDisabled || itemDisabled;
874
+ if (isBoolean(disabled))
875
+ _disabled = disabled;
876
+ if (isFunction(disabled))
877
+ _disabled = disabled(unref$1(getValues).model);
878
+ return _disabled;
879
+ });
880
+ const itemProps = {
881
+ allowClear: _sProps?.allowClear ?? appConf.ui.form.allowClear,
882
+ size: unref$1(getUiSize) === UiSize.MIDDLE ? "default" : unref$1(getUiSize),
883
+ ...unref$1(getComponentProps),
884
+ disabled: unref$1(getDisable)
885
+ };
886
+ if (component === "Select") {
887
+ {
888
+ itemProps.showSearch = true;
889
+ itemProps.optionFilterProp = "label";
890
+ }
891
+ }
892
+ if (!itemProps.disabled && component !== "RangePicker") {
893
+ itemProps.placeholder = unref$1(getComponentProps)?.placeholder || createPlaceholder(component);
894
+ }
895
+ if (["DatePicker", "MonthPicker", "RangePicker"].includes(component)) {
896
+ itemProps.defaultValue = props.formModel[name];
897
+ }
898
+ itemProps.codeName = name;
899
+ itemProps.formValues = unref$1(getValues);
900
+ if (["Select", "DatePicker", "MonthPicker", "WeekPicker", "RangePicker"].includes(component)) {
901
+ itemProps.dropdownClassName += ` ${unref$1(getUiSize)}`;
902
+ }
903
+ const bindValue = {
904
+ [valueField || (isCheck ? "checked" : "value")]: props.formModel[name]
905
+ };
906
+ let compAttr = {
907
+ ...itemProps,
908
+ ...bindValue,
909
+ ...on2
910
+ };
911
+ const Comp = componentMap.get(component);
912
+ if (!renderComponent) {
913
+ return createVNode(Comp, compAttr, null);
914
+ }
915
+ const compSlot = isFunction(renderComponent) ? {
916
+ ...renderComponent(unref$1(getValues))
917
+ } : {
918
+ default: () => renderComponent
919
+ };
920
+ return createVNode(Comp, compAttr, _isSlot$1(compSlot) ? compSlot : {
921
+ default: () => [compSlot]
922
+ });
923
+ }
924
+ function handleRules() {
925
+ const {
926
+ rules: defaultRules = [],
927
+ component,
928
+ label,
929
+ dynamicRules,
930
+ required
931
+ } = props.schema;
932
+ if (!component)
933
+ return [];
934
+ if (isFunction(dynamicRules)) {
935
+ return dynamicRules(unref$1(getValues).model);
936
+ }
937
+ const defaultMsg = createPlaceholder(component) + label;
938
+ let rules = cloneDeep(defaultRules);
939
+ const getRequired = isFunction(required) ? required(unref$1(getValues).model) : required;
940
+ function validator(rule, value) {
941
+ const msg = rule.message || defaultMsg;
942
+ 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) {
943
+ return Promise.reject(msg);
944
+ }
945
+ return Promise.resolve();
946
+ }
947
+ if (!rules || !rules.length) {
948
+ let _required = isBoolean(getRequired) ? getRequired : unref$1(getRequired);
949
+ rules = _required ? [{
950
+ required: _required,
951
+ validator
952
+ }] : [];
953
+ }
954
+ const requiredIndex = rules.findIndex((rule) => Reflect.has(rule, "required") && !Reflect.has(rule, "validator"));
955
+ if (requiredIndex !== -1) {
956
+ const rule = rules[requiredIndex];
957
+ if (!unref$1(getShow)) {
958
+ rule.required = false;
959
+ }
960
+ if (!Reflect.has(rule, "type")) {
961
+ rule.type = component === "InputNumber" ? "number" : "string";
962
+ }
963
+ rule.message = rule.message || defaultMsg;
964
+ if (component.includes("Input") || component.includes("Textarea")) {
965
+ rule.whitespace = true;
966
+ }
967
+ const valueFormat = unref$1(getComponentProps)?.valueFormat;
968
+ setComponentRuleType(rule, component, valueFormat);
969
+ }
970
+ const maxIndex = rules.findIndex((val) => val.max);
971
+ if (maxIndex !== -1 && !rules[maxIndex].validator) {
972
+ rules[maxIndex].message = rules[maxIndex].message || `\u6700\u5927\u503C\u4E3A${rules[maxIndex].max}`;
973
+ }
974
+ return rules;
975
+ }
976
+ return () => {
977
+ let _slot2;
978
+ const {
979
+ colSlot,
980
+ renderCol,
981
+ colProps,
982
+ component,
983
+ render,
984
+ slot
985
+ } = props.schema;
986
+ const {
987
+ colProps: gColProps,
988
+ mode
989
+ } = props.formProps;
990
+ let _colProps = colProps || gColProps || (mode === "search" ? appConf.ui.form.searchColspan : appConf.ui.form.dialogColspan);
991
+ const values = unref$1(getValues);
992
+ if (!component) {
993
+ if (!render && !renderCol && !slot) {
994
+ error(t("NEED_RENDER"));
995
+ return;
996
+ }
997
+ }
998
+ if (component === "Divider") {
999
+ let _slot;
1000
+ let cprops = unref$1(getComponentProps);
1001
+ const span = cprops?.span ?? 24;
1002
+ return createVNode(Col, {
1003
+ "span": span
1004
+ }, {
1005
+ default: () => [createVNode(Divider, cprops, _isSlot$1(_slot = renderLabel()) ? _slot : {
1006
+ default: () => [_slot]
1007
+ })]
1008
+ });
1009
+ }
1010
+ const getContent = () => {
1011
+ return colSlot ? getSlot(slots, colSlot, values) : renderCol ? renderCol(values) : renderItem();
1012
+ };
1013
+ return unref$1(getShow) && createVNode(Col, _colProps, _isSlot$1(_slot2 = getContent()) ? _slot2 : {
1014
+ default: () => [_slot2]
1015
+ });
1016
+ };
1017
+ }
1018
+ };
1019
+ const DtFormItem = /* @__PURE__ */ _export_sfc(_sfc_main$b, [["__file", "D:/dt/dt-frame-front/dt-frames/frames/packages/ui/src/components/form/src/components/FormItem.vue"]]);
1020
+ const _hoisted_1$1 = {
1021
+ key: 0,
1022
+ className: "preIcon pr-1"
1023
+ };
1024
+ const _hoisted_2 = {
1025
+ key: 0,
1026
+ className: "preIcon pl-1"
1027
+ };
1028
+ const _hoisted_3 = { class: "text" };
1029
+ const _hoisted_4 = /* @__PURE__ */ createElementVNode("i", { class: "text-2xl i ic:baseline-arrow-drop-down" }, null, -1);
1030
+ const _hoisted_5 = [
1031
+ _hoisted_4
1032
+ ];
1033
+ const _sfc_main$a = /* @__PURE__ */ defineComponent({
1034
+ __name: "FormButtons",
1035
+ props: {
1036
+ mode: {
1037
+ type: String,
1038
+ default: "search"
1039
+ },
1040
+ show: {
1041
+ type: Boolean,
1042
+ default: true
1043
+ },
1044
+ showAdvancedButton: {
1045
+ type: Boolean,
1046
+ default: true
1047
+ },
1048
+ minShowColumn: {
1049
+ type: Number,
1050
+ default: 2
1051
+ },
1052
+ buttonList: {
1053
+ type: [Array],
1054
+ default: []
1055
+ },
1056
+ isAdvanced: {
1057
+ type: Boolean,
1058
+ default: true
1059
+ }
1060
+ },
1061
+ emits: ["handle-method"],
1062
+ setup(__props, { emit: emits }) {
1063
+ const props = __props;
1064
+ const { t } = useI18n();
1065
+ const advancedRef = ref$1(props.isAdvanced);
1066
+ let key = 0;
1067
+ const showAdvanceRef = computed(() => {
1068
+ return props.mode === "search" ? props.showAdvancedButton : false;
1069
+ });
1070
+ const colOpt = computed(() => {
1071
+ let style = {
1072
+ textAlign: "right"
1073
+ };
1074
+ if (props.mode === "dialog") {
1075
+ Object.assign(style, {
1076
+ display: "inline-block"
1077
+ });
1078
+ }
1079
+ return { style };
1080
+ });
1081
+ const getAdvanceClass = computed(() => {
1082
+ return [
1083
+ "basic-arrow",
1084
+ { "basic-arrow--active": !advancedRef.value }
1085
+ ];
1086
+ });
1087
+ const toggleAdvanced = () => {
1088
+ advancedRef.value = !advancedRef.value;
1089
+ dispatchResize();
1090
+ emits("handle-method", advancedRef.value);
1091
+ };
1092
+ function handleBtnClick(button) {
1093
+ if (button.onClick && isFunction(button.onClick)) {
1094
+ button.onClick();
1095
+ } else {
1096
+ emits("handle-method", button);
1097
+ }
1098
+ }
1099
+ watch(() => props.isAdvanced, (v) => {
1100
+ if (v) {
1101
+ nextTick$1(() => toggleAdvanced());
1102
+ }
1103
+ }, {
1104
+ immediate: true
1105
+ });
1106
+ watch(
1107
+ () => props.buttonList,
1108
+ (v) => key = new Date().getTime(),
1109
+ {
1110
+ immediate: true,
1111
+ deep: true
1112
+ }
1113
+ );
1114
+ return (_ctx, _cache) => {
1115
+ const _component_AButton = Button;
1116
+ const _component_AFormItem = FormItem$1;
1117
+ const _component_ACol = Col$1;
1118
+ const _directive_icon = resolveDirective("icon");
1119
+ const _directive_auth = resolveDirective("auth");
1120
+ return __props.show ? (openBlock(), createBlock(_component_ACol, normalizeProps(mergeProps({ key: 0 }, unref$1(colOpt))), {
1121
+ default: withCtx(() => [
1122
+ createVNode(_component_AFormItem, {
1123
+ class: "dt-form-btns",
1124
+ style: normalizeStyle({
1125
+ "margin-bottom": __props.mode === "search" ? "16px" : "0px"
1126
+ })
1127
+ }, {
1128
+ default: withCtx(() => [
1129
+ (openBlock(true), createElementBlock(Fragment, null, renderList(__props.buttonList, (button) => {
1130
+ return openBlock(), createElementBlock(Fragment, null, [
1131
+ (button.show === void 0 ? true : button.show) ? withDirectives((openBlock(), createBlock(_component_AButton, {
1132
+ type: button.type,
1133
+ class: normalizeClass(button.class),
1134
+ loading: button.loading?.value,
1135
+ disabled: button.disabled,
1136
+ key: unref$1(key),
1137
+ onClick: ($event) => handleBtnClick(button)
1138
+ }, {
1139
+ icon: withCtx(() => [
1140
+ button.preIcon ? withDirectives((openBlock(), createElementBlock("span", _hoisted_1$1, null, 512)), [
1141
+ [_directive_icon, button.preIcon]
1142
+ ]) : createCommentVNode("v-if", true)
1143
+ ]),
1144
+ default: withCtx(() => [
1145
+ createTextVNode(" " + toDisplayString(unref$1(t)(button.name)) + " ", 1),
1146
+ button.postIcon ? withDirectives((openBlock(), createElementBlock("span", _hoisted_2, null, 512)), [
1147
+ [_directive_icon, button.postIcon]
1148
+ ]) : createCommentVNode("v-if", true)
1149
+ ]),
1150
+ _: 2
1151
+ }, 1032, ["type", "class", "loading", "disabled", "onClick"])), [
1152
+ [_directive_auth, button.auth]
1153
+ ]) : createCommentVNode("v-if", true)
1154
+ ], 64);
1155
+ }), 256)),
1156
+ unref$1(showAdvanceRef) ? (openBlock(), createBlock(_component_AButton, {
1157
+ key: 0,
1158
+ type: "link",
1159
+ class: "advanced",
1160
+ onClick: toggleAdvanced
1161
+ }, {
1162
+ default: withCtx(() => [
1163
+ createCommentVNode(" \u6536\u8D77 | \u5C55\u5F00 "),
1164
+ createElementVNode("span", _hoisted_3, toDisplayString(advancedRef.value ? unref$1(t)("UI.ADVANCED") : unref$1(t)("UI.EXPAND")), 1),
1165
+ createElementVNode("span", {
1166
+ class: normalizeClass(unref$1(getAdvanceClass))
1167
+ }, _hoisted_5, 2)
1168
+ ]),
1169
+ _: 1
1170
+ })) : createCommentVNode("v-if", true)
1171
+ ]),
1172
+ _: 1
1173
+ }, 8, ["style"])
1174
+ ]),
1175
+ _: 1
1176
+ }, 16)) : createCommentVNode("v-if", true);
1177
+ };
1178
+ }
1179
+ });
1180
+ const DtFormButtons = /* @__PURE__ */ _export_sfc(_sfc_main$a, [["__file", "D:/dt/dt-frame-front/dt-frames/frames/packages/ui/src/components/form/src/components/FormButtons.vue"]]);
1181
+ const SEARCH_BTN_NAME = "UI.SEARCH";
1182
+ const RESET_BTN_NAME = "UI.RESET";
1183
+ const SEARCH_BTNS = [
1184
+ { name: SEARCH_BTN_NAME, preIcon: "mdi:magnify", type: "primary" },
1185
+ { name: RESET_BTN_NAME, preIcon: "mdi:refresh", type: "default" }
1186
+ ];
1187
+ function useFormEvents({
1188
+ emits,
1189
+ getSchema,
1190
+ formModel,
1191
+ defaultValue,
1192
+ formElRef,
1193
+ schemaRef,
1194
+ getProps,
1195
+ handleFormValues
1196
+ }) {
1197
+ function getFormValues() {
1198
+ const formEl = unref$1(formElRef);
1199
+ if (!formEl)
1200
+ return {};
1201
+ return handleFormValues(toRaw$1(unref$1(formModel)));
1202
+ }
1203
+ function updateSchema(data) {
1204
+ let updateItems = [];
1205
+ updateItems = isObject(data) ? [data] : [...data];
1206
+ if (updateItems?.length && !updateItems.every((it) => it.component !== "Divider" && it.name)) {
1207
+ console.error("\u6240\u6709\u7684\u5143\u7D20\u90FD\u5FC5\u987B\u8BBE\u7F6Ename\u5C5E\u6027");
1208
+ return;
1209
+ }
1210
+ const schema = [];
1211
+ updateItems.forEach((it) => {
1212
+ unref$1(getSchema).forEach((val) => {
1213
+ if (val.name === it.name) {
1214
+ const newSchema = deepMerge(val, it);
1215
+ schema.push(newSchema);
1216
+ } else {
1217
+ schema.push(val);
1218
+ }
1219
+ });
1220
+ });
1221
+ let shcemas = uniqBy(schema, "name");
1222
+ _setValue(shcemas);
1223
+ schemaRef.value = shcemas;
1224
+ }
1225
+ function resetSchema(data) {
1226
+ let updateItems = [];
1227
+ updateItems = isObject(data) ? [data] : [...data];
1228
+ _setValue(updateItems, true);
1229
+ schemaRef.value = updateItems;
1230
+ }
1231
+ function _setValue(data, isReset = false) {
1232
+ data = isArray(data) ? data : [data];
1233
+ let obj = {};
1234
+ data.map((it) => {
1235
+ let name = isArray(it.name) ? it.name[0] : it.name;
1236
+ obj[name] = null;
1237
+ if (!isNullAndUnDef(it.defaultValue))
1238
+ return obj[name] = it.defaultValue;
1239
+ let props = isFunction(it.props) ? it.props(toRaw$1(unref$1(formModel))) : it.props;
1240
+ if (!isNullAndUnDef(props?.defaultValue))
1241
+ obj[name] = props.defaultValue;
1242
+ });
1243
+ if (isReset) {
1244
+ let oldValues = getFormValues();
1245
+ let oldObj = {};
1246
+ Object.keys(oldValues).map((key) => oldObj[key] = null);
1247
+ obj = {
1248
+ ...oldObj,
1249
+ ...obj
1250
+ };
1251
+ }
1252
+ setFormValues(obj);
1253
+ }
1254
+ async function clearValidate(name) {
1255
+ await unref$1(formElRef)?.clearValidate(name);
1256
+ }
1257
+ function resetForms() {
1258
+ const { resetFunc } = unref$1(getProps);
1259
+ resetFunc && isFunction(resetFunc) && resetFunc();
1260
+ if (!unref$1(formElRef))
1261
+ return;
1262
+ Object.keys(formModel).forEach((key) => {
1263
+ const schema = unref$1(getSchema).find((item) => item.name === key);
1264
+ const isInput = schema?.component && ["Input", "InputPassword", "InputSearch", "InputTextArea"].includes(schema.component);
1265
+ formModel[key] = isInput ? defaultValue.value[key] || "" : defaultValue.value[key];
1266
+ });
1267
+ nextTick$1(() => clearValidate());
1268
+ emits("reset", toRaw$1(formModel));
1269
+ }
1270
+ function removeFormByName(names) {
1271
+ if (!names)
1272
+ return;
1273
+ const schemaList = cloneDeep(unref$1(getSchema));
1274
+ const nameList = isString(names) ? [names] : names;
1275
+ for (const name of nameList) {
1276
+ _removeSchemaByName(name, schemaList);
1277
+ }
1278
+ schemaRef.value = schemaList;
1279
+ }
1280
+ function _removeSchemaByName(name, schemaList) {
1281
+ const index2 = schemaList.findIndex((schema) => schema.name === name);
1282
+ if (index2 !== -1) {
1283
+ delete formModel[name];
1284
+ schemaList.splice(index2, 1);
1285
+ }
1286
+ }
1287
+ function appendFormItems(schema, prefixName, first = false) {
1288
+ const schemaList = cloneDeep(unref$1(getSchema));
1289
+ const index2 = schemaList.findIndex((schema2) => schema2.name === prefixName);
1290
+ if (!prefixName || index2 === -1 || first) {
1291
+ first ? schemaList.unshift(...schema) : schemaList.push(...schema);
1292
+ schemaRef.value = schemaList;
1293
+ return;
1294
+ }
1295
+ if (index2 !== -1) {
1296
+ schemaList.splice(index2 + 1, 0, ...schema);
1297
+ }
1298
+ schemaRef.value = schemaList;
1299
+ }
1300
+ function itemIsDateType(key) {
1301
+ return unref$1(getSchema).some((item) => {
1302
+ return item.name === key ? ["DatePicker", "MonthPicker", "WeekPicker", "TimePicker", "RangePicker"].includes(item.component) : false;
1303
+ });
1304
+ }
1305
+ async function validateFields(nameList) {
1306
+ return unref$1(formElRef)?.validateFields(nameList);
1307
+ }
1308
+ function setFormValues(values) {
1309
+ if (!values || !Object.keys(values).length) {
1310
+ for (let it in formModel)
1311
+ formModel[it] = Array.isArray(formModel[it]) ? [] : null;
1312
+ return;
1313
+ }
1314
+ const names = unref$1(getSchema).map((item) => item.name).filter(Boolean);
1315
+ const validKeys = [];
1316
+ Object.keys(values).forEach((key) => {
1317
+ const schema = unref$1(getSchema).find((item) => item.name === key);
1318
+ let value = values[key];
1319
+ const hasKey = Reflect.has(values, key);
1320
+ value = handleInputNumberValue(schema?.component, value);
1321
+ if (hasKey && names.includes(key)) {
1322
+ if (itemIsDateType(key)) {
1323
+ if (Array.isArray(value)) {
1324
+ const arr = [];
1325
+ for (const ele of value) {
1326
+ arr.push(ele ? dayjs(ele) : null);
1327
+ }
1328
+ formModel[key] = arr;
1329
+ } else {
1330
+ const { props } = schema || {};
1331
+ let _props = props;
1332
+ if (typeof props === "function") {
1333
+ _props = props({ formModel });
1334
+ }
1335
+ formModel[key] = value ? _props?.valueFormat ? value : dayjs(value) : null;
1336
+ }
1337
+ } else {
1338
+ formModel[key] = value;
1339
+ }
1340
+ validKeys.push(key);
1341
+ } else {
1342
+ formModel[key] = value;
1343
+ }
1344
+ });
1345
+ return validateFields(validKeys);
1346
+ }
1347
+ async function validate(nameList) {
1348
+ return await unref$1(formElRef)?.validate(nameList);
1349
+ }
1350
+ return {
1351
+ getFormValues,
1352
+ updateSchema,
1353
+ resetSchema,
1354
+ clearValidate,
1355
+ resetForms,
1356
+ removeFormByName,
1357
+ validateFields,
1358
+ setFormValues,
1359
+ validate,
1360
+ appendFormItems
1361
+ };
1362
+ }
1363
+ function useFormValues({
1364
+ defaultValue,
1365
+ getSchema,
1366
+ formModel
1367
+ }) {
1368
+ const getComMap = () => {
1369
+ let comMap = /* @__PURE__ */ new Map();
1370
+ unref$1(getSchema).map((it) => {
1371
+ if (it.component && it.name) {
1372
+ comMap.set(it.name, it);
1373
+ }
1374
+ });
1375
+ return comMap;
1376
+ };
1377
+ function handleFormValues(model) {
1378
+ if (!isObject(model))
1379
+ return {};
1380
+ const vals = {};
1381
+ let comMap = getComMap();
1382
+ for (let [key, val] of Object.entries(model)) {
1383
+ let component = comMap.get(key)?.component;
1384
+ if (!key || Array.isArray(val) && val.length === 0 || isFunction(val)) {
1385
+ continue;
1386
+ }
1387
+ if (component) {
1388
+ if (SINGLE_DATA_TYPE.includes(component)) {
1389
+ val = dayjs(val).valueOf();
1390
+ } else if (MULTIFY_DATA_TYPE.includes(component)) {
1391
+ val = (val || []).map((it) => dayjs(it).valueOf());
1392
+ if (comMap.get(key).extraName?.length) {
1393
+ comMap.get(key).extraName.map((it, i) => {
1394
+ set(vals, it, val.length > 0 ? val[i] : null);
1395
+ });
1396
+ }
1397
+ }
1398
+ }
1399
+ if (isString(val)) {
1400
+ val = val.trim();
1401
+ }
1402
+ set(vals, key, val);
1403
+ }
1404
+ return vals;
1405
+ }
1406
+ function initDefault() {
1407
+ const schema = unref$1(getSchema), obj = {};
1408
+ schema.forEach((item) => {
1409
+ const { props = {}, name, component, defaultValue: gDefaultValue, extraName } = item;
1410
+ const { defaultValue: itemDefaultValue, mode, format, treeCheckable } = isFunction(props) ? props(formModel) : props;
1411
+ if (!name)
1412
+ return;
1413
+ let names = [];
1414
+ if (component === "InputWithDialog") {
1415
+ names = [name, ...extraName];
1416
+ } else if (isArray(name)) {
1417
+ names = name;
1418
+ } else {
1419
+ names = [name];
1420
+ }
1421
+ const defaultValue2 = itemDefaultValue ?? gDefaultValue;
1422
+ if (!isNullAndUnDef(defaultValue2)) {
1423
+ if (DATE_PICKER_TYPES.includes(component)) {
1424
+ if (isArray(defaultValue2)) {
1425
+ let vals = defaultValue2.map((it) => format ? dayjs(it, format) : dayjs(it));
1426
+ if (names.length > 1) {
1427
+ names.map((key, index2) => obj[key] = vals[index2] ?? null);
1428
+ } else {
1429
+ obj[names[0]] = vals;
1430
+ }
1431
+ } else {
1432
+ obj[names[0]] = format ? dayjs(defaultValue2, format) : dayjs(defaultValue2);
1433
+ }
1434
+ } else {
1435
+ if (names.length > 1) {
1436
+ names.forEach((key, index2) => {
1437
+ if (!defaultValue2 || defaultValue2.length - 1 < index2) {
1438
+ obj[key] = null;
1439
+ } else {
1440
+ obj[key] = defaultValue2[index2];
1441
+ }
1442
+ });
1443
+ } else {
1444
+ obj[names[0]] = defaultValue2;
1445
+ }
1446
+ }
1447
+ } else {
1448
+ names.map((it) => {
1449
+ if (component === "TreeSelect" || (mode === "multiple" || treeCheckable) || component === "Select" && mode === "multiple") {
1450
+ obj[it] = [];
1451
+ } else {
1452
+ obj[it] = null;
1453
+ }
1454
+ });
1455
+ }
1456
+ });
1457
+ defaultValue.value = { ...obj };
1458
+ for (let key in obj) {
1459
+ formModel[key] = obj[key];
1460
+ }
1461
+ }
1462
+ return {
1463
+ initDefault,
1464
+ handleFormValues
1465
+ };
1466
+ }
1467
+ function useFormActions(opt) {
1468
+ const { getProps, defaultValue, updateSchema, getFormValues, setFormValues } = opt;
1469
+ const { appConf } = useAppStore();
1470
+ function handleAdvanced(isAdvanced) {
1471
+ const { schemas, minShowColumn = appConf.ui.form?.minShowColumn || 2 } = unref$1(getProps);
1472
+ let schema = schemas.reduce((t, it, index2) => {
1473
+ if (index2 > minShowColumn - 1)
1474
+ it.isAdvanced = isAdvanced;
1475
+ t.push(it);
1476
+ return t;
1477
+ }, []);
1478
+ updateSchema(schema);
1479
+ }
1480
+ function handleMethod(params) {
1481
+ const { onSearch, onReset } = unref$1(getProps);
1482
+ if (isBoolean(params)) {
1483
+ handleAdvanced(params);
1484
+ } else if (params.name === SEARCH_BTN_NAME) {
1485
+ console.log(getProps);
1486
+ onSearch(getFormValues());
1487
+ } else if (params.name === RESET_BTN_NAME) {
1488
+ setFormValues(toRaw(defaultValue.value));
1489
+ onReset(getFormValues());
1490
+ } else {
1491
+ params.onClick();
1492
+ }
1493
+ }
1494
+ return [handleMethod];
1495
+ }
1496
+ const BasicProps = {
1497
+ mode: {
1498
+ type: String,
1499
+ default: "search"
1500
+ },
1501
+ autoFetch: {
1502
+ type: Boolean,
1503
+ default: true
1504
+ },
1505
+ model: {
1506
+ type: Object,
1507
+ default: () => ({})
1508
+ },
1509
+ layout: {
1510
+ type: String,
1511
+ default: "horizontal"
1512
+ },
1513
+ labelWidth: {
1514
+ type: [Number, String],
1515
+ default: 100
1516
+ },
1517
+ enLabelWidth: {
1518
+ type: [Number, String],
1519
+ default: 100
1520
+ },
1521
+ labelAlign: {
1522
+ type: String,
1523
+ default: "right"
1524
+ },
1525
+ labelCol: {
1526
+ type: Object,
1527
+ default: () => ({})
1528
+ },
1529
+ wrapperCol: {
1530
+ type: Object,
1531
+ default: () => ({})
1532
+ },
1533
+ rowProps: {
1534
+ type: Object,
1535
+ default: () => ({})
1536
+ },
1537
+ colProps: {
1538
+ type: Object,
1539
+ default: () => ({})
1540
+ },
1541
+ size: {
1542
+ type: String,
1543
+ default: "small"
1544
+ },
1545
+ disabled: {
1546
+ type: Boolean,
1547
+ default: false
1548
+ },
1549
+ compact: {
1550
+ type: Boolean,
1551
+ default: null
1552
+ },
1553
+ schemas: {
1554
+ type: Array,
1555
+ default: () => []
1556
+ },
1557
+ autoSearchOnEnter: {
1558
+ type: Boolean,
1559
+ default: true
1560
+ },
1561
+ alwaysShowLines: {
1562
+ type: Boolean,
1563
+ default: false
1564
+ },
1565
+ minShowColumn: {
1566
+ type: Number,
1567
+ default: 2
1568
+ },
1569
+ showAdvancedButton: {
1570
+ type: Boolean,
1571
+ default: true
1572
+ },
1573
+ allowClear: {
1574
+ type: Boolean,
1575
+ default: true
1576
+ },
1577
+ scrollToFirstError: {
1578
+ type: Boolean,
1579
+ default: true
1580
+ },
1581
+ colon: {
1582
+ type: Boolean,
1583
+ default: true
1584
+ },
1585
+ loading: {
1586
+ type: Object,
1587
+ default: () => {
1588
+ return {
1589
+ onSearch: ref$1(false),
1590
+ onReset: ref$1(false)
1591
+ };
1592
+ }
1593
+ },
1594
+ onSearch: {
1595
+ type: Function,
1596
+ default: (params) => {
1597
+ }
1598
+ },
1599
+ onReset: {
1600
+ type: Function,
1601
+ default: (params) => {
1602
+ }
1603
+ },
1604
+ buttons: {
1605
+ type: [Array, null, Boolean],
1606
+ default: false
1607
+ },
1608
+ resetFunc: {
1609
+ type: Function
1610
+ },
1611
+ registerInstance: {
1612
+ type: Function
1613
+ }
1614
+ };
1615
+ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
1616
+ __name: "index",
1617
+ props: BasicProps,
1618
+ emits: ["register"],
1619
+ setup(__props, { emit: emits }) {
1620
+ const props = __props;
1621
+ const { getAppConf } = useAppStore();
1622
+ const attrs = useAttrs();
1623
+ const formElRef = ref$1(null);
1624
+ const formModel = reactive({});
1625
+ const defaultValue = ref$1({});
1626
+ const propsRef = ref$1();
1627
+ const schemaRef = ref$1(null);
1628
+ const getProps = computed(() => {
1629
+ let colProps = props.colProps;
1630
+ if (isEmpty(props.colProps)) {
1631
+ colProps = props.mode === "search" ? getAppConf.ui.form.searchColspan || { span: 8 } : getAppConf.ui.form.dialogColspan || { span: 12 };
1632
+ }
1633
+ return {
1634
+ ...props,
1635
+ ...getAppConf.ui.form,
1636
+ colProps,
1637
+ ...unref$1(propsRef)
1638
+ };
1639
+ });
1640
+ const getBindValue = computed(() => {
1641
+ return {
1642
+ ...attrs,
1643
+ ...unref$1(getProps)
1644
+ };
1645
+ });
1646
+ const getSchema = computed(() => {
1647
+ return unref$1(schemaRef) || unref$1(getProps).schemas;
1648
+ });
1649
+ const getFormClass = computed(() => {
1650
+ const { compact, mode } = unref$1(getProps);
1651
+ const getCompact = compact === null ? mode === "dialog" ? false : true : compact;
1652
+ return [
1653
+ "basic-form",
1654
+ `basic-form__${mode}`,
1655
+ {
1656
+ "basic-form__compact": getCompact
1657
+ }
1658
+ ];
1659
+ });
1660
+ function setProps(formProps) {
1661
+ propsRef.value = deepMerge(unref$1(propsRef) || {}, formProps);
1662
+ return null;
1663
+ }
1664
+ function setFormModel(key, value) {
1665
+ formModel[key] = value;
1666
+ const { validateTrigger } = unref$1(getBindValue);
1667
+ if (!validateTrigger || validateTrigger === "change") {
1668
+ validateFields([key]);
1669
+ }
1670
+ }
1671
+ function handleEnterPress() {
1672
+ }
1673
+ const { initDefault, handleFormValues } = useFormValues({
1674
+ defaultValue,
1675
+ getSchema,
1676
+ formModel
1677
+ });
1678
+ const {
1679
+ updateSchema,
1680
+ resetSchema,
1681
+ clearValidate,
1682
+ resetForms,
1683
+ removeFormByName,
1684
+ setFormValues,
1685
+ appendFormItems,
1686
+ validate,
1687
+ validateFields,
1688
+ getFormValues
1689
+ } = useFormEvents({
1690
+ emits,
1691
+ getSchema,
1692
+ formModel,
1693
+ formElRef,
1694
+ defaultValue,
1695
+ schemaRef,
1696
+ getProps,
1697
+ handleFormValues
1698
+ });
1699
+ const formActionMethods = {
1700
+ setProps,
1701
+ updateSchema,
1702
+ resetSchema,
1703
+ clearValidate,
1704
+ resetForms,
1705
+ removeFormByName,
1706
+ setFormValues,
1707
+ appendFormItems,
1708
+ validate,
1709
+ validateFields,
1710
+ getFormValues
1711
+ };
1712
+ const getActionsProps = computed(() => {
1713
+ const {
1714
+ mode,
1715
+ minShowColumn = getAppConf.ui.form.minShowColumn || 2,
1716
+ schemas = [],
1717
+ showAdvancedButton: advanced,
1718
+ loading,
1719
+ buttons
1720
+ } = unref$1(getProps);
1721
+ let showAdvancedButton = mode === "search" ? true : false;
1722
+ if (advanced !== void 0) {
1723
+ showAdvancedButton = advanced;
1724
+ }
1725
+ if (schemas.length <= minShowColumn) {
1726
+ showAdvancedButton = false;
1727
+ }
1728
+ let buttonList = [];
1729
+ if (isArray(buttons)) {
1730
+ buttonList = [...buttons];
1731
+ } else if (mode === "search" && !buttons) {
1732
+ SEARCH_BTNS.forEach((it) => {
1733
+ it.loading = it.name === SEARCH_BTN_NAME ? loading?.onSearch : loading?.onReset;
1734
+ buttonList.push(it);
1735
+ });
1736
+ }
1737
+ let colspan = mode === "search" ? getAppConf.ui.form.searchColspan : getAppConf.ui.form.dialogColspan;
1738
+ return {
1739
+ ...colspan,
1740
+ ...{
1741
+ showAdvancedButton,
1742
+ buttonList
1743
+ }
1744
+ };
1745
+ });
1746
+ const [handleMethod] = useFormActions({
1747
+ getProps,
1748
+ defaultValue,
1749
+ updateSchema,
1750
+ getFormValues,
1751
+ setFormValues
1752
+ });
1753
+ onMounted$1(() => {
1754
+ setFormValues(null);
1755
+ emits("register", formActionMethods);
1756
+ initDefault();
1757
+ });
1758
+ watch(
1759
+ () => unref$1(getProps).onSearch,
1760
+ () => {
1761
+ useTimeoutFn(() => {
1762
+ const { onSearch, autoFetch } = unref$1(getProps);
1763
+ if (autoFetch && onSearch && isFunction(onSearch)) {
1764
+ onSearch(toRaw(defaultValue.value));
1765
+ }
1766
+ }, 1);
1767
+ }
1768
+ );
1769
+ watch(
1770
+ () => unref$1(getProps).model,
1771
+ (v) => {
1772
+ const { model } = unref$1(getProps);
1773
+ if (!model || !Object.keys(model).length)
1774
+ return;
1775
+ setFormValues(model);
1776
+ },
1777
+ {
1778
+ immediate: true,
1779
+ deep: true
1780
+ }
1781
+ );
1782
+ return (_ctx, _cache) => {
1783
+ const _component_ARow = Row;
1784
+ const _component_AForm = Form$1;
1785
+ return openBlock(), createBlock(_component_AForm, mergeProps(unref$1(getBindValue), {
1786
+ ref_key: "formElRef",
1787
+ ref: formElRef,
1788
+ class: unref$1(getFormClass),
1789
+ model: formModel,
1790
+ layout: unref$1(getProps).layout,
1791
+ onKeypress: withKeys(handleEnterPress, ["enter"])
1792
+ }), {
1793
+ default: withCtx(() => [
1794
+ createVNode(_component_ARow, mergeProps(unref$1(getProps).rowProps, { style: {
1795
+ margin: 0
1796
+ } }), {
1797
+ default: withCtx(() => [
1798
+ (openBlock(true), createElementBlock(Fragment, null, renderList(unref$1(getSchema), (schema) => {
1799
+ return openBlock(), createBlock(unref$1(DtFormItem), {
1800
+ key: schema.name,
1801
+ schema,
1802
+ formProps: unref$1(getProps),
1803
+ formModel,
1804
+ defaultValues: defaultValue.value,
1805
+ setFormModel,
1806
+ formActionType: formActionMethods
1807
+ }, createSlots({ _: 2 }, [
1808
+ renderList(Object.keys(_ctx.$slots), (item) => {
1809
+ return {
1810
+ name: item,
1811
+ fn: withCtx((data) => [
1812
+ renderSlot(_ctx.$slots, item, normalizeProps(guardReactiveProps(data || {})))
1813
+ ])
1814
+ };
1815
+ })
1816
+ ]), 1032, ["schema", "formProps", "formModel", "defaultValues"]);
1817
+ }), 128)),
1818
+ unref$1(getActionsProps).buttonList?.length ? (openBlock(), createBlock(unref$1(DtFormButtons), mergeProps({ key: 0 }, unref$1(getActionsProps), { onHandleMethod: unref$1(handleMethod) }), null, 16, ["onHandleMethod"])) : createCommentVNode("v-if", true)
1819
+ ]),
1820
+ _: 3
1821
+ }, 16)
1822
+ ]),
1823
+ _: 3
1824
+ }, 16, ["class", "model", "layout", "onKeypress"]);
1825
+ };
1826
+ }
1827
+ });
1828
+ const Forms = /* @__PURE__ */ _export_sfc(_sfc_main$9, [["__file", "D:/dt/dt-frame-front/dt-frames/frames/packages/ui/src/components/form/src/index.vue"]]);
1829
+ function useForm(props) {
1830
+ const formRef = ref$1(null);
1831
+ const loadedRef = ref$1(false);
1832
+ function register(instance) {
1833
+ if (unref$1(loadedRef) && instance === unref$1(formRef))
1834
+ return;
1835
+ formRef.value = instance;
1836
+ loadedRef.value = true;
1837
+ watch(
1838
+ () => props,
1839
+ () => props && instance.setProps(props),
1840
+ {
1841
+ immediate: true,
1842
+ deep: true
1843
+ }
1844
+ );
1845
+ }
1846
+ async function getForm() {
1847
+ const form = unref$1(formRef);
1848
+ if (!form)
1849
+ console.error("\u8868\u5355\u672A\u7533\u660E!");
1850
+ await nextTick$1();
1851
+ return form;
1852
+ }
1853
+ const methods = {
1854
+ setProps: async (props2) => {
1855
+ const form = await getForm();
1856
+ form.setProps(props2);
1857
+ },
1858
+ updateSchema: async (data) => {
1859
+ const form = await getForm();
1860
+ form.updateSchema(data);
1861
+ },
1862
+ resetSchema: async (data) => {
1863
+ const form = await getForm();
1864
+ form.resetSchema(data);
1865
+ },
1866
+ clearValidate: async (name) => {
1867
+ const form = await getForm();
1868
+ form.clearValidate(name);
1869
+ },
1870
+ resetForms: async () => {
1871
+ const form = await getForm();
1872
+ form.resetForms();
1873
+ },
1874
+ removeFormByName: async (name) => {
1875
+ unref$1(formRef)?.removeFormByName(name);
1876
+ },
1877
+ setFormValues: async (values) => {
1878
+ const form = await getForm();
1879
+ form.setFormValues(values);
1880
+ },
1881
+ appendFormItems: async (schema, prefixName, first) => {
1882
+ const form = await getForm();
1883
+ form.appendFormItems(schema, prefixName, first);
1884
+ },
1885
+ validate: async (nameList) => {
1886
+ const form = await getForm();
1887
+ return form.validate(nameList);
1888
+ },
1889
+ validateFields: async (nameList) => {
1890
+ const form = await getForm();
1891
+ return form.validateFields(nameList);
1892
+ },
1893
+ getFormValues: () => {
1894
+ return unref$1(formRef)?.getFormValues();
1895
+ }
1896
+ };
1897
+ return [register, methods];
1898
+ }
1899
+ const withInstall = (comp) => {
1900
+ comp.install = (app) => {
1901
+ app.component(comp.name, comp);
1902
+ };
1903
+ return comp;
1904
+ };
1905
+ const DtForm = withInstall(Forms);
1906
+ const orgDialogProp = reactive({});
1907
+ const cbTransfer = reactive({});
1908
+ const dataTransfer = reactive({});
1909
+ function useModalOut() {
1910
+ const modal = ref$1(null);
1911
+ const loaded = ref$1(true);
1912
+ const uid = ref$1(null);
1913
+ const { isProd } = useApp();
1914
+ function register(modalMethod, uuid) {
1915
+ if (!getCurrentInstance()) {
1916
+ throw new Error("useModal\u53EA\u80FD\u5728setup()\u6216\u8005\u51FD\u6570\u4E2D\u4F7F\u7528");
1917
+ }
1918
+ uid.value = uuid;
1919
+ onUnmounted(() => {
1920
+ if (unref$1(isProd)) {
1921
+ modal.value = null;
1922
+ loaded.value = false;
1923
+ dataTransfer[unref$1(uid)] = null;
1924
+ orgDialogProp[unref$1(uid)] = null;
1925
+ cbTransfer[unref$1(uid)] = (res) => {
1926
+ };
1927
+ }
1928
+ });
1929
+ if (unref$1(loaded) && modalMethod === unref$1(modal))
1930
+ return;
1931
+ modal.value = modalMethod;
1932
+ loaded.value = true;
1933
+ }
1934
+ const getInstance = () => {
1935
+ const instance = unref$1(modal);
1936
+ if (!instance) {
1937
+ error("useModalOut \u5B9E\u4F8B\u672A\u5B9A\u4E49");
1938
+ }
1939
+ return instance;
1940
+ };
1941
+ const methods = {
1942
+ setModalProps: (props) => {
1943
+ getInstance()?.setModalProps(props);
1944
+ },
1945
+ redoModalHeight: () => {
1946
+ getInstance()?.redoModalHeight?.();
1947
+ },
1948
+ openModal: (params, afterClose) => {
1949
+ const id = unref$1(uid);
1950
+ dataTransfer[id] = isObject(params) ? { ...toRaw(params) } : params;
1951
+ getInstance()?.setModalProps({
1952
+ footer: [],
1953
+ defaultFullscreen: false,
1954
+ ...orgDialogProp[id],
1955
+ visible: true
1956
+ });
1957
+ cbTransfer[id] = (res) => {
1958
+ if (afterClose && isFunction(afterClose)) {
1959
+ afterClose(res);
1960
+ }
1961
+ };
1962
+ },
1963
+ closeModal: () => {
1964
+ getInstance()?.setModalProps({ visible: false });
1965
+ }
1966
+ };
1967
+ return [register, methods];
1968
+ }
1969
+ function useModal(props, setModalData) {
1970
+ const modalInstanceRef = ref$1(null);
1971
+ const currentInstance = getCurrentInstance();
1972
+ const uidRef = ref$1(null);
1973
+ const { isProd } = useApp();
1974
+ const getInstance = () => {
1975
+ const instance = unref$1(modalInstanceRef);
1976
+ if (!instance) {
1977
+ error("useModal \u5B9E\u4F8B\u672A\u5B9A\u4E49");
1978
+ }
1979
+ return instance;
1980
+ };
1981
+ const register = (modalInstance, uuid) => {
1982
+ if (unref$1(isProd)) {
1983
+ modalInstanceRef.value = null;
1984
+ }
1985
+ uidRef.value = uuid;
1986
+ modalInstanceRef.value = modalInstance;
1987
+ currentInstance?.emit("register", modalInstance, uuid);
1988
+ orgDialogProp[uuid] = toRaw(props);
1989
+ modalInstance.setModalProps(props);
1990
+ };
1991
+ watchEffect(() => {
1992
+ const data = dataTransfer[unref$1(uidRef)];
1993
+ if (!data)
1994
+ return;
1995
+ if (!setModalData || !isFunction(setModalData))
1996
+ return;
1997
+ nextTick$1(() => {
1998
+ setModalData(data);
1999
+ });
2000
+ });
2001
+ const methods = {
2002
+ setLoading: (loading = true) => {
2003
+ getInstance()?.setModalProps({ loading });
2004
+ },
2005
+ closeModal: (rsp) => {
2006
+ if (cbTransfer[unref$1(uidRef)])
2007
+ cbTransfer[unref$1(uidRef)](rsp);
2008
+ getInstance()?.setModalProps({ visible: false });
2009
+ },
2010
+ setModalProps: (props2) => {
2011
+ getInstance()?.setModalProps(props2);
2012
+ },
2013
+ redoModalHeight: () => {
2014
+ const callRedo = getInstance()?.redoModalHeight;
2015
+ callRedo && callRedo();
2016
+ }
2017
+ };
2018
+ return [register, methods];
2019
+ }
2020
+ const index$1 = "";
2021
+ const basicProps$1 = {
2022
+ t: {
2023
+ type: String
2024
+ },
2025
+ visible: {
2026
+ type: Boolean
2027
+ },
2028
+ closable: {
2029
+ type: Boolean,
2030
+ default: true
2031
+ },
2032
+ destroyOnClose: {
2033
+ type: Boolean
2034
+ },
2035
+ scrollTop: {
2036
+ type: Boolean,
2037
+ default: true
2038
+ },
2039
+ height: { type: Number },
2040
+ minHeight: { type: Number },
2041
+ width: { type: [String, Number] },
2042
+ draggable: {
2043
+ type: Boolean,
2044
+ default: true
2045
+ },
2046
+ defaultFullscreen: {
2047
+ type: Boolean
2048
+ },
2049
+ canFullscreen: {
2050
+ type: Boolean,
2051
+ default: true
2052
+ },
2053
+ title: {
2054
+ type: String
2055
+ },
2056
+ loading: { type: Boolean, default: false },
2057
+ loadingTip: { type: String, default: "\u52A0\u8F7D\u4E2D..." },
2058
+ useWrapper: {
2059
+ type: Boolean,
2060
+ default: true
2061
+ },
2062
+ wrapClassName: { type: String },
2063
+ zIndex: { type: Number },
2064
+ centered: { type: Boolean },
2065
+ showOkBtn: {
2066
+ type: Boolean,
2067
+ default: true
2068
+ },
2069
+ showCancelBtn: {
2070
+ type: Boolean,
2071
+ default: true
2072
+ },
2073
+ okText: {
2074
+ type: String
2075
+ },
2076
+ cancelText: {
2077
+ type: String
2078
+ },
2079
+ mask: { type: Boolean, default: true },
2080
+ maskClosable: { type: Boolean, default: true },
2081
+ keyboard: { type: Boolean, default: true },
2082
+ maskStyle: Object,
2083
+ footer: {
2084
+ type: Object
2085
+ },
2086
+ bodyStyle: Object,
2087
+ wrapperProps: Object,
2088
+ getContainer: Function,
2089
+ closeFunc: Function,
2090
+ afterClose: Function
2091
+ };
2092
+ function useDragMove(context) {
2093
+ const getStyle = (dom, attr) => {
2094
+ return getComputedStyle(dom)[attr];
2095
+ };
2096
+ const drag = (wrap) => {
2097
+ if (!wrap)
2098
+ return;
2099
+ wrap.setAttribute("data-drag", unref$1(context.draggable));
2100
+ const dialogHeaderEl = wrap.querySelector(".ant-modal-header");
2101
+ const dragDom = wrap.querySelector(".ant-modal");
2102
+ if (!dialogHeaderEl || !dragDom || !unref$1(context.draggable))
2103
+ return;
2104
+ dialogHeaderEl.style.cursor = "move";
2105
+ dialogHeaderEl.onmousedown = (e) => {
2106
+ if (!e)
2107
+ return;
2108
+ const disX = e.clientX;
2109
+ const disY = e.clientY;
2110
+ const screenWidth = document.body.clientWidth;
2111
+ const screenHeight = document.documentElement.clientHeight;
2112
+ const dragDomWidth = dragDom.offsetWidth;
2113
+ const dragDomheight = dragDom.offsetHeight;
2114
+ console.log(dragDomWidth, dragDomheight, screenHeight, screenWidth);
2115
+ const minDragDomLeft = dragDom.offsetLeft;
2116
+ const maxDragDomLeft = screenWidth - dragDom.offsetLeft - dragDomWidth;
2117
+ const minDragDomTop = dragDom.offsetTop;
2118
+ const maxDragDomTop = screenHeight - dragDom.offsetTop - dragDomheight;
2119
+ const domLeft = getStyle(dragDom, "left");
2120
+ const domTop = getStyle(dragDom, "top");
2121
+ let styL = +domLeft;
2122
+ let styT = +domTop;
2123
+ if (domLeft.includes("%")) {
2124
+ styL = +document.body.clientWidth * (+domLeft.replace(/%/g, "") / 100);
2125
+ styT = +document.body.clientHeight * (+domTop.replace(/%/g, "") / 100);
2126
+ } else {
2127
+ styL = +domLeft.replace(/px/g, "");
2128
+ styT = +domTop.replace(/px/g, "");
2129
+ }
2130
+ document.onmousemove = function(e2) {
2131
+ let left = e2.clientX - disX;
2132
+ let top = e2.clientY - disY;
2133
+ if (-left > minDragDomLeft) {
2134
+ left = -minDragDomLeft;
2135
+ } else if (left > maxDragDomLeft) {
2136
+ left = maxDragDomLeft;
2137
+ }
2138
+ if (-top > minDragDomTop) {
2139
+ top = -minDragDomTop;
2140
+ } else if (top > maxDragDomTop) {
2141
+ top = maxDragDomTop;
2142
+ }
2143
+ dragDom.style.cssText += `;left:${left + styL}px;top:${top + styT}px;`;
2144
+ };
2145
+ document.onmouseup = () => {
2146
+ document.onmousemove = null;
2147
+ document.onmouseup = null;
2148
+ };
2149
+ };
2150
+ };
2151
+ const handleDrag = () => {
2152
+ const dragWraps = document.querySelectorAll(".ant-modal-wrap");
2153
+ for (const wrap of Array.from(dragWraps)) {
2154
+ if (!wrap)
2155
+ continue;
2156
+ const display = getStyle(wrap, "display");
2157
+ const draggable = wrap.getAttribute("data-drag");
2158
+ if (display !== "none") {
2159
+ if (draggable === null || unref$1(context.destroyOnClose)) {
2160
+ drag(wrap);
2161
+ }
2162
+ }
2163
+ }
2164
+ };
2165
+ watchEffect(() => {
2166
+ if (!unref$1(context.visible) || !unref$1(context.draggable)) {
2167
+ return;
2168
+ }
2169
+ useTimeoutFn(() => {
2170
+ handleDrag();
2171
+ }, 30);
2172
+ });
2173
+ }
2174
+ function _isSlot(s) {
2175
+ return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s);
2176
+ }
2177
+ const _sfc_main$8 = {
2178
+ name: "Modal",
2179
+ inheritAttrs: false,
2180
+ props: basicProps$1,
2181
+ emits: ["cancel"],
2182
+ setup(props, {
2183
+ slots,
2184
+ emit
2185
+ }) {
2186
+ const {
2187
+ visible,
2188
+ draggable,
2189
+ destroyOnClose
2190
+ } = toRefs(props);
2191
+ const attrs = useAttrs();
2192
+ useDragMove({
2193
+ visible,
2194
+ destroyOnClose,
2195
+ draggable
2196
+ });
2197
+ const {
2198
+ extendSlots
2199
+ } = useSlots();
2200
+ const onCancel = (e) => emit("cancel", e);
2201
+ return () => {
2202
+ let _slot;
2203
+ const propsData = {
2204
+ ...unref$1(attrs),
2205
+ ...props,
2206
+ destroyOnClose: true,
2207
+ onCancel
2208
+ };
2209
+ if (!propsData?.visible)
2210
+ return null;
2211
+ return createVNode(Modal$1, propsData, _isSlot(_slot = extendSlots(slots)) ? _slot : {
2212
+ default: () => [_slot]
2213
+ });
2214
+ };
2215
+ }
2216
+ };
2217
+ const Modal = /* @__PURE__ */ _export_sfc(_sfc_main$8, [["__file", "D:/dt/dt-frame-front/dt-frames/frames/packages/ui/src/components/modal/src/components/Modal.vue"]]);
2218
+ const index = "";
2219
+ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
2220
+ __name: "CloseIcon",
2221
+ props: {
2222
+ canFullscreen: { type: Boolean, default: true },
2223
+ fullScreen: { type: Boolean }
2224
+ },
2225
+ emits: ["cancel", "fullscreen"],
2226
+ setup(__props, { emit }) {
2227
+ const props = __props;
2228
+ const { t } = useI18n("UI");
2229
+ const getClass = computed(() => {
2230
+ return [
2231
+ "dt-basic-modal-close",
2232
+ `dt-basic-modal-close--custom`,
2233
+ {
2234
+ [`dt-basic-modal-close--can-full`]: props.canFullscreen
2235
+ }
2236
+ ];
2237
+ });
2238
+ function handleCancel(e) {
2239
+ emit("cancel", e);
2240
+ }
2241
+ function handleFullScreen(e) {
2242
+ e?.stopPropagation();
2243
+ e?.preventDefault();
2244
+ emit("fullscreen");
2245
+ }
2246
+ return (_ctx, _cache) => {
2247
+ const _component_ATooltip = Tooltip$1;
2248
+ return openBlock(), createElementBlock("div", {
2249
+ class: normalizeClass(["flex h-14 items-center justify-center", unref$1(getClass)])
2250
+ }, [
2251
+ __props.canFullscreen ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
2252
+ __props.fullScreen ? (openBlock(), createBlock(_component_ATooltip, {
2253
+ key: 0,
2254
+ title: unref$1(t)("EXIT_FULLSCREEN"),
2255
+ placement: "bottom"
2256
+ }, {
2257
+ default: withCtx(() => [
2258
+ createElementVNode("i", {
2259
+ class: "i ic:baseline-fullscreen-exit hover:font-bold inline-block w-10 h-14 pr-4",
2260
+ onClick: handleFullScreen
2261
+ })
2262
+ ]),
2263
+ _: 1
2264
+ }, 8, ["title"])) : (openBlock(), createBlock(_component_ATooltip, {
2265
+ key: 1,
2266
+ title: unref$1(t)("FULLSCREEN"),
2267
+ placement: "bottom"
2268
+ }, {
2269
+ default: withCtx(() => [
2270
+ createElementVNode("i", {
2271
+ class: "i ic:baseline-fullscreen hover:font-bold inline-block h-14 w-10 pr-4",
2272
+ onClick: handleFullScreen
2273
+ })
2274
+ ]),
2275
+ _: 1
2276
+ }, 8, ["title"]))
2277
+ ], 64)) : createCommentVNode("v-if", true),
2278
+ createElementVNode("i", {
2279
+ class: "i mdi:close h-14 w-10 pr-4",
2280
+ onClick: handleCancel
2281
+ })
2282
+ ], 2);
2283
+ };
2284
+ }
2285
+ });
2286
+ const CloseIcon = /* @__PURE__ */ _export_sfc(_sfc_main$7, [["__file", "D:/dt/dt-frame-front/dt-frames/frames/packages/ui/src/components/modal/src/components/CloseIcon.vue"]]);
2287
+ const isServer = typeof window === "undefined";
2288
+ const BAR_MAP = {
2289
+ vertical: {
2290
+ offset: "offsetHeight",
2291
+ scroll: "scrollTop",
2292
+ scrollSize: "scrollHeight",
2293
+ size: "height",
2294
+ key: "vertical",
2295
+ axis: "Y",
2296
+ client: "clientY",
2297
+ direction: "top"
2298
+ },
2299
+ horizontal: {
2300
+ offset: "offsetWidth",
2301
+ scroll: "scrollLeft",
2302
+ scrollSize: "scrollWidth",
2303
+ size: "width",
2304
+ key: "horizontal",
2305
+ axis: "X",
2306
+ client: "clientX",
2307
+ direction: "left"
2308
+ }
2309
+ };
2310
+ function renderThumbStyle({ move, size, bar }) {
2311
+ const style = {};
2312
+ const translate = `translate${bar.axis}(${move}%)`;
2313
+ style[bar.size] = size;
2314
+ style.transform = translate;
2315
+ style.msTransform = translate;
2316
+ style.webkitTransform = translate;
2317
+ return style;
2318
+ }
2319
+ function resizeHandler(entries) {
2320
+ for (const entry of entries) {
2321
+ const listeners = entry.target.__resizeListeners__ || [];
2322
+ if (listeners.length) {
2323
+ listeners.forEach((fn) => {
2324
+ fn();
2325
+ });
2326
+ }
2327
+ }
2328
+ }
2329
+ function addResizeListener(element, fn) {
2330
+ if (isServer)
2331
+ return;
2332
+ if (!element.__resizeListeners__) {
2333
+ element.__resizeListeners__ = [];
2334
+ element.__ro__ = new ResizeObserver(resizeHandler);
2335
+ element.__ro__.observe(element);
2336
+ }
2337
+ element.__resizeListeners__.push(fn);
2338
+ }
2339
+ function removeResizeListener(element, fn) {
2340
+ if (!element || !element.__resizeListeners__)
2341
+ return;
2342
+ element.__resizeListeners__.splice(element.__resizeListeners__.indexOf(fn), 1);
2343
+ if (!element.__resizeListeners__.length) {
2344
+ element.__ro__.disconnect();
2345
+ }
2346
+ }
2347
+ const Bar = defineComponent({
2348
+ name: "Bar",
2349
+ props: {
2350
+ vertical: Boolean,
2351
+ size: String,
2352
+ move: Number
2353
+ },
2354
+ setup(props) {
2355
+ const instance = getCurrentInstance$1();
2356
+ const thumb = ref$1();
2357
+ const wrap = inject("scroll-bar-wrap", {});
2358
+ const bar = computed(() => {
2359
+ return BAR_MAP[props.vertical ? "vertical" : "horizontal"];
2360
+ });
2361
+ const barStore = ref$1({});
2362
+ const cursorDown = ref$1();
2363
+ const clickThumbHandler = (e) => {
2364
+ if (e.ctrlKey || e.button === 2) {
2365
+ return;
2366
+ }
2367
+ window.getSelection()?.removeAllRanges();
2368
+ startDrag(e);
2369
+ barStore.value[bar.value.axis] = e.currentTarget[bar.value.offset] - (e[bar.value.client] - e.currentTarget.getBoundingClientRect()[bar.value.direction]);
2370
+ };
2371
+ const clickTrackHandler = (e) => {
2372
+ const offset = Math.abs(
2373
+ e.target.getBoundingClientRect()[bar.value.direction] - e[bar.value.client]
2374
+ );
2375
+ const thumbHalf = thumb.value[bar.value.offset] / 2;
2376
+ const thumbPositionPercentage = (offset - thumbHalf) * 100 / instance?.vnode.el?.[bar.value.offset];
2377
+ wrap.value[bar.value.scroll] = thumbPositionPercentage * wrap.value[bar.value.scrollSize] / 100;
2378
+ };
2379
+ const startDrag = (e) => {
2380
+ e.stopImmediatePropagation();
2381
+ cursorDown.value = true;
2382
+ on(document, "mousemove", mouseMoveDocumentHandler);
2383
+ on(document, "mouseup", mouseUpDocumentHandler);
2384
+ document.onselectstart = () => false;
2385
+ };
2386
+ const mouseMoveDocumentHandler = (e) => {
2387
+ if (cursorDown.value === false)
2388
+ return;
2389
+ const prevPage = barStore.value[bar.value.axis];
2390
+ if (!prevPage)
2391
+ return;
2392
+ const offset = (instance?.vnode.el?.getBoundingClientRect()[bar.value.direction] - e[bar.value.client]) * -1;
2393
+ const thumbClickPosition = thumb.value[bar.value.offset] - prevPage;
2394
+ const thumbPositionPercentage = (offset - thumbClickPosition) * 100 / instance?.vnode.el?.[bar.value.offset];
2395
+ wrap.value[bar.value.scroll] = thumbPositionPercentage * wrap.value[bar.value.scrollSize] / 100;
2396
+ };
2397
+ function mouseUpDocumentHandler() {
2398
+ cursorDown.value = false;
2399
+ barStore.value[bar.value.axis] = 0;
2400
+ off(document, "mousemove", mouseMoveDocumentHandler);
2401
+ document.onselectstart = null;
2402
+ }
2403
+ onUnmounted(() => {
2404
+ off(document, "mouseup", mouseUpDocumentHandler);
2405
+ });
2406
+ return () => h(
2407
+ "div",
2408
+ {
2409
+ class: ["scrollbar__bar", "is-" + bar.value.key],
2410
+ onMousedown: clickTrackHandler
2411
+ },
2412
+ h("div", {
2413
+ ref: thumb,
2414
+ class: "scrollbar__thumb",
2415
+ onMousedown: clickThumbHandler,
2416
+ style: renderThumbStyle({
2417
+ size: props.size,
2418
+ move: props.move,
2419
+ bar: bar.value
2420
+ })
2421
+ })
2422
+ );
2423
+ }
2424
+ });
2425
+ const _hoisted_1 = { class: "scrollbar relative h-full overflow-hidden" };
2426
+ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
2427
+ __name: "scroll-bar",
2428
+ props: {
2429
+ wrapClass: {
2430
+ type: [String, Array],
2431
+ default: ""
2432
+ },
2433
+ wrapStyle: Array,
2434
+ viewClass: {
2435
+ type: [String, Array],
2436
+ default: ""
2437
+ },
2438
+ viewStyle: {
2439
+ type: [String, Array],
2440
+ default: ""
2441
+ },
2442
+ noresize: Boolean,
2443
+ tag: {
2444
+ type: String,
2445
+ default: "div"
2446
+ }
2447
+ },
2448
+ setup(__props) {
2449
+ const props = __props;
2450
+ const sizeWidth = ref$1("0");
2451
+ const sizeHeight = ref$1("0");
2452
+ const moveX = ref$1(0);
2453
+ const moveY = ref$1(0);
2454
+ const wrap = ref$1();
2455
+ const resize = ref$1();
2456
+ provide("scroll-bar-wrap", wrap);
2457
+ const style = computed(() => {
2458
+ let rsStyle = {};
2459
+ if (Array.isArray(props.wrapStyle)) {
2460
+ props.wrapStyle.forEach((it) => {
2461
+ if (it)
2462
+ rsStyle = Object.assign({}, rsStyle, it);
2463
+ });
2464
+ }
2465
+ return rsStyle;
2466
+ });
2467
+ const handleScroll = () => {
2468
+ moveY.value = unref$1(wrap).scrollTop * 100 / unref$1(wrap).clientHeight;
2469
+ moveX.value = unref$1(wrap).scrollLeft * 100 / unref$1(wrap).clientWidth;
2470
+ };
2471
+ const update = () => {
2472
+ if (!unref$1(wrap))
2473
+ return;
2474
+ const heightPercentage = unref$1(wrap).clientHeight * 100 / unref$1(wrap).scrollHeight;
2475
+ const widthPercentage = unref$1(wrap).clientWidth * 100 / unref$1(wrap).scrollWidth;
2476
+ sizeHeight.value = heightPercentage < 100 ? heightPercentage + "%" : "";
2477
+ sizeWidth.value = widthPercentage < 100 ? widthPercentage + "%" : "";
2478
+ };
2479
+ onMounted$1(() => {
2480
+ nextTick$1(update);
2481
+ if (!props.noresize) {
2482
+ addResizeListener(unref$1(resize), update);
2483
+ addResizeListener(unref$1(wrap), update);
2484
+ addEventListener("resize", update);
2485
+ }
2486
+ });
2487
+ onBeforeUnmount(() => {
2488
+ if (!props.noresize) {
2489
+ removeResizeListener(unref$1(resize), update);
2490
+ removeResizeListener(unref$1(wrap), update);
2491
+ removeEventListener("resize", update);
2492
+ }
2493
+ });
2494
+ return (_ctx, _cache) => {
2495
+ return openBlock(), createElementBlock("div", _hoisted_1, [
2496
+ createElementVNode("div", {
2497
+ ref_key: "wrap",
2498
+ ref: wrap,
2499
+ class: normalizeClass([[__props.wrapClass, "scrollbar__wrap--hidden-default"], "h-full overflow-auto"]),
2500
+ style: normalizeStyle(unref$1(style)),
2501
+ onScroll: handleScroll
2502
+ }, [
2503
+ (openBlock(), createBlock(resolveDynamicComponent(__props.tag), {
2504
+ class: normalizeClass(["box-border", __props.viewClass]),
2505
+ ref_key: "resize",
2506
+ ref: resize,
2507
+ style: normalizeStyle(__props.viewStyle)
2508
+ }, {
2509
+ default: withCtx(() => [
2510
+ renderSlot(_ctx.$slots, "default")
2511
+ ]),
2512
+ _: 3
2513
+ }, 8, ["class", "style"]))
2514
+ ], 38),
2515
+ createVNode(unref$1(Bar), {
2516
+ move: moveX.value,
2517
+ size: sizeWidth.value
2518
+ }, null, 8, ["move", "size"]),
2519
+ createVNode(unref$1(Bar), {
2520
+ vertical: "",
2521
+ move: moveY.value,
2522
+ size: sizeHeight.value
2523
+ }, null, 8, ["move", "size"])
2524
+ ]);
2525
+ };
2526
+ }
2527
+ });
2528
+ const ScrollBar = /* @__PURE__ */ _export_sfc(_sfc_main$6, [["__file", "D:/dt/dt-frame-front/dt-frames/frames/packages/ui/src/components/container/src/components/scroll-bar.vue"]]);
2529
+ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
2530
+ __name: "scroll-container",
2531
+ setup(__props) {
2532
+ const scrollbarRef = ref$1(null);
2533
+ return (_ctx, _cache) => {
2534
+ return openBlock(), createBlock(ScrollBar, mergeProps({
2535
+ ref_key: "scrollbarRef",
2536
+ ref: scrollbarRef
2537
+ }, _ctx.$attrs, { class: "w-full h-full" }), {
2538
+ default: withCtx(() => [
2539
+ renderSlot(_ctx.$slots, "default")
2540
+ ]),
2541
+ _: 3
2542
+ }, 16);
2543
+ };
2544
+ }
2545
+ });
2546
+ const ScrollContainer = /* @__PURE__ */ _export_sfc(_sfc_main$5, [["__file", "D:/dt/dt-frame-front/dt-frames/frames/packages/ui/src/components/container/src/scroll-container.vue"]]);
2547
+ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
2548
+ __name: "slot-container",
2549
+ props: {
2550
+ template: {
2551
+ type: Function
2552
+ },
2553
+ data: {
2554
+ type: Object
2555
+ }
2556
+ },
2557
+ setup(__props) {
2558
+ const props = __props;
2559
+ const Container = h("div", [props.template(props.data)]);
2560
+ return (_ctx, _cache) => {
2561
+ return openBlock(), createBlock(unref$1(Container));
2562
+ };
2563
+ }
2564
+ });
2565
+ const SlotContainer = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["__file", "D:/dt/dt-frame-front/dt-frames/frames/packages/ui/src/components/container/src/slot-container.vue"]]);
2566
+ const DtScrollContainer = withInstall(ScrollContainer);
2567
+ withInstall(SlotContainer);
2568
+ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
2569
+ __name: "ModalWrap",
2570
+ props: {
2571
+ useWrapper: { type: Boolean, default: true },
2572
+ modalHeaderHeight: { type: Number, default: 55 },
2573
+ modalFooterHeight: { type: Number, default: 58 },
2574
+ minHeight: { type: Number, default: 200 },
2575
+ height: { type: Number },
2576
+ visible: { type: Boolean },
2577
+ fullScreen: { type: Boolean }
2578
+ },
2579
+ emits: ["ext-height", "height-change"],
2580
+ setup(__props, { emit: emits }) {
2581
+ const props = __props;
2582
+ const wrapperRef = ref$1(null);
2583
+ const wrapRef = ref$1(null);
2584
+ const realHeightRef = ref$1(0);
2585
+ const minRealHeightRef = ref$1(0);
2586
+ let realHeight = 0;
2587
+ const wrapStyle = computed(() => {
2588
+ return {
2589
+ minHeight: `${props.minHeight}px`,
2590
+ [props.fullScreen ? "height" : "maxHeight"]: `${unref$1(realHeightRef)}px`
2591
+ };
2592
+ });
2593
+ onMounted(() => {
2594
+ const { modalHeaderHeight, modalFooterHeight } = props;
2595
+ emits("ext-height", modalHeaderHeight + modalFooterHeight);
2596
+ });
2597
+ async function getModalDom() {
2598
+ const wrapperRefDom = unref$1(wrapperRef);
2599
+ if (!wrapperRefDom)
2600
+ return;
2601
+ const bodyDom = wrapperRefDom.$el.parentElement;
2602
+ if (!bodyDom)
2603
+ return;
2604
+ bodyDom.style.padding = "0";
2605
+ await nextTick$1();
2606
+ const modalDom = bodyDom.parentElement && bodyDom.parentElement.parentElement;
2607
+ return modalDom;
2608
+ }
2609
+ async function setModalHeight() {
2610
+ if (!props.visible)
2611
+ return;
2612
+ try {
2613
+ const modalDom = await getModalDom();
2614
+ if (!modalDom)
2615
+ return;
2616
+ const modalRect = getComputedStyle(modalDom).top;
2617
+ const modalTop = Number.parseInt(modalRect);
2618
+ let maxHeight = window.innerHeight - props.modalFooterHeight - props.modalHeaderHeight - 100;
2619
+ if (modalTop < 40) {
2620
+ maxHeight -= 26;
2621
+ }
2622
+ await nextTick$1();
2623
+ const warpEl = unref$1(wrapRef);
2624
+ if (!warpEl)
2625
+ return;
2626
+ await nextTick$1();
2627
+ realHeight = warpEl.scrollHeight;
2628
+ if (props.fullScreen) {
2629
+ realHeightRef.value = window.innerHeight - props.modalFooterHeight - props.modalHeaderHeight;
2630
+ } else {
2631
+ realHeightRef.value = props.height ? props.height : realHeight > maxHeight ? maxHeight : realHeight;
2632
+ }
2633
+ emits("height-change", unref$1(realHeightRef));
2634
+ const _modalDom = await getModalDom();
2635
+ _modalDom.style.top = (window.innerHeight - _modalDom.offsetHeight) / 2 + "px";
2636
+ } catch (error2) {
2637
+ console.log(error2);
2638
+ }
2639
+ }
2640
+ windowResizeFn(setModalHeight.bind(null, false));
2641
+ watchEffect(() => {
2642
+ props.useWrapper && setModalHeight();
2643
+ });
2644
+ watch(
2645
+ () => props.fullScreen,
2646
+ (v) => {
2647
+ setModalHeight();
2648
+ if (!v) {
2649
+ realHeightRef.value = minRealHeightRef.value;
2650
+ } else {
2651
+ minRealHeightRef.value = realHeightRef.value;
2652
+ }
2653
+ }
2654
+ );
2655
+ return (_ctx, _cache) => {
2656
+ return openBlock(), createBlock(unref$1(DtScrollContainer), {
2657
+ ref_key: "wrapperRef",
2658
+ ref: wrapperRef
2659
+ }, {
2660
+ default: withCtx(() => [
2661
+ createElementVNode("div", {
2662
+ ref_key: "wrapRef",
2663
+ ref: wrapRef,
2664
+ style: normalizeStyle(unref$1(wrapStyle))
2665
+ }, [
2666
+ renderSlot(_ctx.$slots, "default")
2667
+ ], 4)
2668
+ ]),
2669
+ _: 3
2670
+ }, 512);
2671
+ };
2672
+ }
2673
+ });
2674
+ const ModalWrapper = /* @__PURE__ */ _export_sfc(_sfc_main$3, [["__file", "D:/dt/dt-frame-front/dt-frames/frames/packages/ui/src/components/modal/src/components/ModalWrap.vue"]]);
2675
+ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
2676
+ __name: "ModalFooter",
2677
+ props: {
2678
+ buttons: Object,
2679
+ showSave: { type: Boolean, default: true },
2680
+ showCancel: { type: Boolean, default: true },
2681
+ okText: { type: String },
2682
+ cancelText: { type: String }
2683
+ },
2684
+ emits: [
2685
+ "handleSave",
2686
+ "handleCancel"
2687
+ ],
2688
+ setup(__props, { emit: emits }) {
2689
+ const props = __props;
2690
+ const { t } = useI18n("UI");
2691
+ const buttonList = computed(() => {
2692
+ if (props.buttons && props.buttons.length)
2693
+ return props.buttons;
2694
+ let buttonActions = [
2695
+ { t: "\u4FDD\u5B58", name: props.okText || t("SAVE"), preIcon: "mdi:content-save", type: "primary", flag: "OK" },
2696
+ { t: "\u5173\u95ED", name: props.cancelText || t("CLOSE"), preIcon: "mdi:close", flag: "CANCEL" }
2697
+ ];
2698
+ if (!props.showSave)
2699
+ buttonActions = buttonActions.filter((btn) => btn.flag !== "OK");
2700
+ if (!props.showCancel)
2701
+ buttonActions = buttonActions.filter((btn) => btn.flag !== "CANCEL");
2702
+ return buttonActions;
2703
+ });
2704
+ function handleMethod(item) {
2705
+ switch (item.flag) {
2706
+ case "OK":
2707
+ emits("handleSave");
2708
+ break;
2709
+ case "CANCEL":
2710
+ emits("handleCancel");
2711
+ break;
2712
+ }
2713
+ }
2714
+ return (_ctx, _cache) => {
2715
+ return openBlock(), createElementBlock(Fragment, null, [
2716
+ renderSlot(_ctx.$slots, "appendFooter"),
2717
+ createVNode(DtFormButtons, {
2718
+ mode: "dialog",
2719
+ buttonList: unref$1(buttonList),
2720
+ onHandleMethod: _cache[0] || (_cache[0] = ($event) => handleMethod($event))
2721
+ }, null, 8, ["buttonList"])
2722
+ ], 64);
2723
+ };
2724
+ }
2725
+ });
2726
+ const ModalFooter = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["__file", "D:/dt/dt-frame-front/dt-frames/frames/packages/ui/src/components/modal/src/components/ModalFooter.vue"]]);
2727
+ function useFullScreen(wrapClassName) {
2728
+ const fullScreenRef = ref$1(false);
2729
+ const getWrapClassName = computed(() => {
2730
+ const clsName = unref$1(wrapClassName) || "";
2731
+ const cls = unref$1(fullScreenRef) ? `fullscreen-modal ${clsName} ` : unref$1(clsName);
2732
+ return `dt-modal ${cls}`;
2733
+ });
2734
+ function toggleFullScreen(e) {
2735
+ e && e.stopPropagation();
2736
+ fullScreenRef.value = !unref$1(fullScreenRef);
2737
+ dispatchResize();
2738
+ }
2739
+ return {
2740
+ fullScreenRef,
2741
+ getWrapClassName,
2742
+ toggleFullScreen
2743
+ };
2744
+ }
2745
+ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
2746
+ __name: "index",
2747
+ props: basicProps$1,
2748
+ emits: ["visible-change", "height-change", "cancel", "save", "register", "update:visible"],
2749
+ setup(__props, { emit: emits }) {
2750
+ const props = __props;
2751
+ const visibleRef = ref$1(false);
2752
+ const propsRef = ref$1();
2753
+ const modalWrapperRef = ref$1(null);
2754
+ const { getWrapClassName, toggleFullScreen, fullScreenRef } = useFullScreen(computed(() => unref$1(propsRef)?.wrapClassName));
2755
+ const getMergeProps = computed(() => {
2756
+ return {
2757
+ ...props,
2758
+ ...unref$1(propsRef)
2759
+ };
2760
+ });
2761
+ const getBindValue = computed(() => {
2762
+ const bindValue = {
2763
+ ...unref$1(getMergeProps),
2764
+ ...unref$1(propsRef),
2765
+ visible: unref$1(visibleRef),
2766
+ wrapClassName: unref$1(getWrapClassName)
2767
+ };
2768
+ let omitArr = unref$1(fullScreenRef) ? ["height", "title"] : ["title"];
2769
+ if (isArray(unref$1(propsRef)?.footer)) {
2770
+ omitArr.push("footer");
2771
+ }
2772
+ return omit(bindValue, omitArr);
2773
+ });
2774
+ const getWrapperHeight = computed(() => {
2775
+ if (unref$1(fullScreenRef))
2776
+ return void 0;
2777
+ return unref$1(getBindValue).height;
2778
+ });
2779
+ const modalFooterHeight = computed(() => {
2780
+ if (isArray(props.footer)) {
2781
+ return (unref$1(propsRef)?.footer).length ? 0 : void 0;
2782
+ }
2783
+ return props?.footer !== void 0 && !props.footer ? 0 : void 0;
2784
+ });
2785
+ const modalMethods = {
2786
+ setModalProps,
2787
+ redoModalHeight: () => {
2788
+ nextTick$1(() => {
2789
+ if (unref$1(modalWrapperRef)) {
2790
+ unref$1(modalWrapperRef).setModalHeight();
2791
+ }
2792
+ });
2793
+ }
2794
+ };
2795
+ const instance = getCurrentInstance();
2796
+ if (instance) {
2797
+ emits("register", modalMethods, instance.uid);
2798
+ }
2799
+ function handleHeightChange(height) {
2800
+ emits("height-change", height);
2801
+ }
2802
+ function setModalProps(props2) {
2803
+ propsRef.value = deepMerge(unref$1(propsRef) || {}, props2);
2804
+ if (Reflect.has(props2, "visible")) {
2805
+ visibleRef.value = !!props2.visible;
2806
+ }
2807
+ if (Reflect.has(props2, "defaultFullscreen")) {
2808
+ fullScreenRef.value = !!props2.defaultFullscreen;
2809
+ }
2810
+ }
2811
+ function handleSave() {
2812
+ emits("save");
2813
+ }
2814
+ async function handleCancel(e = null) {
2815
+ if (e) {
2816
+ e?.stopPropagation();
2817
+ if (e.target?.classList?.contains("dt-basic-modal-close--custom"))
2818
+ return;
2819
+ if (props.closeFunc && isFunction(props.closeFunc)) {
2820
+ const isClose = await props.closeFunc();
2821
+ visibleRef.value = !isClose;
2822
+ return;
2823
+ }
2824
+ }
2825
+ const { afterClose } = unref$1(getBindValue);
2826
+ if (afterClose && isFunction(afterClose)) {
2827
+ afterClose();
2828
+ }
2829
+ visibleRef.value = false;
2830
+ emits("cancel", e);
2831
+ }
2832
+ watch(() => unref$1(visibleRef), (v) => {
2833
+ emits("visible-change", v);
2834
+ emits("update:visible", v);
2835
+ nextTick$1(() => {
2836
+ if (props.scrollTop && v && unref$1(modalWrapperRef)) {
2837
+ unref$1(modalWrapperRef).$el.scrollTop = 0;
2838
+ }
2839
+ });
2840
+ }, {
2841
+ immediate: false
2842
+ });
2843
+ return (_ctx, _cache) => {
2844
+ const _component_ASpin = Spin;
2845
+ return openBlock(), createBlock(Modal, mergeProps(unref$1(getBindValue), { onCancel: handleCancel }), createSlots({
2846
+ default: withCtx(() => [
2847
+ createVNode(_component_ASpin, {
2848
+ spinning: unref$1(getBindValue).loading,
2849
+ tip: unref$1(getBindValue).loadingTip
2850
+ }, {
2851
+ default: withCtx(() => [
2852
+ createVNode(ModalWrapper, mergeProps({
2853
+ useWrapper: unref$1(getBindValue).useWrapper,
2854
+ fullScreen: unref$1(fullScreenRef),
2855
+ ref_key: "modalWrapperRef",
2856
+ ref: modalWrapperRef,
2857
+ minHeight: unref$1(getBindValue).minHeight,
2858
+ height: unref$1(getWrapperHeight),
2859
+ visible: visibleRef.value,
2860
+ modalFooterHeight: unref$1(modalFooterHeight)
2861
+ }, unref$1(omit)(unref$1(getBindValue).wrapperProps, "visible", "height", "modalFooterHeight"), { onHeightChange: handleHeightChange }), {
2862
+ default: withCtx(() => [
2863
+ renderSlot(_ctx.$slots, "default")
2864
+ ]),
2865
+ _: 3
2866
+ }, 16, ["useWrapper", "fullScreen", "minHeight", "height", "visible", "modalFooterHeight"])
2867
+ ]),
2868
+ _: 3
2869
+ }, 8, ["spinning", "tip"])
2870
+ ]),
2871
+ _: 2
2872
+ }, [
2873
+ !_ctx.$slots.closeIcon ? {
2874
+ name: "closeIcon",
2875
+ fn: withCtx(() => [
2876
+ createVNode(CloseIcon, {
2877
+ canFullscreen: unref$1(getBindValue).canFullscreen,
2878
+ fullScreen: unref$1(fullScreenRef),
2879
+ onCancel: handleCancel,
2880
+ onFullscreen: unref$1(toggleFullScreen)
2881
+ }, null, 8, ["canFullscreen", "fullScreen", "onFullscreen"])
2882
+ ]),
2883
+ key: "0"
2884
+ } : void 0,
2885
+ !_ctx.$slots.title ? {
2886
+ name: "title",
2887
+ fn: withCtx(() => [
2888
+ createTextVNode(toDisplayString(unref$1(getMergeProps).title), 1)
2889
+ ]),
2890
+ key: "1"
2891
+ } : void 0,
2892
+ !_ctx.$slots.footer ? {
2893
+ name: "footer",
2894
+ fn: withCtx(() => [
2895
+ createVNode(ModalFooter, {
2896
+ buttons: propsRef.value?.footer,
2897
+ showSave: unref$1(getBindValue).showOkBtn,
2898
+ showCancel: unref$1(getBindValue).showCancelBtn,
2899
+ okText: unref$1(getBindValue).okText,
2900
+ cancelText: unref$1(getBindValue).cancelText,
2901
+ onHandleSave: handleSave,
2902
+ onHandleCancel: handleCancel
2903
+ }, createSlots({ _: 2 }, [
2904
+ renderList(Object.keys(_ctx.$slots), (item) => {
2905
+ return {
2906
+ name: item,
2907
+ fn: withCtx((data) => [
2908
+ renderSlot(_ctx.$slots, item, normalizeProps(guardReactiveProps(data || {})))
2909
+ ])
2910
+ };
2911
+ })
2912
+ ]), 1032, ["buttons", "showSave", "showCancel", "okText", "cancelText"])
2913
+ ]),
2914
+ key: "2"
2915
+ } : void 0,
2916
+ renderList(Object.keys(unref$1(omit)(_ctx.$slots, "default")), (item) => {
2917
+ return {
2918
+ name: item,
2919
+ fn: withCtx((data) => [
2920
+ renderSlot(_ctx.$slots, item, normalizeProps(guardReactiveProps(data || {})))
2921
+ ])
2922
+ };
2923
+ })
2924
+ ]), 1040);
2925
+ };
2926
+ }
2927
+ });
2928
+ const DtModal$1 = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__file", "D:/dt/dt-frame-front/dt-frames/frames/packages/ui/src/components/modal/src/index.vue"]]);
2929
+ const basicProps = {
2930
+ title: {
2931
+ type: Object
2932
+ },
2933
+ width: {
2934
+ type: [String, Number],
2935
+ default: "50%"
2936
+ },
2937
+ schemas: {
2938
+ type: Array,
2939
+ default: () => []
2940
+ },
2941
+ footer: {
2942
+ type: Array,
2943
+ default: void 0
2944
+ },
2945
+ showFullscreen: {
2946
+ type: Boolean,
2947
+ default: true
2948
+ },
2949
+ showClosable: {
2950
+ type: Boolean,
2951
+ default: true
2952
+ },
2953
+ formProps: {
2954
+ type: Object,
2955
+ default: () => ({})
2956
+ },
2957
+ primaryKey: {
2958
+ type: String,
2959
+ default: "id"
2960
+ },
2961
+ actType: {
2962
+ type: Object
2963
+ },
2964
+ onSave: {
2965
+ type: Function,
2966
+ default: () => ({})
2967
+ },
2968
+ onDeletes: {
2969
+ type: Function,
2970
+ default: (keys) => ({})
2971
+ },
2972
+ onQueryById: {
2973
+ type: Function,
2974
+ default: (id) => ({})
2975
+ },
2976
+ onRegister: {
2977
+ type: Function
2978
+ },
2979
+ registerInstance: {
2980
+ type: Function
2981
+ }
2982
+ };
2983
+ const _sfc_main = /* @__PURE__ */ defineComponent({
2984
+ __name: "Curd",
2985
+ props: basicProps,
2986
+ setup(__props) {
2987
+ const props = __props;
2988
+ const [registerDialog] = useModal({
2989
+ ...omit(toRaw$1(props), [
2990
+ "curd",
2991
+ "formProps",
2992
+ "schemas"
2993
+ ]),
2994
+ destroyOnClose: true
2995
+ });
2996
+ function handleSave() {
2997
+ props?.onSave();
2998
+ }
2999
+ return (_ctx, _cache) => {
3000
+ return openBlock(), createBlock(unref$1(DtModal$1), {
3001
+ onRegister: unref$1(registerDialog),
3002
+ onSave: _cache[0] || (_cache[0] = ($event) => handleSave())
3003
+ }, {
3004
+ default: withCtx(() => [
3005
+ renderSlot(_ctx.$slots, "default")
3006
+ ]),
3007
+ _: 3
3008
+ }, 8, ["onRegister"]);
3009
+ };
3010
+ }
3011
+ });
3012
+ const DtModal = /* @__PURE__ */ _export_sfc(_sfc_main, [["__file", "D:/dt/dt-frame-front/dt-frames/frames/packages/ui/src/components/curd/src/components/Curd.vue"]]);
3013
+ function useCurd(curdOpt) {
3014
+ const [register, {
3015
+ openModal,
3016
+ closeModal,
3017
+ setModalProps
3018
+ }] = useModalOut();
3019
+ const {
3020
+ confirm,
3021
+ message
3022
+ } = useMessage();
3023
+ const {
3024
+ t
3025
+ } = useI18n("UI");
3026
+ const {
3027
+ formProps,
3028
+ schemas
3029
+ } = curdOpt;
3030
+ const oriTitle = isFunction(curdOpt.title) ? curdOpt.title() : unref(curdOpt.title);
3031
+ const title = ref(oriTitle);
3032
+ const [registerForm, curdFormMethods] = useForm({
3033
+ ...formProps || {},
3034
+ schemas,
3035
+ mode: "dialog"
3036
+ });
3037
+ const DtCurdModal = () => {
3038
+ return h(createVNode("div", {
3039
+ "class": "dt-curd-modal"
3040
+ }, [createVNode(DtModal, mergeProps(curdOpt, {
3041
+ "title": title,
3042
+ "onRegister": register
3043
+ }), {
3044
+ default: () => [createVNode(DtForm, {
3045
+ "onRegister": registerForm
3046
+ }, null)]
3047
+ })]));
3048
+ };
3049
+ function add() {
3050
+ title.value = t("ADD") + " - " + oriTitle;
3051
+ openModal();
3052
+ }
3053
+ function del({
3054
+ row
3055
+ }) {
3056
+ const {
3057
+ primaryKey = "id",
3058
+ onDeletes
3059
+ } = curdOpt;
3060
+ if (onDeletes && isFunction(onDeletes)) {
3061
+ onDeletes([row[primaryKey]]);
3062
+ }
3063
+ }
3064
+ function update({
3065
+ row
3066
+ }) {
3067
+ const {
3068
+ primaryKey = "id",
3069
+ onQueryById
3070
+ } = curdOpt;
3071
+ title.value = t("EDIT") + " - " + oriTitle;
3072
+ openModal();
3073
+ if (onQueryById && isFunction(onQueryById)) {
3074
+ onQueryById(row[primaryKey]).then((rsp) => {
3075
+ curdFormMethods.setFormValues(rsp);
3076
+ nextTick(() => dispatchResize());
3077
+ });
3078
+ }
3079
+ }
3080
+ function dels(ids = []) {
3081
+ if (!ids.length) {
3082
+ message.error(t("EMPTY"));
3083
+ return;
3084
+ }
3085
+ const {
3086
+ curd
3087
+ } = curdOpt;
3088
+ if (curd && curd.onDeletes && isFunction(curd.onDeletes)) {
3089
+ confirm({
3090
+ title: t("MULTIFY_DELETE_CONFIRM"),
3091
+ content: t("CONFIRM_MULTIFY_DELETE", {
3092
+ length: ids.length
3093
+ }),
3094
+ iconType: "warning",
3095
+ onOk() {
3096
+ curd.onDeletes(ids);
3097
+ }
3098
+ });
3099
+ } else {
3100
+ error(t("NEED_CURD"));
3101
+ }
3102
+ }
3103
+ const instance = {
3104
+ add,
3105
+ del,
3106
+ update,
3107
+ dels,
3108
+ closeModal,
3109
+ setModalProps,
3110
+ curdFormMethods
3111
+ };
3112
+ curdOpt.registerInstance && curdOpt.registerInstance(instance);
3113
+ return {
3114
+ DtCurdModal,
3115
+ ...instance
3116
+ };
3117
+ }
3118
+ export {
3119
+ useCurd
3120
+ };