mrxy-yk 0.0.1-beta.11

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 (236) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +34 -0
  3. package/dist/@type/components/a-map-canvas/index.d.ts +1 -0
  4. package/dist/@type/components/adaptive-box/AdaptiveBox.d.ts +42 -0
  5. package/dist/@type/components/coordinate-pickup/CoordinatePickup.d.ts +29 -0
  6. package/dist/@type/components/drag-drop-box/DragDropBox.d.ts +33 -0
  7. package/dist/@type/components/drag-drop-container/DragDropContainer.d.ts +39 -0
  8. package/dist/@type/components/drag-drop-container/type.d.ts +3 -0
  9. package/dist/@type/components/echarts-canvas/EChartsCanvas.d.ts +21 -0
  10. package/dist/@type/components/in-body/InBody.d.ts +22 -0
  11. package/dist/@type/components/index.d.ts +12 -0
  12. package/dist/@type/components/position-anchor/PositionAnchor.d.ts +23 -0
  13. package/dist/@type/components/progress-bar/ProgressBar.d.ts +35 -0
  14. package/dist/@type/components/progress-bar/type.d.ts +5 -0
  15. package/dist/@type/components/progress-ring/ProgressRing.d.ts +22 -0
  16. package/dist/@type/components/scroll-container/ScrollContainer.d.ts +35 -0
  17. package/dist/@type/components/show-log/ShowLog.d.ts +25 -0
  18. package/dist/@type/components/ys-video/@type/index.d.ts +151 -0
  19. package/dist/@type/components/ys-video/YsVideo.d.ts +18 -0
  20. package/dist/@type/components/ys-video/components/BtnLineRec.d.ts +7 -0
  21. package/dist/@type/components/ys-video/type.d.ts +9 -0
  22. package/dist/@type/config/index.d.ts +23 -0
  23. package/dist/@type/directive/index.d.ts +1 -0
  24. package/dist/@type/directive/ref-height/index.d.ts +3 -0
  25. package/dist/@type/directive/ref-height/type.d.ts +11 -0
  26. package/dist/@type/directive/table-scroll-carousel/index.d.ts +3 -0
  27. package/dist/@type/element-plus/components/attrs.d.ts +2 -0
  28. package/dist/@type/element-plus/components/date-picker/DatePicker.d.ts +16 -0
  29. package/dist/@type/element-plus/components/date-picker/index.d.ts +22 -0
  30. package/dist/@type/element-plus/components/date-picker/type.d.ts +17 -0
  31. package/dist/@type/element-plus/components/empty/Empty.d.ts +31 -0
  32. package/dist/@type/element-plus/components/empty/config.d.ts +24 -0
  33. package/dist/@type/element-plus/components/empty/hooks/index.d.ts +2 -0
  34. package/dist/@type/element-plus/components/empty/hooks/type.d.ts +12 -0
  35. package/dist/@type/element-plus/components/empty/type.d.ts +9 -0
  36. package/dist/@type/element-plus/components/form-dialog/FormDialog.d.ts +400 -0
  37. package/dist/@type/element-plus/components/form-dialog/type.d.ts +4 -0
  38. package/dist/@type/element-plus/components/images/Images.d.ts +16 -0
  39. package/dist/@type/element-plus/components/images/index.d.ts +9 -0
  40. package/dist/@type/element-plus/components/index.d.ts +9 -0
  41. package/dist/@type/element-plus/components/pagination/Pagination.d.ts +18 -0
  42. package/dist/@type/element-plus/components/table-column/TableColumn.d.ts +27 -0
  43. package/dist/@type/element-plus/components/upload/accept/index.d.ts +1 -0
  44. package/dist/@type/element-plus/components/upload/index.d.ts +42 -0
  45. package/dist/@type/element-plus/components/upload/select-file/SelectFile.d.ts +822 -0
  46. package/dist/@type/element-plus/components/upload/upload-files/UploadFiles.d.ts +844 -0
  47. package/dist/@type/element-plus/components/upload/upload-images/UploadImages.d.ts +842 -0
  48. package/dist/@type/element-plus/hooks/dialog/index.d.ts +2 -0
  49. package/dist/@type/element-plus/hooks/dialog/type.d.ts +20 -0
  50. package/dist/@type/element-plus/hooks/form/index.d.ts +2 -0
  51. package/dist/@type/element-plus/hooks/form/type.d.ts +45 -0
  52. package/dist/@type/element-plus/hooks/form-dialog/index.d.ts +2 -0
  53. package/dist/@type/element-plus/hooks/form-dialog/type.d.ts +70 -0
  54. package/dist/@type/element-plus/hooks/index.d.ts +5 -0
  55. package/dist/@type/element-plus/hooks/table-sort/index.d.ts +20 -0
  56. package/dist/@type/element-plus/hooks/table-sort/type.d.ts +21 -0
  57. package/dist/@type/element-plus/index.d.ts +2 -0
  58. package/dist/@type/element-plus/type.d.ts +15 -0
  59. package/dist/@type/element-plus/utils/form-rule/index.d.ts +4 -0
  60. package/dist/@type/element-plus/utils/form-rule/rule.d.ts +22 -0
  61. package/dist/@type/element-plus/utils/form-rule/type.d.ts +14 -0
  62. package/dist/@type/element-plus/utils/index.d.ts +2 -0
  63. package/dist/@type/element-plus/utils/table-util/index.d.ts +25 -0
  64. package/dist/@type/entity/BigFloat.d.ts +48 -0
  65. package/dist/@type/entity/Pages.d.ts +9 -0
  66. package/dist/@type/entity/RejectError.d.ts +24 -0
  67. package/dist/@type/entity/index.d.ts +3 -0
  68. package/dist/@type/hooks/index.d.ts +1 -0
  69. package/dist/@type/hooks/table-search/index.d.ts +3 -0
  70. package/dist/@type/hooks/table-search/type.d.ts +54 -0
  71. package/dist/@type/icons/index.d.ts +2 -0
  72. package/dist/@type/index.d.ts +13 -0
  73. package/dist/@type/resolver/index.d.ts +3 -0
  74. package/dist/@type/type.d.ts +11 -0
  75. package/dist/@type/typings.d.ts +20 -0
  76. package/dist/@type/utils/amap/@type/AMap.d.ts +24 -0
  77. package/dist/@type/utils/amap/@type/Bounds.d.ts +18 -0
  78. package/dist/@type/utils/amap/@type/Control.d.ts +19 -0
  79. package/dist/@type/utils/amap/@type/Event.d.ts +11 -0
  80. package/dist/@type/utils/amap/@type/Icon.d.ts +12 -0
  81. package/dist/@type/utils/amap/@type/InfoWindow.d.ts +40 -0
  82. package/dist/@type/utils/amap/@type/LngLat.d.ts +34 -0
  83. package/dist/@type/utils/amap/@type/Map.d.ts +218 -0
  84. package/dist/@type/utils/amap/@type/Marker.d.ts +137 -0
  85. package/dist/@type/utils/amap/@type/MarkerCluster.d.ts +65 -0
  86. package/dist/@type/utils/amap/@type/MoveAnimation.d.ts +33 -0
  87. package/dist/@type/utils/amap/@type/Pixel.d.ts +11 -0
  88. package/dist/@type/utils/amap/@type/Polyline.d.ts +80 -0
  89. package/dist/@type/utils/amap/@type/Size.d.ts +9 -0
  90. package/dist/@type/utils/amap/@type/index.d.ts +23 -0
  91. package/dist/@type/utils/amap/@type/other.d.ts +11 -0
  92. package/dist/@type/utils/amap/index.d.ts +3 -0
  93. package/dist/@type/utils/amap/type.d.ts +21 -0
  94. package/dist/@type/utils/amap/utils/coordinates.d.ts +24 -0
  95. package/dist/@type/utils/amap/utils/index.d.ts +12 -0
  96. package/dist/@type/utils/amap/utils/type.d.ts +4 -0
  97. package/dist/@type/utils/echarts/hooks/index.d.ts +76 -0
  98. package/dist/@type/utils/echarts/index.d.ts +3 -0
  99. package/dist/@type/utils/echarts/modules/coordinate/basic.d.ts +27 -0
  100. package/dist/@type/utils/echarts/modules/coordinate/cartesian.d.ts +25 -0
  101. package/dist/@type/utils/echarts/modules/coordinate/polar.d.ts +14 -0
  102. package/dist/@type/utils/echarts/modules/index.d.ts +5 -0
  103. package/dist/@type/utils/echarts/modules/series/bar.d.ts +16 -0
  104. package/dist/@type/utils/echarts/modules/series/line.d.ts +16 -0
  105. package/dist/@type/utils/echarts/modules/series/pie.d.ts +28 -0
  106. package/dist/@type/utils/echarts/modules/type.d.ts +83 -0
  107. package/dist/@type/utils/echarts/type.d.ts +8 -0
  108. package/dist/@type/utils/echarts/utils/assignOption.d.ts +7 -0
  109. package/dist/@type/utils/echarts/utils/index.d.ts +27 -0
  110. package/dist/@type/utils/fn-periodically/FnBatchPeriodically.d.ts +32 -0
  111. package/dist/@type/utils/fn-periodically/FnPeriodically.d.ts +37 -0
  112. package/dist/@type/utils/fn-periodically/index.d.ts +2 -0
  113. package/dist/@type/utils/fn-periodically/type.d.ts +30 -0
  114. package/dist/@type/utils/index.d.ts +6 -0
  115. package/dist/@type/utils/match-unit/dataset.d.ts +8 -0
  116. package/dist/@type/utils/match-unit/index.d.ts +10 -0
  117. package/dist/@type/utils/match-unit/type.d.ts +39 -0
  118. package/dist/@type/utils/mitt/hooks/inject-events/index.d.ts +7 -0
  119. package/dist/@type/utils/mitt/hooks/inject-events/type.d.ts +9 -0
  120. package/dist/@type/utils/prototype/index.d.ts +5 -0
  121. package/dist/@type/utils/prototype/lib/ArrayUtil.d.ts +87 -0
  122. package/dist/@type/utils/prototype/lib/ComponentUtil.d.ts +18 -0
  123. package/dist/@type/utils/prototype/lib/FileUtil.d.ts +19 -0
  124. package/dist/@type/utils/prototype/lib/NumberUtil.d.ts +9 -0
  125. package/dist/@type/utils/prototype/lib/ObjectUtil.d.ts +152 -0
  126. package/dist/@type/utils/prototype/lib/PromiseUtil.d.ts +7 -0
  127. package/dist/@type/utils/prototype/type.d.ts +28 -0
  128. package/dist/@type/utils/sandbox/Sandbox.d.ts +25 -0
  129. package/dist/@type/utils/transition-fade/index.d.ts +32 -0
  130. package/dist/@type/utils/transition-fade/type.d.ts +6 -0
  131. package/dist/_virtual/_plugin-vue_export-helper.es.js +10 -0
  132. package/dist/components/adaptive-box/AdaptiveBox.vue.es.js +7 -0
  133. package/dist/components/adaptive-box/AdaptiveBox.vue.es2.js +170 -0
  134. package/dist/components/coordinate-pickup/CoordinatePickup.vue.es.js +10 -0
  135. package/dist/components/coordinate-pickup/CoordinatePickup.vue.es2.js +302 -0
  136. package/dist/components/drag-drop-box/DragDropBox.vue.es.js +7 -0
  137. package/dist/components/drag-drop-box/DragDropBox.vue.es2.js +59 -0
  138. package/dist/components/drag-drop-container/DragDropContainer.vue.es.js +7 -0
  139. package/dist/components/drag-drop-container/DragDropContainer.vue.es2.js +113 -0
  140. package/dist/components/echarts-canvas/EChartsCanvas.vue.es.js +7 -0
  141. package/dist/components/echarts-canvas/EChartsCanvas.vue.es2.js +73 -0
  142. package/dist/components/in-body/InBody.vue.es.js +24 -0
  143. package/dist/components/in-body/InBody.vue.es2.js +4 -0
  144. package/dist/components/index.es.js +26 -0
  145. package/dist/components/position-anchor/PositionAnchor.vue.es.js +7 -0
  146. package/dist/components/position-anchor/PositionAnchor.vue.es2.js +22 -0
  147. package/dist/components/progress-bar/ProgressBar.vue.es.js +7 -0
  148. package/dist/components/progress-bar/ProgressBar.vue.es2.js +126 -0
  149. package/dist/components/progress-ring/ProgressRing.vue.es.js +7 -0
  150. package/dist/components/progress-ring/ProgressRing.vue.es2.js +87 -0
  151. package/dist/components/scroll-container/ScrollContainer.vue.es.js +7 -0
  152. package/dist/components/scroll-container/ScrollContainer.vue.es2.js +89 -0
  153. package/dist/components/show-log/ShowLog.vue.es.js +7 -0
  154. package/dist/components/show-log/ShowLog.vue.es2.js +61 -0
  155. package/dist/components/ys-video/YsVideo.vue.es.js +7 -0
  156. package/dist/components/ys-video/YsVideo.vue.es2.js +122 -0
  157. package/dist/components/ys-video/components/BtnLineRec.vue.es.js +7 -0
  158. package/dist/components/ys-video/components/BtnLineRec.vue.es2.js +57 -0
  159. package/dist/components/ys-video/images/btn-play.png.es.js +4 -0
  160. package/dist/config/index.es.js +16 -0
  161. package/dist/directive/index.es.js +4 -0
  162. package/dist/directive/ref-height/index.es.js +49 -0
  163. package/dist/element-plus/components/date-picker/DatePicker.vue.es.js +107 -0
  164. package/dist/element-plus/components/date-picker/DatePicker.vue.es2.js +4 -0
  165. package/dist/element-plus/components/date-picker/index.es.js +213 -0
  166. package/dist/element-plus/components/empty/Empty.vue.es.js +92 -0
  167. package/dist/element-plus/components/empty/Empty.vue.es3.js +5 -0
  168. package/dist/element-plus/components/empty/config.es.js +10 -0
  169. package/dist/element-plus/components/empty/hooks/index.es.js +24 -0
  170. package/dist/element-plus/components/form-dialog/FormDialog.vue.es.js +135 -0
  171. package/dist/element-plus/components/form-dialog/FormDialog.vue.es2.js +4 -0
  172. package/dist/element-plus/components/images/Images.vue.es.js +7 -0
  173. package/dist/element-plus/components/images/Images.vue.es2.js +93 -0
  174. package/dist/element-plus/components/images/index.es.js +10 -0
  175. package/dist/element-plus/components/index.es.js +21 -0
  176. package/dist/element-plus/components/pagination/Pagination.vue.es.js +7 -0
  177. package/dist/element-plus/components/pagination/Pagination.vue.es2.js +66 -0
  178. package/dist/element-plus/components/table-column/TableColumn.vue.es.js +34 -0
  179. package/dist/element-plus/components/table-column/TableColumn.vue.es2.js +4 -0
  180. package/dist/element-plus/components/upload/accept/index.es.js +12 -0
  181. package/dist/element-plus/components/upload/index.es.js +35 -0
  182. package/dist/element-plus/components/upload/select-file/SelectFile.vue.es.js +7 -0
  183. package/dist/element-plus/components/upload/select-file/SelectFile.vue.es2.js +66 -0
  184. package/dist/element-plus/components/upload/upload-files/UploadFiles.vue.es.js +7 -0
  185. package/dist/element-plus/components/upload/upload-files/UploadFiles.vue.es2.js +204 -0
  186. package/dist/element-plus/components/upload/upload-images/UploadImages.vue.es.js +7 -0
  187. package/dist/element-plus/components/upload/upload-images/UploadImages.vue.es2.js +212 -0
  188. package/dist/element-plus/hooks/dialog/index.es.js +44 -0
  189. package/dist/element-plus/hooks/form/index.es.js +45 -0
  190. package/dist/element-plus/hooks/form-dialog/index.es.js +53 -0
  191. package/dist/element-plus/hooks/table-sort/index.es.js +30 -0
  192. package/dist/element-plus/index.es.js +51 -0
  193. package/dist/element-plus/utils/form-rule/rule.es.js +107 -0
  194. package/dist/element-plus/utils/table-util/index.es.js +56 -0
  195. package/dist/entity/BigFloat.es.js +102 -0
  196. package/dist/entity/Pages.es.js +11 -0
  197. package/dist/entity/RejectError.es.js +35 -0
  198. package/dist/entity/index.es.js +8 -0
  199. package/dist/hooks/index.es.js +4 -0
  200. package/dist/hooks/table-search/index.es.js +72 -0
  201. package/dist/icons/images/Image.svg.es.js +4 -0
  202. package/dist/icons/images/ImageError.svg.es.js +4 -0
  203. package/dist/icons/index.es.js +12 -0
  204. package/dist/index.es.js +111 -0
  205. package/dist/mrxy-yk.css +1 -0
  206. package/dist/resolver/index.es.js +24 -0
  207. package/dist/styles/plugins/colors/index.scss +52 -0
  208. package/dist/styles/plugins/colors/var.scss +77 -0
  209. package/dist/styles/plugins/template.scss +37 -0
  210. package/dist/utils/amap/index.es.js +21 -0
  211. package/dist/utils/amap/utils/coordinates.es.js +61 -0
  212. package/dist/utils/amap/utils/index.es.js +39 -0
  213. package/dist/utils/echarts/hooks/index.es.js +32 -0
  214. package/dist/utils/echarts/modules/coordinate/basic.es.js +103 -0
  215. package/dist/utils/echarts/modules/coordinate/cartesian.es.js +79 -0
  216. package/dist/utils/echarts/modules/series/bar.es.js +43 -0
  217. package/dist/utils/echarts/modules/series/line.es.js +47 -0
  218. package/dist/utils/echarts/modules/series/pie.es.js +126 -0
  219. package/dist/utils/echarts/utils/assignOption.es.js +40 -0
  220. package/dist/utils/echarts/utils/index.es.js +99 -0
  221. package/dist/utils/fn-periodically/FnBatchPeriodically.es.js +70 -0
  222. package/dist/utils/fn-periodically/FnPeriodically.es.js +85 -0
  223. package/dist/utils/index.es.js +49 -0
  224. package/dist/utils/match-unit/dataset.es.js +143 -0
  225. package/dist/utils/match-unit/index.es.js +56 -0
  226. package/dist/utils/mitt/hooks/inject-events/index.es.js +27 -0
  227. package/dist/utils/prototype/lib/ArrayUtil.es.js +115 -0
  228. package/dist/utils/prototype/lib/ComponentUtil.es.js +45 -0
  229. package/dist/utils/prototype/lib/NumberUtil.es.js +17 -0
  230. package/dist/utils/prototype/lib/ObjectUtil.es.js +277 -0
  231. package/dist/utils/prototype/lib/PromiseUtil.es.js +18 -0
  232. package/dist/utils/transition-fade/index.es.js +79 -0
  233. package/global.d.ts +55 -0
  234. package/package.json +134 -0
  235. package/web-types-mr.json +923 -0
  236. package/web-types-yk.json +923 -0
