@utogether/udp-core 1.0.1-beta.3 → 1.0.1-beta.31

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 (165) hide show
  1. package/build/plugins.ts +3 -3
  2. package/dist/{403-BuP9jvH9.js → 403-DdjDWbkf.js} +1 -1
  3. package/dist/{404-DfQk8kKl.js → 404-D9vF2gFz.js} +1 -1
  4. package/dist/{500-OgROWdiZ.js → 500-mVaDmUjL.js} +1 -1
  5. package/dist/{AuthorityInfo-q2ksfkWH.js → AuthorityInfo-DOUJ_Zrj.js} +1 -1
  6. package/dist/AuthorityInfo.vue_vue_type_style_index_0_lang-B12sAzqt.js +100 -0
  7. package/dist/{Company-DgqowAxc.js → Company-DY__kM9F.js} +3 -3
  8. package/dist/{CompanyPanel-BNb1rUhD.js → CompanyPanel-C5N8QcMA.js} +17 -17
  9. package/dist/{Department-Cl8CROSU.js → Department-DsuDZdy5.js} +3 -3
  10. package/dist/{DepartmentPanel-D5VkqKeP.js → DepartmentPanel-CdwI7Rzu.js} +25 -25
  11. package/dist/{DesignPanel-BGvEusHC.js → DesignPanel-B50-g0TL.js} +1 -1
  12. package/dist/{DesignPanel.vue_vue_type_style_index_0_lang-BQF1uQ7w.js → DesignPanel.vue_vue_type_style_index_0_lang-KV8JOZ6v.js} +28 -30
  13. package/dist/DictView-Be2Z5Obk.js +110 -0
  14. package/dist/InvOrganization-Lui1q3Ou.js +74 -0
  15. package/dist/Org-qO5ExsPN.js +39 -0
  16. package/dist/{Preview-BaGmXH7r.js → Preview-Dq4dfV2D.js} +2 -2
  17. package/dist/{ReportDefine-DkQdBErt.js → ReportDefine-DH3FvbS1.js} +1 -1
  18. package/dist/{ReportDesign-DzB_A_G6.js → ReportDesign-Bou01Jbr.js} +43 -43
  19. package/dist/{ReportQuery-DRcMb6ya.js → ReportQuery-BBkmPPSw.js} +1 -1
  20. package/dist/{ReportQueryFrom-CeA9xhR4.js → ReportQueryFrom-BCY8lTJ7.js} +1 -1
  21. package/dist/{ReportQueryFrom.vue_vue_type_style_index_0_lang-CgGtcs5V.js → ReportQueryFrom.vue_vue_type_style_index_0_lang-CpktcM8J.js} +1 -1
  22. package/dist/{ReportTemplate-qaiTMQuT.js → ReportTemplate-C_yJXxQ-.js} +28 -28
  23. package/dist/{Role-DsFulAjq.js → Role-CTatYsrC.js} +6 -6
  24. package/dist/{RoleAssign-DMRdocpa.js → RoleAssign-Cqt3CelK.js} +9 -9
  25. package/dist/{RolePanel-wXVysDHM.js → RolePanel-C3JMpNu8.js} +1 -1
  26. package/dist/{RolePanel-B9POS_pg.js → RolePanel-brKRJIhD.js} +1 -1
  27. package/dist/RolePanel.vue_vue_type_script_setup_true_lang-DD8u9pq8.js +132 -0
  28. package/dist/{RolePanel.vue_vue_type_script_setup_true_lang-CleVvkcY.js → RolePanel.vue_vue_type_script_setup_true_lang-i6Gq4r5B.js} +44 -38
  29. package/dist/{ScrollPanel.vue_vue_type_style_index_0_lang-DlXUs0j9.js → ScrollPanel.vue_vue_type_style_index_0_lang-CiWKyjm3.js} +23 -23
  30. package/dist/{Staff-Cq4V7ruC.js → Staff-Cd3twQ6Y.js} +3 -3
  31. package/dist/{StaffInfo-CJDKMbud.js → StaffInfo-DJp0a0qd.js} +1 -1
  32. package/dist/{StaffInfo.vue_vue_type_script_setup_true_lang-DQ4DL1KY.js → StaffInfo.vue_vue_type_script_setup_true_lang-Dp2AhJ4I.js} +16 -16
  33. package/dist/{StaffPanel-CG-uggdr.js → StaffPanel-B93hClzs.js} +1 -1
  34. package/dist/{StaffPanel.vue_vue_type_script_setup_true_lang-DAgN7zN2.js → StaffPanel.vue_vue_type_script_setup_true_lang-CXjUzq7n.js} +2 -2
  35. package/dist/{SysUser-kwnzRNdD.js → SysUser-BvI6vaqI.js} +2 -2
  36. package/dist/{SysUserPanel-DTlZf3vk.js → SysUserPanel-C9V8X-Ek.js} +1 -1
  37. package/dist/SysUserPanel.vue_vue_type_script_setup_true_lang-bMqTui07.js +343 -0
  38. package/dist/{SystemMenu-BVT0n-L2.js → SystemMenu-D4WME5d0.js} +27 -27
  39. package/dist/{UserInfo-BbTQ9Zat.js → UserInfo-D-AfdfJs.js} +1 -1
  40. package/dist/{UserInfo.vue_vue_type_style_index_0_lang-D_bpYDmI.js → UserInfo.vue_vue_type_style_index_0_lang-C-JQYIxe.js} +41 -39
  41. package/dist/{childView-BJbIhjmf.js → childView--WMSo-wH.js} +1 -1
  42. package/dist/{childView-DCsGFrG-.js → childView-1MTl6Kaj.js} +1 -1
  43. package/dist/childView.vue_vue_type_style_index_0_lang-B8Losc4Y.js +170 -0
  44. package/dist/{childView.vue_vue_type_style_index_0_lang-BCDxpVoD.js → childView.vue_vue_type_style_index_0_lang-BAVKNIXs.js} +1 -1
  45. package/dist/{code-rule-DePU6cdp.js → code-rule-D-RqrQB6.js} +42 -41
  46. package/dist/core.es.js +19 -10
  47. package/dist/{cron-task-DUM1SIGL.js → cron-task-D-X-KFZm.js} +11 -11
  48. package/dist/flow-task-B07st2aD.js +10 -0
  49. package/dist/{frameView-CEUTDtSm.js → frameView-MAW_-GHJ.js} +1 -1
  50. package/dist/index-Bc9vCX7z.js +2904 -0
  51. package/dist/{layoutView-PCjwVwkX.js → layoutView-De2QIEr2.js} +1639 -1629
  52. package/dist/{log-in-e7D5Ss1P.js → log-in-CpGqc33f.js} +5 -4
  53. package/dist/{log-out--RRncZhN.js → log-out-D1b4VRMZ.js} +30 -24
  54. package/dist/{login-log-CvVnyGi3.js → login-log-BNRXLeMi.js} +4 -3
  55. package/dist/login-rdZ0GPYc.js +249 -0
  56. package/dist/{lov-view-D8wwkxFJ.js → lov-view-Ao7LMspL.js} +5 -5
  57. package/dist/{menuInfo-B5JKVwrB.js → menuInfo-DmOcK6An.js} +1 -1
  58. package/dist/{menuInfo.vue_vue_type_style_index_0_lang-CcM9WX4n.js → menuInfo.vue_vue_type_style_index_0_lang-Ln-zFWV7.js} +121 -99
  59. package/dist/{pda-app-DIa1p1Ww.js → pda-app-DY63mQ2T.js} +202 -188
  60. package/dist/{resource-CCQ7Dd-5.js → resource-B21uV58T.js} +18 -18
  61. package/dist/{su-welcome-CLp9YaJa.js → su-welcome-DgjzJeDF.js} +122 -121
  62. package/dist/sys-config-DOtK2I32.js +370 -0
  63. package/dist/udp-core.css +1 -9
  64. package/dist/utogether-MlnyYtNS.js +4 -0
  65. package/index.ts +19 -6
  66. package/package.json +1 -1
  67. package/src/App.vue +65 -70
  68. package/src/api/http.ts +1 -4
  69. package/src/api/index.ts +5 -3
  70. package/src/api/user.ts +2 -2
  71. package/src/components/SuCharts/src/UserInfo.vue +3 -3
  72. package/src/components/SuScrollTree/ScrollPanel.vue +4 -9
  73. package/src/components/udp/content/index.vue +88 -0
  74. package/src/components/udp/form/form.vue +109 -0
  75. package/src/components/udp/{grid.vue → grid/index.vue} +524 -500
  76. package/src/components/udp/index.ts +4 -6
  77. package/src/components/udp/ut-stamp-badge/index.vue +272 -0
  78. package/src/components/udp/utils.ts +408 -379
  79. package/src/directives/permission/index.ts +1 -1
  80. package/src/layout/components/lay-navbar/index.vue +8 -6
  81. package/src/layout/components/lay-panel/index.vue +150 -150
  82. package/src/layout/components/lay-search/index.vue +1 -1
  83. package/src/layout/components/lay-select-org/index.vue +4 -9
  84. package/src/layout/components/lay-sidebar/horizontal.vue +8 -6
  85. package/src/layout/components/lay-sidebar/mixNav.vue +260 -258
  86. package/src/layout/components/lay-sidebar/sidebar-logo.vue +8 -12
  87. package/src/layout/components/lay-tag/index.vue +596 -625
  88. package/src/layout/hooks/useTag.ts +12 -18
  89. package/src/layout/types.ts +3 -2
  90. package/src/main.ts +115 -110
  91. package/src/plugins/i18n/en.ts +302 -291
  92. package/src/plugins/i18n/module/u-workflow.ts +1 -1
  93. package/src/plugins/i18n/zh.ts +362 -338
  94. package/src/plugins/vxe-table/index.ts +116 -53
  95. package/src/plugins/vxe-table/render.tsx +183 -57
  96. package/src/router/index.ts +101 -97
  97. package/src/router/modules/flow.ts +35 -0
  98. package/src/router/modules/remaining.ts +1 -26
  99. package/src/router/utils.ts +50 -7
  100. package/src/store/modules/app.ts +1 -3
  101. package/src/store/modules/multiTags.ts +15 -14
  102. package/src/store/modules/permission.ts +25 -15
  103. package/src/store/modules/system.ts +1 -3
  104. package/src/style/button.scss +85 -85
  105. package/src/style/login.css +1 -1
  106. package/src/style/vxetable.scss +348 -258
  107. package/src/utils/authority/index.ts +1 -1
  108. package/src/utils/index.ts +3 -1
  109. package/src/utils/propTypes.ts +1 -6
  110. package/src/utils/{http → udp/http}/index.ts +27 -30
  111. package/src/utils/{http → udp/http}/types.d.ts +2 -6
  112. package/src/views/login/login-view.vue +6 -20
  113. package/src/views/organization/company/CompanyPanel.vue +259 -259
  114. package/src/views/organization/department/DepartmentPanel.vue +6 -20
  115. package/src/views/organization/inv-org/InvOrganization.vue +22 -7
  116. package/src/views/organization/org/Org.vue +9 -5
  117. package/src/views/system/cron/cron-task.vue +2 -12
  118. package/src/views/system/menu/SystemMenu.vue +185 -197
  119. package/src/views/system/menu/menuInfo.vue +384 -372
  120. package/src/views/system/role/AuthorityInfo.vue +19 -15
  121. package/src/views/system/role/Role.vue +1 -5
  122. package/src/views/system/role/RolePanel.vue +11 -2
  123. package/src/views/system/role/UserInfo.vue +11 -9
  124. package/src/views/system/role-assign/RoleAssign.vue +2 -2
  125. package/src/views/system/role-assign/RolePanel.vue +12 -9
  126. package/src/views/system/sys/sys-config.vue +70 -21
  127. package/src/views/system/sysUser/SysUserPanel.vue +132 -62
  128. package/src/views/uapp/pda/pda-app.vue +48 -16
  129. package/src/views/udev/coderule/code-rule.vue +132 -121
  130. package/src/views/udev/dict/DictView.vue +118 -106
  131. package/src/views/udev/dict/childView.vue +71 -111
  132. package/src/views/udev/lov/childView.vue +1 -7
  133. package/src/views/udev/lov/lov-view.vue +91 -91
  134. package/src/views/ufile/aggregation/File.vue +5 -5
  135. package/src/views/ufile/file/water-mark.vue +14 -14
  136. package/src/views/uhome/components/menu-favorite.vue +314 -331
  137. package/src/views/uhome/su-welcome.vue +3 -3
  138. package/src/views/ulogin/login.vue +19 -12
  139. package/src/views/upms/interface/log-in.vue +2 -8
  140. package/src/views/upms/interface/log-out.vue +2 -8
  141. package/src/views/upms/user/login-log.vue +2 -8
  142. package/src/views/urpt/design/DesignPanel.vue +16 -35
  143. package/src/views/urpt/design/Preview.vue +1 -0
  144. package/src/views/urpt/design/ReportDesign.vue +17 -23
  145. package/src/views/urpt/static-resource/resource.vue +3 -3
  146. package/src/views/urpt/template/ReportTemplate.vue +7 -7
  147. package/src/views/utask/flow-task.vue +18 -0
  148. package/types/global.d.ts +4 -9
  149. package/vite.config.ts +2 -1
  150. package/dist/AuthorityInfo.vue_vue_type_style_index_0_lang-Bwsf6lMH.js +0 -102
  151. package/dist/DictView-BnxfaOBv.js +0 -96
  152. package/dist/InvOrganization-5y79ZLdY.js +0 -66
  153. package/dist/Org-2oBAXN2r.js +0 -35
  154. package/dist/RolePanel.vue_vue_type_script_setup_true_lang-t6S_0zmJ.js +0 -126
  155. package/dist/SysUserPanel.vue_vue_type_script_setup_true_lang-BW6PlGjM.js +0 -288
  156. package/dist/childView.vue_vue_type_style_index_0_lang-CDtsalCm.js +0 -187
  157. package/dist/index-ZdgOD7cF.js +0 -3399
  158. package/dist/login-B1CjWVKu.js +0 -252
  159. package/dist/sys-config-BBmf_SqF.js +0 -277
  160. package/dist/utogether-Bkptx2lB.js +0 -182
  161. package/src/components/udp/form-upload.vue +0 -183
  162. package/src/components/udp/lov.vue +0 -410
  163. package/src/components/udp/modal-form.vue +0 -180
  164. package/src/components/udp/modal-grid.vue +0 -297
  165. package/src/utils/udp/useRender.ts +0 -420
