el-plus2 0.0.0

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 (299) hide show
  1. package/dist/index.full.js +2204 -0
  2. package/dist/index.full.min.js +2 -0
  3. package/dist/index.full.min.js.map +1 -0
  4. package/dist/index.full.min.mjs +2 -0
  5. package/dist/index.full.min.mjs.map +1 -0
  6. package/dist/index.full.mjs +2176 -0
  7. package/env.d.ts +17 -0
  8. package/es/components/buttons/index.d.ts +359 -0
  9. package/es/components/buttons/index.mjs +8 -0
  10. package/es/components/buttons/index.mjs.map +1 -0
  11. package/es/components/buttons/src/buttons-vue.d.ts +142 -0
  12. package/es/components/buttons/src/buttons-vue.mjs +70 -0
  13. package/es/components/buttons/src/buttons-vue.mjs.map +1 -0
  14. package/es/components/buttons/src/buttons.d.ts +57 -0
  15. package/es/components/buttons/src/buttons.mjs +23 -0
  16. package/es/components/buttons/src/buttons.mjs.map +1 -0
  17. package/es/components/form/index.d.ts +291 -0
  18. package/es/components/form/index.mjs +10 -0
  19. package/es/components/form/index.mjs.map +1 -0
  20. package/es/components/form/src/form-item-vue.d.ts +135 -0
  21. package/es/components/form/src/form-item-vue.mjs +40 -0
  22. package/es/components/form/src/form-item-vue.mjs.map +1 -0
  23. package/es/components/form/src/form-item.d.ts +68 -0
  24. package/es/components/form/src/form-item.mjs +33 -0
  25. package/es/components/form/src/form-item.mjs.map +1 -0
  26. package/es/components/form/src/form.d.ts +66 -0
  27. package/es/components/form/src/form.mjs +50 -0
  28. package/es/components/form/src/form.mjs.map +1 -0
  29. package/es/components/form/src/form.vue.d.ts +161 -0
  30. package/es/components/form/src/form.vue.mjs +6 -0
  31. package/es/components/form/src/form.vue.mjs.map +1 -0
  32. package/es/components/form/src/form.vue2.mjs +124 -0
  33. package/es/components/form/src/form.vue2.mjs.map +1 -0
  34. package/es/components/form/src/hooks/use-form-item.d.ts +12 -0
  35. package/es/components/form/src/hooks/use-form-item.mjs +97 -0
  36. package/es/components/form/src/hooks/use-form-item.mjs.map +1 -0
  37. package/es/components/form/src/hooks/use-form.d.ts +25 -0
  38. package/es/components/form/src/hooks/use-form.mjs +53 -0
  39. package/es/components/form/src/hooks/use-form.mjs.map +1 -0
  40. package/es/components/index.d.ts +6 -0
  41. package/es/components/index.mjs +9 -0
  42. package/es/components/index.mjs.map +1 -0
  43. package/es/components/input/index.d.ts +468 -0
  44. package/es/components/input/index.mjs +8 -0
  45. package/es/components/input/index.mjs.map +1 -0
  46. package/es/components/input/src/input.d.ts +122 -0
  47. package/es/components/input/src/input.mjs +28 -0
  48. package/es/components/input/src/input.mjs.map +1 -0
  49. package/es/components/input/src/input.vue.d.ts +268 -0
  50. package/es/components/input/src/input.vue.mjs +6 -0
  51. package/es/components/input/src/input.vue.mjs.map +1 -0
  52. package/es/components/input/src/input.vue2.mjs +144 -0
  53. package/es/components/input/src/input.vue2.mjs.map +1 -0
  54. package/es/components/searchListPage/index.d.ts +8583 -0
  55. package/es/components/searchListPage/index.mjs +8 -0
  56. package/es/components/searchListPage/index.mjs.map +1 -0
  57. package/es/components/searchListPage/src/searchListPage.d.ts +64 -0
  58. package/es/components/searchListPage/src/searchListPage.mjs +61 -0
  59. package/es/components/searchListPage/src/searchListPage.mjs.map +1 -0
  60. package/es/components/searchListPage/src/searchListPage.vue.d.ts +2760 -0
  61. package/es/components/searchListPage/src/searchListPage.vue.mjs +6 -0
  62. package/es/components/searchListPage/src/searchListPage.vue.mjs.map +1 -0
  63. package/es/components/searchListPage/src/searchListPage.vue2.mjs +99 -0
  64. package/es/components/searchListPage/src/searchListPage.vue2.mjs.map +1 -0
  65. package/es/components/searchListPage/src/use-search-list-page.d.ts +2671 -0
  66. package/es/components/searchListPage/src/use-search-list-page.mjs +177 -0
  67. package/es/components/searchListPage/src/use-search-list-page.mjs.map +1 -0
  68. package/es/components/select/index.d.ts +664 -0
  69. package/es/components/select/index.mjs +8 -0
  70. package/es/components/select/index.mjs.map +1 -0
  71. package/es/components/select/src/select.d.ts +283 -0
  72. package/es/components/select/src/select.mjs +47 -0
  73. package/es/components/select/src/select.mjs.map +1 -0
  74. package/es/components/select/src/select.vue.d.ts +384 -0
  75. package/es/components/select/src/select.vue.mjs +6 -0
  76. package/es/components/select/src/select.vue.mjs.map +1 -0
  77. package/es/components/select/src/select.vue2.mjs +113 -0
  78. package/es/components/select/src/select.vue2.mjs.map +1 -0
  79. package/es/components/select/src/use-select.d.ts +12 -0
  80. package/es/components/select/src/use-select.mjs +87 -0
  81. package/es/components/select/src/use-select.mjs.map +1 -0
  82. package/es/components/table/index.d.ts +2975 -0
  83. package/es/components/table/index.mjs +8 -0
  84. package/es/components/table/index.mjs.map +1 -0
  85. package/es/components/table/src/table.d.ts +781 -0
  86. package/es/components/table/src/table.mjs +81 -0
  87. package/es/components/table/src/table.mjs.map +1 -0
  88. package/es/components/table/src/table.vue.d.ts +1708 -0
  89. package/es/components/table/src/table.vue.mjs +6 -0
  90. package/es/components/table/src/table.vue.mjs.map +1 -0
  91. package/es/components/table/src/table.vue2.mjs +204 -0
  92. package/es/components/table/src/table.vue2.mjs.map +1 -0
  93. package/es/components/table/src/use-table.d.ts +241 -0
  94. package/es/components/table/src/use-table.mjs +260 -0
  95. package/es/components/table/src/use-table.mjs.map +1 -0
  96. package/es/components.d.ts +3 -0
  97. package/es/components.mjs +11 -0
  98. package/es/components.mjs.map +1 -0
  99. package/es/directives/index.d.ts +2 -0
  100. package/es/directives/index.mjs +3 -0
  101. package/es/directives/index.mjs.map +1 -0
  102. package/es/directives/permission/index.d.ts +6 -0
  103. package/es/directives/permission/index.mjs +55 -0
  104. package/es/directives/permission/index.mjs.map +1 -0
  105. package/es/directives/repeat-click/index.d.ts +16 -0
  106. package/es/directives/repeat-click/index.mjs +68 -0
  107. package/es/directives/repeat-click/index.mjs.map +1 -0
  108. package/es/directives/vite.config.d.ts +2 -0
  109. package/es/hooks/index.d.ts +1 -0
  110. package/es/hooks/index.mjs +2 -0
  111. package/es/hooks/index.mjs.map +1 -0
  112. package/es/hooks/use-request.d.ts +20 -0
  113. package/es/hooks/use-request.mjs +82 -0
  114. package/es/hooks/use-request.mjs.map +1 -0
  115. package/es/index.d.ts +9 -0
  116. package/es/index.mjs +24 -0
  117. package/es/index.mjs.map +1 -0
  118. package/es/package.json.mjs +4 -0
  119. package/es/package.json.mjs.map +1 -0
  120. package/es/theme-chalk/gulpfile.d.ts +0 -0
  121. package/es/theme-chalk/gulpfile.mjs +2 -0
  122. package/es/theme-chalk/gulpfile.mjs.map +1 -0
  123. package/es/types/env.d.mjs +2 -0
  124. package/es/types/env.d.mjs.map +1 -0
  125. package/es/types/global.d.mjs +2 -0
  126. package/es/types/global.d.mjs.map +1 -0
  127. package/es/types/vue-shim.d.mjs +2 -0
  128. package/es/types/vue-shim.d.mjs.map +1 -0
  129. package/es/utils/bem.d.ts +10 -0
  130. package/es/utils/bem.mjs +31 -0
  131. package/es/utils/bem.mjs.map +1 -0
  132. package/es/utils/cookie.d.ts +7 -0
  133. package/es/utils/cookie.mjs +29 -0
  134. package/es/utils/cookie.mjs.map +1 -0
  135. package/es/utils/env.d.ts +3 -0
  136. package/es/utils/env.mjs +27 -0
  137. package/es/utils/env.mjs.map +1 -0
  138. package/es/utils/props.d.ts +37 -0
  139. package/es/utils/props.mjs +66 -0
  140. package/es/utils/props.mjs.map +1 -0
  141. package/es/utils/request.d.ts +6 -0
  142. package/es/utils/request.mjs +157 -0
  143. package/es/utils/request.mjs.map +1 -0
  144. package/es/utils/type.d.ts +15 -0
  145. package/es/utils/type.mjs +2 -0
  146. package/es/utils/type.mjs.map +1 -0
  147. package/es/utils/with-install.d.ts +4 -0
  148. package/es/utils/with-install.mjs +9 -0
  149. package/es/utils/with-install.mjs.map +1 -0
  150. package/es/version.d.ts +1 -0
  151. package/es/version.mjs +4 -0
  152. package/es/version.mjs.map +1 -0
  153. package/global.d.ts +13 -0
  154. package/lib/components/buttons/index.d.ts +359 -0
  155. package/lib/components/buttons/index.js +13 -0
  156. package/lib/components/buttons/index.js.map +1 -0
  157. package/lib/components/buttons/src/buttons-vue.d.ts +142 -0
  158. package/lib/components/buttons/src/buttons-vue.js +74 -0
  159. package/lib/components/buttons/src/buttons-vue.js.map +1 -0
  160. package/lib/components/buttons/src/buttons.d.ts +57 -0
  161. package/lib/components/buttons/src/buttons.js +25 -0
  162. package/lib/components/buttons/src/buttons.js.map +1 -0
  163. package/lib/components/form/index.d.ts +291 -0
  164. package/lib/components/form/index.js +21 -0
  165. package/lib/components/form/index.js.map +1 -0
  166. package/lib/components/form/src/form-item-vue.d.ts +135 -0
  167. package/lib/components/form/src/form-item-vue.js +44 -0
  168. package/lib/components/form/src/form-item-vue.js.map +1 -0
  169. package/lib/components/form/src/form-item.d.ts +68 -0
  170. package/lib/components/form/src/form-item.js +36 -0
  171. package/lib/components/form/src/form-item.js.map +1 -0
  172. package/lib/components/form/src/form.d.ts +66 -0
  173. package/lib/components/form/src/form.js +55 -0
  174. package/lib/components/form/src/form.js.map +1 -0
  175. package/lib/components/form/src/form.vue.d.ts +161 -0
  176. package/lib/components/form/src/form.vue.js +10 -0
  177. package/lib/components/form/src/form.vue.js.map +1 -0
  178. package/lib/components/form/src/form.vue2.js +128 -0
  179. package/lib/components/form/src/form.vue2.js.map +1 -0
  180. package/lib/components/form/src/hooks/use-form-item.d.ts +12 -0
  181. package/lib/components/form/src/hooks/use-form-item.js +101 -0
  182. package/lib/components/form/src/hooks/use-form-item.js.map +1 -0
  183. package/lib/components/form/src/hooks/use-form.d.ts +25 -0
  184. package/lib/components/form/src/hooks/use-form.js +56 -0
  185. package/lib/components/form/src/hooks/use-form.js.map +1 -0
  186. package/lib/components/index.d.ts +6 -0
  187. package/lib/components/index.js +35 -0
  188. package/lib/components/index.js.map +1 -0
  189. package/lib/components/input/index.d.ts +468 -0
  190. package/lib/components/input/index.js +15 -0
  191. package/lib/components/input/index.js.map +1 -0
  192. package/lib/components/input/src/input.d.ts +122 -0
  193. package/lib/components/input/src/input.js +32 -0
  194. package/lib/components/input/src/input.js.map +1 -0
  195. package/lib/components/input/src/input.vue.d.ts +268 -0
  196. package/lib/components/input/src/input.vue.js +10 -0
  197. package/lib/components/input/src/input.vue.js.map +1 -0
  198. package/lib/components/input/src/input.vue2.js +148 -0
  199. package/lib/components/input/src/input.vue2.js.map +1 -0
  200. package/lib/components/searchListPage/index.d.ts +8583 -0
  201. package/lib/components/searchListPage/index.js +13 -0
  202. package/lib/components/searchListPage/index.js.map +1 -0
  203. package/lib/components/searchListPage/src/searchListPage.d.ts +64 -0
  204. package/lib/components/searchListPage/src/searchListPage.js +63 -0
  205. package/lib/components/searchListPage/src/searchListPage.js.map +1 -0
  206. package/lib/components/searchListPage/src/searchListPage.vue.d.ts +2760 -0
  207. package/lib/components/searchListPage/src/searchListPage.vue.js +10 -0
  208. package/lib/components/searchListPage/src/searchListPage.vue.js.map +1 -0
  209. package/lib/components/searchListPage/src/searchListPage.vue2.js +103 -0
  210. package/lib/components/searchListPage/src/searchListPage.vue2.js.map +1 -0
  211. package/lib/components/searchListPage/src/use-search-list-page.d.ts +2671 -0
  212. package/lib/components/searchListPage/src/use-search-list-page.js +179 -0
  213. package/lib/components/searchListPage/src/use-search-list-page.js.map +1 -0
  214. package/lib/components/select/index.d.ts +664 -0
  215. package/lib/components/select/index.js +17 -0
  216. package/lib/components/select/index.js.map +1 -0
  217. package/lib/components/select/src/select.d.ts +283 -0
  218. package/lib/components/select/src/select.js +53 -0
  219. package/lib/components/select/src/select.js.map +1 -0
  220. package/lib/components/select/src/select.vue.d.ts +384 -0
  221. package/lib/components/select/src/select.vue.js +10 -0
  222. package/lib/components/select/src/select.vue.js.map +1 -0
  223. package/lib/components/select/src/select.vue2.js +117 -0
  224. package/lib/components/select/src/select.vue2.js.map +1 -0
  225. package/lib/components/select/src/use-select.d.ts +12 -0
  226. package/lib/components/select/src/use-select.js +89 -0
  227. package/lib/components/select/src/use-select.js.map +1 -0
  228. package/lib/components/table/index.d.ts +2975 -0
  229. package/lib/components/table/index.js +16 -0
  230. package/lib/components/table/index.js.map +1 -0
  231. package/lib/components/table/src/table.d.ts +781 -0
  232. package/lib/components/table/src/table.js +86 -0
  233. package/lib/components/table/src/table.js.map +1 -0
  234. package/lib/components/table/src/table.vue.d.ts +1708 -0
  235. package/lib/components/table/src/table.vue.js +10 -0
  236. package/lib/components/table/src/table.vue.js.map +1 -0
  237. package/lib/components/table/src/table.vue2.js +208 -0
  238. package/lib/components/table/src/table.vue2.js.map +1 -0
  239. package/lib/components/table/src/use-table.d.ts +241 -0
  240. package/lib/components/table/src/use-table.js +264 -0
  241. package/lib/components/table/src/use-table.js.map +1 -0
  242. package/lib/components.d.ts +3 -0
  243. package/lib/components.js +15 -0
  244. package/lib/components.js.map +1 -0
  245. package/lib/directives/index.d.ts +2 -0
  246. package/lib/directives/index.js +10 -0
  247. package/lib/directives/index.js.map +1 -0
  248. package/lib/directives/permission/index.d.ts +6 -0
  249. package/lib/directives/permission/index.js +60 -0
  250. package/lib/directives/permission/index.js.map +1 -0
  251. package/lib/directives/repeat-click/index.d.ts +16 -0
  252. package/lib/directives/repeat-click/index.js +72 -0
  253. package/lib/directives/repeat-click/index.js.map +1 -0
  254. package/lib/directives/vite.config.d.ts +2 -0
  255. package/lib/hooks/index.d.ts +1 -0
  256. package/lib/hooks/index.js +8 -0
  257. package/lib/hooks/index.js.map +1 -0
  258. package/lib/hooks/use-request.d.ts +20 -0
  259. package/lib/hooks/use-request.js +84 -0
  260. package/lib/hooks/use-request.js.map +1 -0
  261. package/lib/index.d.ts +9 -0
  262. package/lib/index.js +53 -0
  263. package/lib/index.js.map +1 -0
  264. package/lib/package.json.js +6 -0
  265. package/lib/package.json.js.map +1 -0
  266. package/lib/theme-chalk/gulpfile.d.ts +0 -0
  267. package/lib/theme-chalk/gulpfile.js +3 -0
  268. package/lib/theme-chalk/gulpfile.js.map +1 -0
  269. package/lib/types/env.d.js +3 -0
  270. package/lib/types/env.d.js.map +1 -0
  271. package/lib/types/global.d.js +3 -0
  272. package/lib/types/global.d.js.map +1 -0
  273. package/lib/types/vue-shim.d.js +3 -0
  274. package/lib/types/vue-shim.d.js.map +1 -0
  275. package/lib/utils/bem.d.ts +10 -0
  276. package/lib/utils/bem.js +33 -0
  277. package/lib/utils/bem.js.map +1 -0
  278. package/lib/utils/cookie.d.ts +7 -0
  279. package/lib/utils/cookie.js +33 -0
  280. package/lib/utils/cookie.js.map +1 -0
  281. package/lib/utils/env.d.ts +3 -0
  282. package/lib/utils/env.js +30 -0
  283. package/lib/utils/env.js.map +1 -0
  284. package/lib/utils/props.d.ts +37 -0
  285. package/lib/utils/props.js +73 -0
  286. package/lib/utils/props.js.map +1 -0
  287. package/lib/utils/request.d.ts +6 -0
  288. package/lib/utils/request.js +162 -0
  289. package/lib/utils/request.js.map +1 -0
  290. package/lib/utils/type.d.ts +15 -0
  291. package/lib/utils/type.js +3 -0
  292. package/lib/utils/type.js.map +1 -0
  293. package/lib/utils/with-install.d.ts +4 -0
  294. package/lib/utils/with-install.js +11 -0
  295. package/lib/utils/with-install.js.map +1 -0
  296. package/lib/version.d.ts +1 -0
  297. package/lib/version.js +6 -0
  298. package/lib/version.js.map +1 -0
  299. package/package.json +27 -0
