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,260 @@
1
+ <script lang="ts" setup>
2
+ import {
3
+ computed,
4
+ nextTick,
5
+ onBeforeUnmount,
6
+ onMounted,
7
+ PropType,
8
+ ref,
9
+ } from "vue";
10
+ import { compKey, useZIndex } from "@/api/system";
11
+ import StarHorseIcon from "@/components/comp/StarHorseIcon.vue";
12
+
13
+ defineOptions({
14
+ name: "PageEditorContentMenu",
15
+ });
16
+
17
+ const props = defineProps({
18
+ menuData: { type: Array as PropType<any>, default: () => [] },
19
+ isSubMenu: { type: Boolean, default: false },
20
+ autoHide: { type: Boolean, default: true },
21
+ active: { type: [String, Number], default: "" },
22
+ });
23
+ const emit = defineEmits<{
24
+ hide: [];
25
+ show: [];
26
+ mouseenter: [];
27
+ }>();
28
+
29
+ const menu = ref<HTMLDivElement>();
30
+ const buttons = ref<Array<any>>();
31
+ const subMenu = ref<any>();
32
+ const visible = ref(false);
33
+ const subMenuData = ref<Array<any>>([]);
34
+ const zIndex = useZIndex();
35
+ const curZIndex = ref<number>(0);
36
+
37
+ const menuPosition = ref({
38
+ left: 0,
39
+ top: 0,
40
+ });
41
+
42
+ const menuStyle = computed(() => ({
43
+ top: `${menuPosition.value.top}px`,
44
+ left: `${menuPosition.value.left}px`,
45
+ zIndex: curZIndex.value,
46
+ }));
47
+
48
+ const contains = (el: HTMLElement) =>
49
+ menu.value?.contains(el) || subMenu.value?.contains(el);
50
+
51
+ const hide = () => {
52
+ if (!visible.value) return;
53
+ visible.value = false;
54
+ subMenu.value?.hide();
55
+ emit("hide");
56
+ };
57
+
58
+ const clickHandler = (item: any) => {
59
+ if (!props.autoHide) return;
60
+ item.handler();
61
+ hide();
62
+ };
63
+
64
+ const outsideClickHideHandler = (e: MouseEvent) => {
65
+ if (!props.autoHide) return;
66
+ const target = e.target as HTMLElement | undefined;
67
+ if (!visible.value || !target) {
68
+ return;
69
+ }
70
+ if (contains(target)) {
71
+ return;
72
+ }
73
+ hide();
74
+ };
75
+
76
+ const setPosition = (e: MouseEvent) => {
77
+ const menuHeight = menu.value?.clientHeight || 0;
78
+ let top = e.clientY;
79
+ if (menuHeight + e.clientY > document.body.clientHeight) {
80
+ top = document.body.clientHeight - menuHeight;
81
+ }
82
+ let left = e.clientX;
83
+ menuPosition.value = {
84
+ top,
85
+ left,
86
+ };
87
+ };
88
+
89
+ const show = (e?: MouseEvent) => {
90
+ // 加setTimeout是以为,如果菜单中的按钮监听的是mouseup,那么菜单显示出来时鼠标如果正好在菜单上就会马上触发按钮的mouseup
91
+ setTimeout(() => {
92
+ visible.value = true;
93
+ nextTick(() => {
94
+ e && setPosition(e);
95
+ curZIndex.value = zIndex.nextZIndex();
96
+ emit("show");
97
+ });
98
+ }, 300);
99
+ };
100
+ const showSubMenu = (item: any, index: number) => {
101
+ const menuItem = item;
102
+ if (typeof item !== "object") {
103
+ return;
104
+ }
105
+ subMenuData.value = menuItem.items || [];
106
+ setTimeout(() => {
107
+ if (!visible.value) {
108
+ return;
109
+ }
110
+
111
+ if (menu.value) {
112
+ // 将子菜单放置在按钮右侧,与按钮齐平
113
+ let y = menu.value.offsetTop;
114
+ if (buttons.value?.[index]?.$el) {
115
+ const rect = buttons.value?.[index].$el.getBoundingClientRect();
116
+ y = rect.top;
117
+ }
118
+ subMenu.value?.show({
119
+ clientX: menu.value.offsetLeft + menu.value.clientWidth,
120
+ clientY: y,
121
+ });
122
+ }
123
+ }, 0);
124
+ };
125
+
126
+ const mouseenterHandler = () => {
127
+ emit("mouseenter");
128
+ };
129
+
130
+ onMounted(() => {
131
+ if (props.isSubMenu) return;
132
+ globalThis.addEventListener("mousedown", outsideClickHideHandler, true);
133
+ });
134
+
135
+ onBeforeUnmount(() => {
136
+ if (props.isSubMenu) return;
137
+ globalThis.removeEventListener("mousedown", outsideClickHideHandler, true);
138
+ });
139
+
140
+ defineExpose({
141
+ menu,
142
+ menuPosition,
143
+ hide,
144
+ show,
145
+ contains,
146
+ setPosition,
147
+ });
148
+ </script>
149
+ <template>
150
+ <transition name="fade">
151
+ <div
152
+ v-show="visible"
153
+ class="content-menu"
154
+ ref="menu"
155
+ :style="menuStyle"
156
+ @mouseenter="mouseenterHandler()"
157
+ >
158
+ <slot name="title"></slot>
159
+
160
+ <template v-for="(item, index) in menuData" :key="compKey(item, index)">
161
+ <el-divider v-if="item.type == 'divider'" :direction="item.direction" />
162
+ <div
163
+ v-if="item.type == 'button' && item.display"
164
+ ref="buttons"
165
+ class="menu-item button"
166
+ :class="{ active: active && item.id === active }"
167
+ :data="item"
168
+ :key="index"
169
+ @mouseup="clickHandler(item)"
170
+ @mouseenter="showSubMenu(item, index)"
171
+ >
172
+ <star-horse-icon :icon-class="item.icon" />
173
+ {{ item.text }}
174
+ </div>
175
+ </template>
176
+ <teleport to="body">
177
+ <content-menu
178
+ v-if="subMenuData.length"
179
+ class="sub-menu"
180
+ ref="subMenu"
181
+ :active="active"
182
+ :menu-data="subMenuData"
183
+ :is-sub-menu="true"
184
+ @hide="hide"
185
+ ></content-menu>
186
+ </teleport>
187
+ </div>
188
+ </transition>
189
+ </template>
190
+ <style lang="scss" scoped>
191
+ :deep(.el-divider) {
192
+ margin: 5px auto;
193
+ }
194
+
195
+ .content-menu {
196
+ position: fixed;
197
+ font-size: 12px;
198
+ background: #fff;
199
+ box-shadow: 0 2px 8px 2px rgba(68, 73, 77, 0.16);
200
+ z-index: 999999;
201
+ transform-origin: 0 0;
202
+ font-weight: 600;
203
+ padding: 4px 0;
204
+ overflow: auto;
205
+ max-height: 80%;
206
+ min-width: 180px;
207
+
208
+ .menu-item {
209
+ color: #333;
210
+ display: flex;
211
+ -webkit-box-align: center;
212
+ align-items: center;
213
+ flex-direction: row;
214
+ vertical-align: middle;
215
+ cursor: pointer;
216
+ line-height: 35px;
217
+ min-width: 140px;
218
+ transition: all 0.2s ease 0s;
219
+ padding: 5px 14px;
220
+ border-left: 2px solid transparent;
221
+
222
+ .button {
223
+ width: 100%;
224
+ justify-content: flex-start;
225
+ }
226
+
227
+ .el-button--text,
228
+ i {
229
+ color: var(--star-horse-style);
230
+ }
231
+
232
+ svg {
233
+ margin-right: 5px;
234
+ }
235
+
236
+ &.divider {
237
+ padding: 0 14px;
238
+
239
+ .el-divider {
240
+ margin: 0;
241
+ }
242
+ }
243
+ &.button {
244
+ &:hover {
245
+ background-color: #6b778c;
246
+
247
+ &.menu-item i {
248
+ color: var(--star-horse-style);
249
+ }
250
+ }
251
+ &.active {
252
+ background-color: #6b778c;
253
+ &.menu-item i {
254
+ color: #fff;
255
+ }
256
+ }
257
+ }
258
+ }
259
+ }
260
+ </style>
@@ -0,0 +1,344 @@
1
+ <script setup lang="ts" name="StarHorseButtonList">
2
+ import {Config} from "@/api/settings";
3
+ import {download} from "@/api/star_horse_apis";
4
+ import {compKey} from "@/api/system";
5
+ import Help from "@/components/help.vue";
6
+ import {ApiUrls} from "@/components/types/ApiUrls";
7
+ import {PreValid} from "@/components/types/BtnAuth";
8
+ import {DialogProps} from "@/components/types/DialogProps";
9
+ import {UserFuncInfo} from "@/components/types/PageFieldInfo";
10
+ import piniaInstance from "@/store";
11
+ import {useGlobalConfigStore} from "@/store/GlobalConfig";
12
+ import {getToken} from "@/utils/auth";
13
+ import {error, warning} from "@/utils/message";
14
+ import {computed, onMounted, PropType, ref} from "vue";
15
+
16
+ const props = defineProps({
17
+ dialogProps: {type: Object as PropType<DialogProps>, required: true},
18
+ compUrl: {type: Object as PropType<ApiUrls>, required: true},
19
+ viewFlag: {type: Boolean, default: false},
20
+ //自定义按钮
21
+ extendBtns: {type: Array as PropType<UserFuncInfo[]>},
22
+ //预检查方法,如果设置了预检查方法,必须要检查通过后,按钮事件才能继续往下执行
23
+ preValidFunc: {type: Object as PropType<Array<PreValid>>},
24
+ btnPermissions: {type: Object as PropType<any>, required: false},
25
+ });
26
+ const emits = defineEmits([
27
+ "upload",
28
+ "uploadProcess",
29
+ "uploadError",
30
+ "uploadSuccess",
31
+ "btnOperation",
32
+ "tableCompFunc",
33
+ ]);
34
+ let configStore = useGlobalConfigStore(piniaInstance);
35
+ let compSize = computed(
36
+ () => configStore.configFormInfo?.buttonSize || Config.compSize,
37
+ );
38
+ let showType = computed(
39
+ () => configStore.configFormInfo?.buttonShowType || "dropdown",
40
+ );
41
+ let permissions = computed(() => props.btnPermissions);
42
+ const dataForm = ref<any>({});
43
+ /**
44
+ * 向往抛出事件
45
+ * @param funcName
46
+ */
47
+ const tableCompFunc = (funcName: string) => {
48
+ emits("tableCompFunc", funcName);
49
+ };
50
+ const btnOperation = (funcName: string) => {
51
+ //检查前置条件
52
+ if (props.preValidFunc?.length > 0 && Array.isArray(props.preValidFunc)) {
53
+ const preFunc = props.preValidFunc.find(
54
+ (item: PreValid) => item.authority == funcName,
55
+ );
56
+ if (preFunc) {
57
+ const result = preFunc.valid?.();
58
+ if (!result) {
59
+ if (preFunc.msg?.length > 1) {
60
+ warning(preFunc.msg);
61
+ }
62
+ return;
63
+ }
64
+ }
65
+ }
66
+ //?表示判断是否为空 !表示断言not null
67
+ if (funcName == "add") {
68
+ // dataForm.value = {};
69
+ props.dialogProps!.ids = -1;
70
+ props.dialogProps!.editVisible = true;
71
+ props.dialogProps!.dialogTitle = "新增数据";
72
+ } else if (funcName == "batchAdd") {
73
+ props.dialogProps!.batchEditVisible = true;
74
+ props.dialogProps!.batchDialogTitle = "批量新增数据";
75
+ } else if (funcName == "download") {
76
+ downloadTemplate();
77
+ } else {
78
+ tableCompFunc(funcName);
79
+ }
80
+ };
81
+ /**
82
+ * 刷新数据
83
+ * @param file
84
+ * @param fileList
85
+ */
86
+ const downloadTemplate = () => {
87
+ download(props.compUrl?.downloadTemplateUrl!, {}).catch((err) => {
88
+ error("接口不存在或网络异常:" + err);
89
+ });
90
+ };
91
+ const upload = (file: any, fileList: any) => {
92
+ emits("upload", file, fileList);
93
+ };
94
+ const beforeUpload = (_file: any, _fileList: any) => {
95
+ //load("数据导入中");
96
+ };
97
+ /**
98
+ * 上传过程
99
+ */
100
+ const uploadProcess = (_event: any, _file: any, _fileList: any) => {
101
+ };
102
+ /**
103
+ * 上传失败
104
+ */
105
+ const uploadError = (_err: any, _file: any, _fileList: any) => {
106
+ // closeLoad();
107
+ tableCompFunc("refresh");
108
+ };
109
+ /**
110
+ * 上传成功
111
+ */
112
+ const uploadSuccess = (_response: any, _file: any, _fileList: any) => {
113
+ //closeLoad();
114
+ tableCompFunc("refresh");
115
+ };
116
+ const buttonList = computed(() => {
117
+ return extendBtnFunction();
118
+ });
119
+ /**
120
+ * 扩展按钮
121
+ */
122
+ const extendBtnFunction = (): Array<UserFuncInfo> | any => {
123
+ let arr: Array<UserFuncInfo | any> = [];
124
+ if (props.viewFlag) {
125
+ return arr;
126
+ }
127
+ arr.push({
128
+ btnName: "新增",
129
+ icon: "add",
130
+ authority: "add",
131
+ priority: 100,
132
+ funcName: (actionName: string) => btnOperation(actionName),
133
+ });
134
+ arr.push({
135
+ btnName: "批量新增",
136
+ icon: "batch-add",
137
+ authority: "batchAdd",
138
+ priority: 110,
139
+ funcName: (actionName: string) => btnOperation(actionName),
140
+ });
141
+ arr.push({
142
+ btnName: "下载模板",
143
+ icon: "download",
144
+ authority: "download",
145
+ priority: 120,
146
+ funcName: (actionName: string) => btnOperation(actionName),
147
+ });
148
+ arr.push({
149
+ btnName: "执行",
150
+ icon: "run",
151
+ authority: "execution",
152
+ priority: 130,
153
+ funcName: (actionName: string) => btnOperation(actionName),
154
+ });
155
+ arr.push({
156
+ btnName: "导入数据",
157
+ icon: "excel-upload",
158
+ authority: "upload",
159
+ priority: 140,
160
+ funcName: (actionName: string) => btnOperation(actionName),
161
+ });
162
+ arr.push({
163
+ btnName: "导出数据",
164
+ icon: "excel-export",
165
+ authority: "export",
166
+ helpMsg:
167
+ "如果选择了数据,则按选择数据导出;\n没有选择数据,则根据查询条件导出",
168
+ priority: 150,
169
+ funcName: (actionName: string) => btnOperation(actionName),
170
+ });
171
+ arr.push({
172
+ btnName: "批量删除",
173
+ icon: "batch_delete1",
174
+ authority: "batchDelete",
175
+ priority: 160,
176
+ funcName: (actionName: string) => btnOperation(actionName),
177
+ });
178
+ //自定义按钮,如果时自定义按钮,则覆盖原有的按钮
179
+ if (props.extendBtns?.length > 0) {
180
+ let extBtns: UserFuncInfo[] =
181
+ props.extendBtns.filter((item) => item.position == "toolbar") || [];
182
+ if (extBtns?.length > 0) {
183
+ for (let i = 0; i < arr.length; i++) {
184
+ let temp: UserFuncInfo = arr[i];
185
+ if (
186
+ extBtns.find(
187
+ (item: UserFuncInfo) =>
188
+ item.btnName == temp.btnName && item.authority == temp.authority,
189
+ )
190
+ ) {
191
+ arr.splice(i, 1);
192
+ }
193
+ }
194
+ arr.push(...extBtns);
195
+ }
196
+ }
197
+ arr.sort(
198
+ (a: UserFuncInfo, b: UserFuncInfo) =>
199
+ (a.priority || 100) - (b.priority || 100),
200
+ );
201
+ return arr;
202
+ };
203
+ const setFormData = (val: any) => {
204
+ dataForm.value = {...val};
205
+ };
206
+ /**
207
+ * 获取授权按钮长度
208
+ */
209
+ const authBtnLength = () => {
210
+ const result = buttonList.value.filter((item) => permissions.value[item.authority]) || [];
211
+ return result.length;
212
+ };
213
+ const init = async () => {
214
+ };
215
+ onMounted(() => {
216
+ init();
217
+ });
218
+ defineExpose({
219
+ setFormData,
220
+ });
221
+ </script>
222
+ <template>
223
+ <template v-if="showType == 'dropdown' && Object.keys(permissions || {}).length > 0&&authBtnLength()>3">
224
+ <el-menu mode="horizontal" :ellipsis="false">
225
+ <el-sub-menu index="1">
226
+ <template #title>
227
+ <el-tooltip content="操作" placement="top">
228
+ <star-horse-icon icon-class="operation" size="16px" cursor="pointer"/>
229
+ </el-tooltip>
230
+ </template>
231
+ <template v-for="(item, index) in buttonList" :key="compKey(item, index)">
232
+ <template v-if="item.children?.length > 0">
233
+ <el-sub-menu :index="'2-' + index" v-if="permissions[item.authority]">
234
+ <template #title>
235
+ {{ item.btnName }}
236
+ </template>
237
+ <template v-for="(sitem, sindex) in item.children" :key="compKey(sitem, sindex)">
238
+ <el-menu-item :index="'3-' + index + '-' + sindex" @click="sitem.funcName(sitem.authority)"
239
+ v-if="permissions[sitem.authority]">
240
+ <star-horse-icon :icon-class="item.icon || 'edit'" :color="item.authority == 'delete' ||
241
+ item.authority == 'batchDelete'
242
+ ? 'var(--el-style-danger)'
243
+ : 'var(--star-horse-style)'
244
+ " size="14px"/>
245
+ {{ sitem.btnName }}
246
+ <help :message="sitem.helpMsg" v-if="sitem.helpMsg"/>
247
+ </el-menu-item>
248
+ </template>
249
+ </el-sub-menu>
250
+ </template>
251
+ <template v-else>
252
+ <el-menu-item :index="'1-' + index" v-if="permissions[item.authority]">
253
+ <el-upload :auto-upload="true" :on-change="upload" :on-error="uploadError" :on-progress="uploadProcess"
254
+ :on-success="uploadSuccess" :show-file-list="false" accept=".xls,.xlsx"
255
+ :before-upload="beforeUpload"
256
+ :action="compUrl?.importUrl" :headers="{ token: getToken() }"
257
+ class="upload flex items-center w-[100%]"
258
+ name="file" v-if="item.authority == 'upload'">
259
+ <div class="flex items-center w-[100%]">
260
+ <star-horse-icon icon-class="excel-upload" size="14px"/>
261
+ {{ item.btnName }}
262
+ </div>
263
+ </el-upload>
264
+ <div class="flex items-center w-[100%]" @click="item.funcName(item.authority)" v-else>
265
+ <star-horse-icon :icon-class="item.icon || 'edit'" :color="item.authority == 'delete' || item.authority == 'batchDelete'
266
+ ? 'var(--el-color-danger)'
267
+ : 'var(--star-horse-style)'
268
+ " size="14px"/>
269
+ {{ item.btnName }}
270
+ <help :message="item.helpMsg" v-if="item.helpMsg"/>
271
+ </div>
272
+ </el-menu-item>
273
+ </template>
274
+ </template>
275
+ </el-sub-menu>
276
+ </el-menu>
277
+ </template>
278
+ <template v-else-if="Object.keys(permissions || {}).length > 0">
279
+ <ul class="inner_button">
280
+ <template v-for="(item, key) in buttonList" :key="compKey(item, key)">
281
+ <template v-if="item.children?.length > 0">
282
+ <el-dropdown :size="compSize" split-button style="
283
+ background: var(--star-horse-style);
284
+ color: var(--star-horse-white);
285
+ " placement="top-start" v-if="permissions[item.authority]">
286
+ <star-horse-icon :icon-class="item.icon" size="18px"/>
287
+ {{ item.btnName }}
288
+ <template #dropdown>
289
+ <el-dropdown-menu>
290
+ <template v-for="(sitem, skey) in item.children" :key="compKey(sitem, skey)">
291
+ <el-dropdown-item v-if="permissions[sitem.authority]" @click="sitem.funcName(sitem.btnName)">
292
+ <star-horse-icon :icon-class="item.icon || 'edit'" size="18px" :color="item.authority == 'delete' ||
293
+ item.authority == 'batchDelete'
294
+ ? '#f56c6c'
295
+ : 'var(--star-horse-style)'
296
+ "/>
297
+ {{ sitem.btnName }}
298
+ <help :message="sitem.helpMsg" v-if="sitem.helpMsg"/>
299
+ </el-dropdown-item>
300
+ </template>
301
+ </el-dropdown-menu>
302
+ </template>
303
+ </el-dropdown>
304
+ </template>
305
+ <template v-else>
306
+ <li v-if="permissions[item.authority] && item.authority == 'upload'">
307
+ <el-upload :auto-upload="true" :on-change="upload" :on-error="uploadError" :on-progress="uploadProcess"
308
+ :on-success="uploadSuccess" :show-file-list="false" accept=".xls,.xlsx"
309
+ :before-upload="beforeUpload"
310
+ :action="compUrl?.importUrl" :headers="{ token: getToken() }" class="upload" name="file"
311
+ title="导入">
312
+ <star-horse-icon title="导入" width="27px" size="18px" icon-class="excel-upload"/>
313
+ </el-upload>
314
+ </li>
315
+ <li v-else-if="permissions[item.authority]" @click="item.funcName(item.authority)" :title="item.btnName">
316
+ <star-horse-icon :icon-class="item.icon || 'edit'" :title="item.btnName" size="18px" width="27px" :color="item.authority == 'delete' || item.authority == 'batchDelete'
317
+ ? '#f56c6c'
318
+ : 'var(--star-horse-style)'
319
+ "/>
320
+ <help :message="item.helpMsg" v-if="item.helpMsg"/>
321
+ </li>
322
+ </template>
323
+ </template>
324
+ </ul>
325
+ </template>
326
+ </template>
327
+ <style lang="scss" scoped>
328
+ :deep(.el-tooltip__trigger:focus-visible) {
329
+ outline: unset;
330
+ }
331
+
332
+ .el-menu {
333
+ background: none;
334
+ border-bottom: none;
335
+ }
336
+
337
+ :deep(.el-sub-menu) {
338
+ background: none;
339
+ }
340
+
341
+ .el-menu--horizontal {
342
+ height: 30px;
343
+ }
344
+ </style>
@@ -0,0 +1,97 @@
1
+ <script setup lang="ts" name="StarHorseHmenu">
2
+ import { ModelRef, onMounted, PropType } from "vue";
3
+ import MenuItem from "@/components/menu/MenuItem.vue";
4
+ import { compKey } from "@/api/system";
5
+ defineProps({
6
+ preps: {
7
+ type: Object as PropType<any>,
8
+ default: () => {
9
+ return {
10
+ id: "id",
11
+ value: "value",
12
+ icon: "icon",
13
+ label: "name",
14
+ children: "children",
15
+ };
16
+ },
17
+ },
18
+ });
19
+ const emits = defineEmits(["selectItem"]);
20
+ let dataList: ModelRef<any> = defineModel("dataList");
21
+ const initData = async () => {};
22
+ const selectItem = (item: any) => {
23
+ emits("selectItem", item);
24
+ };
25
+ onMounted(() => {
26
+ initData();
27
+ });
28
+ </script>
29
+ <template>
30
+ <el-menu class="system-menu" v-bind="$attrs">
31
+ <MenuItem
32
+ v-for="(sitem, key) in dataList"
33
+ :key="compKey(sitem, key)"
34
+ :item="sitem"
35
+ @selectItem="selectItem"
36
+ :preps="preps"
37
+ />
38
+ </el-menu>
39
+ </template>
40
+ <style lang="scss" scoped>
41
+ .el-menu--horizontal {
42
+ .el-menu-item {
43
+ height: inherit;
44
+ }
45
+
46
+ .el-menu-item.is-active,
47
+ .el-menu-item:hover,
48
+ .el-submenu__title:hover,
49
+ .el-submenu__title.is-opened {
50
+ background-color: unset !important;
51
+ }
52
+ }
53
+
54
+ :deep(.el-submenu__title:hover),
55
+ :deep(.el-sub-menu:hover),
56
+ .el-tooltip__trigger:hover,
57
+ .el-submenu__title.is-opened {
58
+ background-color: unset !important;
59
+ }
60
+
61
+ .sub-class:hover {
62
+ background-color: unset !important;
63
+ }
64
+
65
+ .system-menu {
66
+ --el-menu-bg-color: #fff;
67
+ --el-menu-text-color: #eee;
68
+ --el-menu-active-color: #ffd04b;
69
+ --el-menu-hover-bg-color: rgb(245, 235, 255, 0.5);
70
+ max-height: 50px;
71
+ background-color: unset !important;
72
+ width: 100% !important;
73
+ border-bottom: unset !important;
74
+ color: var(--star-horse-white);
75
+ font-weight: bold;
76
+ font-size: 16px;
77
+ align-items: center;
78
+ }
79
+
80
+ :deep(.el-sub-menu) {
81
+ box-sizing: border-box;
82
+ background-color: unset !important;
83
+ }
84
+
85
+ .star-icon {
86
+ font-size: 26px;
87
+ color: var(--star-horse-white);
88
+ }
89
+
90
+ :deep(.el-icon) {
91
+ svg {
92
+ height: 1.5em;
93
+ width: 1.5em;
94
+ color: var(--star-horse-white) !important;
95
+ }
96
+ }
97
+ </style>