sohelp-eleplus 1.1.13

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 (191) hide show
  1. package/README.md +7 -0
  2. package/cache/DictCache.js +58 -0
  3. package/cache/ModuleCache.js +352 -0
  4. package/components.js +45 -0
  5. package/core-export.js +4 -0
  6. package/http/CrudHttp.js +115 -0
  7. package/http/DictHttp.js +12 -0
  8. package/http/ModuleHttp.js +68 -0
  9. package/http/SohelpHttp.js +125 -0
  10. package/index.js +6 -0
  11. package/installer.js +8 -0
  12. package/lang/en_US.js +4 -0
  13. package/lang/zh_CN.js +4 -0
  14. package/lang/zh_TW.js +4 -0
  15. package/package.json +9 -0
  16. package/sohelp-ace-editor/index.vue +198 -0
  17. package/sohelp-application-select/index.vue +15 -0
  18. package/sohelp-autocode/index.vue +53 -0
  19. package/sohelp-calendar-view/index.vue +11 -0
  20. package/sohelp-card-view/index.vue +11 -0
  21. package/sohelp-condition/index.vue +210 -0
  22. package/sohelp-cry-input/index.vue +64 -0
  23. package/sohelp-date/index.vue +27 -0
  24. package/sohelp-datetime/index.vue +44 -0
  25. package/sohelp-datetime-picker/index.vue +86 -0
  26. package/sohelp-datetime-range/index.vue +59 -0
  27. package/sohelp-dict/index.vue +207 -0
  28. package/sohelp-dict/props.js +68 -0
  29. package/sohelp-drawer/index.vue +31 -0
  30. package/sohelp-drop-card/index.vue +94 -0
  31. package/sohelp-drop-card/props.js +68 -0
  32. package/sohelp-dyn-select/index.vue +99 -0
  33. package/sohelp-dyn-select/props.js +67 -0
  34. package/sohelp-dyn-tree/index.vue +82 -0
  35. package/sohelp-dyn-tree-select/index.vue +114 -0
  36. package/sohelp-entity-form/index.vue +524 -0
  37. package/sohelp-entity-grid/index.vue +30 -0
  38. package/sohelp-file-upload/index.vue +218 -0
  39. package/sohelp-filter-scheme/components/condition.vue +102 -0
  40. package/sohelp-filter-scheme/components/filter.vue +45 -0
  41. package/sohelp-filter-scheme/components/keywords.vue +15 -0
  42. package/sohelp-filter-scheme/components/scheme.vue +49 -0
  43. package/sohelp-filter-scheme/index.vue +113 -0
  44. package/sohelp-grid/SohelpGridConfig.js~ +408 -0
  45. package/sohelp-grid/components/filter-condition-item.vue +298 -0
  46. package/sohelp-grid/index.vue +1886 -0
  47. package/sohelp-grid/js/ConditionType.js +101 -0
  48. package/sohelp-grid/js/DefaultGridOptions.js +141 -0
  49. package/sohelp-grid/js/DefaultProps.js +27 -0
  50. package/sohelp-grid/js/SohelpConfigFunction.js +0 -0
  51. package/sohelp-grid/js/SohelpGridConfig.js +101 -0
  52. package/sohelp-grid/js/useSohelpGridConfig.js +519 -0
  53. package/sohelp-grid-select/index.vue +245 -0
  54. package/sohelp-grid-view/filter/config/grid-filter-condition.vue +221 -0
  55. package/sohelp-grid-view/filter/config/grid-filter-config.vue +27 -0
  56. package/sohelp-grid-view/filter/config/grid-filter-field.vue +378 -0
  57. package/sohelp-grid-view/filter/config/grid-filter-keywords.vue +310 -0
  58. package/sohelp-grid-view/filter/config/grid-filter-list.vue +313 -0
  59. package/sohelp-grid-view/filter/config/grid-filter-scheme.vue +264 -0
  60. package/sohelp-grid-view/filter/config/grid-filter-sort.vue +310 -0
  61. package/sohelp-grid-view/filter/config/index.vue +206 -0
  62. package/sohelp-grid-view/filter/filter-form.vue +427 -0
  63. package/sohelp-grid-view/filter/filter-toolbar.vue +110 -0
  64. package/sohelp-grid-view/filter/index.vue +160 -0
  65. package/sohelp-grid-view/index.vue +379 -0
  66. package/sohelp-grid-view-select/index.vue +141 -0
  67. package/sohelp-group-view/index.vue +11 -0
  68. package/sohelp-icon-select/index.vue +96 -0
  69. package/sohelp-icon-select/vxeui-icon.js +90 -0
  70. package/sohelp-image-upload/index.vue +286 -0
  71. package/sohelp-input/index.vue +39 -0
  72. package/sohelp-modal/index.vue +49 -0
  73. package/sohelp-module/index.vue +54 -0
  74. package/sohelp-module/useModalManager.js +89 -0
  75. package/sohelp-module/useSohelpModule.js +66 -0
  76. package/sohelp-number-input/index.vue +32 -0
  77. package/sohelp-number-range/index.vue +135 -0
  78. package/sohelp-org-select/index.vue +30 -0
  79. package/sohelp-org-tree/index.vue +18 -0
  80. package/sohelp-org-tree-select/index.vue +93 -0
  81. package/sohelp-org-user-tree/index.vue +26 -0
  82. package/sohelp-org-user-tree-select/index.vue +11 -0
  83. package/sohelp-pagination/index.vue +11 -0
  84. package/sohelp-power/index.vue +105 -0
  85. package/sohelp-pro-form/components/pro-form-footer.vue +44 -0
  86. package/sohelp-pro-form/components/pro-form-item.vue +1133 -0
  87. package/sohelp-pro-form/index.vue +257 -0
  88. package/sohelp-pro-form/util.js +140 -0
  89. package/sohelp-pro-layout/index.vue +11 -0
  90. package/sohelp-pro-table/index.vue +14 -0
  91. package/sohelp-process/index.vue +216 -0
  92. package/sohelp-rate/index.vue +56 -0
  93. package/sohelp-rate/props.js +71 -0
  94. package/sohelp-relation/index.vue +11 -0
  95. package/sohelp-rich-text/index.vue +242 -0
  96. package/sohelp-rich-text/util.js +231 -0
  97. package/sohelp-richtext/index.vue +10 -0
  98. package/sohelp-role-select/index.vue +33 -0
  99. package/sohelp-search/components/search-config.vue +0 -0
  100. package/sohelp-search/index.vue +49 -0
  101. package/sohelp-search-pro-form/index.vue +11 -0
  102. package/sohelp-select/index.vue +120 -0
  103. package/sohelp-split-panel/index.vue +15 -0
  104. package/sohelp-switch/index.vue +56 -0
  105. package/sohelp-table/index.vue +151 -0
  106. package/sohelp-tenant-select/index.vue +128 -0
  107. package/sohelp-text/index.vue +14 -0
  108. package/sohelp-textarea-input/index.vue +36 -0
  109. package/sohelp-time/index.vue +10 -0
  110. package/sohelp-tree/index.vue +37 -0
  111. package/sohelp-tree-select/index.vue +18 -0
  112. package/sohelp-user-select/index.vue +44 -0
  113. package/sohelp-user-select/index.vue~ +53 -0
  114. package/sohelp-user-select/props.js +71 -0
  115. package/sohelp-user-tag/index.vue +12 -0
  116. package/sohelp-user-tree/index.vue +11 -0
  117. package/sohelp-vform-drawer/index.vue +40 -0
  118. package/sohelp-vform-eleplus/favicon.ico +0 -0
  119. package/sohelp-vform-eleplus/index.vue +297 -0
  120. package/sohelp-vform-eleplus/preview.html +91 -0
  121. package/sohelp-vform-eleplus/render.es.js +72433 -0
  122. package/sohelp-vform-eleplus/render.style.css +16 -0
  123. package/sohelp-vform-eleplus/render.umd.js +57 -0
  124. package/sohelp-vform-eleplus/tinymce/langs/zh_CN.js +462 -0
  125. package/sohelp-vform-eleplus/tinymce/langs/zh_TW.js +419 -0
  126. package/sohelp-vform-eleplus/tinymce/skins/content/dark/content.css +72 -0
  127. package/sohelp-vform-eleplus/tinymce/skins/content/dark/content.min.css +7 -0
  128. package/sohelp-vform-eleplus/tinymce/skins/content/default/content.css +67 -0
  129. package/sohelp-vform-eleplus/tinymce/skins/content/default/content.min.css +7 -0
  130. package/sohelp-vform-eleplus/tinymce/skins/content/document/content.css +72 -0
  131. package/sohelp-vform-eleplus/tinymce/skins/content/document/content.min.css +7 -0
  132. package/sohelp-vform-eleplus/tinymce/skins/content/writer/content.css +68 -0
  133. package/sohelp-vform-eleplus/tinymce/skins/content/writer/content.min.css +7 -0
  134. package/sohelp-vform-eleplus/tinymce/skins/ui/oxide/content.css +732 -0
  135. package/sohelp-vform-eleplus/tinymce/skins/ui/oxide/content.inline.css +726 -0
  136. package/sohelp-vform-eleplus/tinymce/skins/ui/oxide/content.inline.min.css +7 -0
  137. package/sohelp-vform-eleplus/tinymce/skins/ui/oxide/content.min.css +7 -0
  138. package/sohelp-vform-eleplus/tinymce/skins/ui/oxide/content.mobile.css +29 -0
  139. package/sohelp-vform-eleplus/tinymce/skins/ui/oxide/content.mobile.min.css +7 -0
  140. package/sohelp-vform-eleplus/tinymce/skins/ui/oxide/fonts/tinymce-mobile.woff +0 -0
  141. package/sohelp-vform-eleplus/tinymce/skins/ui/oxide/skin.css +3047 -0
  142. package/sohelp-vform-eleplus/tinymce/skins/ui/oxide/skin.min.css +7 -0
  143. package/sohelp-vform-eleplus/tinymce/skins/ui/oxide/skin.mobile.css +673 -0
  144. package/sohelp-vform-eleplus/tinymce/skins/ui/oxide/skin.mobile.min.css +7 -0
  145. package/sohelp-vform-eleplus/tinymce/skins/ui/oxide/skin.shadowdom.css +37 -0
  146. package/sohelp-vform-eleplus/tinymce/skins/ui/oxide/skin.shadowdom.min.css +7 -0
  147. package/sohelp-vform-eleplus/tinymce/skins/ui/oxide-dark/content.css +714 -0
  148. package/sohelp-vform-eleplus/tinymce/skins/ui/oxide-dark/content.inline.css +726 -0
  149. package/sohelp-vform-eleplus/tinymce/skins/ui/oxide-dark/content.inline.min.css +7 -0
  150. package/sohelp-vform-eleplus/tinymce/skins/ui/oxide-dark/content.min.css +7 -0
  151. package/sohelp-vform-eleplus/tinymce/skins/ui/oxide-dark/content.mobile.css +29 -0
  152. package/sohelp-vform-eleplus/tinymce/skins/ui/oxide-dark/content.mobile.min.css +7 -0
  153. package/sohelp-vform-eleplus/tinymce/skins/ui/oxide-dark/fonts/tinymce-mobile.woff +0 -0
  154. package/sohelp-vform-eleplus/tinymce/skins/ui/oxide-dark/skin.css +3047 -0
  155. package/sohelp-vform-eleplus/tinymce/skins/ui/oxide-dark/skin.min.css +7 -0
  156. package/sohelp-vform-eleplus/tinymce/skins/ui/oxide-dark/skin.mobile.css +673 -0
  157. package/sohelp-vform-eleplus/tinymce/skins/ui/oxide-dark/skin.mobile.min.css +7 -0
  158. package/sohelp-vform-eleplus/tinymce/skins/ui/oxide-dark/skin.shadowdom.css +37 -0
  159. package/sohelp-vform-eleplus/tinymce/skins/ui/oxide-dark/skin.shadowdom.min.css +7 -0
  160. package/sohelp-vform-modal/index.vue +41 -0
  161. package/sohelp-vform-select/index.vue +11 -0
  162. package/sohelp-vform-vant/favicon.ico +0 -0
  163. package/sohelp-vform-vant/render.es.js +14608 -0
  164. package/sohelp-vform-vant/render.style.css +1 -0
  165. package/sohelp-vform-vant/render.umd.js +22 -0
  166. package/sohelp-vxe-grid/DefaultGridOptions.js +102 -0
  167. package/sohelp-vxe-grid/DefaultProps.js +37 -0
  168. package/sohelp-vxe-grid/SohelpGridConfig.js +142 -0
  169. package/sohelp-vxe-grid/index.vue +518 -0
  170. package/sohelp-vxe-grid-select/index.vue +148 -0
  171. package/sohelp-vxe-table/index.vue +184 -0
  172. package/sohelp-workflow/index.vue +495 -0
  173. package/sohelp-workflow/nodeWrap.vue +53 -0
  174. package/sohelp-workflow/nodes/addNode.vue +27 -0
  175. package/sohelp-workflow/nodes/approver.vue +125 -0
  176. package/sohelp-workflow/nodes/branch.vue +434 -0
  177. package/sohelp-workflow/nodes/promoter.vue +80 -0
  178. package/sohelp-workflow/nodes/send.vue +95 -0
  179. package/sohelp-workflow-drawer/components/approval-modal.vue +182 -0
  180. package/sohelp-workflow-drawer/components/draw-box.vue +141 -0
  181. package/sohelp-workflow-drawer/components/form.vue +79 -0
  182. package/sohelp-workflow-drawer/components/table.vue +153 -0
  183. package/sohelp-workflow-drawer/components/timeline.vue +189 -0
  184. package/sohelp-workflow-drawer/components/workflow.vue +68 -0
  185. package/sohelp-workflow-drawer/index.vue +311 -0
  186. package/sohelp-workflow-drawer/js/index.js +119 -0
  187. package/style/index.scss +0 -0
  188. package/utils/ProFormConvertUtil.js +76 -0
  189. package/utils/core.js +310 -0
  190. package/utils/use-form-data.js +48 -0
  191. package/utils/use-mobile.js +43 -0