@@ -0,0 +1,2176 @@
1
+ /*! ElPlus vundefined */
2
+
3
+ import { useAttrs, defineComponent, computed, createVNode, Fragment, withDirectives, resolveComponent, mergeProps, resolveDirective, useTemplateRef, ref, createTextVNode, h, mergeModels, useModel, createElementBlock, openBlock, normalizeStyle, normalizeClass, unref, createCommentVNode, withCtx, renderSlot, renderList, createBlock, vShow, toDisplayString, reactive, useSlots, watch, onMounted, createSlots, normalizeProps, guardReactiveProps, createElementVNode } from 'vue';
4
+ import { buttonProps, ElMessage, ElLoading, ElMessageBox, formProps as formProps$1, formEmits as formEmits$1, formItemProps as formItemProps$1, inputProps as inputProps$1, inputEmits as inputEmits$1, ElTable, selectProps as selectProps$1, selectEmits as selectEmits$1 } from 'element-plus';
5
+ import axios from 'axios';
6
+ import 'element-plus/es/components/message/style/css';
7
+ import 'element-plus/es/components/loading/style/css';
8
+ import elTableProps from 'element-plus/es/components/table/src/table/defaults';
9
+
10
+ const buttonsProps = {
11
+ ...buttonProps,
12
+ disabled: {
13
+ type: [Boolean, Function]
14
+ },
15
+ list: {
16
+ type: Array,
17
+ default: () => []
18
+ },
19
+ size: {
20
+ ...buttonProps.size,
21
+ default: "small"
22
+ },
23
+ type: {
24
+ ...buttonProps.type,
25
+ default: "default"
26
+ }
27
+ };
28
+
29
+ function _bem(prefix, block, element, modifier) {
30
+ if (block) {
31
+ prefix += "-" + block;
32
+ }
33
+ if (element) {
34
+ prefix += "__" + element;
35
+ }
36
+ if (modifier) {
37
+ prefix += "--" + modifier;
38
+ }
39
+ return prefix;
40
+ }
41
+ function createBEM(prefix) {
42
+ return {
43
+ b: (block = "") => _bem(prefix, block, "", ""),
44
+ e: (element = "") => element ? _bem(prefix, "", element, "") : "",
45
+ m: (modifier = "") => modifier ? _bem(prefix, "", "", modifier) : "",
46
+ be: (block = "", element = "") => block && element ? _bem(prefix, block, element, "") : "",
47
+ bm: (block = "", modifier = "") => block && modifier ? _bem(prefix, block, "", modifier) : "",
48
+ em: (element = "", modifier = "") => element && modifier ? _bem(prefix, "", element, modifier) : "",
49
+ bem: (block = "", element = "", modifier) => block && element && modifier ? _bem(prefix, block, element, modifier) : "",
50
+ is: (name = "", state) => state ? `is-${name}` : ""
51
+ };
52
+ }
53
+ function createNameSpace(name) {
54
+ const prefix = `ep-${name}`;
55
+ return createBEM(prefix);
56
+ }
57
+
58
+ const apiProps = {
59
+ api: {
60
+ type: [String, Function]
61
+ },
62
+ method: {
63
+ type: String
64
+ },
65
+ reqData: {
66
+ type: Object
67
+ },
68
+ reqParams: {
69
+ type: Object
70
+ },
71
+ reqBefore: {
72
+ type: Function
73
+ },
74
+ reqAfter: {
75
+ type: Function
76
+ }
77
+ };
78
+ const visibleProps = {
79
+ show: {
80
+ type: [Boolean, Function]
81
+ },
82
+ hide: {
83
+ type: [Boolean, Function]
84
+ }
85
+ };
86
+ const prepareProps = (props, excludeKeys = []) => {
87
+ return Object.keys(props).reduce((acc, key) => {
88
+ if (!excludeKeys.includes(key)) {
89
+ acc[key] = props[key];
90
+ }
91
+ return acc;
92
+ }, {});
93
+ };
94
+ const prepareEvents = (emit, eventKeys) => {
95
+ return eventKeys.reduce(
96
+ (acc, key) => {
97
+ let eventName;
98
+ if (key.startsWith("on")) {
99
+ eventName = key;
100
+ } else {
101
+ if (key.includes("-")) {
102
+ eventName = "on" + key.split("-").map((word) => word.charAt(0).toUpperCase() + word.slice(1)).join("");
103
+ } else {
104
+ eventName = `on${key.charAt(0).toUpperCase()}${key.slice(1)}`;
105
+ }
106
+ }
107
+ acc[eventName] = (...args) => emit(key, ...args);
108
+ return acc;
109
+ },
110
+ {}
111
+ );
112
+ };
113
+ const prepareClassNames = () => {
114
+ return useAttrs().class || "";
115
+ };
116
+ const prepareStyles = () => {
117
+ return useAttrs().style || {};
118
+ };
119
+
120
+ const SCOPE = "_RepeatClick";
121
+ const vRepeatClick = {
122
+ name: "repeatClick",
123
+ // 在绑定元素的 attribute 前
124
+ // 或事件监听器应用前调用
125
+ // created(el, binding, vnode) {
126
+ // // el.style.display = 'none'
127
+ // // 下面会介绍各个参数的细节
128
+ // console.log('created', el, binding, vnode)
129
+ // },
130
+ // 在元素被插入到 DOM 前调用
131
+ beforeMount(el, binding) {
132
+ const { delay = 300, immediate } = typeof binding.value === "object" ? binding.value : {};
133
+ const handler = typeof binding.value === "object" ? binding.value.handler : binding.value;
134
+ let isPending = false;
135
+ let timer;
136
+ const start = (e) => {
137
+ if (e.button !== 0) return;
138
+ timer && clearTimeout(timer);
139
+ timer = setTimeout(() => {
140
+ if (immediate) {
141
+ isPending = false;
142
+ } else {
143
+ handler?.(e);
144
+ }
145
+ }, delay);
146
+ if (immediate) {
147
+ if (isPending) {
148
+ return;
149
+ }
150
+ isPending = true;
151
+ handler?.(e);
152
+ }
153
+ };
154
+ el[SCOPE] = { start };
155
+ el.addEventListener("click", start);
156
+ },
157
+ // // 在绑定元素的父组件
158
+ // // 及他自己的所有子节点都挂载完成后调用
159
+ // mounted(el, binding, vnode) {
160
+ // console.log('mounted', el, binding, vnode)
161
+ // },
162
+ // // 绑定元素的父组件更新前调用
163
+ // beforeUpdate(el, binding, vnode, prevVnode) {
164
+ // console.log('beforeUpdate', el, binding, vnode, prevVnode)
165
+ // },
166
+ // // 在绑定元素的父组件
167
+ // // 及他自己的所有子节点都更新后调用
168
+ // updated(el, binding, vnode, prevVnode) {
169
+ // console.log('updated', el, binding, vnode, prevVnode)
170
+ // },
171
+ // // 绑定元素的父组件卸载前调用
172
+ // beforeUnmount(el, binding, vnode) {
173
+ // console.log('beforeUnmount', el, binding, vnode)
174
+ // },
175
+ // 绑定元素的父组件卸载后调用
176
+ unmounted(el) {
177
+ if (!el[SCOPE]) return;
178
+ const { start } = el[SCOPE];
179
+ if (start) {
180
+ el.removeEventListener("mousedown", start);
181
+ }
182
+ el[SCOPE] = null;
183
+ }
184
+ };
185
+
186
+ const getEnv = (mark = "hxjf", hostname = window.location.hostname) => {
187
+ const tag = hostname.match(new RegExp(`.*(?=${mark})`));
188
+ if (hostname === "hxdv-ui.hongxinshop.com") {
189
+ return "production";
190
+ }
191
+ if (!tag) {
192
+ return "local";
193
+ }
194
+ return tag[0] ? tag[0].replace("-", "") : "production";
195
+ };
196
+ const getBaseUrl = (env = "sit", isOpenApi) => {
197
+ let url = "";
198
+ if (getEnv() === "local") {
199
+ const query = {};
200
+ query.devProxy = location.search.slice(1).split("=")[1] || location.hash.slice(1).split("=")[1];
201
+ const devProxy = query.devProxy || `${env}-api`;
202
+ url = `${devProxy}${""}`;
203
+ } else {
204
+ url = "/vue-api";
205
+ }
206
+ return url;
207
+ };
208
+
209
+ const getCookie = (name) => {
210
+ const reg = new RegExp("(^| )" + name + "=([^;]*)(;|$)");
211
+ const arr = document.cookie.match(reg);
212
+ if (arr) {
213
+ return decodeURIComponent(arr[2]);
214
+ }
215
+ return null;
216
+ };
217
+
218
+ const instance = axios.create({
219
+ method: "post",
220
+ timeout: 2e4,
221
+ baseURL: getBaseUrl(),
222
+ headers: {
223
+ "Content-Type": "application/json"
224
+ }
225
+ });
226
+ let reqNum = 0;
227
+ let loading = { close: () => {
228
+ } };
229
+ function startLoading() {
230
+ if (reqNum === 0) {
231
+ loading = ElLoading.service({
232
+ fullscreen: true,
233
+ lock: true,
234
+ text: "\u8BF7\u7A0D\u7B49\uFF0C\u6B63\u5728\u52A0\u8F7D\u4E2D...",
235
+ spinner: "el-icon-loading",
236
+ background: "rgba(0,0,0,0.7)"
237
+ });
238
+ }
239
+ reqNum++;
240
+ }
241
+ function closeLoading() {
242
+ if (reqNum <= 0) {
243
+ return;
244
+ }
245
+ reqNum--;
246
+ if (reqNum === 0) {
247
+ loading.close();
248
+ }
249
+ }
250
+ function endLoading() {
251
+ closeLoading();
252
+ }
253
+ instance.interceptors.request.use(
254
+ async (config) => {
255
+ const token = getCookie("access_token");
256
+ if (token) {
257
+ config.headers["Authorization"] = `Bearer ${token}`;
258
+ }
259
+ if (config.loading) {
260
+ startLoading();
261
+ }
262
+ config.headers = {
263
+ ...config.headers,
264
+ ...window.hx && window.hx.getSignHeaders({
265
+ // 只有openapi接口需要传sign
266
+ sign: config.sign || window.ELPLUSSIGN,
267
+ config
268
+ })
269
+ };
270
+ const cancelRequest = config.cancelRequest;
271
+ config.cancelToken = new axios.CancelToken(function(cancel) {
272
+ cancelRequest && cancelRequest(cancel);
273
+ });
274
+ return config;
275
+ },
276
+ (error) => {
277
+ console.log(error);
278
+ return Promise.reject(error);
279
+ }
280
+ );
281
+ instance.interceptors.response.use(
282
+ (response) => {
283
+ const config = response.config;
284
+ if (config.loading) {
285
+ endLoading();
286
+ }
287
+ const responseCode = response.data.code;
288
+ const { hideToast, hideToastCode = {} } = response.config.headers;
289
+ hideToastCode.length = Object.keys(hideToastCode).length;
290
+ if (responseCode === 200) {
291
+ return Promise.resolve(response.data);
292
+ } else if (hideToast || Array.prototype.slice.call(hideToastCode).indexOf(responseCode) > -1) {
293
+ return Promise.reject(response.data);
294
+ } else {
295
+ setTimeout(() => {
296
+ ElMessage.error({
297
+ message: `<pre>${response.data.msg}</pre>`,
298
+ type: "error",
299
+ duration: 2e3,
300
+ dangerouslyUseHTMLString: true
301
+ });
302
+ }, 300);
303
+ return Promise.reject(response.data);
304
+ }
305
+ },
306
+ (error) => {
307
+ const { config = {}, message } = error;
308
+ const { url } = config;
309
+ if (config.loading) {
310
+ endLoading();
311
+ }
312
+ if (error && error.response) {
313
+ const { status } = error.response;
314
+ switch (status) {
315
+ case 400:
316
+ error.message = error.response.data.message || error.response.data.msg;
317
+ break;
318
+ case 403:
319
+ error.message = "\u62D2\u7EDD\u8BBF\u95EE(403)";
320
+ break;
321
+ case 404:
322
+ error.message = "\u8BF7\u6C42\u51FA\u9519(404)";
323
+ break;
324
+ case 408:
325
+ error.message = "\u8BF7\u6C42\u8D85\u65F6(408)";
326
+ break;
327
+ case 500:
328
+ error.message = "\u670D\u52A1\u5668\u9519\u8BEF(500)";
329
+ break;
330
+ case 501:
331
+ error.message = "\u670D\u52A1\u672A\u5B9E\u73B0(501)";
332
+ break;
333
+ case 502:
334
+ error.message = "\u7F51\u7EDC\u9519\u8BEF(502)";
335
+ break;
336
+ case 503:
337
+ error.message = "\u670D\u52A1\u4E0D\u53EF\u7528(503)";
338
+ break;
339
+ case 504:
340
+ error.message = "\u7F51\u7EDC\u8D85\u65F6(504)";
341
+ break;
342
+ case 505:
343
+ error.message = "HTTP\u7248\u672C\u4E0D\u53D7\u652F\u6301(505)";
344
+ break;
345
+ default:
346
+ error.message = `\u8FDE\u63A5\u51FA\u9519(${error.response.status})!`;
347
+ }
348
+ } else {
349
+ if (error.message.includes("timeout")) {
350
+ error.message = `\u8BF7\u6C42${url ? url : ""}\u8D85\u65F6\uFF0C\u8BF7\u68C0\u67E5\u7F51\u7EDC\u662F\u5426\u8FDE\u63A5\u6B63\u5E38`;
351
+ } else {
352
+ error.message = `\u8BF7\u6C42${url ? url : ""}\u5931\u8D25\uFF0C\u8BF7\u68C0\u67E5\u7F51\u7EDC\u662F\u5426\u5DF2\u8FDE\u63A5`;
353
+ }
354
+ }
355
+ if (!axios.isCancel(error) || !config.noErrorMsg) {
356
+ ElMessage.error({
357
+ message: error.message,
358
+ type: "error",
359
+ duration: 2e3,
360
+ dangerouslyUseHTMLString: true
361
+ });
362
+ }
363
+ return Promise.reject(error);
364
+ }
365
+ );
366
+ const fetch = instance.request;
367
+
368
+ const vPermisson = {
369
+ name: "permission",
370
+ mounted(el, binding) {
371
+ const { arg, value } = binding.value;
372
+ if (!arg && !value) {
373
+ return;
374
+ }
375
+ el.style.display = "none";
376
+ const permission = `${arg}:${value}`;
377
+ checkPermission(permission, el);
378
+ },
379
+ updated(el, binding) {
380
+ const { arg, value } = binding.value;
381
+ if (!arg && !value) {
382
+ if (el.style.display === "none") {
383
+ el.style.display = "";
384
+ }
385
+ return;
386
+ }
387
+ const permission = `${arg}:${value}`;
388
+ checkPermission(permission, el);
389
+ }
390
+ };
391
+ async function checkPermission(permission, el) {
392
+ const { data: roles = [] } = await queryRoles();
393
+ const hasPermission = roles.indexOf(permission) > -1;
394
+ if (!hasPermission) {
395
+ el && el.parentNode && el.parentNode.removeChild(el);
396
+ } else {
397
+ el.style.display = "";
398
+ }
399
+ return hasPermission;
400
+ }
401
+ let requestPromise = null;
402
+ async function queryRoles() {
403
+ try {
404
+ if (requestPromise) {
405
+ return requestPromise;
406
+ }
407
+ requestPromise = fetch({
408
+ url: "/api-u/api/saas/user/appButtonRoleList",
409
+ loading: true,
410
+ noErrorMsg: true
411
+ });
412
+ return requestPromise;
413
+ } catch (error) {
414
+ console.error(error);
415
+ return { data: [] };
416
+ }
417
+ }
418
+
419
+ const bem$1 = createNameSpace("button");
420
+ var Buttons$1 = /* @__PURE__ */ defineComponent({
421
+ name: "EpButtons",
422
+ directives: {
423
+ [vRepeatClick.name]: vRepeatClick,
424
+ [vPermisson.name]: vPermisson
425
+ },
426
+ inheritAttrs: false,
427
+ props: buttonsProps,
428
+ setup(props, {
429
+ emit
430
+ }) {
431
+ const {
432
+ list,
433
+ ...buttonProps
434
+ } = props;
435
+ const customList = computed(() => {
436
+ return list.filter((button) => {
437
+ if ("show" in button) {
438
+ return typeof button.show === "function" ? button.show(button) : button.show;
439
+ } else if ("hide" in button) {
440
+ return typeof button.hide === "function" ? !button.hide(button) : !button.hide;
441
+ }
442
+ return true;
443
+ });
444
+ });
445
+ const clickFn = async (item) => {
446
+ if (item.confirm) {
447
+ const confirmText = item.confirmText || `\u786E\u5B9A\u8981${item.name}\u5417\uFF1F`;
448
+ await ElMessageBox.confirm(confirmText, "Warning", {
449
+ confirmButtonText: "\u786E\u5B9A",
450
+ cancelButtonText: "\u53D6\u6D88",
451
+ type: "warning"
452
+ });
453
+ }
454
+ item.onClick();
455
+ };
456
+ return () => createVNode(Fragment, null, [customList.value.map((item) => {
457
+ const permissionArr = item.permission?.split(":") || [];
458
+ return withDirectives(createVNode(resolveComponent("el-button"), mergeProps({
459
+ "class": [bem$1.b(), prepareClassNames()],
460
+ "style": prepareStyles(),
461
+ "key": item.prop || item.name
462
+ }, {
463
+ ...prepareProps(buttonProps),
464
+ ...prepareProps(item, ["scopedSlots", "name", "onClick"])
465
+ }), {
466
+ default: () => item.name,
467
+ ...item.scopedSlots
468
+ }), [[resolveDirective("repeat-click"), typeof item.onClick === "function" ? {
469
+ handler: () => clickFn(item),
470
+ immediate: true
471
+ } : () => clickFn(item)], [resolveDirective("permission"), {
472
+ arg: permissionArr[0],
473
+ value: permissionArr[1]
474
+ }]]);
475
+ })]);
476
+ }
477
+ });
478
+
479
+ function withInstall(comp) {
480
+ comp.install = (app) => {
481
+ app.component(comp.name, comp);
482
+ };
483
+ return comp;
484
+ }
485
+
486
+ var Buttons = withInstall(Buttons$1);
487
+
488
+ const expandFormProps = {
489
+ // 表单列表
490
+ formItemList: {
491
+ type: Array,
492
+ default: () => []
493
+ },
494
+ // 是否显示折叠
495
+ isShowFold: Boolean,
496
+ // 最大显示的表单数
497
+ showFieldCount: {
498
+ type: Number,
499
+ default: 8
500
+ },
501
+ // 每行的列数
502
+ col: {
503
+ type: Number,
504
+ default: 4
505
+ }
506
+ };
507
+ const formProps = {
508
+ ...formProps$1,
509
+ ...expandFormProps,
510
+ size: {
511
+ ...formProps$1.size,
512
+ default: "small"
513
+ },
514
+ // 标签的长度
515
+ labelWidth: {
516
+ ...formProps$1.labelWidth,
517
+ default: 120
518
+ },
519
+ scrollIntoViewOptions: {
520
+ ...formProps$1.scrollIntoViewOptions,
521
+ default: () => {
522
+ return { inline: "center" };
523
+ }
524
+ }
525
+ };
526
+ const expandFormPropsKeys = Object.keys(expandFormProps);
527
+ const formEmits = {
528
+ ...formEmits$1,
529
+ toggleStatus: (status) => true
530
+ // 折叠状态切换时触发
531
+ };
532
+ const formEmitsKeys = Object.keys(formEmits);
533
+
534
+ const useCollapse = ({ isShowFold, showFieldCount, filterFormItemList }, emit) => {
535
+ const open = ref(false);
536
+ const toggleStatus = () => {
537
+ open.value = !open.value;
538
+ emit("toggleStatus", open.value);
539
+ };
540
+ const isShowFoldBtn = computed(() => {
541
+ return isShowFold && filterFormItemList.value.length > showFieldCount;
542
+ });
543
+ const isShowFormItem = (index) => {
544
+ return index < showFieldCount || open.value || !isShowFoldBtn.value;
545
+ };
546
+ return {
547
+ open,
548
+ toggleStatus,
549
+ isShowFoldBtn,
550
+ isShowFormItem
551
+ };
552
+ };
553
+ const useForm$1 = (props) => {
554
+ const elFormRef = useTemplateRef("elFormRef");
555
+ const filterFormItemList = computed(() => {
556
+ return props.formItemList.filter((item) => {
557
+ if ("show" in item) {
558
+ return typeof item.show === "function" ? item.show(item) : item.show;
559
+ } else if ("hide" in item) {
560
+ return typeof item.hide === "function" ? !item.hide(item) : !item.hide;
561
+ }
562
+ return true;
563
+ });
564
+ });
565
+ const validate = () => {
566
+ return elFormRef.value.validate();
567
+ };
568
+ const resetFields = (props2) => {
569
+ return elFormRef.value.resetFields(props2);
570
+ };
571
+ const clearValidate = (props2) => {
572
+ return elFormRef.value.clearValidate(props2);
573
+ };
574
+ return {
575
+ filterFormItemList,
576
+ elFormRef,
577
+ validate,
578
+ resetFields,
579
+ clearValidate
580
+ };
581
+ };
582
+
583
+ const useFormItemSlots = (props) => {
584
+ const attrs = useAttrs();
585
+ const {
586
+ type,
587
+ label,
588
+ render,
589
+ required,
590
+ labelRender
591
+ } = props;
592
+ const prop = props.tableProp || props.prop;
593
+ const {
594
+ scopedSlots: renderScopedSlots,
595
+ ...renderProps
596
+ } = props.props || {};
597
+ const events = {};
598
+ for (const key in attrs) {
599
+ if (key.startsWith("on")) {
600
+ events[key] = attrs[key];
601
+ }
602
+ }
603
+ const formData = attrs["form-data"];
604
+ const scopedSlots = {
605
+ default: () => {
606
+ return type ? h(resolveComponent(type), {
607
+ modelValue: formData[prop],
608
+ "onUpdate:modelValue": (value) => {
609
+ formData[prop] = value;
610
+ },
611
+ ...renderProps,
612
+ ...events
613
+ }, renderScopedSlots) : formData[prop];
614
+ },
615
+ label: () => {
616
+ return createVNode(resolveComponent("el-tooltip"), {
617
+ "placement": "top",
618
+ "effect": "light",
619
+ "content": label,
620
+ "disabled": !props.isShowLabel
621
+ }, {
622
+ default: () => [createVNode("span", null, [!props.hideRequiredAsterisk && required ? createVNode("span", {
623
+ "style": "color: var(--el-color-danger);"
624
+ }, [createTextVNode("*")]) : null, props.isShowLabel ? createVNode("span", null, [label]) : ""])]
625
+ });
626
+ }
627
+ };
628
+ if (labelRender) {
629
+ scopedSlots.label = () => labelRender({
630
+ label
631
+ });
632
+ }
633
+ if (render) {
634
+ scopedSlots.default = render;
635
+ }
636
+ return {
637
+ scopedSlots
638
+ };
639
+ };
640
+ const useFormItemRules = (props) => {
641
+ const {
642
+ required,
643
+ rules,
644
+ label
645
+ } = props;
646
+ let mergeRules = [];
647
+ if (required) {
648
+ const requiredDefault = {
649
+ required: true
650
+ };
651
+ mergeRules.push(requiredDefault);
652
+ }
653
+ if (rules) {
654
+ if (Array.isArray(rules)) {
655
+ mergeRules = mergeRules.concat(rules);
656
+ }
657
+ if (Object.prototype.toString.call(rules) === "[object Object]") {
658
+ mergeRules.push(rules);
659
+ }
660
+ }
661
+ if (mergeRules) {
662
+ mergeRules.forEach((r) => {
663
+ if (r.required && typeof r.message === "undefined") {
664
+ r.message = `${label || ""}\u4E0D\u80FD\u4E3A\u7A7A`;
665
+ }
666
+ });
667
+ }
668
+ return {
669
+ rules: mergeRules
670
+ };
671
+ };
672
+
673
+ const expandFormItemProps = {
674
+ type: {
675
+ type: String
676
+ // default: 'EpInput',
677
+ },
678
+ col: Number,
679
+ render: Function,
680
+ labelRender: Function,
681
+ props: Object,
682
+ ...visibleProps,
683
+ class: String,
684
+ style: {
685
+ type: [String, Object]
686
+ },
687
+ isShowLabel: {
688
+ type: Boolean,
689
+ default: true
690
+ },
691
+ hideRequiredAsterisk: Boolean,
692
+ tableProp: String
693
+ // 用于table里的表单需要绑定的prop
694
+ };
695
+ const formItemProps = {
696
+ ...formItemProps$1,
697
+ ...expandFormItemProps
698
+ };
699
+ const expandFormItemPropsKeys = Object.keys(expandFormItemProps);
700
+
701
+ const bem = createNameSpace("form-item");
702
+ var EpFormItem = /* @__PURE__ */ defineComponent({
703
+ name: "EpFormItem",
704
+ inheritAttrs: false,
705
+ props: formItemProps,
706
+ setup(props, {
707
+ emit
708
+ }) {
709
+ const attrs = useAttrs();
710
+ const {
711
+ scopedSlots
712
+ } = useFormItemSlots(props);
713
+ const {
714
+ rules
715
+ } = useFormItemRules(props);
716
+ const {
717
+ props: childProps,
718
+ ...formItemProps2
719
+ } = props;
720
+ return () => {
721
+ return createVNode(resolveComponent("el-form-item"), mergeProps({
722
+ "class": [bem.b(), prepareClassNames()],
723
+ "style": prepareStyles()
724
+ }, {
725
+ ...prepareProps(formItemProps2, [...expandFormItemPropsKeys]),
726
+ rules,
727
+ "label-width": attrs["form-label-width"]
728
+ }), scopedSlots);
729
+ };
730
+ }
731
+ });
732
+
733
+ var _sfc_main$4 = /* @__PURE__ */ defineComponent({
734
+ ...{
735
+ name: "EpForm",
736
+ inheritAttrs: false
737
+ },
738
+ __name: "form",
739
+ props: /* @__PURE__ */ mergeModels(formProps, {
740
+ "modelValue": { type: Object, ...{
741
+ default: () => reactive({})
742
+ } },
743
+ "modelModifiers": {}
744
+ }),
745
+ emits: /* @__PURE__ */ mergeModels(formEmits, ["update:modelValue"]),
746
+ setup(__props, { expose: __expose, emit: __emit }) {
747
+ const bem = createNameSpace("form");
748
+ const props = __props;
749
+ const emit = __emit;
750
+ const customAttrs = computed(() => {
751
+ return {
752
+ ...prepareProps(props, ["modelValue", "model", ...expandFormPropsKeys]),
753
+ hideRequiredAsterisk: true,
754
+ // 隐藏必填星号, 使用自己的*
755
+ scrollToError: true,
756
+ ...prepareEvents(emit, formEmitsKeys)
757
+ };
758
+ });
759
+ const formData = useModel(__props, "modelValue");
760
+ const { filterFormItemList, elFormRef, validate, resetFields, clearValidate } = useForm$1(props);
761
+ const { open, toggleStatus, isShowFoldBtn, isShowFormItem } = useCollapse(
762
+ {
763
+ filterFormItemList,
764
+ isShowFold: props.isShowFold,
765
+ showFieldCount: props.showFieldCount
766
+ },
767
+ emit
768
+ );
769
+ __expose({
770
+ elFormRef,
771
+ validate,
772
+ resetFields,
773
+ clearValidate
774
+ });
775
+ return (_ctx, _cache) => {
776
+ const _component_el_col = resolveComponent("el-col");
777
+ const _component_el_row = resolveComponent("el-row");
778
+ const _component_el_form = resolveComponent("el-form");
779
+ return openBlock(), createElementBlock(
780
+ "div",
781
+ {
782
+ class: normalizeClass([
783
+ unref(bem).b(),
784
+ unref(prepareClassNames)(),
785
+ unref(bem).is("open", unref(open)),
786
+ unref(bem).is("fold", unref(isShowFoldBtn))
787
+ ]),
788
+ style: normalizeStyle({
789
+ ...unref(prepareStyles)()
790
+ })
791
+ },
792
+ [
793
+ createVNode(_component_el_form, mergeProps({
794
+ ref_key: "elFormRef",
795
+ ref: elFormRef,
796
+ model: formData.value
797
+ }, customAttrs.value), {
798
+ default: withCtx(() => [
799
+ renderSlot(_ctx.$slots, "default", {}, () => [
800
+ createVNode(_component_el_row, null, {
801
+ default: withCtx(() => [
802
+ (openBlock(true), createElementBlock(
803
+ Fragment,
804
+ null,
805
+ renderList(unref(filterFormItemList), (item, index) => {
806
+ return withDirectives((openBlock(), createBlock(_component_el_col, {
807
+ key: item.prop || index,
808
+ class: normalizeClass(unref(bem).e("col")),
809
+ span: item.col || 24 / _ctx.col
810
+ }, {
811
+ default: withCtx(() => [
812
+ createVNode(unref(EpFormItem), mergeProps({
813
+ "form-data": formData.value,
814
+ "form-label-width": _ctx.labelWidth
815
+ }, { ref_for: true }, item), null, 16, ["form-data", "form-label-width"])
816
+ ]),
817
+ _: 2
818
+ /* DYNAMIC */
819
+ }, 1032, ["class", "span"])), [
820
+ [vShow, unref(isShowFormItem)(index)]
821
+ ]);
822
+ }),
823
+ 128
824
+ /* KEYED_FRAGMENT */
825
+ ))
826
+ ]),
827
+ _: 1
828
+ /* STABLE */
829
+ })
830
+ ])
831
+ ]),
832
+ _: 3
833
+ /* FORWARDED */
834
+ }, 16, ["model"]),
835
+ unref(isShowFoldBtn) ? (openBlock(), createElementBlock("div", {
836
+ key: 0,
837
+ class: normalizeClass(unref(bem).e("fold")),
838
+ onClick: unref(toggleStatus)
839
+ }, toDisplayString(unref(open) ? "\u6536\u8D77" : "\u66F4\u591A"), 11, ["onClick"])) : createCommentVNode("v-if", true)
840
+ ],
841
+ 6
842
+ /* CLASS, STYLE */
843
+ );
844
+ };
845
+ }
846
+ });
847
+
848
+ var Form = withInstall(_sfc_main$4);
849
+
850
+ const inputProps = {
851
+ ...inputProps$1,
852
+ max: Number,
853
+ min: Number,
854
+ radix: Number,
855
+ nonzero: Boolean,
856
+ placeholder: {
857
+ type: String,
858
+ default: "\u8BF7\u8F93\u5165"
859
+ },
860
+ thousand: {
861
+ type: Boolean,
862
+ default: true
863
+ },
864
+ clearable: {
865
+ ...inputProps$1.clearable,
866
+ default: true
867
+ }
868
+ };
869
+ const inputEmits = {
870
+ ...inputEmits$1
871
+ };
872
+ const inputEmitsKeys = Object.keys(inputEmits);
873
+
874
+ var _sfc_main$3 = /* @__PURE__ */ defineComponent({
875
+ ...{
876
+ name: "EpInput",
877
+ inheritAttrs: false
878
+ },
879
+ __name: "input",
880
+ props: /* @__PURE__ */ mergeModels(inputProps, {
881
+ "modelValue": { type: null },
882
+ "modelModifiers": {}
883
+ }),
884
+ emits: /* @__PURE__ */ mergeModels(inputEmits, ["update:modelValue"]),
885
+ setup(__props, { emit: __emit }) {
886
+ const bem = createNameSpace("input");
887
+ const props = __props;
888
+ const emit = __emit;
889
+ const slots = computed(() => {
890
+ return Object.keys(useSlots());
891
+ });
892
+ let isBluring = false;
893
+ let isFocusing = false;
894
+ const customAttrs = computed(() => {
895
+ return {
896
+ ...prepareProps(props, ["modelValue"]),
897
+ ...prepareEvents(emit, inputEmitsKeys),
898
+ placeholder: props.disabled ? "" : props.placeholder,
899
+ onFocus: (e) => {
900
+ isFocusing = true;
901
+ if (props.thousand) {
902
+ e.target.value = value.value ? String(value.value) : "";
903
+ }
904
+ emit("focus", e);
905
+ },
906
+ onBlur: (e) => {
907
+ if (props.type === "number") {
908
+ let val = value.value;
909
+ if (props.nonzero && +val === 0) {
910
+ val = "";
911
+ }
912
+ if (val && val[val.length - 1] === ".") {
913
+ val = String(val).slice(0, -1);
914
+ }
915
+ if (val && val === "-") {
916
+ val = "";
917
+ }
918
+ value.value = val ? +val : val;
919
+ e.target.value = toThousand(value.value);
920
+ }
921
+ isBluring = true;
922
+ isFocusing = false;
923
+ emit("blur", e);
924
+ }
925
+ };
926
+ });
927
+ const value = useModel(__props, "modelValue");
928
+ const inputRef = ref();
929
+ const toThousand = (val) => {
930
+ if (props.thousand) {
931
+ return val ? window.hx.thousand(val) : val;
932
+ }
933
+ return val;
934
+ };
935
+ watch(
936
+ () => value.value,
937
+ (val) => {
938
+ if (props.type === "number") {
939
+ onMounted(() => {
940
+ inputRef.value.input.value = toThousand(val);
941
+ });
942
+ }
943
+ if (isBluring) {
944
+ isBluring = false;
945
+ return;
946
+ }
947
+ if (!isFocusing) {
948
+ return;
949
+ }
950
+ if (props.type === "number") {
951
+ if (typeof val === "number") {
952
+ val = "" + val;
953
+ }
954
+ if (typeof val === "string") {
955
+ const zeroReg = new RegExp("^[-+]?0[0-9]\\d*");
956
+ if (zeroReg.test(val)) {
957
+ val = val.replace("0", "");
958
+ }
959
+ const reg = new RegExp("^([-+])?\\d*(\\.?\\d*)", "g");
960
+ val = val.match(reg) ? val.match(reg)[0] : "";
961
+ if (props.radix || props.radix === 0) {
962
+ const reg2 = props.radix === 0 ? new RegExp("^([-+])?\\d*", "g") : new RegExp(`^([-+])?\\d*(\\.?\\d{0,${props.radix}})`, "g");
963
+ val = val.match(reg2) ? val.match(reg2)[0] : "";
964
+ }
965
+ if ((props.max || props.max === 0) && +val > props.max) {
966
+ val = props.max;
967
+ }
968
+ if ((props.min || props.min === 0) && (val || val === 0) && +val < props.min) {
969
+ val = props.min;
970
+ }
971
+ }
972
+ } else if (props.type === "text") {
973
+ val = val.trim();
974
+ }
975
+ value.value = val;
976
+ },
977
+ {
978
+ immediate: true
979
+ }
980
+ );
981
+ return (_ctx, _cache) => {
982
+ const _component_el_input = resolveComponent("el-input");
983
+ return openBlock(), createBlock(_component_el_input, mergeProps({
984
+ ref_key: "inputRef",
985
+ ref: inputRef,
986
+ modelValue: value.value,
987
+ "onUpdate:modelValue": ($event) => value.value = $event,
988
+ class: `${unref(bem).b()} ${unref(prepareClassNames)()}`,
989
+ style: {
990
+ ...unref(prepareStyles)()
991
+ }
992
+ }, customAttrs.value, {
993
+ type: _ctx.type === "number" ? "text" : _ctx.type
994
+ }), createSlots({
995
+ _: 2
996
+ /* DYNAMIC */
997
+ }, [
998
+ renderList(slots.value, (name) => {
999
+ return {
1000
+ name,
1001
+ fn: withCtx((scope) => [
1002
+ renderSlot(_ctx.$slots, name, normalizeProps(guardReactiveProps(scope)))
1003
+ ])
1004
+ };
1005
+ })
1006
+ ]), 1040, ["modelValue", "onUpdate:modelValue", "class", "style", "type"]);
1007
+ };
1008
+ }
1009
+ });
1010
+
1011
+ var Input = withInstall(_sfc_main$3);
1012
+
1013
+ const inheritTableProps = {
1014
+ ...elTableProps,
1015
+ // Table 的尺寸
1016
+ size: {
1017
+ ...elTableProps.size,
1018
+ default: "default"
1019
+ },
1020
+ // 是否带有纵向边框
1021
+ border: {
1022
+ ...elTableProps.border,
1023
+ default: true
1024
+ },
1025
+ // 表头样式
1026
+ headerCellStyle: {
1027
+ ...elTableProps.headerCellStyle,
1028
+ default: () => ({
1029
+ background: "#EEEFF3",
1030
+ // textAlign: 'center',
1031
+ fontSize: "14px",
1032
+ color: "#505050"
1033
+ })
1034
+ }
1035
+ };
1036
+ const expandTableProps = {
1037
+ ...apiProps,
1038
+ columns: {
1039
+ type: Array,
1040
+ default: () => []
1041
+ },
1042
+ // 是否显示勾选列
1043
+ showSelectionCol: Boolean,
1044
+ // 是否显示序号列
1045
+ showIndexCol: {
1046
+ type: Boolean,
1047
+ default: true
1048
+ },
1049
+ // 对齐方式
1050
+ align: {
1051
+ type: String,
1052
+ default: "center"
1053
+ },
1054
+ // 序号列自定义
1055
+ indexFormatter: {
1056
+ type: [Number, Function]
1057
+ },
1058
+ disabled: Boolean,
1059
+ reserveSelection: Boolean,
1060
+ selectable: {
1061
+ type: Function
1062
+ },
1063
+ paginationProps: {
1064
+ type: Object,
1065
+ default: () => ({})
1066
+ },
1067
+ showPagination: Boolean,
1068
+ isFrontPage: Boolean,
1069
+ // 操作列
1070
+ actionButtons: {
1071
+ type: Array,
1072
+ default: () => []
1073
+ },
1074
+ // 链接列
1075
+ linkProps: {
1076
+ type: Array,
1077
+ default: () => []
1078
+ }
1079
+ };
1080
+ const tableProps = {
1081
+ ...inheritTableProps,
1082
+ ...expandTableProps
1083
+ };
1084
+ const expandTablePropsKeys = Object.keys(expandTableProps);
1085
+ const tableEmits = ElTable.emits;
1086
+ const tableEmitsKeys = tableEmits;
1087
+
1088
+ const useRequest = ({
1089
+ api,
1090
+ method,
1091
+ reqData,
1092
+ reqParams,
1093
+ reqBefore,
1094
+ reqAfter,
1095
+ cancelToken,
1096
+ hooks
1097
+ }) => {
1098
+ if (!api) return {};
1099
+ const loading = ref(false);
1100
+ let cancelRequest;
1101
+ let apiFn;
1102
+ if (typeof api === "string") {
1103
+ const config = {
1104
+ url: api,
1105
+ method
1106
+ };
1107
+ if (cancelToken) {
1108
+ config.cancelRequest = (cancel) => {
1109
+ cancelRequest = cancel;
1110
+ };
1111
+ }
1112
+ apiFn = (data = {}, params) => {
1113
+ if (config.method === "get") {
1114
+ config.params = data;
1115
+ } else {
1116
+ config.data = data;
1117
+ config.params = params;
1118
+ }
1119
+ config.data = {
1120
+ ...reqData,
1121
+ ...config.data
1122
+ };
1123
+ config.params = {
1124
+ ...reqParams,
1125
+ ...config.params
1126
+ };
1127
+ if (data.$query) {
1128
+ config.data[data.$query] = data.$searchValue;
1129
+ delete data.$searchValue;
1130
+ }
1131
+ if (reqBefore) {
1132
+ reqBefore(config);
1133
+ }
1134
+ return fetch(config);
1135
+ };
1136
+ } else {
1137
+ apiFn = api;
1138
+ }
1139
+ const requestFn = async (data = {}) => {
1140
+ if (loading.value && !cancelToken) return;
1141
+ loading.value = true;
1142
+ try {
1143
+ cancelRequest && cancelRequest();
1144
+ const res = await apiFn(data);
1145
+ if (reqAfter) {
1146
+ reqAfter(res);
1147
+ }
1148
+ if (hooks?.success) {
1149
+ hooks.success(res.data);
1150
+ }
1151
+ } catch (error) {
1152
+ if (hooks?.fail) {
1153
+ hooks.fail(error);
1154
+ }
1155
+ } finally {
1156
+ loading.value = false;
1157
+ }
1158
+ };
1159
+ return {
1160
+ loading,
1161
+ requestFn
1162
+ };
1163
+ };
1164
+
1165
+ const useTable$1 = (props) => {
1166
+ const elFormRef = useTemplateRef("elFormRef");
1167
+ const elTableRef = useTemplateRef("elTableRef");
1168
+ const customData = ref([]);
1169
+ const {
1170
+ loading,
1171
+ requestFn
1172
+ } = useRequest({
1173
+ api: props.api,
1174
+ method: props.method,
1175
+ reqData: props.reqData,
1176
+ reqParams: props.reqParams,
1177
+ reqBefore: props.reqBefore,
1178
+ reqAfter: props.reqAfter,
1179
+ cancelToken: true,
1180
+ hooks: {
1181
+ success(data) {
1182
+ if (Array.isArray(data)) {
1183
+ customData.value = data;
1184
+ } else if (data && typeof data === "object") {
1185
+ const rawData = data;
1186
+ customData.value = rawData?.list || rawData?.data || [];
1187
+ } else {
1188
+ customData.value = [];
1189
+ }
1190
+ if (props.showPagination) {
1191
+ pagination.total = (props.isFrontPage ? customData.value.length : data.total) || 0;
1192
+ }
1193
+ },
1194
+ fail(error) {
1195
+ console.error(error);
1196
+ }
1197
+ }
1198
+ });
1199
+ const search = (init = false, isPagination = false) => {
1200
+ if (init) {
1201
+ pagination.pageNo = 1;
1202
+ }
1203
+ if (isPagination && props.isFrontPage) {
1204
+ const {
1205
+ pageNo,
1206
+ pageSize
1207
+ } = pagination;
1208
+ const data = customData.value.filter((item, index) => {
1209
+ return index < pageNo * pageSize && index >= (pageNo - 1) * pageSize;
1210
+ });
1211
+ customData.value = data;
1212
+ } else {
1213
+ if (props.api) {
1214
+ requestFn({
1215
+ pageNo: pagination.pageNo,
1216
+ pageSize: pagination.pageSize
1217
+ });
1218
+ } else if (props.data?.length) {
1219
+ customData.value = props.data;
1220
+ }
1221
+ }
1222
+ };
1223
+ const {
1224
+ pagination,
1225
+ paginationProps
1226
+ } = usePagination(props, search);
1227
+ search(true);
1228
+ const validate = () => {
1229
+ return elFormRef.value.validate();
1230
+ };
1231
+ const resetFields = (props2) => {
1232
+ return elFormRef.value.resetFields(props2);
1233
+ };
1234
+ const clearValidate = (props2) => {
1235
+ return elFormRef.value.clearValidate(props2);
1236
+ };
1237
+ const formatActionButtons = (list, scope) => {
1238
+ return list.map((item) => {
1239
+ if (item.onClick) {
1240
+ item.onClick = item.onClick.bind(null, scope);
1241
+ }
1242
+ return item;
1243
+ });
1244
+ };
1245
+ return {
1246
+ loading,
1247
+ data: customData,
1248
+ search,
1249
+ pagination,
1250
+ paginationProps,
1251
+ validate,
1252
+ resetFields,
1253
+ clearValidate,
1254
+ elFormRef,
1255
+ elTableRef,
1256
+ formatActionButtons
1257
+ };
1258
+ };
1259
+ const usePagination = function(props, search) {
1260
+ const pageSizes = [20, 50, 100, 200];
1261
+ const pagination = reactive({
1262
+ total: 0,
1263
+ pageNo: 1,
1264
+ pageSize: pageSizes[0]
1265
+ });
1266
+ const paginationProps = computed(() => {
1267
+ const defaultPaginationProps = props.paginationProps || {};
1268
+ const onSizeChange = defaultPaginationProps.onSizeChange;
1269
+ const onCurrentChange = defaultPaginationProps.onCurrentChange;
1270
+ return {
1271
+ ...defaultPaginationProps,
1272
+ pageSizes,
1273
+ layout: "total, sizes, prev, pager, next, jumper",
1274
+ onSizeChange: (value) => {
1275
+ onSizeChange && onSizeChange(value);
1276
+ search(true, true);
1277
+ },
1278
+ onCurrentChange: (value) => {
1279
+ onCurrentChange && onCurrentChange(value);
1280
+ search(false, true);
1281
+ }
1282
+ };
1283
+ });
1284
+ return {
1285
+ pagination,
1286
+ paginationProps
1287
+ };
1288
+ };
1289
+ const useTableColumn = (props, tableData) => {
1290
+ const columnProps = (column) => {
1291
+ const attrs = {
1292
+ align: column.align || props.align
1293
+ // ...prepareEvents<TableEmits>(emit, tableEmits),
1294
+ };
1295
+ if (!column.renderHeader) {
1296
+ let required = column.required;
1297
+ if (typeof column.required === "function") {
1298
+ required = column.required();
1299
+ }
1300
+ if (required) {
1301
+ attrs["renderHeader"] = (data) => {
1302
+ const {
1303
+ column: column2
1304
+ } = data;
1305
+ return createVNode("span", null, [createVNode("span", {
1306
+ "style": "color:var(--el-color-danger)"
1307
+ }, [createTextVNode(" * ")]), column2.label]);
1308
+ };
1309
+ }
1310
+ }
1311
+ if (column.headerRender) {
1312
+ attrs.renderHeader = column.headerRender;
1313
+ }
1314
+ if (column.filter) {
1315
+ const arr = tableData.value.map((item) => item[column.prop]);
1316
+ attrs.filters = [...new Set(arr)].map((item) => {
1317
+ return {
1318
+ text: item,
1319
+ value: item
1320
+ };
1321
+ });
1322
+ attrs.filterMethod = (value, row) => {
1323
+ return row[column.prop] === value;
1324
+ };
1325
+ }
1326
+ return {
1327
+ ...attrs,
1328
+ ...prepareProps(column)
1329
+ };
1330
+ };
1331
+ const columnList = computed(() => {
1332
+ return props.columns.filter((column) => {
1333
+ if (props.linkProps.length) {
1334
+ const linkColumn = props.linkProps.find((item) => item.prop === column.prop);
1335
+ if (linkColumn) {
1336
+ column.type = "EpButtons";
1337
+ column.className = "table-column-link";
1338
+ column.props = {
1339
+ list: [linkColumn],
1340
+ type: "text",
1341
+ ...column.props
1342
+ };
1343
+ }
1344
+ }
1345
+ if ("show" in column) {
1346
+ return typeof column.show === "function" ? column.show(column) : column.show;
1347
+ } else if ("hide" in column) {
1348
+ return typeof column.hide === "function" ? !column.hide(column) : !column.hide;
1349
+ }
1350
+ return true;
1351
+ });
1352
+ });
1353
+ return {
1354
+ columnProps,
1355
+ columnList
1356
+ };
1357
+ };
1358
+ const useTableFormItem = (props) => {
1359
+ const formItemProps = (scope, item) => {
1360
+ let required = item.required;
1361
+ if (typeof required === "function") {
1362
+ required = required();
1363
+ }
1364
+ if (item.cellRequired) {
1365
+ required = item.cellRequired(scope);
1366
+ }
1367
+ let disabled = props.disabled;
1368
+ if ("disabled" in item) {
1369
+ if (typeof item.disabled === "function") {
1370
+ disabled = item.disabled(scope);
1371
+ } else {
1372
+ disabled = item.disabled || false;
1373
+ }
1374
+ }
1375
+ if (item.type === "EpSelect" && item.props) {
1376
+ if ("options" in item.props && typeof item.props.options === "function") {
1377
+ item.props.options = item.props.options(scope);
1378
+ }
1379
+ if ("disabledOption" in item.props && typeof item.props.disabledOption === "function") {
1380
+ const disabledOption = item.props.disabledOption;
1381
+ item.props.disabledOption = (...args) => disabledOption(...args, scope);
1382
+ }
1383
+ }
1384
+ if (item.type === "EpButtons" && item.props) {
1385
+ item.props.list.forEach((btnItem) => {
1386
+ if (btnItem.prop) {
1387
+ btnItem.name = scope.row[btnItem.prop];
1388
+ }
1389
+ if (btnItem.onClick) {
1390
+ btnItem.onClick = btnItem.onClick.bind(null, scope);
1391
+ }
1392
+ });
1393
+ }
1394
+ for (const key in item) {
1395
+ if (key.startsWith("on") && typeof item[key] === "function") {
1396
+ const fn = item[key];
1397
+ item[key] = (...args) => fn(...args, scope);
1398
+ }
1399
+ }
1400
+ return {
1401
+ ...prepareProps(item),
1402
+ isShowLabel: false,
1403
+ required,
1404
+ hideRequiredAsterisk: "cellRequired" in item ? false : required,
1405
+ prop: `table.${scope.$index}.${item.prop}`,
1406
+ tableProp: item.prop,
1407
+ // table里的表单需要绑定的prop
1408
+ props: {
1409
+ ...item.props,
1410
+ disabled
1411
+ }
1412
+ };
1413
+ };
1414
+ return {
1415
+ formItemProps
1416
+ };
1417
+ };
1418
+
1419
+ var _sfc_main$2 = /* @__PURE__ */ defineComponent({
1420
+ ...{
1421
+ name: "EpTable",
1422
+ inheritAttrs: false
1423
+ },
1424
+ __name: "table",
1425
+ props: tableProps,
1426
+ emits: tableEmits,
1427
+ setup(__props, {
1428
+ expose: __expose,
1429
+ emit: __emit
1430
+ }) {
1431
+ const bem = createNameSpace("table");
1432
+ const props = __props;
1433
+ const emit = __emit;
1434
+ const slots = computed(() => {
1435
+ return Object.keys(useSlots());
1436
+ });
1437
+ const customAttrs = computed(() => {
1438
+ return {
1439
+ ...prepareProps(props, ["modelValue", ...expandTablePropsKeys]),
1440
+ size: "small",
1441
+ data: data.value,
1442
+ ...prepareEvents(emit, tableEmitsKeys)
1443
+ };
1444
+ });
1445
+ const {
1446
+ pagination,
1447
+ paginationProps,
1448
+ data,
1449
+ validate,
1450
+ resetFields,
1451
+ clearValidate,
1452
+ loading,
1453
+ search,
1454
+ elFormRef,
1455
+ elTableRef,
1456
+ formatActionButtons
1457
+ } = useTable$1(props);
1458
+ const {
1459
+ columnProps,
1460
+ columnList
1461
+ } = useTableColumn(props, data);
1462
+ const {
1463
+ formItemProps
1464
+ } = useTableFormItem(props);
1465
+ __expose({
1466
+ elFormRef,
1467
+ elTableRef,
1468
+ validate,
1469
+ resetFields,
1470
+ clearValidate,
1471
+ search
1472
+ });
1473
+ return (_ctx, _cache) => {
1474
+ const _component_el_table_column = resolveComponent("el-table-column");
1475
+ const _component_EpButtons = resolveComponent("EpButtons");
1476
+ const _component_el_table = resolveComponent("el-table");
1477
+ const _component_el_form = resolveComponent("el-form");
1478
+ const _component_el_pagination = resolveComponent("el-pagination");
1479
+ const _directive_loading = resolveDirective("loading");
1480
+ return openBlock(), createElementBlock(
1481
+ "div",
1482
+ {
1483
+ class: normalizeClass(`${unref(bem).b()} ${unref(prepareClassNames)()}`),
1484
+ style: normalizeStyle({
1485
+ ...unref(prepareStyles)()
1486
+ })
1487
+ },
1488
+ [createVNode(_component_el_form, {
1489
+ ref_key: "elFormRef",
1490
+ ref: elFormRef,
1491
+ model: {
1492
+ table: unref(data)
1493
+ },
1494
+ size: "small",
1495
+ "hide-required-asterisk": "",
1496
+ "scroll-to-error": "",
1497
+ "scroll-into-view-options": {
1498
+ inline: "center"
1499
+ },
1500
+ class: "ep-form"
1501
+ }, {
1502
+ default: withCtx(() => [withDirectives((openBlock(), createBlock(
1503
+ _component_el_table,
1504
+ mergeProps({
1505
+ ref_key: "elTableRef",
1506
+ ref: elTableRef
1507
+ }, customAttrs.value),
1508
+ createSlots({
1509
+ default: withCtx(() => [_ctx.showSelectionCol ? (openBlock(), createBlock(_component_el_table_column, {
1510
+ key: 0,
1511
+ type: "selection",
1512
+ width: "55",
1513
+ align: _ctx.align,
1514
+ selectable: _ctx.selectable,
1515
+ fixed: ""
1516
+ }, null, 8, ["align", "selectable"])) : createCommentVNode("v-if", true), _ctx.showIndexCol ? (openBlock(), createBlock(_component_el_table_column, {
1517
+ key: 1,
1518
+ type: "index",
1519
+ width: "56",
1520
+ align: _ctx.align,
1521
+ label: "\u5E8F\u53F7",
1522
+ fixed: "",
1523
+ index: _ctx.indexFormatter
1524
+ }, null, 8, ["align", "index"])) : createCommentVNode("v-if", true), _ctx.actionButtons.length ? (openBlock(), createBlock(_component_el_table_column, {
1525
+ key: 2,
1526
+ label: "\u64CD\u4F5C",
1527
+ align: _ctx.align,
1528
+ fixed: "",
1529
+ width: "200"
1530
+ }, {
1531
+ default: withCtx((scope) => [createElementVNode(
1532
+ "span",
1533
+ {
1534
+ class: normalizeClass(unref(bem).e("action-buttons"))
1535
+ },
1536
+ [createVNode(_component_EpButtons, {
1537
+ list: unref(formatActionButtons)(_ctx.actionButtons, scope),
1538
+ type: "text"
1539
+ }, null, 8, ["list"])],
1540
+ 2
1541
+ /* CLASS */
1542
+ )]),
1543
+ _: 1
1544
+ /* STABLE */
1545
+ }, 8, ["align"])) : createCommentVNode("v-if", true), (openBlock(true), createElementBlock(
1546
+ Fragment,
1547
+ null,
1548
+ renderList(unref(columnList), (item, index) => {
1549
+ return openBlock(), createBlock(
1550
+ _component_el_table_column,
1551
+ mergeProps({
1552
+ key: index
1553
+ }, {
1554
+ ref_for: true
1555
+ }, unref(columnProps)(item)),
1556
+ {
1557
+ default: withCtx((scope) => [item.type ? (openBlock(), createBlock(unref(EpFormItem), mergeProps({
1558
+ key: 0,
1559
+ "form-data": scope.row
1560
+ }, {
1561
+ ref_for: true
1562
+ }, unref(formItemProps)(scope, item)), null, 16, ["form-data"])) : (openBlock(), createElementBlock(
1563
+ Fragment,
1564
+ {
1565
+ key: 1
1566
+ },
1567
+ [createTextVNode(
1568
+ toDisplayString(scope.row[item.prop]),
1569
+ 1
1570
+ /* TEXT */
1571
+ )],
1572
+ 64
1573
+ /* STABLE_FRAGMENT */
1574
+ ))]),
1575
+ _: 2
1576
+ /* DYNAMIC */
1577
+ },
1578
+ 1040
1579
+ /* FULL_PROPS, DYNAMIC_SLOTS */
1580
+ );
1581
+ }),
1582
+ 128
1583
+ /* KEYED_FRAGMENT */
1584
+ ))]),
1585
+ _: 2
1586
+ /* DYNAMIC */
1587
+ }, [renderList(slots.value, (name) => {
1588
+ return {
1589
+ name,
1590
+ fn: withCtx((scope) => [renderSlot(_ctx.$slots, name, normalizeProps(guardReactiveProps(scope)))])
1591
+ };
1592
+ })]),
1593
+ 1040
1594
+ /* FULL_PROPS, DYNAMIC_SLOTS */
1595
+ )), [[_directive_loading, unref(loading)]])]),
1596
+ _: 3
1597
+ /* FORWARDED */
1598
+ }, 8, ["model"]), _ctx.showPagination ? (openBlock(), createBlock(_component_el_pagination, mergeProps({
1599
+ key: 0,
1600
+ "current-page": unref(pagination).pageNo,
1601
+ "onUpdate:currentPage": ($event) => unref(pagination).pageNo = $event,
1602
+ "page-size": unref(pagination).pageSize,
1603
+ "onUpdate:pageSize": ($event) => unref(pagination).pageSize = $event,
1604
+ total: unref(pagination).total
1605
+ }, unref(paginationProps)), null, 16, ["current-page", "onUpdate:currentPage", "page-size", "onUpdate:pageSize", "total"])) : createCommentVNode("v-if", true)],
1606
+ 6
1607
+ /* CLASS, STYLE */
1608
+ );
1609
+ };
1610
+ }
1611
+ });
1612
+
1613
+ var Table = withInstall(_sfc_main$2);
1614
+
1615
+ console.log(formProps.formItemList);
1616
+ const searchListPageProps = {
1617
+ ...apiProps,
1618
+ customColumnModule: Number,
1619
+ // 自定义列模块
1620
+ showOperationColumn: Boolean,
1621
+ // 是否显示操作列
1622
+ // 表单列表
1623
+ formItemList: {
1624
+ ...formProps.formItemList
1625
+ },
1626
+ // 左侧按钮
1627
+ leftButtons: {
1628
+ ...buttonsProps.list
1629
+ },
1630
+ // 表格列
1631
+ columns: {
1632
+ ...tableProps.columns
1633
+ },
1634
+ // 操作列
1635
+ actionButtons: {
1636
+ ...tableProps.actionButtons
1637
+ },
1638
+ // 链接列
1639
+ linkProps: {
1640
+ ...tableProps.linkProps
1641
+ },
1642
+ showSelectionCol: Boolean,
1643
+ showIndexCol: {
1644
+ type: Boolean,
1645
+ default: true
1646
+ },
1647
+ add: Function,
1648
+ // 新增
1649
+ templateDownloadApi: String,
1650
+ // 模板下载
1651
+ importApi: String,
1652
+ // 导入
1653
+ exportApi: String,
1654
+ // 导出
1655
+ // 表格额外距离
1656
+ offsetTop: {
1657
+ type: Number,
1658
+ default: 0
1659
+ },
1660
+ formData: {
1661
+ type: Object,
1662
+ default: () => ({})
1663
+ },
1664
+ tableProps: Object,
1665
+ formProps: Object,
1666
+ buttonsProps: Object
1667
+ };
1668
+
1669
+ const useSearchListPage = (props) => {
1670
+ const { calcTableHeight, tableProps, tableRef } = useTable(props);
1671
+ const { formProps, validate, resetFields, formRef } = useForm(props, {
1672
+ calcTableHeight
1673
+ });
1674
+ const { buttonsProps, searchButtons, search, reset } = useButtons(props, {
1675
+ validate,
1676
+ resetFields,
1677
+ tableRef
1678
+ });
1679
+ return {
1680
+ formProps,
1681
+ tableProps,
1682
+ buttonsProps,
1683
+ searchButtons,
1684
+ search,
1685
+ reset,
1686
+ tableRef,
1687
+ formRef
1688
+ };
1689
+ };
1690
+ const useTable = (props) => {
1691
+ const instanceName = "tableRef";
1692
+ const tableRef = useTemplateRef(instanceName);
1693
+ const tableHeight = ref(window.innerHeight);
1694
+ const tableProps = computed(() => {
1695
+ return {
1696
+ ref: instanceName,
1697
+ columns: props.columns,
1698
+ showPagination: true,
1699
+ height: tableHeight.value,
1700
+ showIndexCol: props.showIndexCol,
1701
+ showSelectionCol: props.showSelectionCol,
1702
+ actionButtons: props.actionButtons,
1703
+ linkProps: props.linkProps,
1704
+ api: props.api,
1705
+ reqData: props.formData,
1706
+ ...props.tableProps
1707
+ };
1708
+ });
1709
+ const calcTableHeight = () => {
1710
+ const topHeight = document.getElementById("top").offsetHeight;
1711
+ const middleHeight = document.getElementById("middle").offsetHeight;
1712
+ let paginationHeight = 0;
1713
+ if (tableProps.value.showPagination) {
1714
+ paginationHeight = document.querySelector(".el-pagination").offsetHeight + 12;
1715
+ }
1716
+ const frameDistance = 40;
1717
+ tableHeight.value = window.innerHeight - topHeight - middleHeight - paginationHeight - frameDistance - props.offsetTop;
1718
+ };
1719
+ onMounted(calcTableHeight);
1720
+ return {
1721
+ tableRef,
1722
+ tableProps,
1723
+ calcTableHeight
1724
+ };
1725
+ };
1726
+ const useForm = (props, { calcTableHeight }) => {
1727
+ const instanceName = "formRef";
1728
+ const formRef = useTemplateRef(instanceName);
1729
+ const formProps = computed(() => {
1730
+ return {
1731
+ ref: instanceName,
1732
+ formItemList: props.formItemList,
1733
+ isShowFold: true,
1734
+ modelValue: props.formData,
1735
+ ...props.formProps,
1736
+ onToggleStatus: () => {
1737
+ setTimeout(() => {
1738
+ calcTableHeight();
1739
+ }, 0);
1740
+ }
1741
+ };
1742
+ });
1743
+ const validate = () => {
1744
+ return formRef.value.validate();
1745
+ };
1746
+ const resetFields = (props2) => {
1747
+ return formRef.value.resetFields(props2);
1748
+ };
1749
+ const clearValidate = (props2) => {
1750
+ return formRef.value.clearValidate(props2);
1751
+ };
1752
+ return {
1753
+ formProps,
1754
+ formRef,
1755
+ validate,
1756
+ resetFields,
1757
+ clearValidate
1758
+ };
1759
+ };
1760
+ const useButtons = (props, { validate, resetFields, tableRef }) => {
1761
+ const defaultButtons = [
1762
+ {
1763
+ name: "\u65B0\u589E",
1764
+ prop: "add",
1765
+ show: () => {
1766
+ return !!props.add;
1767
+ },
1768
+ onClick: () => {
1769
+ props.add?.();
1770
+ }
1771
+ },
1772
+ {
1773
+ name: "\u6A21\u7248\u4E0B\u8F7D",
1774
+ prop: "templateDownload",
1775
+ show: !!props.templateDownloadApi
1776
+ },
1777
+ {
1778
+ name: "\u5BFC\u5165",
1779
+ prop: "import",
1780
+ show: !!props.importApi
1781
+ },
1782
+ {
1783
+ name: "\u5BFC\u51FA",
1784
+ prop: "export",
1785
+ show: !!props.exportApi
1786
+ }
1787
+ ];
1788
+ props.leftButtons?.forEach((item) => {
1789
+ const defaultIndex = defaultButtons.findIndex(
1790
+ (item1) => item1.prop === item.prop
1791
+ );
1792
+ if (defaultIndex !== -1) {
1793
+ defaultButtons[defaultIndex] = {
1794
+ ...defaultButtons[defaultIndex],
1795
+ ...item
1796
+ };
1797
+ }
1798
+ });
1799
+ const list = defaultButtons.concat(props.leftButtons);
1800
+ list.forEach((item) => {
1801
+ if (item.onClick) {
1802
+ const clickFn = item.onClick;
1803
+ item.onClick = () => {
1804
+ const rows = tableRef.value.elTableRef.getSelectionRows();
1805
+ clickFn(rows);
1806
+ };
1807
+ }
1808
+ });
1809
+ const buttonsProps = computed(() => {
1810
+ return {
1811
+ list,
1812
+ ...props.buttonsProps
1813
+ };
1814
+ });
1815
+ const search = async () => {
1816
+ await validate();
1817
+ tableRef.value.search(true);
1818
+ };
1819
+ const reset = async () => {
1820
+ resetFields();
1821
+ search();
1822
+ };
1823
+ const searchButtons = [
1824
+ {
1825
+ name: "\u641C\u7D22",
1826
+ type: "primary",
1827
+ onClick: search
1828
+ },
1829
+ {
1830
+ name: "\u6E05\u7A7A",
1831
+ onClick: reset
1832
+ }
1833
+ ];
1834
+ return {
1835
+ buttonsProps,
1836
+ searchButtons,
1837
+ search,
1838
+ reset
1839
+ };
1840
+ };
1841
+
1842
+ var _sfc_main$1 = /* @__PURE__ */ defineComponent({
1843
+ ...{ name: "EpSearchListPage" },
1844
+ __name: "searchListPage",
1845
+ props: searchListPageProps,
1846
+ setup(__props, { expose: __expose }) {
1847
+ const bem = createNameSpace("search-list-page");
1848
+ const props = __props;
1849
+ const {
1850
+ formProps,
1851
+ buttonsProps,
1852
+ searchButtons,
1853
+ search,
1854
+ reset,
1855
+ tableRef,
1856
+ formRef,
1857
+ tableProps
1858
+ } = useSearchListPage(props);
1859
+ __expose({
1860
+ search,
1861
+ reset,
1862
+ tableRef,
1863
+ formRef
1864
+ });
1865
+ return (_ctx, _cache) => {
1866
+ const _component_EpButtons = resolveComponent("EpButtons");
1867
+ return openBlock(), createElementBlock(
1868
+ "div",
1869
+ {
1870
+ class: normalizeClass([unref(bem).b(), unref(prepareClassNames)()]),
1871
+ style: normalizeStyle({
1872
+ ...unref(prepareStyles)()
1873
+ })
1874
+ },
1875
+ [
1876
+ createElementVNode("div", { id: "top" }, [
1877
+ createVNode(
1878
+ unref(Form),
1879
+ normalizeProps(guardReactiveProps(unref(formProps))),
1880
+ null,
1881
+ 16
1882
+ /* FULL_PROPS */
1883
+ )
1884
+ ]),
1885
+ createElementVNode("div", { id: "middle" }, [
1886
+ createElementVNode(
1887
+ "div",
1888
+ {
1889
+ class: normalizeClass(unref(bem).e("middle-left"))
1890
+ },
1891
+ [
1892
+ createVNode(
1893
+ _component_EpButtons,
1894
+ normalizeProps(guardReactiveProps(unref(buttonsProps))),
1895
+ null,
1896
+ 16
1897
+ /* FULL_PROPS */
1898
+ )
1899
+ ],
1900
+ 2
1901
+ /* CLASS */
1902
+ ),
1903
+ createElementVNode(
1904
+ "div",
1905
+ {
1906
+ class: normalizeClass(unref(bem).e("middle-right"))
1907
+ },
1908
+ [
1909
+ createVNode(_component_EpButtons, { list: unref(searchButtons) }, null, 8, ["list"])
1910
+ ],
1911
+ 2
1912
+ /* CLASS */
1913
+ )
1914
+ ]),
1915
+ renderSlot(_ctx.$slots, "tableBefore"),
1916
+ createVNode(
1917
+ unref(Table),
1918
+ normalizeProps(guardReactiveProps(unref(tableProps))),
1919
+ null,
1920
+ 16
1921
+ /* FULL_PROPS */
1922
+ )
1923
+ ],
1924
+ 6
1925
+ /* CLASS, STYLE */
1926
+ );
1927
+ };
1928
+ }
1929
+ });
1930
+
1931
+ var SearchListPage = withInstall(_sfc_main$1);
1932
+
1933
+ const inheritSelectProps = {
1934
+ ...selectProps$1,
1935
+ clearable: {
1936
+ ...selectProps$1.clearable,
1937
+ default: true
1938
+ }
1939
+ };
1940
+ const expandSelectProps = {
1941
+ ...apiProps,
1942
+ disabledOption: {
1943
+ type: Function,
1944
+ default: () => false
1945
+ },
1946
+ labelKey: {
1947
+ type: String,
1948
+ default: "label"
1949
+ },
1950
+ valueKey: {
1951
+ type: String,
1952
+ default: "value"
1953
+ },
1954
+ formatLabel: {
1955
+ type: Function
1956
+ },
1957
+ // api模式生效
1958
+ lazy: Boolean,
1959
+ // option是否同时展示code label, 默认值展示label, 传string展示指定字段
1960
+ codeInLabel: {
1961
+ type: [String, Boolean]
1962
+ }
1963
+ };
1964
+ const selectProps = {
1965
+ ...inheritSelectProps,
1966
+ ...expandSelectProps
1967
+ };
1968
+ const expandSelectPropsKeys = Object.keys(expandSelectProps);
1969
+ const selectEmits = {
1970
+ ...selectEmits$1,
1971
+ change: (value, item) => true
1972
+ };
1973
+ const selectEmitsKeys = Object.keys(selectEmits);
1974
+
1975
+ function useSelect(props, emit) {
1976
+ let hasLoaded = false;
1977
+ const { loading, requestFn } = useRequest({
1978
+ api: props.api,
1979
+ method: props.method,
1980
+ reqData: props.reqData,
1981
+ reqParams: props.reqParams,
1982
+ reqBefore: props.reqBefore,
1983
+ reqAfter: props.reqAfter,
1984
+ cancelToken: props.remote,
1985
+ hooks: {
1986
+ success(data) {
1987
+ if (Array.isArray(data)) {
1988
+ customOptions.value = data;
1989
+ } else if (data && typeof data === "object") {
1990
+ const rawData = data;
1991
+ customOptions.value = rawData?.list || rawData?.data || [];
1992
+ } else {
1993
+ customOptions.value = [];
1994
+ }
1995
+ hasLoaded = true;
1996
+ },
1997
+ fail(error) {
1998
+ console.error(error);
1999
+ }
2000
+ }
2001
+ });
2002
+ const customOptions = ref([]);
2003
+ const loadOptions = (value, desc) => {
2004
+ if ((value || value === 0) && desc) {
2005
+ customOptions.value = [
2006
+ {
2007
+ [props.labelKey]: desc,
2008
+ [props.valueKey]: value
2009
+ }
2010
+ ];
2011
+ }
2012
+ if (props.api) {
2013
+ if (!props.lazy && !props.remote) {
2014
+ requestFn();
2015
+ }
2016
+ } else if (props.options?.length) {
2017
+ customOptions.value = props.options;
2018
+ }
2019
+ };
2020
+ const getSelectItem = (value) => {
2021
+ if (Array.isArray(value)) {
2022
+ if (!props.options) return [];
2023
+ return props.options.filter((item) => {
2024
+ return value.indexOf(item[props.valueKey]) > -1;
2025
+ });
2026
+ }
2027
+ if (!props.options) return {};
2028
+ return props.options.find((item) => {
2029
+ return item[props.valueKey] === value;
2030
+ }) || {};
2031
+ };
2032
+ const expandAttrs = {
2033
+ loading: props.loading || loading?.value,
2034
+ remoteMethod: (query) => {
2035
+ if (!query) return;
2036
+ requestFn({
2037
+ $searchValue: query
2038
+ });
2039
+ },
2040
+ onChange(value) {
2041
+ emit("change", value, getSelectItem(value));
2042
+ },
2043
+ onVisibleChange(visible) {
2044
+ if (props.api && props.lazy && visible && !hasLoaded && !props.remote) {
2045
+ requestFn();
2046
+ }
2047
+ emit("visible-change", visible);
2048
+ }
2049
+ };
2050
+ return {
2051
+ customOptions,
2052
+ loadOptions,
2053
+ expandAttrs
2054
+ };
2055
+ }
2056
+
2057
+ var _sfc_main = /* @__PURE__ */ defineComponent({
2058
+ ...{
2059
+ name: "EpSelect",
2060
+ inheritAttrs: false
2061
+ },
2062
+ __name: "select",
2063
+ props: /* @__PURE__ */ mergeModels(selectProps, {
2064
+ "modelValue": { type: null },
2065
+ "modelModifiers": {},
2066
+ "desc": { type: String },
2067
+ "descModifiers": {}
2068
+ }),
2069
+ emits: /* @__PURE__ */ mergeModels(selectEmits, ["update:modelValue", "update:desc"]),
2070
+ setup(__props, { emit: __emit }) {
2071
+ const bem = createNameSpace("select");
2072
+ const props = __props;
2073
+ const emit = __emit;
2074
+ const slots = computed(() => {
2075
+ return Object.keys(useSlots());
2076
+ });
2077
+ const { customOptions, loadOptions, expandAttrs } = useSelect(props, emit);
2078
+ const value = useModel(__props, "modelValue");
2079
+ const desc = useModel(__props, "desc");
2080
+ const customAttrs = computed(() => {
2081
+ return {
2082
+ ...prepareProps(props, ["modelValue", "desc", ...expandSelectPropsKeys]),
2083
+ ...prepareEvents(emit, selectEmitsKeys),
2084
+ ...expandAttrs
2085
+ };
2086
+ });
2087
+ loadOptions(value.value, desc.value);
2088
+ return (_ctx, _cache) => {
2089
+ const _component_el_option = resolveComponent("el-option");
2090
+ const _component_el_select = resolveComponent("el-select");
2091
+ return openBlock(), createBlock(_component_el_select, mergeProps({
2092
+ modelValue: value.value,
2093
+ "onUpdate:modelValue": ($event) => value.value = $event,
2094
+ class: `${unref(bem).b()} ${unref(prepareClassNames)()}`
2095
+ }, customAttrs.value, {
2096
+ style: {
2097
+ ...unref(prepareStyles)()
2098
+ }
2099
+ }), createSlots({
2100
+ default: withCtx(() => [
2101
+ (openBlock(true), createElementBlock(
2102
+ Fragment,
2103
+ null,
2104
+ renderList(unref(customOptions), (item) => {
2105
+ return openBlock(), createBlock(_component_el_option, {
2106
+ key: item[_ctx.valueKey],
2107
+ class: normalizeClass(unref(bem).e("option")),
2108
+ label: item.formatLabel ? item.formatLabel(item) : _ctx.formatLabel ? _ctx.formatLabel(item) : item[_ctx.labelKey],
2109
+ value: item[_ctx.valueKey],
2110
+ disabled: _ctx.disabledOption(item)
2111
+ }, {
2112
+ default: withCtx(() => [
2113
+ renderSlot(_ctx.$slots, "option", { item }, () => [
2114
+ _ctx.codeInLabel || _ctx.codeInLabel === "" ? (openBlock(), createElementBlock(
2115
+ Fragment,
2116
+ { key: 0 },
2117
+ [
2118
+ createElementVNode(
2119
+ "span",
2120
+ { style: { "float": "left" } },
2121
+ toDisplayString(item[_ctx.labelKey]),
2122
+ 1
2123
+ /* TEXT */
2124
+ ),
2125
+ createElementVNode(
2126
+ "span",
2127
+ { style: { "float": "right", "color": "var(--el-text-color-secondary)", "font-size": "13px" } },
2128
+ toDisplayString(item[typeof _ctx.codeInLabel === "string" && _ctx.codeInLabel ? _ctx.codeInLabel : _ctx.valueKey]),
2129
+ 1
2130
+ /* TEXT */
2131
+ )
2132
+ ],
2133
+ 64
2134
+ /* STABLE_FRAGMENT */
2135
+ )) : createCommentVNode("v-if", true)
2136
+ ])
2137
+ ]),
2138
+ _: 2
2139
+ /* DYNAMIC */
2140
+ }, 1032, ["class", "label", "value", "disabled"]);
2141
+ }),
2142
+ 128
2143
+ /* KEYED_FRAGMENT */
2144
+ ))
2145
+ ]),
2146
+ _: 2
2147
+ /* DYNAMIC */
2148
+ }, [
2149
+ renderList(slots.value, (name) => {
2150
+ return {
2151
+ name,
2152
+ fn: withCtx((scope) => [
2153
+ renderSlot(_ctx.$slots, name, normalizeProps(guardReactiveProps(scope)))
2154
+ ])
2155
+ };
2156
+ })
2157
+ ]), 1040, ["modelValue", "onUpdate:modelValue", "class", "style"]);
2158
+ };
2159
+ }
2160
+ });
2161
+
2162
+ var Select = withInstall(_sfc_main);
2163
+
2164
+ var components = [Buttons, Form, Input, SearchListPage, Select, Table];
2165
+
2166
+ var version = "0.0.1";
2167
+
2168
+ const install = (app, options) => {
2169
+ components.forEach((c) => app.use(c));
2170
+ };
2171
+ const plugin = {
2172
+ install,
2173
+ version
2174
+ };
2175
+
2176
+ export { EpFormItem, buttonsProps, plugin as default, expandFormItemPropsKeys, expandFormPropsKeys, expandSelectPropsKeys, expandTablePropsKeys, formEmits, formEmitsKeys, formItemProps, formProps, inheritSelectProps, inputEmits, inputEmitsKeys, inputProps, install, searchListPageProps, selectEmits, selectEmitsKeys, selectProps, tableEmits, tableEmitsKeys, tableProps, useRequest, vPermisson as vPermission, vRepeatClick };