@@ -0,0 +1,212 @@
1
+ import { ElUpload, ElIcon, ElImageViewer } from "element-plus/es";
2
+ import { defineComponent, getCurrentInstance, ref, inject, shallowRef, onMounted, onBeforeUnmount, computed, watch, createElementBlock, openBlock, normalizeStyle, normalizeClass, createVNode, createBlock, createCommentVNode, withCtx, renderSlot, unref, nextTick } from "vue";
3
+ import { Plus } from "@element-plus/icons-vue";
4
+ import "element-plus";
5
+ import { acceptMIMELib } from "../accept/index.es.js";
6
+ import { ElUploadImagesGlobal, ElUploadGlobal } from "../index.es.js";
7
+ import { useInjectEventsHooks } from "../../../../utils/mitt/hooks/inject-events/index.es.js";
8
+ import { MatchUnit } from "../../../../utils/match-unit/index.es.js";
9
+ import { PromiseUtil } from "../../../../utils/prototype/lib/PromiseUtil.es.js";
10
+ import { ArrayUtil } from "../../../../utils/prototype/lib/ArrayUtil.es.js";
11
+ var _sfc_main = /* @__PURE__ */ defineComponent({
12
+ __name: "UploadImages",
13
+ props: {
14
+ modelValue: {},
15
+ isJoin: { type: Boolean, default: true },
16
+ uploadClass: { default: "" },
17
+ accept: { default: "png,jpg,jpeg" },
18
+ width: { default: "248px" },
19
+ height: { default: "148px" },
20
+ maxSize: { default: Infinity },
21
+ limit: { default: Infinity },
22
+ getUrlMethod: {},
23
+ uploadMethod: {}
24
+ },
25
+ emits: ["update:modelValue", "change", "error"],
26
+ setup(__props, { expose: __expose, emit: __emit }) {
27
+ const props = __props;
28
+ const emits = __emit;
29
+ const instance = getCurrentInstance();
30
+ const uploadRef = ref();
31
+ const formDialogInject = inject("/YkElFormDialog");
32
+ const formDialogInjectEvent = shallowRef();
33
+ onMounted(() => {
34
+ if (!formDialogInject) return;
35
+ formDialogInjectEvent.value = useInjectEventsHooks({ mittEvent: formDialogInject.eventBus });
36
+ formDialogInjectEvent.value.on("resetFields", clearFiles);
37
+ formDialogInjectEvent.value.on("getUploadHandle", () => {
38
+ formDialogInjectEventEmit("uploadHandleResult", {
39
+ count: uploadUserFile.value.filter((item) => item.raw).length,
40
+ handle: uploadHandle
41
+ });
42
+ });
43
+ });
44
+ function formDialogInjectEventEmit(type, data) {
45
+ if (formDialogInjectEvent.value) {
46
+ formDialogInjectEvent.value.emit(type, data);
47
+ }
48
+ }
49
+ const uploadGroup = inject("YkUploadGroup");
50
+ onMounted(() => {
51
+ if (uploadGroup) {
52
+ uploadGroup.register(instance);
53
+ }
54
+ });
55
+ onBeforeUnmount(() => {
56
+ if (uploadGroup) {
57
+ uploadGroup.unregister(instance);
58
+ }
59
+ });
60
+ const uploadImageStyle = computed(() => ({
61
+ "--upload-size-w": props.width,
62
+ "--upload-size-h": props.height
63
+ }));
64
+ const getUrlMethod = props.getUrlMethod || ElUploadImagesGlobal.props.getUrlMethod.default || ElUploadGlobal.props.getUrlMethod.default || function(url) {
65
+ return url;
66
+ };
67
+ const uploadMethod = props.uploadMethod || ElUploadImagesGlobal.props.uploadMethod.default || ElUploadGlobal.props.uploadMethod.default;
68
+ const imageViewerState = ref(false);
69
+ const imageViewerUrlList = shallowRef([]);
70
+ const initialIndex = ref(0);
71
+ function showImageViewer(e) {
72
+ initialIndex.value = uploadUserFile.value.indexOf(e);
73
+ imageViewerState.value = true;
74
+ }
75
+ function hideImageViewer() {
76
+ imageViewerState.value = false;
77
+ }
78
+ const uploadUserFile = ref([]);
79
+ const uploadUserFileUrlDic = computed(() => ArrayUtil.createStrDic(uploadUserFile.value, "url"));
80
+ const modelFileListCustomer = computed({
81
+ get() {
82
+ return uploadUserFile.value;
83
+ },
84
+ set(val) {
85
+ uploadUserFile.value = val;
86
+ imageViewerUrlList.value = uploadUserFile.value.map((item) => item.url);
87
+ }
88
+ });
89
+ watch(() => props.modelValue, () => {
90
+ let urls = typeof props.modelValue === "string" ? props.modelValue.split(",") : props.modelValue || [];
91
+ urls = urls.filter(Boolean);
92
+ uploadUserFile.value = urls.map((url) => {
93
+ if (uploadUserFileUrlDic.value[url]?.raw) {
94
+ return uploadUserFileUrlDic.value[url];
95
+ } else {
96
+ const file = uploadUserFile.value.find((item) => item._url === url);
97
+ return file || {
98
+ url: /^https?:\/\/.*$/.test(url) ? url : getUrlMethod(url),
99
+ status: "success",
100
+ _url: url
101
+ };
102
+ }
103
+ });
104
+ imageViewerUrlList.value = uploadUserFile.value.map((item) => item.url);
105
+ }, { immediate: true });
106
+ function reverseSync() {
107
+ const urls = uploadUserFile.value.map((item) => {
108
+ return item.status === "success" ? item._url : item.url;
109
+ });
110
+ emits("update:modelValue", urls.join(","));
111
+ }
112
+ function onFileChange(file) {
113
+ let error = null;
114
+ if (!verifyFileType(file.raw)) {
115
+ error = new Error("文件类型应为" + props.accept);
116
+ } else if (file.size > props.maxSize) {
117
+ const unitVal = MatchUnit.matchMaxNum({
118
+ value: props.maxSize,
119
+ unit: "bit",
120
+ fractionDigits: 2,
121
+ carryNumber: 1024
122
+ });
123
+ error = new Error("文件大小不能超过" + unitVal.value + unitVal.unit);
124
+ }
125
+ if (error) {
126
+ uploadRef.value.handleRemove(file.raw);
127
+ emits("error", error);
128
+ } else {
129
+ nextTick(() => {
130
+ reverseSync();
131
+ emits("change", file);
132
+ });
133
+ }
134
+ }
135
+ function onFileRemove() {
136
+ nextTick(() => {
137
+ reverseSync();
138
+ });
139
+ }
140
+ async function uploadHandle() {
141
+ const retUrl = [];
142
+ for (let i = 0; i < uploadUserFile.value.length; i++) {
143
+ const file = uploadUserFile.value[i];
144
+ if (file.status !== "success" && file.raw) {
145
+ const [res] = await PromiseUtil.safe(uploadMethod(file.raw));
146
+ retUrl.push(res);
147
+ formDialogInjectEventEmit("uploadSuccess");
148
+ } else {
149
+ retUrl.push(file._url);
150
+ }
151
+ }
152
+ const ret = props.isJoin ? retUrl.join(",") : retUrl;
153
+ emits("update:modelValue", ret);
154
+ return ret;
155
+ }
156
+ function clearFiles() {
157
+ uploadRef.value.clearFiles();
158
+ imageViewerUrlList.value = [];
159
+ }
160
+ const uploadAccept = computed(() => props.accept.split(",").map((key) => acceptMIMELib[key]).join(","));
161
+ function verifyFileType(file) {
162
+ return props.accept.split(",").includes(file.name.replace(/^.*\.(\w*)$/, "$1"));
163
+ }
164
+ __expose({ upload: uploadHandle, clearFiles });
165
+ return (_ctx, _cache) => {
166
+ const _component_ElIcon = ElIcon;
167
+ const _component_el_upload = ElUpload;
168
+ const _component_ElImageViewer = ElImageViewer;
169
+ return openBlock(), createElementBlock("div", {
170
+ class: normalizeClass(["upload-image", { "limit_is-max": uploadUserFile.value?.length >= props.limit }]),
171
+ style: normalizeStyle(uploadImageStyle.value)
172
+ }, [
173
+ createVNode(_component_el_upload, {
174
+ ref_key: "uploadRef",
175
+ ref: uploadRef,
176
+ "file-list": modelFileListCustomer.value,
177
+ "onUpdate:fileList": _cache[0] || (_cache[0] = ($event) => modelFileListCustomer.value = $event),
178
+ "auto-upload": false,
179
+ accept: uploadAccept.value,
180
+ limit: props.limit,
181
+ multiple: "",
182
+ "list-type": "picture-card",
183
+ "on-preview": showImageViewer,
184
+ class: normalizeClass([__props.uploadClass]),
185
+ onChange: onFileChange,
186
+ onRemove: onFileRemove
187
+ }, {
188
+ default: withCtx(() => [
189
+ renderSlot(_ctx.$slots, "default", {}, () => [
190
+ createVNode(_component_ElIcon, null, {
191
+ default: withCtx(() => [
192
+ createVNode(unref(Plus))
193
+ ]),
194
+ _: 1
195
+ })
196
+ ], true)
197
+ ]),
198
+ _: 3
199
+ }, 8, ["file-list", "accept", "limit", "class"]),
200
+ imageViewerState.value ? (openBlock(), createBlock(_component_ElImageViewer, {
201
+ key: 0,
202
+ "url-list": unref(imageViewerUrlList),
203
+ "initial-index": initialIndex.value,
204
+ onClose: hideImageViewer
205
+ }, null, 8, ["url-list", "initial-index"])) : createCommentVNode("", true)
206
+ ], 6);
207
+ };
208
+ }
209
+ });
210
+ export {
211
+ _sfc_main as default
212
+ };
@@ -0,0 +1,44 @@
1
+ import { ref, nextTick } from "vue";
2
+ function useElDialogHooks(options) {
3
+ const ops = Object.assign({
4
+ show: null,
5
+ close: null
6
+ }, options);
7
+ const model = ref(false);
8
+ async function show(...args) {
9
+ if (ops.beforeShow) {
10
+ const result = await ops.beforeShow(...args);
11
+ if (result !== false) {
12
+ model.value = true;
13
+ }
14
+ } else {
15
+ model.value = true;
16
+ }
17
+ if (ops.show) {
18
+ await nextTick(() => {
19
+ ops.show(...args);
20
+ });
21
+ }
22
+ return model.value;
23
+ }
24
+ async function close(...args) {
25
+ if (ops.beforeClose) {
26
+ const result = await ops.beforeClose(...args);
27
+ if (result !== false) {
28
+ model.value = false;
29
+ }
30
+ } else {
31
+ model.value = false;
32
+ }
33
+ if (ops.close) {
34
+ await nextTick(() => {
35
+ ops.close(...args);
36
+ });
37
+ }
38
+ return !model.value;
39
+ }
40
+ return { show, close, model };
41
+ }
42
+ export {
43
+ useElDialogHooks
44
+ };
@@ -0,0 +1,45 @@
1
+ import { isRef, ref, shallowRef, useTemplateRef } from "vue";
2
+ import { ObjectUtil } from "../../../utils/prototype/lib/ObjectUtil.es.js";
3
+ import { PromiseUtil } from "../../../utils/prototype/lib/PromiseUtil.es.js";
4
+ function useElFormHooks(options) {
5
+ const ops = Object.assign({
6
+ form: {},
7
+ rules: []
8
+ }, options);
9
+ const form = isRef(ops.form) ? ops.form : ref(ops.form);
10
+ const formSnapshot = ObjectUtil.toJSON(form.value);
11
+ let formRef = shallowRef();
12
+ if (typeof ops.ref === "string") {
13
+ formRef = useTemplateRef(ops.ref);
14
+ } else if (ops.ref) {
15
+ formRef = ops.ref;
16
+ }
17
+ async function submitHandle(...args) {
18
+ let result = true;
19
+ if (formRef.value) {
20
+ const _result = await PromiseUtil.safe(formRef.value.validate());
21
+ result = _result[0];
22
+ }
23
+ if (result && ops.submit) {
24
+ if (ops.beforeSubmit) {
25
+ await ops.beforeSubmit();
26
+ }
27
+ await ops.submit(...args);
28
+ }
29
+ }
30
+ function resetFields() {
31
+ form.value = ObjectUtil.toJSON(formSnapshot);
32
+ formRef.value?.clearValidate();
33
+ }
34
+ return {
35
+ ref: formRef,
36
+ form,
37
+ rules: ops.rules,
38
+ submit: submitHandle,
39
+ resetFields,
40
+ _option: ops
41
+ };
42
+ }
43
+ export {
44
+ useElFormHooks
45
+ };
@@ -0,0 +1,53 @@
1
+ import { useElFormHooks } from "../form/index.es.js";
2
+ import { useElDialogHooks } from "../dialog/index.es.js";
3
+ import { computed } from "vue";
4
+ function useElFormDialogHooks(options) {
5
+ const ops = Object.assign({
6
+ closeResetFields: true,
7
+ submitAutoUploadFile: true,
8
+ title: ""
9
+ }, options);
10
+ const submit = ops.submit;
11
+ ops.submit = async (...args) => {
12
+ if (submit) {
13
+ const submitResult = submit(...args);
14
+ if (submitResult instanceof Promise) {
15
+ await submitResult;
16
+ if (ops.submitAutoClose !== false) await dialogHook.close(...[]);
17
+ } else {
18
+ if (ops.submitAutoClose === true) await dialogHook.close(...[]);
19
+ }
20
+ }
21
+ };
22
+ const formHook = useElFormHooks(ops);
23
+ const dialogHook = useElDialogHooks(ops);
24
+ const title = computed(() => {
25
+ const form = formHook.form.value;
26
+ return (form.id ? "编辑" : "添加") + ops.title;
27
+ });
28
+ async function show(...args) {
29
+ const result = await dialogHook.show(...args);
30
+ if (result) formHook.resetFields();
31
+ return result;
32
+ }
33
+ async function close(...args) {
34
+ const result = await dialogHook.close(...args);
35
+ if (result) closed();
36
+ return result;
37
+ }
38
+ function closed() {
39
+ if (ops.closeResetFields) formHook.resetFields();
40
+ }
41
+ return {
42
+ ...formHook,
43
+ ...dialogHook,
44
+ show,
45
+ close,
46
+ title,
47
+ _formHook: formHook,
48
+ _options: ops
49
+ };
50
+ }
51
+ export {
52
+ useElFormDialogHooks
53
+ };
@@ -0,0 +1,30 @@
1
+ import { ref, watch } from "vue";
2
+ function useElTableSortHooks(options) {
3
+ const tableData = options.data;
4
+ const isEnable = ref(false);
5
+ const sortValue = ref([]);
6
+ watch(() => tableData.value.length, () => {
7
+ if (isEnable.value) updateSortValue();
8
+ }, { deep: false });
9
+ function updateSortValue() {
10
+ const length = tableData.value.length;
11
+ sortValue.value = Array.from({ length }, (_, i) => i + 1);
12
+ }
13
+ function enable() {
14
+ isEnable.value = true;
15
+ updateSortValue();
16
+ }
17
+ function disable() {
18
+ isEnable.value = false;
19
+ sortValue.value = [];
20
+ }
21
+ function sort(index) {
22
+ const tableItem = tableData.value.splice(index, 1);
23
+ tableData.value.splice(sortValue.value[index] - 1, 0, ...tableItem);
24
+ updateSortValue();
25
+ }
26
+ return { isEnable, enable, disable, sort, sortValue };
27
+ }
28
+ export {
29
+ useElTableSortHooks
30
+ };
@@ -0,0 +1,51 @@
1
+ import { ElLoading } from "element-plus";
2
+ import { useElDialogHooks } from "./hooks/dialog/index.es.js";
3
+ import { useElFormHooks } from "./hooks/form/index.es.js";
4
+ import { useElTableSortHooks } from "./hooks/table-sort/index.es.js";
5
+ import { useElFormDialogHooks } from "./hooks/form-dialog/index.es.js";
6
+ import { useElEmptyHooks } from "./components/empty/hooks/index.es.js";
7
+ import { TableUtil } from "./utils/table-util/index.es.js";
8
+ import { integerRule, integerTag, ipRule, ipTag, numberRule, numberTag, passwordRule, passwordTag, phoneRule, phoneTag, positionRule, positionTag, positiveIntegerRule, positiveIntegerTag, positiveNumberRule, positiveNumberTag, required, usernameRule, usernameTag, validator } from "./utils/form-rule/rule.es.js";
9
+ const elLoadingService = ElLoading.service;
10
+ let showServiceCount = 0;
11
+ ElLoading.service = function(options) {
12
+ const instance = elLoadingService(options);
13
+ showServiceCount++;
14
+ const instanceClose = instance.close;
15
+ instance.close = function() {
16
+ showServiceCount--;
17
+ if (showServiceCount <= 0) {
18
+ showServiceCount = 0;
19
+ instanceClose();
20
+ }
21
+ };
22
+ return instance;
23
+ };
24
+ export {
25
+ TableUtil,
26
+ integerRule,
27
+ integerTag,
28
+ ipRule,
29
+ ipTag,
30
+ numberRule,
31
+ numberTag,
32
+ passwordRule,
33
+ passwordTag,
34
+ phoneRule,
35
+ phoneTag,
36
+ positionRule,
37
+ positionTag,
38
+ positiveIntegerRule,
39
+ positiveIntegerTag,
40
+ positiveNumberRule,
41
+ positiveNumberTag,
42
+ required,
43
+ useElDialogHooks,
44
+ useElEmptyHooks,
45
+ useElFormDialogHooks,
46
+ useElFormHooks,
47
+ useElTableSortHooks,
48
+ usernameRule,
49
+ usernameTag,
50
+ validator
51
+ };
@@ -0,0 +1,107 @@
1
+ import { ObjectUtil } from "../../../utils/prototype/lib/ObjectUtil.es.js";
2
+ const required = function(message = "此项为必填项", trigger = "blur") {
3
+ return { required: true, message, trigger };
4
+ };
5
+ ["blur", "change"].forEach((trigger) => {
6
+ required[trigger] = (message) => required(message, trigger);
7
+ });
8
+ const validator = function(fn, ops = {}) {
9
+ return { validator: fn, trigger: "blur", ...ops };
10
+ };
11
+ ["blur", "change"].forEach((trigger) => {
12
+ validator[trigger] = (fn, ops = {}) => validator(fn, {
13
+ trigger,
14
+ ...ops
15
+ });
16
+ });
17
+ function phoneTag(value) {
18
+ return /^1\d{10}$/.test(value) ? void 0 : new Error("手机号格式不正确");
19
+ }
20
+ const phoneRule = validator.blur((rule, value, callback) => {
21
+ callback(ObjectUtil.isNotEmpty(value) ? phoneTag(value) : void 0);
22
+ });
23
+ function usernameTag(value) {
24
+ const username = /^\w{8,16}$/;
25
+ return username.test(value) ? void 0 : new Error("账号为8 ~ 16位字母、数字");
26
+ }
27
+ const usernameRule = validator.blur((rule, value, callback) => {
28
+ callback(ObjectUtil.isNotEmpty(value) ? usernameTag(value) : void 0);
29
+ });
30
+ function passwordTag(value) {
31
+ if (ObjectUtil.isEmpty(value)) return;
32
+ const password = /^(?=.*[A-Za-z])(?=.*\d)[\w\-+.@#$%^&*!]{8,16}$/;
33
+ const passwordTwo = /^[\w\-+.]{8,16}$/;
34
+ if (password.test(value)) {
35
+ return;
36
+ } else if (passwordTwo.test(value)) {
37
+ return new Error("密码至少包含1位字母或数字");
38
+ } else {
39
+ return new Error("密码为8 ~ 16位字母、数字");
40
+ }
41
+ }
42
+ const passwordRule = validator.blur((rule, value, callback) => {
43
+ callback(ObjectUtil.isNotEmpty(value) ? passwordTag(value) : void 0);
44
+ });
45
+ function positionTag(value) {
46
+ const position = /^((-?180)|(-?1[0-7]\d)|(-?[1-9]\d)|(-?[1-9])|0)(\.\d+)?,((-?90)|(-?[1-8]\d)|(-?[1-9])|0)(\.\d+)?$/;
47
+ return position.test(value) ? void 0 : new Error("坐标格式为(±180,±90)");
48
+ }
49
+ const positionRule = validator.blur((rule, value, callback) => {
50
+ callback(ObjectUtil.isNotEmpty(value) ? positionTag(value) : void 0);
51
+ });
52
+ function ipTag(value) {
53
+ const tag = /^(1[0-9]{2}|2[0-4][0-9]|25[0-5]|[1-9]?[0-9])(\.(1[0-9]{2}|2[0-4][0-9]|25[0-5]|[1-9]?[0-9])){3}$/;
54
+ return tag.test(value) ? void 0 : new Error("Ip格式为(192.168.1.1)");
55
+ }
56
+ const ipRule = validator.blur((rule, value, callback) => {
57
+ callback(ObjectUtil.isNotEmpty(value) ? ipTag(value) : void 0);
58
+ });
59
+ function numberTag(value) {
60
+ return ObjectUtil.isEmpty(value) || !Number.isNaN(Number(value)) ? void 0 : new Error("此项应为正整数");
61
+ }
62
+ const numberRule = validator.blur((rule, value, callback) => {
63
+ callback(ObjectUtil.isNotEmpty(value) ? numberTag(value) : void 0);
64
+ });
65
+ function positiveNumberTag(value) {
66
+ const isNumber = !Number.isNaN(Number(value));
67
+ return ObjectUtil.isEmpty(value) || isNumber && Number(value) > 0 ? void 0 : new Error("此项应为正数数字");
68
+ }
69
+ const positiveNumberRule = validator.blur((rule, value, callback) => {
70
+ callback(ObjectUtil.isNotEmpty(value) ? positiveNumberTag(value) : void 0);
71
+ });
72
+ function integerTag(value) {
73
+ const tag = /^-?\d+$/;
74
+ return ObjectUtil.isEmpty(value) || tag.test(value.toString()) ? void 0 : new Error("此项应为正整数");
75
+ }
76
+ const integerRule = validator.blur((rule, value, callback) => {
77
+ callback(ObjectUtil.isNotEmpty(value) ? integerTag(value) : void 0);
78
+ });
79
+ function positiveIntegerTag(value) {
80
+ const tag = /^\d+$/;
81
+ return ObjectUtil.isEmpty(value) || tag.test(value.toString()) ? void 0 : new Error("此项应为正整数");
82
+ }
83
+ const positiveIntegerRule = validator.blur((rule, value, callback) => {
84
+ callback(ObjectUtil.isNotEmpty(value) ? positiveIntegerTag(value) : void 0);
85
+ });
86
+ export {
87
+ integerRule,
88
+ integerTag,
89
+ ipRule,
90
+ ipTag,
91
+ numberRule,
92
+ numberTag,
93
+ passwordRule,
94
+ passwordTag,
95
+ phoneRule,
96
+ phoneTag,
97
+ positionRule,
98
+ positionTag,
99
+ positiveIntegerRule,
100
+ positiveIntegerTag,
101
+ positiveNumberRule,
102
+ positiveNumberTag,
103
+ required,
104
+ usernameRule,
105
+ usernameTag,
106
+ validator
107
+ };
@@ -0,0 +1,56 @@
1
+ import "element-plus";
2
+ import "vue";
3
+ const TableUtil = {
4
+ /**
5
+ * 计算表格序号
6
+ * @param pages
7
+ */
8
+ indexMethod(pages) {
9
+ return (index) => pages.pageSize * (pages.pageNum - 1) + index + 1;
10
+ },
11
+ /**
12
+ * 前端分页
13
+ * @param tableData
14
+ * @param pages
15
+ */
16
+ paging(tableData, pages) {
17
+ if (tableData.length === 0) {
18
+ pages.pageNum = 1;
19
+ return [];
20
+ }
21
+ let start = pages.pageSize * (pages.pageNum - 1);
22
+ let end = start + pages.pageSize;
23
+ if (tableData.length < start) {
24
+ pages.pageNum = Math.ceil(tableData.length / pages.pageSize);
25
+ start = pages.pageSize * pages.pageNum;
26
+ end = start + pages.pageSize;
27
+ }
28
+ if (end > tableData.length) {
29
+ end = tableData.length;
30
+ }
31
+ const retData = [];
32
+ for (; start < end; start++) {
33
+ retData.push(tableData[start]);
34
+ }
35
+ return retData;
36
+ },
37
+ /**
38
+ * 高亮某一行
39
+ * @param ref
40
+ * @param index
41
+ * @param timeout
42
+ */
43
+ highlightRow(ref, index, timeout = 12e3) {
44
+ const trs = ref.$el.querySelectorAll(".el-table__body tbody tr") || [];
45
+ const row = trs[index];
46
+ if (row) {
47
+ row.classList.add("elc-highlight-row");
48
+ setTimeout(() => {
49
+ row.classList.remove("elc-highlight-row");
50
+ }, timeout);
51
+ }
52
+ }
53
+ };
54
+ export {
55
+ TableUtil
56
+ };