star-horse-lowcode 2.7.62 → 2.7.65

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 (221) hide show
  1. package/.env.development +3 -0
  2. package/.env.production +3 -0
  3. package/.eslintrc-auto-import.json +77 -0
  4. package/.gitignore +27 -0
  5. package/.idea/.gitignore +5 -0
  6. package/.idea/MarsCodeWorkspaceAppSettings.xml +6 -0
  7. package/.idea/inspectionProfiles/Project_Default.xml +7 -0
  8. package/.idea/modules.xml +8 -0
  9. package/.idea/testcode.iml +12 -0
  10. package/.idea/vcs.xml +6 -0
  11. package/.idea/watcherTasks.xml +4 -0
  12. package/.idea/workspace.xml +207 -0
  13. package/.npmignore +21 -0
  14. package/.prettierignore +26 -0
  15. package/README.md +2 -0
  16. package/auto-imports.d.ts +137 -0
  17. package/components.d.ts +189 -0
  18. package/dist/assets/index.css +1 -1
  19. package/dist/index.es.js +941 -720
  20. package/dist/types/index.d.ts +8 -8
  21. package/eslint.config.js +37 -0
  22. package/index.html +14 -0
  23. package/package-lock.json +8276 -0
  24. package/package.json +6 -6
  25. package/prettier.config.js +20 -0
  26. package/public/logo.svg +660 -0
  27. package/src/App.vue +11 -0
  28. package/src/api/date_utils.ts +219 -0
  29. package/src/api/finger_utils.ts +71 -0
  30. package/src/api/form_utils.ts +281 -0
  31. package/src/api/jquery.min.js +2 -0
  32. package/src/api/pcas-code.json +1 -0
  33. package/src/api/settings.ts +81 -0
  34. package/src/api/star_horse_apis.ts +196 -0
  35. package/src/api/star_horse_utils.ts +797 -0
  36. package/src/api/system.ts +351 -0
  37. package/src/api/user_func.ts +147 -0
  38. package/src/api/valid_utils.ts +165 -0
  39. package/src/assets/css/index.scss +908 -0
  40. package/src/assets/icons.css +574 -0
  41. package/src/assets/star-horse-icons.woff +0 -0
  42. package/src/components/comp/ShDynamicForm.vue +160 -0
  43. package/src/components/comp/ShForm.vue +30 -0
  44. package/src/components/comp/ShTableListColumn.vue +61 -0
  45. package/src/components/comp/StarHorseDataSelector.vue +139 -0
  46. package/src/components/comp/StarHorseDataView.vue +110 -0
  47. package/src/components/comp/StarHorseDataViewItems.vue +61 -0
  48. package/src/components/comp/StarHorseDataViewTable.vue +102 -0
  49. package/src/components/comp/StarHorseDialog.vue +383 -0
  50. package/src/components/comp/StarHorseDraggable.vue +401 -0
  51. package/src/components/comp/StarHorseForm.vue +458 -0
  52. package/src/components/comp/StarHorseFormItem.vue +82 -0
  53. package/src/components/comp/StarHorseFormList.vue +516 -0
  54. package/src/components/comp/StarHorseFormTable.vue +56 -0
  55. package/src/components/comp/StarHorseIcon.vue +76 -0
  56. package/src/components/comp/StarHorseItem.vue +302 -0
  57. package/src/components/comp/StarHorseJsonEditor.vue +115 -0
  58. package/src/components/comp/StarHorsePopover.vue +66 -0
  59. package/src/components/comp/StarHorseSearchComp.vue +253 -0
  60. package/src/components/comp/StarHorseStaticTable.vue +395 -0
  61. package/src/components/comp/StarHorseTableColumn.vue +249 -0
  62. package/src/components/comp/StarHorseTableComp.vue +1193 -0
  63. package/src/components/comp/StarHorseTableViewColumn.vue +61 -0
  64. package/src/components/comp/StarHorseTree.vue +494 -0
  65. package/src/components/comp/index.ts +22 -0
  66. package/src/components/comp/items/UTableColumn.vue +65 -0
  67. package/src/components/comp/items/boxItem.vue +98 -0
  68. package/src/components/comp/items/callitem.ts +9 -0
  69. package/src/components/comp/items/cardItem.vue +152 -0
  70. package/src/components/comp/items/collapseItem.vue +134 -0
  71. package/src/components/comp/items/dytableItem.vue +135 -0
  72. package/src/components/comp/items/otherItem.vue +65 -0
  73. package/src/components/comp/items/tabItem.vue +155 -0
  74. package/src/components/comp/items/tabPanelItem.vue +110 -0
  75. package/src/components/comp/items/tableColumn.vue +129 -0
  76. package/src/components/comp/items/tableItem.vue +97 -0
  77. package/src/components/comp/items/tablebtn.vue +158 -0
  78. package/src/components/comp/items/viewBoxItem.vue +55 -0
  79. package/src/components/comp/items/viewCardItem.vue +47 -0
  80. package/src/components/comp/items/viewCollapseItem.vue +71 -0
  81. package/src/components/comp/items/viewDytableItem.vue +77 -0
  82. package/src/components/comp/items/viewOtherItem.vue +55 -0
  83. package/src/components/comp/items/viewTabItem.vue +77 -0
  84. package/src/components/comp/items/viewTabPanelItem.vue +54 -0
  85. package/src/components/comp/items/viewTableItem.vue +74 -0
  86. package/src/components/comp/selfcomp.ts +9 -0
  87. package/src/components/comp/utils/DataPicker.vue +302 -0
  88. package/src/components/comp/utils/DataTag.vue +51 -0
  89. package/src/components/cron/Crontab-Day.vue +230 -0
  90. package/src/components/cron/Crontab-Hour.vue +165 -0
  91. package/src/components/cron/Crontab-Min.vue +166 -0
  92. package/src/components/cron/Crontab-Month.vue +166 -0
  93. package/src/components/cron/Crontab-Result.vue +615 -0
  94. package/src/components/cron/Crontab-Second.vue +185 -0
  95. package/src/components/cron/Crontab-Week.vue +208 -0
  96. package/src/components/cron/Crontab-Year.vue +183 -0
  97. package/src/components/cron/Crontab.vue +474 -0
  98. package/src/components/enums/ModuleEnums.ts +10 -0
  99. package/src/components/enums/ServiceEnums.ts +18 -0
  100. package/src/components/formcomp/container/box-container.vue +162 -0
  101. package/src/components/formcomp/container/callitem.ts +9 -0
  102. package/src/components/formcomp/container/card-container.vue +170 -0
  103. package/src/components/formcomp/container/collapse-container.vue +133 -0
  104. package/src/components/formcomp/container/dytable-col.vue +448 -0
  105. package/src/components/formcomp/container/dytable-container.vue +57 -0
  106. package/src/components/formcomp/container/dytableUtils.ts +358 -0
  107. package/src/components/formcomp/container/group-box-container.vue +331 -0
  108. package/src/components/formcomp/container/index.ts +6 -0
  109. package/src/components/formcomp/container/tab-container.vue +153 -0
  110. package/src/components/formcomp/container/table-container.vue +249 -0
  111. package/src/components/formcomp/items/allitem.ts +9 -0
  112. package/src/components/formcomp/items/area-item.vue +116 -0
  113. package/src/components/formcomp/items/audio-item.vue +163 -0
  114. package/src/components/formcomp/items/autocomplete-item.vue +118 -0
  115. package/src/components/formcomp/items/barcode-item.vue +87 -0
  116. package/src/components/formcomp/items/base-json-item.vue +207 -0
  117. package/src/components/formcomp/items/button-item.vue +228 -0
  118. package/src/components/formcomp/items/cascade-item.vue +113 -0
  119. package/src/components/formcomp/items/checkbox-item.vue +97 -0
  120. package/src/components/formcomp/items/color-item.vue +70 -0
  121. package/src/components/formcomp/items/cron-item.vue +115 -0
  122. package/src/components/formcomp/items/datetime-item.vue +99 -0
  123. package/src/components/formcomp/items/depart-item.vue +51 -0
  124. package/src/components/formcomp/items/dialog-input-item.vue +207 -0
  125. package/src/components/formcomp/items/divider-item.vue +66 -0
  126. package/src/components/formcomp/items/html-item.vue +65 -0
  127. package/src/components/formcomp/items/htmleditor-item.vue +104 -0
  128. package/src/components/formcomp/items/icon-item.vue +195 -0
  129. package/src/components/formcomp/items/image-item.vue +247 -0
  130. package/src/components/formcomp/items/index.ts +44 -0
  131. package/src/components/formcomp/items/input-item.vue +150 -0
  132. package/src/components/formcomp/items/json-array-item.vue +67 -0
  133. package/src/components/formcomp/items/json-item.vue +66 -0
  134. package/src/components/formcomp/items/markdown-item.vue +77 -0
  135. package/src/components/formcomp/items/number-item.vue +94 -0
  136. package/src/components/formcomp/items/number-range-item.vue +278 -0
  137. package/src/components/formcomp/items/page-select-item.vue +407 -0
  138. package/src/components/formcomp/items/password-item.vue +71 -0
  139. package/src/components/formcomp/items/qrcode-item.vue +84 -0
  140. package/src/components/formcomp/items/radio-item.vue +112 -0
  141. package/src/components/formcomp/items/rate-item.vue +68 -0
  142. package/src/components/formcomp/items/select-item.vue +133 -0
  143. package/src/components/formcomp/items/signature-item.vue +216 -0
  144. package/src/components/formcomp/items/slider-item.vue +68 -0
  145. package/src/components/formcomp/items/starhorse-form-item.vue +334 -0
  146. package/src/components/formcomp/items/switch-item.vue +77 -0
  147. package/src/components/formcomp/items/tag-item.vue +77 -0
  148. package/src/components/formcomp/items/text-item.vue +75 -0
  149. package/src/components/formcomp/items/textarea-item.vue +85 -0
  150. package/src/components/formcomp/items/time-item.vue +77 -0
  151. package/src/components/formcomp/items/time-picker-item.vue +74 -0
  152. package/src/components/formcomp/items/transfer-item.vue +93 -0
  153. package/src/components/formcomp/items/tselect-item.vue +121 -0
  154. package/src/components/formcomp/items/unknown-item.vue +51 -0
  155. package/src/components/formcomp/items/upload-item.vue +189 -0
  156. package/src/components/formcomp/items/user-item.vue +177 -0
  157. package/src/components/formcomp/items/usercomp-item.vue +85 -0
  158. package/src/components/formcomp/items/view-markdown-item.vue +77 -0
  159. package/src/components/formcomp/utils/EditDataDialog.vue +67 -0
  160. package/src/components/formcomp/utils/FieldList.vue +125 -0
  161. package/src/components/formcomp/utils/ItemRelationEventUtils.ts +284 -0
  162. package/src/components/help.vue +31 -0
  163. package/src/components/menu/MenuItem.vue +95 -0
  164. package/src/components/menu/SubMenu.vue +68 -0
  165. package/src/components/menu/SubSystemMenu.vue +142 -0
  166. package/src/components/register.ts +24 -0
  167. package/src/components/system/ContentMenu.vue +260 -0
  168. package/src/components/system/StarHorseButtonList.vue +344 -0
  169. package/src/components/system/StarHorseMenu.vue +97 -0
  170. package/src/components/system/StarHorseSvg.vue +62 -0
  171. package/src/components/system/SystemComp.ts +9 -0
  172. package/src/components/system/index.ts +4 -0
  173. package/src/components/types/ApiUrls.ts +168 -0
  174. package/src/components/types/BtnAction.ts +51 -0
  175. package/src/components/types/BtnAuth.ts +43 -0
  176. package/src/components/types/CompInfo.ts +81 -0
  177. package/src/components/types/DialogProps.ts +55 -0
  178. package/src/components/types/DyCompField.ts +23 -0
  179. package/src/components/types/DynamicNode.ts +42 -0
  180. package/src/components/types/MenusInfo.ts +45 -0
  181. package/src/components/types/PageFieldInfo.ts +530 -0
  182. package/src/components/types/PageProps.ts +25 -0
  183. package/src/components/types/Params.ts +93 -0
  184. package/src/components/types/RuleType.ts +10 -0
  185. package/src/components/types/SearchProps.ts +42 -0
  186. package/src/components/types/ShortKey.ts +30 -0
  187. package/src/components/types/StarHorseType.ts +18 -0
  188. package/src/components/types/index.ts +15 -0
  189. package/src/config/element.ts +15 -0
  190. package/src/config/styles.ts +4 -0
  191. package/src/index.ts +98 -0
  192. package/src/install.ts +33 -0
  193. package/src/lang/en_US.ts +81 -0
  194. package/src/lang/index.ts +35 -0
  195. package/src/lang/zh_CN.ts +84 -0
  196. package/src/main.ts +57 -0
  197. package/src/plugins/AblesPlugin.ts +618 -0
  198. package/src/plugins/registerCompPlugin.ts +15 -0
  199. package/src/sample/test.vue +9 -0
  200. package/src/store/ButtonPermission.ts +101 -0
  201. package/src/store/ConsumerView.ts +52 -0
  202. package/src/store/ContinusConfig.ts +78 -0
  203. package/src/store/CopyerOperation.ts +74 -0
  204. package/src/store/DesignForm.ts +481 -0
  205. package/src/store/DesignPage.ts +59 -0
  206. package/src/store/DynamicForm.ts +241 -0
  207. package/src/store/GlobalConfig.ts +90 -0
  208. package/src/store/SelfOperation.ts +95 -0
  209. package/src/store/UserInfo.ts +88 -0
  210. package/src/store/index.ts +6 -0
  211. package/src/theme/localStorge.ts +16 -0
  212. package/src/theme/theme.ts +27 -0
  213. package/src/utils/FieldOperationUtils.ts +91 -0
  214. package/src/utils/auth.ts +83 -0
  215. package/src/utils/message.ts +69 -0
  216. package/src/utils/preview.ts +125 -0
  217. package/tsconfig.json +39 -0
  218. package/tsconfig.node.json +10 -0
  219. package/vite-env.d.ts +16 -0
  220. package/vite.config.ts +162 -0
  221. package/yarn.lock +4627 -0
