star-horse-lowcode 2.7.63 → 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 +1 -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 +19 -19
  20. package/dist/types/index.d.ts +7 -7
  21. package/eslint.config.js +37 -0
  22. package/index.html +14 -0
  23. package/package-lock.json +8276 -0
  24. package/package.json +4 -4
  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,118 @@
1
+ <template>
2
+ <starhorse-form-item
3
+ :showFormItem="showFormItem"
4
+ :isDesign="isDesign"
5
+ :disabled="disabled"
6
+ :bareFlag="bareFlag"
7
+ :formItem="field"
8
+ :parentField="parentField"
9
+ >
10
+ <el-autocomplete
11
+ :fid="field.fieldName"
12
+ :disabled="checkIsDisabled(props)"
13
+ :fetch-suggestions="querySearch"
14
+ v-bind="field.preps"
15
+ v-on="getDynamicEvents(props, itemAction)"
16
+ v-model="formData[field.fieldName]"
17
+ />
18
+ </starhorse-form-item>
19
+ </template>
20
+ <script setup lang="ts">
21
+ import { onMounted, PropType, watch } from "vue";
22
+ import {
23
+ compDynamicData,
24
+ createFilter,
25
+ dynamicUrlOperation,
26
+ } from "@/api/star_horse_utils";
27
+ import { SearchParams } from "@/components/types/Params";
28
+ import {
29
+ allAction,
30
+ checkIsDisabled,
31
+ initCompCallEvent,
32
+ } from "@/components/formcomp/utils/ItemRelationEventUtils";
33
+ import { getDynamicEvents } from "@/api/system";
34
+
35
+ const props = defineProps({
36
+ isDesign: {
37
+ type: Boolean,
38
+ default: false,
39
+ },
40
+ disabled: {
41
+ type: Boolean,
42
+ default: false,
43
+ },
44
+ showFormItem: {
45
+ type: Boolean,
46
+ default: false,
47
+ },
48
+ bareFlag: {
49
+ type: Boolean,
50
+ default: false,
51
+ },
52
+ isSearch: {
53
+ type: Boolean,
54
+ default: false,
55
+ },
56
+ field: {
57
+ type: Object as PropType<any>,
58
+ required: true,
59
+ },
60
+ parentField: {
61
+ type: Object as PropType<any>,
62
+ },
63
+ formInfo: {
64
+ type: Object as PropType<any>,
65
+ },
66
+ });
67
+ const emits = defineEmits(["selfFunc", "selectItem"]);
68
+ const formData = defineModel("formData");
69
+
70
+ const itemAction = (prep: any) => {
71
+ allAction(props, emits, formData, prep);
72
+ };
73
+ /**
74
+ * 动态获取数据
75
+ */
76
+ const initData = async () => {
77
+ const data = await compDynamicData(props.field);
78
+ if (data?.length) {
79
+ props.field.preps["values"] = data;
80
+ }
81
+ };
82
+ onMounted(() => {
83
+ if (!props.field.preps) {
84
+ props.field.preps = {};
85
+ }
86
+ initData();
87
+ initCompCallEvent(props, emits, formData);
88
+ });
89
+ const querySearch = async (queryString: string, cb: (arg: any) => void) => {
90
+ let temp = props.field.preps;
91
+ let dataSource = temp["dataSource"];
92
+ if (dataSource == "url") {
93
+ let searchParams: SearchParams[] = [];
94
+ searchParams.push({
95
+ propertyName: temp["selectLabel"],
96
+ value: queryString,
97
+ operation: "lk",
98
+ });
99
+ temp["values"] = await dynamicUrlOperation(temp, searchParams);
100
+ cb(temp["values"]);
101
+ } else {
102
+ const results = queryString
103
+ ? temp["values"].filter(createFilter(queryString))
104
+ : temp["values"];
105
+ cb(results);
106
+ }
107
+ };
108
+ watch(
109
+ () => formData.value[props.field.fieldName + "OptionList"],
110
+ (val) => {
111
+ if (val?.length > 0) {
112
+ props.field.preps["data"] = val;
113
+ }
114
+ },
115
+ { immediate: true },
116
+ );
117
+ </script>
118
+ <style scoped></style>
@@ -0,0 +1,87 @@
1
+ <script setup lang="ts">
2
+ import Vue3Barcode from "vue3-barcode";
3
+ import { computed, nextTick, onMounted, PropType, ref, watch } from "vue";
4
+ import { allAction } from "../utils/ItemRelationEventUtils";
5
+
6
+ const props = defineProps({
7
+ isDesign: {
8
+ type: Boolean,
9
+ default: false,
10
+ },
11
+ disabled: {
12
+ type: Boolean,
13
+ default: false,
14
+ },
15
+ showFormItem: {
16
+ type: Boolean,
17
+ default: false,
18
+ },
19
+ bareFlag: {
20
+ type: Boolean,
21
+ default: false,
22
+ },
23
+ isSearch: {
24
+ type: Boolean,
25
+ default: false,
26
+ },
27
+ field: {
28
+ type: Object as PropType<any>,
29
+ required: true,
30
+ },
31
+ parentField: {
32
+ type: Object as PropType<any>,
33
+ },
34
+ formInfo: {
35
+ type: Object as PropType<any>,
36
+ },
37
+ });
38
+ const barcodeRef = ref();
39
+ const emits = defineEmits(["selfFunc", "selectItem"]);
40
+ const formData = defineModel("formData");
41
+ const dataValue = computed(() => formData.value[props.field.preps?.name]);
42
+ const createCode = () => {
43
+ barcodeRef.value = {
44
+ format: props.field.preps?.format ?? "CODE39", //选择要使用的条形码类型
45
+ width: props.field.preps?.width ?? 1, //设置条之间的宽度
46
+ height: props.field.preps?.height ?? 40, //高度
47
+ displayValue: props.field.preps?.displayValue ?? true, //是否在条形码下方显示文字
48
+ // text: dataValue.value,//覆盖显示的文本
49
+ fontOptions: props.field.preps?.fontOptions, //使文字加粗体或变斜体
50
+ font: props.field.preps?.font, //设置文本的字体
51
+ textAlign: props.field.preps?.textAlign ?? "center", //设置文本的水平对齐方式
52
+ textPosition: props.field.preps?.textPosition ?? "bottom", //设置文本的垂直位置
53
+ textMargin: props.field.preps?.textMargin ?? 5, //设置条形码和文本之间的间距
54
+ fontSize: props.field.preps?.fontSize ?? 15, //设置文本的大小
55
+ background: props.field.preps?.fontSize ?? "#fff", //设置条形码的背景
56
+ lineColor: props.field.preps?.fontSize ?? "#000", //设置条和文本的颜色。
57
+ margin: props.field.preps?.margin ?? 15, //设置条形码周围的空白边距
58
+ };
59
+ };
60
+ onMounted(() => {
61
+ nextTick(() => {
62
+ createCode();
63
+ allAction(props, emits, formData, "change", true);
64
+ });
65
+ });
66
+ watch(
67
+ () => [dataValue.value, props.field.preps],
68
+ () => {
69
+ createCode();
70
+ allAction(props, emits, formData, "change", false);
71
+ },
72
+ { immediate: false, deep: true },
73
+ );
74
+ </script>
75
+ <template>
76
+ <starhorse-form-item
77
+ :showFormItem="showFormItem"
78
+ :isDesign="isDesign"
79
+ :disabled="disabled"
80
+ :bareFlag="bareFlag"
81
+ :formItem="field"
82
+ :parentField="parentField"
83
+ >
84
+ <Vue3Barcode :value="dataValue" :options="barcodeRef" />
85
+ </starhorse-form-item>
86
+ </template>
87
+ <style scoped></style>
@@ -0,0 +1,207 @@
1
+ <template>
2
+ <!-- 对话框部分(与原 json-item.vue 完全一致) -->
3
+ <star-horse-dialog
4
+ :title="field.label + 'JSON编辑'"
5
+ :self-func="true"
6
+ :dialog-visible="dialogInputVisible"
7
+ @merge="selectItem"
8
+ @resetForm="resetForm"
9
+ @closeAction="closeAction"
10
+ >
11
+ <star-horse-json-editor
12
+ v-if="field.preps?.devType"
13
+ v-model:modelValue="jsonData"
14
+ style="height: 100vh"
15
+ />
16
+ <star-horse-form v-else :field-list="jsonTableField" ref="jsonFormRef" />
17
+ </star-horse-dialog>
18
+
19
+ <!-- 输入框+按钮部分(与原 json-item.vue 完全一致) -->
20
+ <starhorse-form-item
21
+ :isDesign="isDesign"
22
+ :disabled="disabled"
23
+ :showFormItem="showFormItem"
24
+ :bareFlag="bareFlag"
25
+ :formItem="field"
26
+ :parentField="parentField"
27
+ >
28
+ <div class="json-comp">
29
+ <div class="json-box">
30
+ <el-input
31
+ :fid="field.fieldName"
32
+ :disabled="checkIsDisabled(props)"
33
+ :rows="field.preps?.rows || 3"
34
+ type="textarea"
35
+ resize="vertical"
36
+ readonly
37
+ v-on="getDynamicEvents(props, itemAction)"
38
+ v-model="formData[field.fieldName]"
39
+ />
40
+ </div>
41
+ <div class="json-btn">
42
+ <star-horse-icon
43
+ class="w-full"
44
+ @click="editJsonData(false)"
45
+ icon-class="edit"
46
+ style="cursor: pointer"
47
+ title="设计模式编辑"
48
+ />
49
+ <div class="h-[10px]" />
50
+ <star-horse-icon
51
+ @click="editJsonData(true)"
52
+ icon-class="code"
53
+ style="cursor: pointer"
54
+ title="开发模式编辑"
55
+ />
56
+ </div>
57
+ </div>
58
+ </starhorse-form-item>
59
+ </template>
60
+
61
+ <script setup lang="ts">
62
+ import { nextTick, PropType, reactive, shallowRef } from "vue";
63
+ import { PageFieldInfo } from "@/components/types/PageFieldInfo";
64
+ import {
65
+ allAction,
66
+ checkIsDisabled,
67
+ } from "@/components/formcomp/utils/ItemRelationEventUtils";
68
+ import { isJson } from "@/api/star_horse_utils";
69
+ import { getDynamicEvents } from "@/api/system";
70
+ import JSON5 from "json5";
71
+
72
+ // 公共 props(两个组件原有的 props 完全一致)
73
+ const props = defineProps({
74
+ isDesign: { type: Boolean, default: false },
75
+ showFormItem: { type: Boolean, default: false },
76
+ disabled: { type: Boolean, default: false },
77
+ bareFlag: { type: Boolean, default: false },
78
+ isSearch: { type: Boolean, default: false },
79
+ field: { type: Object as PropType<any>, required: true },
80
+ parentField: { type: Object as PropType<any> },
81
+ formInfo: { type: Object as PropType<any> },
82
+ // 新增:区分 JSON 对象/数组的关键参数
83
+ dataType: {
84
+ type: String,
85
+ default: "object",
86
+ validator: (v) => ["object", "array"].includes(v),
87
+ },
88
+ });
89
+
90
+ const emits = defineEmits(["selfFunc", "selectItem"]);
91
+ const formData = defineModel("formData");
92
+ const dialogInputVisible = shallowRef(false);
93
+ const jsonFormRef = shallowRef();
94
+ const jsonData = shallowRef<any>({}); // 统一存储解析后的 JSON 数据(对象或数组)
95
+
96
+ // 公共的表格字段配置(两个组件原有的 jsonTableField 完全一致)
97
+ const jsonTableField = reactive<PageFieldInfo>({
98
+ batchFieldList: [
99
+ {
100
+ batchName: "jsonDatas",
101
+ fieldList: [
102
+ {
103
+ label: "Name/名称",
104
+ fieldName: "name",
105
+ required: true,
106
+ formVisible: true,
107
+ },
108
+ {
109
+ label: "Value/值",
110
+ fieldName: "value",
111
+ required: true,
112
+ formVisible: true,
113
+ },
114
+ ],
115
+ },
116
+ ],
117
+ });
118
+
119
+ // 公共事件方法
120
+ const itemAction = (prep: any) => allAction(props, emits, formData, prep);
121
+
122
+ // 关键差异逻辑:根据 dataType 动态处理
123
+ const editJsonData = async (devType: boolean) => {
124
+ props.field.preps["devType"] = devType;
125
+ const jsonStr = formData.value[props.field.fieldName];
126
+ const temp: any = {};
127
+
128
+ if (jsonStr && isJson(jsonStr)) {
129
+ // 根据 dataType 解析为对象或数组
130
+ const parsedData = JSON5.parse(jsonStr);
131
+ jsonData.value = parsedData;
132
+
133
+ // 对象需要转换为键值对数组,数组直接使用
134
+ temp["jsonDatas"] =
135
+ props.dataType === "object"
136
+ ? Object.entries(parsedData).map(([name, value]) => ({ name, value }))
137
+ : parsedData;
138
+ } else {
139
+ temp["jsonDatas"] = props.dataType === "object" ? [{}] : [];
140
+ }
141
+
142
+ dialogInputVisible.value = true;
143
+ await nextTick();
144
+ if (!devType) jsonFormRef.value.setFormData(temp);
145
+ };
146
+
147
+ const selectItem = async () => {
148
+ if (props.field.preps["devType"]) {
149
+ // 开发模式直接序列化当前 jsonData
150
+ formData.value[props.field.fieldName] = JSON5.stringify(
151
+ jsonData.value,
152
+ null,
153
+ 4,
154
+ );
155
+ } else {
156
+ // 设计模式根据 dataType 转换数据
157
+ let flag = false;
158
+ await jsonFormRef.value.$refs.starHorseFormRef.validate(
159
+ (res) => (flag = res),
160
+ );
161
+ if (!flag) return;
162
+
163
+ const temp = jsonFormRef.value.getFormData().value;
164
+ const dataList = temp["jsonDatas"];
165
+
166
+ // 数组直接使用,对象需要转换为键值对对象
167
+ formData.value[props.field.fieldName] =
168
+ props.dataType === "object"
169
+ ? JSON5.stringify(
170
+ Object.fromEntries(
171
+ dataList.map(({ name, value }) => [name, value]),
172
+ ),
173
+ null,
174
+ 4,
175
+ )
176
+ : JSON5.stringify(dataList, null, 4);
177
+ }
178
+ closeAction();
179
+ };
180
+
181
+ // 公共方法(与原组件一致)
182
+ const resetForm = () => jsonFormRef.value.setFormData({ jsonDatas: [{}] });
183
+ const closeAction = () => (dialogInputVisible.value = false);
184
+ </script>
185
+
186
+ <style lang="scss" scoped>
187
+ /* 与原 json-item.vue 样式完全一致 */
188
+ .json-comp {
189
+ width: 100%;
190
+ display: flex;
191
+ align-items: center;
192
+
193
+ .json-box {
194
+ flex: 1;
195
+ margin-right: 5px;
196
+ }
197
+
198
+ .json-btn {
199
+ cursor: pointer;
200
+ flex-direction: column;
201
+ width: 50px;
202
+ display: flex;
203
+ align-items: center;
204
+ justify-content: center;
205
+ }
206
+ }
207
+ </style>
@@ -0,0 +1,228 @@
1
+ <template>
2
+ <star-horse-dialog
3
+ :title="field.preps?.dialogTitle || '配置按钮事件'"
4
+ :selfFunc="true"
5
+ @merge="operResultAction"
6
+ :dialogVisible="btnDialogVisible"
7
+ :boxWidth="field.preps?.boxWidth || '50%'"
8
+ :isShowReset="field.preps?.isShowReset ?? false"
9
+ @closeAction="close"
10
+ :btnText="field.preps?.dialogBtn ?? '确定'"
11
+ >
12
+ <star-horse-form
13
+ ref="btnFormRef"
14
+ :fieldList="{
15
+ fieldList: field.preps?.fieldList,
16
+ }"
17
+ v-if="field.preps?.viewType == 'form'"
18
+ />
19
+ <component
20
+ :is="field.preps?.componentName"
21
+ ref="btnCompRef"
22
+ v-else-if="field.preps?.viewType == 'usercomp'"
23
+ :params="field.preps?.params"
24
+ />
25
+ <star-horse-editor
26
+ v-else-if="field.preps?.viewType == 'code'"
27
+ ref="btnCompRef"
28
+ />
29
+ </star-horse-dialog>
30
+ <starhorse-form-item
31
+ :showFormItem="showFormItem"
32
+ :isDesign="isDesign"
33
+ :disabled="disabled"
34
+ :bareFlag="bareFlag"
35
+ :formItem="field"
36
+ :parentField="parentField"
37
+ >
38
+ <el-button
39
+ :disabled="checkIsDisabled(props)"
40
+ v-bind="field.preps"
41
+ @click="dynamicFunc(field.preps?.code)"
42
+ >
43
+ <star-horse-icon
44
+ v-if="field.preps?.icon"
45
+ :icon-class="field.preps.icon"
46
+ style="vertical-align: middle; color: var(--star-horse-style)"
47
+ />
48
+ {{ field?.label }}
49
+ </el-button>
50
+ </starhorse-form-item>
51
+ </template>
52
+ <script setup lang="ts" name="buttonItem">
53
+ import { onMounted, PropType, shallowRef, unref } from "vue";
54
+ import {
55
+ buttonAction,
56
+ checkIsDisabled,
57
+ initCompCallEvent,
58
+ } from "@/components/formcomp/utils/ItemRelationEventUtils";
59
+ import { httpRequest } from "@/api/star_horse_apis";
60
+ import { operationConfirm, warning } from "@/utils/message";
61
+ import { BtnAction, DynamicParamField } from "@/components/types/BtnAction";
62
+ import { SearchParams } from "@/components/types/Params";
63
+ import { createCondition } from "@/api/star_horse_utils";
64
+
65
+ const props = defineProps({
66
+ isDesign: {
67
+ type: Boolean,
68
+ default: false,
69
+ },
70
+ disabled: {
71
+ type: Boolean,
72
+ default: false,
73
+ },
74
+ showFormItem: {
75
+ type: Boolean,
76
+ default: false,
77
+ },
78
+ bareFlag: {
79
+ type: Boolean,
80
+ default: false,
81
+ },
82
+ isSearch: {
83
+ type: Boolean,
84
+ default: false,
85
+ },
86
+ field: {
87
+ type: Object as PropType<any>,
88
+ required: true,
89
+ },
90
+ parentField: {
91
+ type: Object as PropType<any>,
92
+ },
93
+ formInfo: {
94
+ type: Object as PropType<any>,
95
+ },
96
+ });
97
+ const emits = defineEmits(["selfFunc", "selectItem"]);
98
+ const formData = defineModel("formData");
99
+
100
+ let btnDialogVisible = shallowRef<boolean>(false);
101
+ const btnCompRef = shallowRef();
102
+
103
+ const operResultAction = async () => {
104
+ let action: BtnAction = props.field.preps;
105
+ let formData: any = {};
106
+ if (action?.viewType == "comp") {
107
+ formData = await btnCompRef.value?.getFormData("请先填写表单数据");
108
+ if (!formData) {
109
+ return;
110
+ }
111
+ } else {
112
+ formData = await btnCompRef.value?.getFormData().value;
113
+ }
114
+ formData.value[props.field.fieldName] = JSON.stringify(unref(formData));
115
+ close();
116
+ };
117
+ //打开对话框
118
+ const openDialog = async () => {
119
+ /**
120
+ * 1、调用公共的方法
121
+ * --2、调用公共的组件
122
+ * --3、调用指定接口
123
+ * --4、执行程序块
124
+ * --5、传入表单参数,生成表单
125
+ *
126
+ */
127
+ let action: BtnAction = props.field.preps;
128
+ //执行代码块
129
+ if (action?.needConfirm) {
130
+ let result = operationConfirm(action.confirmMsg ?? "确定要执行此操作吗");
131
+ if (!result) {
132
+ return;
133
+ }
134
+ }
135
+ if (action?.viewType == "inter") {
136
+ //如果参数是动态参数,则在当前form中寻找对应名称的值
137
+ let urlParam: any = {};
138
+ if (action.isDynamicParam == "Y") {
139
+ let dynamicParams: SearchParams[] | DynamicParamField[] | any =
140
+ action.params;
141
+ let params: SearchParams[] = [];
142
+ dynamicParams?.forEach((dynamicParam: any) => {
143
+ let value =
144
+ formData.value[dynamicParam.paramName] ?? dynamicParam.defaultValue;
145
+ params.push(
146
+ createCondition(
147
+ dynamicParam.paramName,
148
+ value,
149
+ dynamicParam.matchType,
150
+ ),
151
+ );
152
+ });
153
+ urlParam["fieldList"] = params;
154
+ } else {
155
+ urlParam = action.params;
156
+ }
157
+ if (!action.url) {
158
+ warning("请提供需要调用的接口");
159
+ return;
160
+ }
161
+ httpRequest(action.url!, action.method ?? "POST", urlParam).then(
162
+ (res: any) => {
163
+ //仅仅执行,则直接调用接口
164
+ console.log(res);
165
+ let reData = res.data;
166
+ if (reData.code) {
167
+ warning(reData.cnMessage);
168
+ return;
169
+ }
170
+ let datas = reData?.data;
171
+ if (action?.afterAction) {
172
+ if (!datas) {
173
+ warning("返回数据为空,无法赋值");
174
+ return;
175
+ }
176
+ if (Array.isArray(datas)) {
177
+ warning("返回数据为数组,无法赋值");
178
+ return;
179
+ }
180
+ //执行后搜集返回结果
181
+ if (action?.afterAction == "assignCurrentName") {
182
+ formData.value[props.field.fieldName] = datas;
183
+ } else if (action?.afterAction == "assignForm") {
184
+ let entries = Object.entries(datas);
185
+ entries.forEach(([key, value]) => {
186
+ formData.value[key] = value;
187
+ });
188
+ }
189
+ }
190
+ },
191
+ );
192
+ } else if (action?.viewType == "code") {
193
+ if (!action.code) {
194
+ warning("请提供需要执行的代码");
195
+ return;
196
+ }
197
+ buttonAction(props, emits, formData, action.code);
198
+ } else if (action?.viewType == "method") {
199
+ if (!action.actions) {
200
+ warning("请提供需要执行的函数");
201
+ return;
202
+ }
203
+ action.actions(formData);
204
+ } else {
205
+ btnDialogVisible.value = true;
206
+ }
207
+ };
208
+ const close = () => {
209
+ btnDialogVisible.value = false;
210
+ };
211
+ const dynamicFunc = (code: any) => {
212
+ // openDialog();
213
+ //如果是配置的标准操作
214
+ if (props.field.preps?.viewType) {
215
+ openDialog();
216
+ } else {
217
+ buttonAction(props, emits, formData, code);
218
+ }
219
+ };
220
+ onMounted(() => {
221
+ initCompCallEvent(props, emits, formData);
222
+ });
223
+ </script>
224
+ <style lang="scss" scoped>
225
+ :deep(.el-icon) {
226
+ display: none;
227
+ }
228
+ </style>