@@ -0,0 +1,518 @@
1
+ <template>
2
+ <div class="sohelp-vxe-grid">
3
+ <vxe-grid
4
+ v-bind="gridOptions"
5
+ row-id="id"
6
+ @page-change="pageChangeEvent"
7
+ ref="sohelpVxeGridRef"
8
+ @menuClick="menuEvents"
9
+ @toolbarButtonClick="onToolbarButtonClick"
10
+ @checkboxChange="onCheckboxChange"
11
+ @checkboxAll="onCheckboxAllChange"
12
+ @radioChange="onRadioChange"
13
+ @cellClick.stop="onCellClick"
14
+ >
15
+ <template #searchSlot>
16
+ <div class="search-wrap">
17
+ <div class="search-box">
18
+ <ele-tooltip :content="getKeywordsPlaceholder" placement="top" :offset="3">
19
+ <sohelp-input
20
+ v-model="keywords"
21
+ :placeholder="getKeywordsPlaceholder"
22
+ clearable
23
+ @keyup.enter="reload(gridOptions.params)"
24
+ class="input-with-select"
25
+ >
26
+ <template #append>
27
+ <el-button :icon="Search" @click="reload(gridOptions.params)" size="small" />
28
+ </template>
29
+ </sohelp-input>
30
+ </ele-tooltip>
31
+ </div>
32
+ <slot name="toolbarRight"></slot>
33
+ </div>
34
+ </template>
35
+
36
+ <template #draggableDefault>
37
+ <span class="drag-btn">
38
+ <ele-text :icon="DragOutlined"></ele-text>
39
+ </span>
40
+ </template>
41
+
42
+ <!-- 编历插槽 -->
43
+ <template v-for="(_, name) in $slots" v-slot:[name]="slotData">
44
+ <slot :name="name" v-bind="slotData"></slot>
45
+ </template>
46
+ </vxe-grid>
47
+ </div>
48
+ </template>
49
+
50
+ <script>
51
+ import { EleMessage } from '@/components/ele-admin-plus/components';
52
+ import { DragOutlined } from '@/components/icons';
53
+ import { reactive, ref, nextTick, watch, computed } from 'vue';
54
+ import DefaultProps from './DefaultProps';
55
+ import initial from './SohelpGridConfig';
56
+ import { Search } from '@element-plus/icons-vue';
57
+
58
+ export default {
59
+ name: 'SohelpVxeGrid',
60
+ extends: [],
61
+ props: DefaultProps,
62
+ emits: [
63
+ 'pageChange',
64
+ 'checkboxAll',
65
+ 'checkboxChange',
66
+ 'toolbarButtonClick',
67
+ 'menuClick',
68
+ 'cellClick',
69
+ 'pageChange',
70
+ 'refresh',
71
+ 'radioChange',
72
+ 'update:value',
73
+ 'update:value'
74
+ ],
75
+ setup(props, { emit }) {
76
+ /**判断配置是否初始化完毕*/
77
+ const isConfigInitialized = ref(false);
78
+ const sohelpConfig = reactive({});
79
+ const isPage = ref(false);
80
+ const selectedValue = ref([]);
81
+ const selectedData = ref([]);
82
+ const keywords = ref('');
83
+ const propertiesMap = reactive({});
84
+
85
+ /**列表实例*/
86
+ const sohelpVxeGridRef = ref(null);
87
+ const gridOptions = reactive({});
88
+ /**初始化配置*/
89
+ initial(sohelpVxeGridRef, props)
90
+ .then((config) => {
91
+ /**配置刷新功能 */
92
+ config.gridOptions = {
93
+ ...config.gridOptions,
94
+ toolbarConfig: {
95
+ ...config.gridOptions?.toolbarConfig,
96
+ refresh: true,
97
+ zoom: true
98
+ },
99
+ proxyConfig: {
100
+ ajax: {
101
+ query: () => refresh() // 简写箭头函数
102
+ }
103
+ }
104
+ };
105
+
106
+ Object.assign(gridOptions, config.gridOptions);
107
+ Object.assign(sohelpConfig, config.sohelpConfig);
108
+ Object.assign(propertiesMap, config.propertiesMap);
109
+
110
+ /**配置初始化完成*/
111
+ isConfigInitialized.value = true;
112
+ })
113
+ .catch((e) => {
114
+ EleMessage.error(e.message);
115
+ });
116
+
117
+ const getKeywordsPlaceholder = computed(() => {
118
+ if (sohelpConfig?.filter?.keywords?.length) {
119
+ return (
120
+ '请输入关键 ' +
121
+ sohelpConfig.filter.keywords
122
+ .filter((key) => propertiesMap[key])
123
+ .map((key) => propertiesMap[key].label)
124
+ .join('、') +
125
+ ' 进行查询'
126
+ );
127
+ }
128
+ return '请输入关键字';
129
+ });
130
+
131
+ /**判断配置是否初始化完毕*/
132
+ const isConfigDone = async () => {
133
+ return new Promise((resolve) => {
134
+ if (isConfigInitialized.value) {
135
+ resolve();
136
+ } else {
137
+ let timer = setInterval(() => {
138
+ if (isConfigInitialized.value) {
139
+ clearInterval(timer);
140
+ resolve();
141
+ }
142
+ }, 10);
143
+ }
144
+ });
145
+ };
146
+
147
+ /**根据参数加载数据*/
148
+ const reload = async (param = {}) => {
149
+ gridOptions.loading = true;
150
+ gridOptions.params = param;
151
+ //配置初始化完毕后,才可以执行刷新
152
+ await isConfigDone();
153
+ const $grid = sohelpVxeGridRef.value;
154
+ if ($grid) {
155
+ const url = props.url || sohelpConfig.requestValue;
156
+ if (!url) {
157
+ gridOptions.loading = false;
158
+ return { results: [], total: 0 };
159
+ }
160
+
161
+ let pageConfig = {};
162
+ // 是否分页
163
+ if (gridOptions.pagerConfig?.enabled) {
164
+ pageConfig.page = gridOptions.pagerConfig?.currentPage ?? 1;
165
+ pageConfig.limit = gridOptions.pagerConfig?.pageSize ?? 50;
166
+ }
167
+
168
+ const res = await SohelpHttp.get(url, {
169
+ ...param,
170
+ keywords: keywords.value,
171
+ ...pageConfig
172
+ }).catch((e) => {
173
+ gridOptions.loading = false;
174
+ EleMessage.error(e);
175
+ });
176
+
177
+ gridOptions.loading = false;
178
+ if (!res.meta.success) {
179
+ EleMessage.error(res.meta.message);
180
+ return { results: [], total: 0 };
181
+ }
182
+ $grid.loadData(res.data.results || res.data);
183
+ if (gridOptions?.pagerConfig?.enabled) {
184
+ gridOptions.pagerConfig.total = res.data.total;
185
+ }
186
+ }
187
+ gridOptions.loading = false;
188
+ initValue();
189
+ };
190
+
191
+ /**实现分页事件*/
192
+ const pageChangeEvent = (page) => {
193
+ isPage.value = true;
194
+ gridOptions.pagerConfig.currentPage = page.currentPage;
195
+ gridOptions.pagerConfig.pageSize = page.pageSize;
196
+ emit('pageChange', page);
197
+ };
198
+
199
+ /**刷新数据*/
200
+ const refresh = () => {
201
+ if (!isPage.value) {
202
+ keywords.value = '';
203
+ if (gridOptions.pagerConfig && gridOptions.pagerConfig.enabled) {
204
+ gridOptions.pagerConfig.currentPage = 1;
205
+ } else {
206
+ gridOptions.pagerConfig = {
207
+ currentPage: 1
208
+ };
209
+ }
210
+ //清空选中
211
+ selectedValue.value = [];
212
+ sohelpVxeGridRef.value?.clearCheckboxRow();
213
+ emit('refresh');
214
+ }
215
+ isPage.value = false;
216
+ const autoLoad = props.autoLoad || sohelpConfig?.autoLoad || true;
217
+
218
+ if (autoLoad) {
219
+ reload({ ...gridOptions.params });
220
+ }
221
+ };
222
+
223
+ /**
224
+ * grid事件
225
+ * @param param0
226
+ */
227
+ const menuEvents = async ({ menu, row, column, rowIndex }) => {
228
+ const $grid = sohelpVxeGridRef.value;
229
+ if ($grid) {
230
+ $grid.setCurrentRow(row);
231
+ switch (menu.code) {
232
+ case 'insert':
233
+ const { row } = await $grid.insertAt(
234
+ {
235
+ role_name: 'sales user'
236
+ },
237
+ rowIndex
238
+ );
239
+ break;
240
+ }
241
+ }
242
+ };
243
+
244
+ /**
245
+ * 工具栏点击事件
246
+ * @param params
247
+ */
248
+ const onToolbarButtonClick = (params) => {
249
+ emit('toolbarButtonClick', params);
250
+ };
251
+
252
+ /**
253
+ * checkbox 点击
254
+ * @param params
255
+ */
256
+ const onCheckboxChange = (params) => {
257
+ emit('checkboxChange', params);
258
+ if (props.multiple) {
259
+ setSelectedValue(params.row);
260
+ updateData();
261
+ }
262
+ };
263
+
264
+ /**
265
+ * 获取表格当前页数据
266
+ */
267
+ const getTableData = () => {
268
+ return JSON.parse(JSON.stringify(sohelpVxeGridRef.value?.getTableData().tableData));
269
+ };
270
+
271
+ /**
272
+ * 全选、取消全选 更新value,data值
273
+ * @param param0
274
+ */
275
+ const onCheckboxAllChange = (params) => {
276
+ const data = getTableData();
277
+ const ids = data.map((item) => item.id);
278
+ if (params.checked) {
279
+ selectedValue.value = [...new Set([...selectedValue.value, ...ids])];
280
+ selectedData.value = Array.from(
281
+ [...selectedData.value, ...data].reduce((map, item) => map.set(item.id, item), new Map()).values()
282
+ );
283
+ } else {
284
+ selectedValue.value = selectedValue.value.filter((item) => !ids.includes(item));
285
+ }
286
+
287
+ emit('checkboxAll', params);
288
+ updateData();
289
+ };
290
+
291
+ /**
292
+ * checkbox row click selectValue, selectedData设置是否选中
293
+ * @param row
294
+ */
295
+ const setSelectedValue = (row) => {
296
+ let idx = selectedValue.value.findIndex((id) => id === row.id);
297
+ if (idx != -1) {
298
+ selectedValue.value.splice(idx, 1);
299
+ } else {
300
+ selectedValue.value.push(row.id);
301
+ let _idx = selectedData.value.findIndex((item) => item.id === row.id);
302
+ if (_idx === -1) {
303
+ selectedData.value.push({ ...row });
304
+ }
305
+ }
306
+ };
307
+
308
+ /**
309
+ * 行点击
310
+ * @param params
311
+ */
312
+ const onCellClick = (params) => {
313
+ emit('cellClick', params);
314
+ };
315
+
316
+ /**
317
+ *
318
+ * @param params 单选框点击
319
+ */
320
+ const onRadioChange = (params) => {
321
+ emit('radioChange', params);
322
+ if (!props.multiple) {
323
+ clear();
324
+ const row = sohelpVxeGridRef.value?.getRadioRecord();
325
+ if (row) {
326
+ selectedValue.value = [row.id];
327
+ selectedData.value = Array.from(
328
+ new Map([row, ...selectedData.value].map((item) => [item.id, item])).values()
329
+ );
330
+ } else {
331
+ selectedData.value = props.data;
332
+ selectedValue.value = [];
333
+ }
334
+
335
+ updateData();
336
+ }
337
+ };
338
+
339
+ /**
340
+ * 更新value,data
341
+ */
342
+ const updateData = () => {
343
+ emit('update:value', [...selectedValue.value]);
344
+ emit('update:data', [...selectedData.value]);
345
+ };
346
+
347
+ /**grid 事件处理 */
348
+ const gridEvents = {
349
+ cellMenu({ row, rowIndex }) {
350
+ const $grid = sohelpVxeGridRef.value;
351
+ if ($grid) {
352
+ $grid.setCurrentRow(row);
353
+ }
354
+ },
355
+ menuClick({ menu, column, row, rowIndex }) {
356
+ const $grid = sohelpVxeGridRef.value;
357
+ if ($grid) {
358
+ switch (menu.code) {
359
+ case 'insert':
360
+ // $grid.insert();
361
+ $grid.insertAt({}, rowIndex);
362
+
363
+ let _table = $grid.getTableData();
364
+
365
+ break;
366
+ case 'copy':
367
+ break;
368
+ }
369
+
370
+ emit('menuClick', $grid, code);
371
+ }
372
+ }
373
+ };
374
+
375
+ const loadData = (data) =>{
376
+ const $grid = sohelpVxeGridRef.value;
377
+ $grid.loadData(data);
378
+ }
379
+
380
+ /**
381
+ * 数据回显
382
+ */
383
+ const initValue = () => {
384
+ nextTick(() => {
385
+ const $grid = sohelpVxeGridRef.value;
386
+ if ($grid && selectedValue.value.length) {
387
+ setTimeout(() => {
388
+ $grid.setCheckboxRowKey(selectedValue.value, true);
389
+ }, 100);
390
+ }
391
+ });
392
+ };
393
+
394
+ /**
395
+ * 清空
396
+ */
397
+ const clear = () => {
398
+ const $grid = sohelpVxeGridRef.value;
399
+ $grid?.clearCheckboxReserve();
400
+ $grid?.clearCheckboxRow();
401
+ $grid.clearSelected();
402
+ };
403
+
404
+ const getSelection = () => {
405
+ return sohelpVxeGridRef.value?.getCheckboxRecords() || []
406
+ };
407
+
408
+ watch(
409
+ () => props.value,
410
+ (val) => {
411
+ let arr = Array.isArray(val) ? val : val ? [val] : [];
412
+ selectedValue.value = props.multiple ? [...arr] : [arr[0]];
413
+ if (props.data && props.data?.length > 0) {
414
+ selectedData.value = [...props.data];
415
+ }
416
+ },
417
+ {
418
+ immediate: true
419
+ }
420
+ );
421
+
422
+ return {
423
+ getSelection,
424
+ gridOptions,
425
+ loadData,
426
+ sohelpVxeGridRef,
427
+ DragOutlined,
428
+ refresh,
429
+ reload,
430
+ pageChangeEvent,
431
+ gridEvents,
432
+ menuEvents,
433
+ onToolbarButtonClick,
434
+ onCheckboxChange,
435
+ onCellClick,
436
+ onCheckboxAllChange,
437
+ onRadioChange,
438
+ selectedData,
439
+ selectedValue,
440
+ updateData,
441
+ initValue,
442
+ clear,
443
+ getTableData,
444
+ keywords,
445
+ Search,
446
+ getKeywordsPlaceholder,
447
+ propertiesMap,
448
+ clearRadioRow: () => {
449
+ sohelpVxeGridRef.value.clearRadioRow();
450
+ }
451
+ };
452
+ }
453
+ };
454
+ </script>
455
+
456
+ <style lang="scss" scoped>
457
+ .sohelp-vxe-grid {
458
+ width: 100%;
459
+ height: 100%;
460
+ box-sizing: border-box;
461
+ :deep(.vxe-grid) {
462
+ height: 100%;
463
+ width: 100%;
464
+ min-width: 100px;
465
+
466
+ .vxe-grid--layout-body-content-wrapper {
467
+ display: flex;
468
+ flex-direction: column;
469
+
470
+ .vxe-grid--toolbar-wrapper {
471
+ .vxe-toolbar {
472
+ box-sizing: border-box;
473
+ padding: 0 5px 5px 5px;
474
+ }
475
+ }
476
+
477
+ .vxe-grid--table-container {
478
+ flex: 1;
479
+ height: 100%;
480
+ .vxe-table {
481
+ height: 100%;
482
+ .vxe-table--render-wrapper {
483
+ height: 100%;
484
+ .vxe-table--layout-wrapper {
485
+ height: calc(100% - 10px);
486
+ .col--selected {
487
+ //去除单元格选中效果
488
+ box-shadow: none;
489
+ }
490
+ }
491
+ }
492
+ }
493
+ }
494
+ }
495
+ }
496
+ }
497
+
498
+ .drag-btn {
499
+ cursor: move;
500
+ font-size: 12px;
501
+ }
502
+
503
+ .vxe-body--row.sortable-ghost,
504
+ .vxe-body--row.sortable-chosen {
505
+ background-color: #dfecfb;
506
+ }
507
+
508
+ .search-wrap {
509
+ display: flex;
510
+ align-items: center;
511
+ justify-content: flex-start;
512
+ gap: 10px;
513
+ margin-right: 10px;
514
+ .search-box {
515
+ width: 200px;
516
+ }
517
+ }
518
+ </style>
@@ -0,0 +1,148 @@
1
+ <script setup>
2
+ import { computed, nextTick, ref } from "vue";
3
+ import SohelpVxeGrid from "../sohelp-vxe-grid/index.vue";
4
+
5
+ /**
6
+ * 组件属性定义
7
+ * @property {Array|String} modelValue - 当前绑定的值(支持单选或多选)
8
+ * @property {String} refid - 必填字段,标识引用ID
9
+ * @property {Boolean} multiple - 是否允许多选,默认为false
10
+ * @property {Object|Array} data - 已选中的数据对象或数组
11
+ * @property {String} labelField - 显示文本对应的字段名,默认"label"
12
+ * @property {String} valueField - 值字段名,默认"id"
13
+ */
14
+ const props = defineProps({
15
+ modelValue: {
16
+ type: [String, Array],
17
+ default: () => []
18
+ },
19
+ gridOptions: Object,
20
+ multiple: {
21
+ type: Boolean,
22
+ default: false
23
+ },
24
+ data: [Object, Array],
25
+ labelField: {
26
+ type: String,
27
+ default: "label"
28
+ },
29
+ valueField: {
30
+ type: String,
31
+ default: "id"
32
+ },
33
+ title: {
34
+ type: String,
35
+ default: "选择数据"
36
+ }
37
+
38
+ });
39
+ /**
40
+ * 创建一个ref对象,用于存储表格视图组件的引用
41
+ */
42
+ const tableRef = ref(null);
43
+
44
+ /**
45
+ * 定义事件发射器
46
+ * @event update:modelValue - 更新modelValue时触发
47
+ * @event update:data - 更新data时触发
48
+ * @event confirm - 用户确认选择时触发
49
+ */
50
+ const emit = defineEmits(["update:modelValue", "update:data", "confirm", "show"]);
51
+
52
+ // 控制弹窗是否可见的状态变量
53
+ const visible = ref(false);
54
+
55
+ /**
56
+ * 打开对话框
57
+ */
58
+ const showDialog = () => {
59
+ visible.value = true;
60
+ emit("show");
61
+ };
62
+
63
+ /**
64
+ * 计算属性:处理传入的数据格式统一转换为数组形式
65
+ * @returns {Array} 返回标准化后的数组数据
66
+ */
67
+ const _data = computed(() => {
68
+ return props.data?.constructor === Object ? [props.data] : props.data;
69
+ });
70
+
71
+ /**
72
+ * 关闭标签
73
+ * @param tag - 被关闭的标签项
74
+ */
75
+ const handleClose = (tag) => {
76
+ if (props.multiple) {
77
+ props.data.splice(props.data.indexOf(tag), 1);
78
+ } else {
79
+ emit("update:modelValue", null);
80
+ emit("update:data", null);
81
+ }
82
+ };
83
+
84
+ /**
85
+ * 取消操作并关闭弹窗
86
+ */
87
+ const cancel = () => {
88
+ visible.value = false;
89
+ };
90
+
91
+ /**
92
+ * 确认选择操作
93
+ * 根据multiple属性决定是单选还是多选模式,
94
+ * 并通过emit更新modelValue、data以及发送confirm事件
95
+ */
96
+ const confirm = () => {
97
+ const rows = tableRef.value.getSelection();
98
+ if (props.multiple) {
99
+ let _data = [];
100
+ for (let i = 0; i < rows.length; i++) {
101
+ let obj = {};
102
+ obj[props.valueField] = rows[i][props.valueField];
103
+ obj[props.labelField] = rows[i][props.labelField];
104
+ _data.push(obj);
105
+ }
106
+ emit("update:modelValue", _data.map((item) => item[props.valueField]));
107
+ emit("update:data", _data);
108
+ emit("confirm", rows);
109
+ } else {
110
+ emit("update:modelValue", rows.length > 0 ? rows[0][props.valueField] : null);
111
+ emit("update:data", rows[0]);
112
+ emit("confirm", rows[0]);
113
+ }
114
+ visible.value = false;
115
+
116
+ };
117
+
118
+ defineExpose({ $grid: tableRef });
119
+
120
+ </script>
121
+
122
+ <template>
123
+ <!-- 输入框组件,用于展示已选中的标签项,并提供打开选择弹窗的按钮 -->
124
+ <el-input clearable placeholder="请选择">
125
+ <!-- 前缀插槽:显示当前已选中项的标签列表 -->
126
+ <template #prefix>
127
+ <el-tag v-for="item in _data" :key="item.id" closable @close="handleClose(item)">{{ item[labelField] }}</el-tag>
128
+ </template>
129
+ <!-- 后缀插槽:添加按钮,点击后打开数据选择弹窗 -->
130
+ <template #append>
131
+ <el-button icon="Plus" @click="showDialog" />
132
+ </template>
133
+ </el-input>
134
+ <!-- 数据选择弹窗组件 -->
135
+ <ele-modal :title="title" v-model="visible" maxable>
136
+ <!-- 表格视图组件,用于展示可选项 -->
137
+ <sohelp-vxe-grid ref="tableRef" :gridOptions="gridOptions" />
138
+ <!-- 弹窗底部操作按钮区域 -->
139
+ <template #footer>
140
+ <el-button @click="cancel">取消</el-button>
141
+ <el-button type="primary" @click="confirm">确定</el-button>
142
+ </template>
143
+ </ele-modal>
144
+ </template>
145
+
146
+ <style scoped lang="scss">
147
+
148
+ </style>