@@ -0,0 +1,351 @@
1
+ import { isJson } from "@/api/star_horse_utils";
2
+ import { DyCompField } from "@/components/types/DyCompField";
3
+ import { SearchParams } from "@/components/types/Params";
4
+ import { error, success } from "@/utils/message";
5
+ import { useDark, useToggle } from "@vueuse/core";
6
+ import { v4 as uuidv4 } from "uuid";
7
+ import { computed, Ref, ref, unref } from "vue";
8
+
9
+ /**
10
+ * UUID
11
+ */
12
+ export function uuid() {
13
+ return "sh" + uuidv4();
14
+ }
15
+
16
+ export async function copyText(text: any) {
17
+ try {
18
+ await navigator.clipboard.writeText(text);
19
+ success("复制成功");
20
+ } catch (err) {
21
+ error("复制失败:" + err);
22
+ }
23
+ }
24
+
25
+ /**
26
+ * 调用Table组件查询数据
27
+ * @param tableComp
28
+ * @param data
29
+ */
30
+ export function searchData(tableComp: any, data: SearchParams[]) {
31
+ tableComp.createSearchParams(data);
32
+ }
33
+
34
+ export const isDark = useDark();
35
+ isDark.value = false;
36
+ export const toggle = useToggle(isDark);
37
+
38
+ const exclusionItems: Array<any> = [
39
+ "number",
40
+ "switch",
41
+ "rate",
42
+ "slider",
43
+ "datetime",
44
+ "time",
45
+ "time-picker",
46
+ "number-range",
47
+ "textarea",
48
+ "htmleditor",
49
+ "json",
50
+ "json-array",
51
+ "html",
52
+ "signature",
53
+ "markdown",
54
+ ];
55
+ /**
56
+ * 批量修改公共属性
57
+ * @param items
58
+ * @param val
59
+ * @param fieldName
60
+ */
61
+ export const batchModifyAction = (
62
+ items: Array<any>,
63
+ val: any,
64
+ fieldName: string,
65
+ ) => {
66
+ for (const index in items) {
67
+ const item = items[index];
68
+ if (item.compType == "container") {
69
+ const sitems = item.preps.elements;
70
+ for (const sindex in sitems) {
71
+ const col = sitems[sindex];
72
+ if (col.columns) {
73
+ col.columns.forEach((temp: any) => {
74
+ batchModifyAction(temp.items, val, fieldName);
75
+ });
76
+ } else {
77
+ batchModifyAction(col.items, val, fieldName);
78
+ }
79
+ }
80
+ } else {
81
+ // 排除数字类型
82
+ if (!exclusionItems.includes(item.itemType) || fieldName == "precision") {
83
+ item.preps[fieldName] = val;
84
+ }
85
+ }
86
+ }
87
+ };
88
+
89
+ const inputType: Array<string> = [
90
+ "input",
91
+ "textarea",
92
+ "password",
93
+ "number",
94
+ "view-markdown",
95
+ "json",
96
+ "json-array",
97
+ ];
98
+ const selectType: Array<string> = [
99
+ "select",
100
+ "tselect",
101
+ "cascader",
102
+ "autocomplete",
103
+ "area",
104
+ "cron",
105
+ "transfer",
106
+ "icon",
107
+ "dialog-input",
108
+ "page-select",
109
+ ];
110
+ const dateType: Array<string> = [
111
+ "year",
112
+ "month",
113
+ "date",
114
+ "datetime",
115
+ "week",
116
+ "datetimerange",
117
+ "daterange",
118
+ ];
119
+ /**
120
+ *下拉组件
121
+ * @returns
122
+ */
123
+ export function selectCompList() {
124
+ return selectType;
125
+ }
126
+ /**
127
+ * 输入组件
128
+ * @returns
129
+ */
130
+ export function inputCompList() {
131
+ return inputType;
132
+ }
133
+ /**
134
+ * 日期组件
135
+ * @returns
136
+ */
137
+ export function dateCompList() {
138
+ return dateType;
139
+ }
140
+
141
+ /**
142
+ * 给组件添加placeholder属性
143
+ * @param item
144
+ * @param itemType
145
+ */
146
+ export function fieldPlaceholder(item: any, itemType: string) {
147
+ if (!item.preps) {
148
+ item.preps = {};
149
+ }
150
+ item.preps["clearable"] = item.preps["clearable"] ?? true;
151
+ item.preps["readonly"] = item?.readonly || item.preps["readonly"] || false;
152
+ if (inputType.includes(itemType)) {
153
+ item.preps["placeholder"] =
154
+ item.preps["placeholder"]?.trim() || "请输入" + item.label;
155
+ } else if (selectType.includes(itemType)) {
156
+ item.preps["filterable"] = true;
157
+ item.preps["collapseTags"] = true;
158
+ item.preps["collapseTagsTooltip"] = true;
159
+ item.preps["placeholder"] =
160
+ item.preps["placeholder"]?.trim() || "请选择" + item.label;
161
+ }
162
+ if (itemType == "datetime") {
163
+ if (item?.type?.includes("range")) {
164
+ item.preps["startPlaceholder"] =
165
+ item.preps["startPlaceholder"]?.trim() || "请选择开始日期";
166
+ item.preps["endPlaceholder"] =
167
+ item.preps["endPlaceholder"]?.trim() || "请选择结束日期";
168
+ } else {
169
+ item.preps["placeholder"] =
170
+ item.preps["placeholder"]?.trim() || "请选择" + item.label;
171
+ }
172
+ } else if (itemType == "number-range") {
173
+ item.preps["minPlaceholder"] =
174
+ item.preps["minPlaceholder"]?.trim() || "请输入最小值";
175
+ item.preps["maxPlaceholder"] =
176
+ item.preps["maxPlaceholder"]?.trim() || "请输入最大值";
177
+ }
178
+ if (item.preps["noPlaceholder"]) {
179
+ delete item.preps["placeholder"];
180
+ delete item.preps["startPlaceholder"];
181
+ delete item.preps["endPlaceholder"];
182
+ delete item.preps["minPlaceholder"];
183
+ delete item.preps["maxPlaceholder"];
184
+ return;
185
+ }
186
+ }
187
+
188
+ /**
189
+ * 校验组件
190
+ * @param item
191
+ */
192
+ export function itemCheck(item: any) {
193
+ //如果不是容器
194
+ if (item?.compType == "formItem") {
195
+ item.label = item.label || item.preps?.label;
196
+ item.fieldName = item.fieldName || item.preps?.fieldName;
197
+ item.type = item.type || item.itemType;
198
+ item.actions = item.actions || item.preps?.actions;
199
+ fieldPlaceholder(item, item.type);
200
+ // 新增:字符串转函数逻辑
201
+
202
+ if (typeof item.actions === "string") {
203
+ try {
204
+ // 将字符串转换为函数(假设函数需要访问当前 item 上下文,可根据实际参数调整)
205
+ // item.actions = new Function('item', `return ${item.actions}`)(item);
206
+ // 或直接转换为函数体(无参数时):
207
+ item.actions = {
208
+ click: new Function(item.actions),
209
+ };
210
+ } catch (e) {
211
+ console.error("actions 字符串转函数失败:", e);
212
+ item.actions = null; // 转换失败时置空避免错误
213
+ }
214
+ } else if (isJson(item.actions)) {
215
+ let tempRecord: Record<string, Function> = {};
216
+ Object.entries(item.actions).forEach(([key, value]) => {
217
+ tempRecord[key] = new Function(value as any);
218
+ });
219
+ item.actions = tempRecord;
220
+ }
221
+ }
222
+ return (
223
+ item?.itemType + (item?.compType === "container" ? "-container" : "-item")
224
+ );
225
+ }
226
+
227
+ /**
228
+ * 动态创建组件
229
+ * @param compInfo 组件信息
230
+ */
231
+ export function createComponent(compInfo: DyCompField) {
232
+ const app = __starHorseHostApp__;
233
+ !app && console.log("app is null,please define __starHorseHostApp__");
234
+ // 检查是否已存在同名组件
235
+ const existingComponent = app.component(compInfo.name);
236
+ if (existingComponent) {
237
+ return compInfo.name; // 存在同名组件,返回名称
238
+ }
239
+ app?.component(compInfo.name, {
240
+ components: compInfo.components || {},
241
+ template: compInfo.template,
242
+ data: () => compInfo.data || {},
243
+ props: compInfo.props || {},
244
+ methods: compInfo.methods,
245
+ onMounted: compInfo.onMounted,
246
+ emits: compInfo.emits,
247
+ computed: compInfo.computed,
248
+ watch: compInfo.watch,
249
+ onActivated: compInfo.onActivated,
250
+ onDeactivated: compInfo.onDeactivated,
251
+ });
252
+ return compInfo.name;
253
+ }
254
+
255
+ /**
256
+ * 删除查询条件中出现的空值和空对象
257
+ * @param condition
258
+ */
259
+ export function removeEmptyCondition(
260
+ condition: SearchParams[],
261
+ ): SearchParams[] {
262
+ const params: SearchParams[] = [];
263
+ if (!condition || condition.length == 0) {
264
+ return params;
265
+ }
266
+ for (const a in condition) {
267
+ const temp = condition[a];
268
+ if (temp && isJson(temp) && Object.keys(temp).length > 0) {
269
+ params.push(temp);
270
+ }
271
+ }
272
+ return params;
273
+ }
274
+
275
+ /**
276
+ * 组件key
277
+ * @param item
278
+ * @param key
279
+ * @param isComp 是否组件
280
+ * @param prefix 前缀
281
+ * @param suffix 后缀
282
+ */
283
+ export function compKey(
284
+ item: any,
285
+ key: number | string,
286
+ isComp?: boolean,
287
+ prefix?: string,
288
+ suffix?: string,
289
+ ) {
290
+ let name = "";
291
+ if (item) {
292
+ name = item.id || item._uuid || item.fieldName || item.tabName;
293
+ }
294
+ return (
295
+ (prefix ?? "") +
296
+ name +
297
+ "_" +
298
+ (isComp ? "comp_" : "temp_") +
299
+ key +
300
+ (suffix ?? "")
301
+ );
302
+ }
303
+
304
+ const zIndex = ref(0);
305
+ export const DEFAULT_INITIAL_Z_INDEX = 2000;
306
+ export const useZIndex = (zIndexOverrides?: Ref<number>) => {
307
+ const zIndexInjection = zIndexOverrides;
308
+ const initialZIndex = computed(() => {
309
+ const zIndexFromInjection = unref(zIndexInjection);
310
+ return zIndexFromInjection ?? DEFAULT_INITIAL_Z_INDEX;
311
+ });
312
+ const currentZIndex = computed(() => initialZIndex.value + zIndex.value);
313
+ const nextZIndex = () => {
314
+ zIndex.value += 1;
315
+ return currentZIndex.value;
316
+ };
317
+
318
+ return {
319
+ initialZIndex,
320
+ currentZIndex,
321
+ nextZIndex,
322
+ };
323
+ };
324
+
325
+ // 添加动态事件处理方法
326
+ export function getDynamicEvents(props: any, recall: Function) {
327
+ const events: Record<string, any> = {};
328
+ const actions = props.field.actions;
329
+ const actionNames: string[] = Object.keys(actions || {});
330
+ // 统一处理带修饰符的事件
331
+ const handleEvent = (eventName: string, e: any) => {
332
+ if (eventName.includes(".")) {
333
+ const modifier = eventName.split(".")[1];
334
+ if (modifier == e.key.toLowerCase()) {
335
+ console.log("成功触发事件:");
336
+ recall(modifier); // 传递完整事件名称
337
+ }
338
+ } else {
339
+ recall(eventName); // 传递完整事件名称
340
+ }
341
+ };
342
+ actionNames?.forEach((actionName: string) => {
343
+ if (actionName.includes(".")) {
344
+ const baseEvent = actionName.split(".")[0];
345
+ events[baseEvent] = (e: Event) => handleEvent(actionName, e);
346
+ } else {
347
+ events[actionName] = (e: Event) => handleEvent(actionName, e);
348
+ }
349
+ });
350
+ return events;
351
+ }
@@ -0,0 +1,147 @@
1
+ import { useSelfOperationStore } from "@/store/SelfOperation";
2
+ import piniaInstance from "@/store";
3
+ import {
4
+ download,
5
+ getRequest,
6
+ postRequest,
7
+ uploadRequest,
8
+ } from "@/api/star_horse_apis";
9
+ import { getUserInfo } from "@/utils/auth";
10
+ import { Ref } from "vue";
11
+ import { createCondition } from "@/api/star_horse_utils";
12
+ import { success, warning } from "@/utils/message";
13
+ import { UserFuncInfo } from "@/components/types/PageFieldInfo";
14
+
15
+ /**
16
+ * 动态表单用户自定义驱动
17
+ */
18
+ const userOperation = useSelfOperationStore(piniaInstance);
19
+ /**
20
+ * 用户自定义事件对接接口
21
+ * @param code 需要执行的代码
22
+ * @param context 组件上下文信息
23
+ * @param formData
24
+ * @param formInfo
25
+ */
26
+ export const userFunction = (code: string, context: any, formData: any) => {
27
+ if (!code) {
28
+ return;
29
+ }
30
+ //表单元素
31
+ const formFields: any = userOperation.fieldItemList;
32
+ //表单数据
33
+ // let formData: any = userOperation.formData;
34
+ //表单实例
35
+ const formInstance: any = userOperation.formInstance;
36
+ /**
37
+ * currentField 当前组件信息
38
+ * formData 表单数据
39
+ * formFields 表单所有属性
40
+ * formInstance 表单实例
41
+ * userInfo 当前登录信息
42
+ * postRequest Post 请求接口
43
+ * getRequest Get 请求接口
44
+ * download 下载数据接口
45
+ * upload 上传数据接口
46
+ */
47
+ const fun = new Function(
48
+ "currentField",
49
+ "formData",
50
+ "formFields",
51
+ "formInstance",
52
+ "userInfo",
53
+ "postRequest",
54
+ "getRequest",
55
+ "download",
56
+ "upload",
57
+ code,
58
+ );
59
+ fun.call(
60
+ this,
61
+ context.formInfo,
62
+ formData,
63
+ formFields,
64
+ formInstance,
65
+ getUserInfo(),
66
+ postRequest,
67
+ getRequest,
68
+ download,
69
+ uploadRequest,
70
+ );
71
+ };
72
+
73
+ /**
74
+ * 用户自定义按钮
75
+ * @param tableRef 表格实例
76
+ * @param primaryKey 主键名称
77
+ * @param datas 按钮信息
78
+ */
79
+ export function userAction(
80
+ tableRef: Ref,
81
+ primaryKey: string,
82
+ datas: Array<any>,
83
+ ): Array<UserFuncInfo> {
84
+ const btnList: Array<UserFuncInfo> = [];
85
+ if (datas && datas.length > 0) {
86
+ datas.forEach((item: any) => {
87
+ const content = item["funcName"];
88
+ if (item["eventType"] == "interface") {
89
+ if (item["authority"] == "download") {
90
+ item["funcName"] = (row: any) => {
91
+ const fieldList: any = [];
92
+ fieldList.push(createCondition(primaryKey, row[primaryKey]));
93
+ download(content, {
94
+ fieldList: fieldList,
95
+ }).catch((e) => {
96
+ warning(e.message);
97
+ });
98
+ };
99
+ } else {
100
+ item["funcName"] = (row: any) => {
101
+ const fieldList: any = [];
102
+ fieldList.push(createCondition(primaryKey, row[primaryKey]));
103
+ postRequest(content, {
104
+ fieldList: fieldList,
105
+ }).then((res) => {
106
+ if (res.data.code) {
107
+ warning(res.data.cnMessage);
108
+ return;
109
+ }
110
+ success("操作成功");
111
+ tableRef.value?.loadByPage();
112
+ });
113
+ };
114
+ }
115
+ } else if (item["eventType"] == "dialog") {
116
+ //弹出对话框
117
+ warning("暂未实现");
118
+ } else if (item["eventType"] == "page") {
119
+ //打开页面
120
+ let router = window.__hostRouter__;
121
+ item["funcName"] = (row: any) => {
122
+ router.push({
123
+ path: content,
124
+ query: {
125
+ param: JSON.stringify(row),
126
+ },
127
+ });
128
+ };
129
+ }
130
+ btnList.push(item);
131
+ });
132
+ }
133
+ return btnList;
134
+ }
135
+
136
+ /**
137
+ * 判断是否是Promise
138
+ * @param obj
139
+ */
140
+ export function isPromise<T = any>(obj: any): obj is Promise<T> {
141
+ return (
142
+ !!obj &&
143
+ (typeof obj === "object" || typeof obj === "function") &&
144
+ typeof obj.then === "function" &&
145
+ typeof obj.catch === "function"
146
+ );
147
+ }
@@ -0,0 +1,165 @@
1
+ import { SelectOption } from "@/components/types/SearchProps";
2
+
3
+ const validTypes: any = [
4
+ {
5
+ message: "邮箱格式不正确",
6
+ value: "email",
7
+ pattern:
8
+ /^[A-Za-z\d]+([-_.][A-Za-z\d]+)*@([A-Za-z\d]+[-.])+[A-Za-z\d]{2,4}$/,
9
+ },
10
+ { message: "手机号格式不正确", value: "phone", pattern: /^1[3456789]\d{9}$/ },
11
+ {
12
+ message: "座机号码格式不正确",
13
+ value: "landlinePhone",
14
+ pattern: /^(0\d{2,3})-?\d{7,8}$/,
15
+ },
16
+ {
17
+ message: "身份证非法",
18
+ value: "idCard",
19
+ pattern:
20
+ /^[1-9]\d{5}(18|19|20)\d{2}((0[1-9])|(1[0-2]))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/,
21
+ },
22
+ { message: "只能是数字", value: "digit", pattern: /^[0-9]*$/ },
23
+ {
24
+ message: "IP格式不正确",
25
+ value: "ip",
26
+ pattern:
27
+ /^((2(5[0-5]|[0-4]\d))|[0-1]?\d{1,2})(\.((2(5[0-5]|[0-4]\d))|[0-1]?\d{1,2})){3}$/,
28
+ },
29
+ {
30
+ message: "URL格式不正确",
31
+ value: "url",
32
+ pattern:
33
+ /^((https?|ftp|file|git|svn):\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?$/,
34
+ },
35
+ {
36
+ message: "域名格式不正确",
37
+ value: "domain",
38
+ pattern:
39
+ /^[a-zA-Z0-9][-a-zA-Z0-9]{0,62}(\.[a-zA-Z0-9][-a-zA-Z0-9]{0,62})+\.?$/,
40
+ },
41
+ { message: "只能是字母", value: "letter", pattern: /^[a-zA-Z]*$/ },
42
+ {
43
+ message: "只能是字母或数字",
44
+ value: "letterDigit",
45
+ pattern: /^[a-zA-Z0-9]*$/,
46
+ },
47
+ {
48
+ message: (min: number, max: number) => `长度范围须在 ${min} 到 ${max} 之间`,
49
+ value: "dataLength",
50
+ pattern: (min: number, max: number) => new RegExp(`^.{${min},${max}}$`),
51
+ },
52
+ {
53
+ message: "只能是字母、数字和下划线",
54
+ value: "letterDigitUnderline",
55
+ pattern: /^[a-zA-Z0-9_]*$/,
56
+ },
57
+ {
58
+ message: "只能是字母、数字、下划线和中横线",
59
+ value: "letterDigitUnderlineHyphen",
60
+ pattern: /^[a-zA-Z0-9_\-]*$/,
61
+ },
62
+ {
63
+ message: "密码需包含大写字母、小写字母、数字和特殊字符,长度 8 - 16",
64
+ value: "strongPassword",
65
+ pattern:
66
+ /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,16}$/,
67
+ },
68
+ {
69
+ message: "日期格式应为 YYYY-MM-DD",
70
+ value: "dateFormat",
71
+ pattern: /^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])$/,
72
+ },
73
+ {
74
+ message: "邮政编码格式不正确",
75
+ value: "postalCode",
76
+ pattern: /^[1-9]\d{5}$/,
77
+ },
78
+ {
79
+ message: "中文姓名应为 2 - 6 个汉字",
80
+ value: "chineseName",
81
+ pattern: /^[\u4e00-\u9fa5]{2,6}$/,
82
+ },
83
+ {
84
+ message: "信用卡号格式不正确",
85
+ value: "creditCard",
86
+ pattern: /^4\d{15}$/,
87
+ },
88
+ {
89
+ message:
90
+ "微信号格式不正确,需以字母开头,包含字母、数字、下划线和减号,长度 6 - 20 个字符",
91
+ value: "wechatId",
92
+ pattern: /^[a-zA-Z][a-zA-Z0-9_-]{5,19}$/,
93
+ },
94
+ {
95
+ message: "车牌号格式不正确",
96
+ value: "licensePlate",
97
+ pattern:
98
+ /^[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼]{1}[A-HJ-NP-Z]{1}[A-HJ-NP-Z0-9]{5}$/,
99
+ },
100
+ {
101
+ message: "港澳通行证号码格式不正确",
102
+ value: "hkMacaoPass",
103
+ pattern: /^[CW]\d{8}$/,
104
+ },
105
+ {
106
+ message: "台胞证号码格式不正确",
107
+ value: "taiwanPass",
108
+ pattern: /^([A-Z]\d{9}|\d{8})$/,
109
+ },
110
+ {
111
+ message: "16 进制颜色代码格式不正确",
112
+ value: "hexColor",
113
+ pattern: /^#([A-Fa-f0-9]{3}|[A-Fa-f0-9]{6})$/,
114
+ },
115
+ {
116
+ message: "国际电话号码格式不正确",
117
+ value: "internationalPhone",
118
+ pattern: /^\+(?:[0-9] ?){6,14}[0-9]$/,
119
+ },
120
+ ];
121
+
122
+ export const validRulesList: Array<SelectOption> = [
123
+ { name: "邮箱", value: "email" },
124
+ { name: "手机号", value: "phone" },
125
+ { name: "座机号码", value: "landlinePhone" },
126
+ { name: "身份证", value: "idCard" },
127
+ { name: "数字", value: "digit" },
128
+ { name: "字母", value: "letter" },
129
+ { name: "IP", value: "ip" },
130
+ { name: "URL", value: "url" },
131
+ { name: "域名", value: "domain" },
132
+ { name: "字母或数字", value: "letterDigit" },
133
+ { name: "字母、数字和下划线", value: "letterDigitUnderline" },
134
+ { name: "字母、数字、下划线和中横线", value: "letterDigitUnderlineHyphen" },
135
+ { name: "数据长度6到12", value: "dataLength" },
136
+ { name: "强密码", value: "strongPassword" },
137
+ { name: "日期格式(YYYY-MM-DD)", value: "dateFormat" },
138
+ { name: "邮政编码", value: "postalCode" },
139
+ { name: "中文姓名", value: "chineseName" },
140
+ { name: "信用卡号", value: "creditCard" },
141
+ { name: "微信号", value: "wechatId" },
142
+ { name: "车牌号", value: "licensePlate" },
143
+ { name: "港澳通行证号码", value: "hkMacaoPass" },
144
+ { name: "台胞证号码", value: "taiwanPass" },
145
+ { name: "国际电话号码", value: "internationalPhone" },
146
+ { name: "16进制颜色代码", value: "hexColor" },
147
+ { name: "自定义", value: "custom" },
148
+ ];
149
+
150
+ /**
151
+ * 获取验证类型
152
+ * @param type
153
+ */
154
+ export function getValidType(type: any, options?: any) {
155
+ const typeConfig = validTypes.find((item: any) => item.value === type);
156
+ if (!typeConfig) return {};
157
+ // 处理带参数的验证类型
158
+ if (type === "dataLength") {
159
+ return {
160
+ message: typeConfig.message(options?.min ?? 2, options?.max ?? 6),
161
+ pattern: typeConfig.pattern(options?.min ?? 2, options?.max ?? 6),
162
+ };
163
+ }
164
+ return typeConfig;
165
+ }