@@ -1,297 +0,0 @@
1
- <!--
2
- * @Author: wei.li
3
- * @Date: 2021-11-24 17:53:49
4
- * @LastEditors: levi7754 levi7754@163.com
5
- * @LastEditTime: 2025-07-22 11:42:46
6
- * @Description: 共用弹框
7
- -->
8
- <template>
9
- <div>
10
- <vxe-modal
11
- v-model="showModal"
12
- :title="title"
13
- :width="width"
14
- :height="height"
15
- :loading="data.loading"
16
- :show-footer="showFooter"
17
- resize
18
- destroy-on-close
19
- @close="close"
20
- >
21
- <template #default>
22
- <slot />
23
- <vxe-grid
24
- ref="xGrid"
25
- v-bind="data"
26
- resizable
27
- v-on="attrs.events || {}"
28
- @edit-activated="onEditActived"
29
- @toolbarButtonClick="toolbarButtonClick"
30
- @toolbarToolClick="toolbarButtonClick"
31
- @cell-click="cellClick"
32
- />
33
- </template>
34
- <template #footer>
35
- <slot name="bottom" />
36
- <ut-button icon="ri-close-line" status="warning" content="cancel" @tap="close" />
37
- <ut-button icon="ri-save-3-line" content="confirm" @tap="onConfirm" />
38
- </template>
39
- </vxe-modal>
40
- </div>
41
- </template>
42
- <script lang="ts">
43
- export default {
44
- name: 'UtModalGrid'
45
- };
46
- </script>
47
- <script lang="ts" setup>
48
- // @ts-nocheck
49
- import { onBeforeMount, reactive, ref, toRaw, getCurrentInstance, useAttrs } from 'vue';
50
- import { useI18n } from 'vue-i18n';
51
- import { VxeGridProps } from 'vxe-table';
52
- import { formatGridItems, i18nColums, formatRules, successMessage, warnMessage } from '@utogether/utils';
53
- import { clone, isFunction } from 'xe-utils';
54
- import {
55
- queryAll,
56
- query,
57
- del,
58
- save,
59
- footerSumMethod,
60
- getToolBarConfig,
61
- onCheckMethod,
62
- getAttrs
63
- } from './utils';
64
-
65
- // import type { IRecord, IFormItemProps, ITableColProps } from '../../types';
66
-
67
- export interface IProps {
68
- checkMethod?: Function;
69
- columns: Array<ITableColProps>; // 列表行
70
- defaultValue?: IRecord;
71
- defaultParams?: IRecord;
72
- gridOptions?: IRecord;
73
- auth?: IRecord;
74
- url?: string; // 查询服务路径
75
- submitUrl?: string; // 确认
76
- checkRowKeys?: Array<string>; // 默认选中列表
77
- items?: Array<IFormItemProps>; // 查询条件
78
- title?: string; // 标题
79
- width?: number | string;
80
- height?: number;
81
- editable?: boolean; // 可编辑
82
- needExport?: boolean; // 是否需要导出
83
- showFooter?: boolean; // 显示底部按钮
84
- addChild?: boolean; // 可编辑
85
- autoClose?: boolean; // 组件自主关闭
86
- autoLoad?: boolean; // 是否自动加载查询数据
87
- }
88
- const attrs: IRecord = getAttrs(useAttrs());
89
-
90
- const props = withDefaults(defineProps<IProps>(), {
91
- gridOptions: () => {
92
- return {};
93
- },
94
- items: () => [],
95
- columns: () => [],
96
- checkRowKeys: () => [],
97
- addChild: false,
98
- editable: true,
99
- showFooter: false,
100
- autoLoad: true,
101
- needExport: true,
102
- autoClose: true,
103
- width: '520',
104
- height: 420,
105
- title: '数据记录',
106
- url: '',
107
- submitUrl: ''
108
- });
109
-
110
- const showModal = ref(false);
111
-
112
- const xGrid = ref(null);
113
- const instance = getCurrentInstance()!;
114
-
115
- const hasAuthority = instance.appContext.config.globalProperties.$hasAuthority;
116
- const serviceApi = instance.appContext.config.globalProperties.$serviceApi;
117
- const $mode = instance.appContext.config.globalProperties.$mode;
118
-
119
- const { t } = useI18n();
120
-
121
- /**
122
- * @description: colum 统一添加国家化
123
- */
124
- const getColumns = () => {
125
- const col = props.columns.map(m => {
126
- if (!props.editable) {
127
- m.editRender = { enabled: false };
128
- } else if (!m.type && !m.editRender && props.editable && !!m.editable) {
129
- m.editRender = { name: 'VxeInput' };
130
- }
131
- return m;
132
- });
133
- return i18nColums(col);
134
- };
135
-
136
- const getItems = () => {
137
- if (!props.items.length) return props.items;
138
- return formatGridItems(clone(props.items, true));
139
- };
140
-
141
- /**
142
- * @description: 根据items 获取必填选
143
- */
144
- const getRules = () => {
145
- if (!props.columns.length) return {};
146
- return formatRules(props.columns, t);
147
- };
148
-
149
- const data = reactive<VxeGridProps>({
150
- loading: false,
151
- border: true,
152
- pagerConfig: {},
153
- formConfig: {},
154
- toolbarConfig: { enabled: false },
155
- height: 'auto',
156
- editConfig: {},
157
- rowConfig: { keyField: '_X_ROW_KEY' },
158
- editRules: getRules(),
159
- proxyConfig: {
160
- form: true, // 查询是需要启用表单代理
161
- autoLoad: props.autoLoad,
162
- ajax: {
163
- queryAll: ({ form }) => queryAll(props, serviceApi, form),
164
- query: ({ page, form }) => query(props, form, page, serviceApi, $mode),
165
- delete: ({ body: { removeRecords } }) => del(serviceApi, removeRecords, props),
166
- save: ({ body }) => Promise.all(save(serviceApi, body, props))
167
- }
168
- },
169
- checkboxConfig: {
170
- checkMethod: ({ row }) => onCheckMethod(row, props),
171
- checkRowKeys: props.checkRowKeys
172
- },
173
- columns: getColumns(),
174
- ...props.gridOptions
175
- });
176
-
177
- // 确认数据
178
- const onConfirm = async () => {
179
- let records = null;
180
- const type = props.columns[0].type;
181
- if (type === 'checkbox') {
182
- records = xGrid.value.getCheckboxRecords();
183
- } else if (type === 'radio') {
184
- records = xGrid.value.getRadioRecord();
185
- } else {
186
- records = xGrid.value.getTableData().fullData;
187
- }
188
- if (type === 'checkbox' && !records.length && !props.addChild) {
189
- return warnMessage(t('message.selectedRecord'));
190
- } else if (type === 'radio' && !records) {
191
- return warnMessage(t('message.selectedRecord'));
192
- }
193
- if (isFunction(attrs.beforeConfirm) && !attrs.beforeConfirm(records)) return;
194
- const { submitUrl } = props;
195
- // 服务submitUrl
196
- if (submitUrl) {
197
- showLoading();
198
- let res;
199
- try {
200
- records.forEach(record => Object.assign(record, props.defaultParams));
201
- res = await serviceApi.post(submitUrl, records);
202
- } finally {
203
- res && emit('confirm', res);
204
- res && successMessage(t('message.operateSuccess'));
205
- close();
206
- hiddenLoading();
207
- }
208
- } else {
209
- props.autoClose && close();
210
- emit('confirm', records);
211
- }
212
- };
213
- // 请求数据
214
- const refreshData = () => {
215
- xGrid.value.commitProxy('query');
216
- };
217
- const refreshColumn = () => {
218
- data.editRules = getRules();
219
- xGrid.value.refreshColumn();
220
- };
221
- const getInstance = () => {
222
- return toRaw(xGrid.value);
223
- };
224
- const cellClick = ({ row }) => {
225
- const type = props.columns[0].type;
226
- if (type === 'checkbox') {
227
- xGrid.value.setCheckboxRow(row, true);
228
- } else if (type === 'radio') {
229
- xGrid.value.setRadioRow(row);
230
- }
231
- };
232
- // 单元格被激活编辑激活回调
233
- const onEditActived = data => {
234
- emit('actived', data);
235
- };
236
- const toolbarButtonClick = ({ code }) => {
237
- emit('buttonClick', code);
238
- };
239
- const showLoading = () => {
240
- data.loading = true;
241
- };
242
- const hiddenLoading = () => {
243
- data.loading = false;
244
- };
245
- const emit = defineEmits<{
246
- (e: 'close'): void;
247
- (e: 'confirm', record: any): void;
248
- (e: 'actived', record: any): void;
249
- (e: 'buttonClick', code: string): void;
250
- }>();
251
- // 关闭弹框
252
- const close = () => {
253
- if (isFunction(attrs.beforeClose) && !attrs.beforeClose()) return;
254
- showModal.value = false;
255
- emit('close');
256
- };
257
-
258
- /**
259
- * @description: 设置grid参数
260
- */
261
-
262
- const setGridConfig = () => {
263
- // 查询
264
- if (props.items.length) {
265
- data.formConfig = {
266
- titleWidth: 100,
267
- titleAlign: 'right',
268
- items: getItems(),
269
- rules: formatRules(props.items, t),
270
- validConfig: { showMessage: false }
271
- };
272
- }
273
- // tool bar
274
- const obj = getToolBarConfig(data, props, attrs, hasAuthority);
275
- Object.assign(data, obj);
276
-
277
- // 合计方法
278
- if (attrs.mergeFooter) {
279
- data.showFooter = true;
280
- data.footerMethod = ({ columns, data }) => footerSumMethod({ columns, data }, attrs.mergeFooter);
281
- }
282
- };
283
-
284
- // 子组件需对外暴露方法
285
- defineExpose({
286
- refreshData,
287
- refreshColumn,
288
- getInstance,
289
- showLoading,
290
- hiddenLoading,
291
- close
292
- });
293
- onBeforeMount(() => {
294
- showModal.value = true;
295
- setGridConfig();
296
- });
297
- </script>
@@ -1,420 +0,0 @@
1
- /*
2
- * @Author: wei.li
3
- * @Date: 2021-11-29 18:18:00
4
- * @LastEditors: levi7754 levi7754@163.com
5
- * @LastEditTime: 2025-04-18 11:09:01
6
- * @Description: file content
7
- */
8
-
9
- declare interface Fn<T = any, R = T> {
10
- (...arg: T[]): R;
11
- }
12
-
13
- interface IAttrs {
14
- disabled?: boolean;
15
- defaultValue?: string;
16
- code?: string;
17
- [x: string]: any;
18
- }
19
-
20
- interface IEvents {
21
- change?: Fn;
22
- clear?: Fn;
23
- blur?: Fn;
24
- focus?: Fn;
25
- input?: Fn;
26
- filterMethod?: Fn;
27
- }
28
- import { isObject, isEmpty, isString, isFunction } from 'xe-utils';
29
- import { storageLocal } from '@utogether/utils';
30
-
31
- export const useRender = () => {
32
- const optionProps = { value: 'dictCode', label: 'dictName' };
33
- /**
34
- * @description: 字典下拉渲染
35
- * @param {*} attrs string|object string时默认未code
36
- * @param {*} methods fn|object 回调函数 fn默认为onChange
37
- */
38
- const renderDict = (attrs: IAttrs | string, methods?) => {
39
- const events = getEvents(methods);
40
- let props = {
41
- clearable: true,
42
- disabled: false,
43
- showValue: false,
44
- placeholder: null
45
- };
46
- let defaultValue;
47
- let dictCode;
48
- if (isObject(attrs)) {
49
- props = Object.assign(props, attrs);
50
- defaultValue = attrs.defaultValue;
51
- dictCode = attrs?.code;
52
- // keyValue = attrs?.keyValue;
53
- } else {
54
- dictCode = attrs;
55
- }
56
- const opts = storageLocal.getItem('kLov')[dictCode]?.children;
57
- const options = opts ? opts.filter(opt => opt.enabled === '1') : [];
58
- return {
59
- name: '#select',
60
- optionProps,
61
- options,
62
- props,
63
- defaultValue,
64
- events
65
- };
66
- };
67
- /**
68
- * @description: 远程搜索下拉选择-编辑
69
- * @param {*} attrs attrs
70
- * @return {*}
71
- */
72
- const renderSelect = (attrs, methods?) => {
73
- const events = getEvents(methods);
74
- return {
75
- name: '#SuSelect',
76
- optionProps: attrs?.optionProps || { label: 'label', value: 'value' },
77
- props: attrs?.props,
78
- options: attrs?.options || [],
79
- events
80
- };
81
- };
82
- /**
83
- * @description: 查询关联了用户的员工
84
- * @param {*} attr '渲染器属性'
85
- * @param {*} callback 回调函数
86
- * @return {*} 渲染组件
87
- */
88
- const renderUser = (attr?, callback?) => {
89
- const attrs = {
90
- optionProps: { extLabel: 'userName', value: 'employeeName' },
91
- props: {
92
- attrs: { disabled: attr?.disabled },
93
- disabled: attr?.disabled,
94
- defaultValue: attr?.defaultValue,
95
- mapField: attr?.mapField,
96
- code: 'SYS037',
97
- url: '/uums/employee/listEmployeeIsUser',
98
- fetchField: 'employeeName'
99
- }
100
- };
101
- return renderSelect(attrs, callback);
102
- };
103
- /**
104
- * @description: 系统用户下拉
105
- * @param {*} options 映射字段
106
- * @return {*}
107
- */
108
- const renderSysUser = (options?) => {
109
- const attrs = {
110
- optionProps: { extLabel: 'userName', value: 'name' },
111
- props: {
112
- code: 'sys/listUsers',
113
- url: '/uums/user',
114
- fetchField: 'name',
115
- mapField: options?.mapField
116
- }
117
- };
118
- return renderSelect(attrs);
119
- };
120
-
121
- /**
122
- * @description: 查询库存组织
123
- * @param {*} name '渲染器属性'
124
- * @param {*} callback 回调函数
125
- * @return {*} 渲染组件
126
- */
127
- const renderInvOrg = (attrs?, methods?) => {
128
- const optionProps = {
129
- label: 'organizationName',
130
- value: attrs?.field || 'organizationName'
131
- };
132
- const props = {
133
- mapField: {},
134
- defaultParams: attrs?.defaultParams,
135
- url: '/uums/cusOrganization',
136
- fetchField: 'organizationName'
137
- };
138
- const mapField = {
139
- organizationId: 'id',
140
- organizationCode: 'organizationCode'
141
- };
142
- Object.assign(props.mapField, mapField, attrs?.mapField || {});
143
- return { name: '#SuSelect', props, optionProps, options: [], methods };
144
- };
145
- /**
146
- * @description: 查询业务单元
147
- * @param {*} name '渲染器属性'
148
- * @param {*} callback 回调函数
149
- * @return {*} 渲染组件
150
- */
151
- const renderBU = (attrs?, methods?) => {
152
- const optionProps = {
153
- label: 'orgName',
154
- value: attrs?.field || 'orgName'
155
- };
156
- const props = {
157
- mapField: {},
158
- defaultParams: attrs?.defaultParams,
159
- url: '/uums/org',
160
- fetchField: 'orgName'
161
- };
162
- const mapField = { orgId: 'id', orgCode: 'orgCode' };
163
- Object.assign(props.mapField, mapField, attrs?.mapField || {});
164
- return { name: '#SuSelect', props, optionProps, options: [], methods };
165
- };
166
- /**
167
- * @description: item input渲染器
168
- * @param {*} name 渲染器名称
169
- * @param {*} props 渲染的参数(请查看目标渲染的 Props)
170
- * @return {*} item 渲染器
171
- */
172
- const renderInput = (attrs?, methods?) => {
173
- const props = Object.assign({ disabled: false }, attrs);
174
- const defaultValue = props?.defaultValue;
175
- return {
176
- name: 'VxeInput',
177
- props,
178
- defaultValue,
179
- events: getEvents(methods)
180
- };
181
- };
182
- /**
183
- * @description: item input渲染器
184
- * @param {*} name 渲染器名称
185
- * @param {*} props 渲染的参数(请查看目标渲染的 Props)
186
- * @return {*} item 渲染器
187
- */
188
- const renderTextarea = (attrs?, methods?) => {
189
- const props = Object.assign({ disabled: false, rows: 3 }, attrs);
190
- const defaultValue = props?.defaultValue;
191
- return {
192
- name: 'VxeTextarea',
193
- props,
194
- defaultValue,
195
- events: getEvents(methods)
196
- };
197
- };
198
- /**
199
- * @description: checkbox
200
- * @param {*} attrs
201
- * @return {*} checkbox渲染器
202
- */
203
- const renderCheckBox = (attrs, methods?) => {
204
- const name = 'VxeCheckbox';
205
- const { defaultValue, options, props } = commonProps(attrs);
206
- return { name, defaultValue, options, props, events: getEvents(methods) };
207
- };
208
- /**
209
- * @description: radio
210
- * @param {*} attrs
211
- * @param {*} methods 事件
212
- * @return {*} radio渲染器
213
- */
214
- const renderRadio = (attrs: string | IAttrs, methods?) => {
215
- const name = 'VxeRadio';
216
- const { defaultValue, options, props } = commonProps(attrs);
217
- return { name, defaultValue, options, props, events: getEvents(methods) };
218
- };
219
- const commonProps = (attrs: string | IAttrs) => {
220
- let props = { disabled: false };
221
- let defaultValue;
222
- const dictData = storageLocal.getItem('kLov');
223
- let code = '';
224
- if (isObject(attrs)) {
225
- defaultValue = attrs.defaultValue;
226
- code = attrs.code!;
227
- props = Object.assign(props, attrs || {});
228
- } else if (isString(attrs)) {
229
- code = attrs;
230
- }
231
- const options = code
232
- ? dictData[code]?.children.map(m => {
233
- return { label: m.dictName, value: m.dictCode };
234
- })
235
- : [];
236
- return { props, defaultValue, options };
237
- };
238
- /**
239
- * @description: 数值录入
240
- * @param {*} attrs 渲染的参数(请查看目标渲染的props)
241
- * @param {*} methods 渲染目标的events,
242
- * @return {*} editRender
243
- */
244
- const renderNumber = (attrs?, methods?) => {
245
- const events = getEvents(methods);
246
- const props = Object.assign(
247
- { type: 'number', clearable: true, min: 0, controls: false },
248
- attrs || {}
249
- );
250
-
251
- return {
252
- name: 'VxeInput',
253
- props,
254
- defaultValue: attrs?.defaultValue,
255
- events
256
- };
257
- };
258
- /**
259
- * @description: 时间日期
260
- * @param {*} attrs 渲染的参数(请查看目标渲染的props)
261
- * @param {*} methods 渲染目标的events,
262
- * @return {*} editRender
263
- */
264
- const renderDate = (attrs?, methods?) => {
265
- const events = getEvents(methods);
266
- const valueFormat = 'yyyy-MM-dd HH:mm:ss';
267
- const defaultValue = attrs?.defaultValue;
268
- const prop = { type: 'date', valueFormat, clearable: true };
269
- const props = Object.assign(prop, attrs || {});
270
- return { name: 'VxeInput', props, defaultValue, events };
271
- };
272
- /**
273
- * @description: 值集视图
274
- * @param {*} attrs 渲染的参数
275
- * @param {*} methods 渲染目标的events,
276
- * @return {*} editRender
277
- */
278
- const renderLov = (attrs, methods?) => {
279
- const events = getEvents(methods);
280
- const props = Object.assign({}, attrs || {});
281
- return { name: '#lov', props, events };
282
- };
283
- /**
284
- * @description: 本地下拉选择
285
- * @param {*} attrs 同ElSelect
286
- * @param {*} methods 事件, 默认为change事件
287
- * @return {*}
288
- */
289
- const renderSelectLocal = (attrs, methods?) => {
290
- const events = getEvents(methods);
291
- const optionProps = attrs?.optionProps || {
292
- label: 'label',
293
- value: 'value'
294
- };
295
- const props = Object.assign({ clearable: true, disabled: false, showValue: false }, attrs || {});
296
- console.log('itemRender');
297
- return {
298
- name: '#select',
299
- optionProps,
300
- options: attrs?.options || [],
301
- props,
302
- events
303
- };
304
- };
305
- /**
306
- * @description: 渲染成switch
307
- * @param {*} attrs 请查看目标渲染的props
308
- * @param {*} methods 请查看目标渲染的event
309
- * @return {*} switchRender
310
- */
311
- const renderSwitch = (attrs?: string | IAttrs, methods?) => {
312
- let props = {
313
- openLabel: '是',
314
- closeLabel: '否',
315
- openValue: 'Y',
316
- closeValue: 'N'
317
- };
318
- let defaultValue = 'Y';
319
- if (isObject(attrs) && !isFunction(attrs)) {
320
- props = Object.assign(props, attrs || {});
321
- defaultValue = attrs.defaultValue || defaultValue;
322
- } else if (!isEmpty(attrs) && isString(attrs)) {
323
- defaultValue = attrs;
324
- props = Object.assign(props, { defaultValue });
325
- }
326
- // @ts-ignore
327
- const events = isFunction(attrs) ? getEvents(attrs) : getEvents(methods);
328
- return { name: 'VxeSwitch', props, defaultValue, events };
329
- };
330
- /**
331
- * @description: 表格渲染el-tag组件
332
- * @param {*} code 数据字典code
333
- * @param {*} tagMap 渲染tag对应的type {1: 'success'}
334
- * @return {*} table cellRender
335
- */
336
- const renderCellTag = (code, tagMap) => {
337
- return { name: '#tag', props: { code, tagMap } };
338
- };
339
- /**
340
- * @description: cell渲染成el-switch
341
- * @param {*} attrs 请查看目标渲染的props
342
- * @param {*} methods 请查看目标渲染的event
343
- * @return {*} cellRender
344
- */
345
- const renderEnabled = (options?, methods?) => {
346
- const props: IAttrs = {
347
- openLabel: '启用',
348
- closeLabel: '禁用',
349
- openValue: '1',
350
- closeValue: '0',
351
- defaultValue: '1'
352
- };
353
- if (!isFunction(options) && isObject(options)) {
354
- Object.assign(props, options);
355
- }
356
- const fun = isFunction(options) ? options : methods;
357
- return renderSwitch(props, fun);
358
- // return { name: "#switch", props, events };
359
- };
360
- /**
361
- * icon选择器
362
- * @returns render 函数
363
- */
364
- const renderIconSelect = () => {
365
- return { name: '#iconSelect' };
366
- };
367
- /**
368
- * 树形选择器
369
- * @param sourceData 展示数据
370
- * @param props 请查看element plus的TreeSelect渲染的props
371
- * @param events 事件
372
- * @returns render 函数
373
- */
374
- const renderTreeSelect = (sourceData: IRecord[] = [], props = {}, events?) => {
375
- return { name: '#treeSelect', sourceData, props, events };
376
- };
377
-
378
- const getEvents = (methods: IEvents | Fn) => {
379
- let events: any = {};
380
- if (isObject(methods) && !isFunction(methods)) {
381
- events = {
382
- change: methods?.change || cb,
383
- blur: methods?.blur || cb,
384
- focus: methods?.focus || cb,
385
- input: methods?.input || cb,
386
- clear: methods?.clear || cb,
387
- filterMethod: methods?.filterMethod
388
- };
389
- } else if (methods) {
390
- events = { change: methods };
391
- }
392
- return events;
393
- };
394
-
395
- function cb() {}
396
- // 回调函数
397
- // const callback = (e) => cb && cb(e);
398
-
399
- return {
400
- renderDict,
401
- renderSelect,
402
- renderInput,
403
- renderTextarea,
404
- renderCheckBox,
405
- renderRadio,
406
- renderUser,
407
- renderSysUser,
408
- renderInvOrg,
409
- renderBU,
410
- renderNumber,
411
- renderLov,
412
- renderSelectLocal,
413
- renderDate,
414
- renderSwitch,
415
- renderCellTag,
416
- renderEnabled,
417
- renderIconSelect,
418
- renderTreeSelect
419
- };
420
- };