@utogether/udp-core 1.0.0 → 1.0.1-beta.10

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 (201) hide show
  1. package/build/plugins.ts +39 -26
  2. package/dist/{403-B1R-4vXw.js → 403-Ctxjn4q8.js} +9 -8
  3. package/dist/{404-fXPl8csw.js → 404-W5yzyiZ9.js} +15 -14
  4. package/dist/{500-eI5842YB.js → 500-DXuGEOm4.js} +11 -10
  5. package/dist/{AuthorityInfo-CfVH6PaB.js → AuthorityInfo-C2tflCt8.js} +1 -1
  6. package/dist/AuthorityInfo.vue_vue_type_style_index_0_lang-SVgy3HX7.js +100 -0
  7. package/dist/{AuthorityPanel-BaLMwMgW.js → AuthorityPanel-BeBNiwqc.js} +1 -1
  8. package/dist/{AuthorityPanel.vue_vue_type_style_index_0_lang-C_bkqLD9.js → AuthorityPanel.vue_vue_type_style_index_0_lang-CIYmnP9-.js} +6 -6
  9. package/dist/{Company-CYC9Avfz.js → Company-PLez5GoH.js} +3 -3
  10. package/dist/{CompanyPanel-B4MzoqN_.js → CompanyPanel-CIGaQooL.js} +20 -20
  11. package/dist/{Department-B4BNSiYx.js → Department-B9wLsXFm.js} +3 -3
  12. package/dist/{DepartmentPanel-zJO89L2O.js → DepartmentPanel-DSM4lTaz.js} +23 -23
  13. package/dist/{DesignPanel-S8P0J97f.js → DesignPanel-B6a9wW_A.js} +1 -1
  14. package/dist/{DesignPanel.vue_vue_type_style_index_0_lang-DW-_Vqrr.js → DesignPanel.vue_vue_type_style_index_0_lang-DtHfoDQk.js} +28 -30
  15. package/dist/DictView-DhFbQxdJ.js +110 -0
  16. package/dist/{InvOrganization-MuM2jtsG.js → InvOrganization-D90AbR3b.js} +2 -2
  17. package/dist/Org-DxBkYabD.js +39 -0
  18. package/dist/{Preview-CRyiwUIR.js → Preview-BFtRpBxw.js} +1 -1
  19. package/dist/{ReportDefine-WZYIx8Sm.js → ReportDefine-BIa2QryC.js} +1 -1
  20. package/dist/{ReportDesign-D-7GKgpb.js → ReportDesign-CnyjI-WD.js} +44 -44
  21. package/dist/{ReportQuery-BIIJny6w.js → ReportQuery-BiK7yEhV.js} +5 -5
  22. package/dist/{ReportQueryFrom-OoUl7N2O.js → ReportQueryFrom-C2rqdFTm.js} +1 -1
  23. package/dist/{ReportQueryFrom.vue_vue_type_style_index_0_lang-B878fgj8.js → ReportQueryFrom.vue_vue_type_style_index_0_lang-Ba9HLnXQ.js} +6 -5
  24. package/dist/{ReportTemplate-Cfeq9US-.js → ReportTemplate-DdkLscP3.js} +30 -30
  25. package/dist/{Role-BwTV2QMH.js → Role-BrsxgK8D.js} +6 -6
  26. package/dist/{RoleAssign-De1JjOun.js → RoleAssign-DiqwJqDa.js} +8 -8
  27. package/dist/{RolePanel-pUBXsqCM.js → RolePanel-BDusGyo7.js} +1 -1
  28. package/dist/{RolePanel-E3RcdByM.js → RolePanel-Dqx5dI3f.js} +1 -1
  29. package/dist/RolePanel.vue_vue_type_script_setup_true_lang-2Z1q_5uW.js +132 -0
  30. package/dist/{RolePanel.vue_vue_type_script_setup_true_lang-B2pQwHb0.js → RolePanel.vue_vue_type_script_setup_true_lang-B5lUnaMI.js} +40 -34
  31. package/dist/{ScrollPanel.vue_vue_type_style_index_0_lang-vMR1fBi0.js → ScrollPanel.vue_vue_type_style_index_0_lang-vSP23fEq.js} +23 -23
  32. package/dist/{Staff-Czm7A8vI.js → Staff-Cwi9LQiZ.js} +3 -3
  33. package/dist/StaffInfo-XjVtyaMv.js +4 -0
  34. package/dist/{StaffInfo.vue_vue_type_style_index_0_lang-DMTL7KCh.js → StaffInfo.vue_vue_type_script_setup_true_lang-wSrAuyet.js} +16 -16
  35. package/dist/{StaffPanel-CHk60LEz.js → StaffPanel-C-wYcFdv.js} +1 -1
  36. package/dist/{StaffPanel.vue_vue_type_script_setup_true_lang-iPKLb5wG.js → StaffPanel.vue_vue_type_script_setup_true_lang-DZNArmnC.js} +46 -49
  37. package/dist/{SysUser-BGwbttRn.js → SysUser-O4tvr-Ur.js} +2 -2
  38. package/dist/{SysUserPanel-BCbKoLKt.js → SysUserPanel-B853docZ.js} +1 -1
  39. package/dist/SysUserPanel.vue_vue_type_script_setup_true_lang-DhiYYC97.js +294 -0
  40. package/dist/{SystemMenu-BkqZSDKl.js → SystemMenu-CXR6mrXr.js} +52 -50
  41. package/dist/{UserInfo-BsyAcT2d.js → UserInfo-BkP8pE2a.js} +1 -1
  42. package/dist/{UserInfo.vue_vue_type_style_index_0_lang-D0-KDxAh.js → UserInfo.vue_vue_type_style_index_0_lang-D4r_umjV.js} +38 -36
  43. package/dist/{childView-CyuLTUqC.js → childView-D0HwbgDT.js} +1 -1
  44. package/dist/{childView-CF83nhxb.js → childView-TRqUkSDC.js} +1 -1
  45. package/dist/{childView.vue_vue_type_style_index_0_lang-CNSgGda3.js → childView.vue_vue_type_style_index_0_lang-BzISq0Jf.js} +43 -43
  46. package/dist/{childView.vue_vue_type_style_index_0_lang-Cch4lE-i.js → childView.vue_vue_type_style_index_0_lang-DQRgNsJY.js} +1 -1
  47. package/dist/{code-rule-Bz-gnktN.js → code-rule-BV7PQWhK.js} +13 -14
  48. package/dist/core.es.js +13 -10
  49. package/dist/{cron-task-CIifSUdW.js → cron-task-9ZS9bi7K.js} +11 -11
  50. package/dist/{frameView-_d2mqjjQ.js → frameView-DE83AN50.js} +15 -14
  51. package/dist/img/l_img.svg +1 -1
  52. package/dist/img/minicolors.png +0 -0
  53. package/dist/img/v_img.svg +1 -1
  54. package/dist/index-DVARtten.js +2623 -0
  55. package/dist/{layoutView-DLKVepB8.js → layoutView-D1U-c4By.js} +730 -724
  56. package/dist/{login-log-CvVnyGi3.js → login-log-kqKzKTto.js} +1 -1
  57. package/dist/{login-LREiDfFU.js → login-sPCEiTGT.js} +107 -113
  58. package/dist/{lov-view-DDrIVILB.js → lov-view-76NcYTYl.js} +5 -5
  59. package/dist/{menuInfo-B1FUV-Sk.js → menuInfo-CxjfjFpm.js} +1 -1
  60. package/dist/{menuInfo.vue_vue_type_style_index_0_lang-Cnk3vdtD.js → menuInfo.vue_vue_type_style_index_0_lang-C2qahH3r.js} +98 -95
  61. package/dist/pda-app-BUH16bLj.js +710 -0
  62. package/dist/redirect-BqegffKC.js +15 -0
  63. package/dist/{resource-BCwx9fEv.js → resource-CCuHzoA6.js} +18 -18
  64. package/dist/{su-welcome-189A7N4r.js → su-welcome-mRArONsd.js} +133 -133
  65. package/dist/{sys-config-BZ3sejow.js → sys-config-Cvt05yF6.js} +21 -21
  66. package/dist/udp-core.css +2 -2
  67. package/dist/{utogether-r08LNiIZ.js → utogether-Dm_VBQHR.js} +6 -6
  68. package/index.ts +40 -36
  69. package/package.json +4 -2
  70. package/src/App.vue +65 -70
  71. package/src/api/index.ts +1 -1
  72. package/src/components/SuCharts/src/UserInfo.vue +78 -78
  73. package/src/components/SuScrollTree/ScrollPanel.vue +3 -3
  74. package/src/components/udp/count-down.vue +536 -0
  75. package/src/components/udp/flip-down/FlipCard/flip-card.vue +251 -0
  76. package/src/components/udp/flip-down/FlipCard/interfaces.ts +4 -0
  77. package/src/components/udp/flip-down/FlipClock/flip-clock.vue +113 -0
  78. package/src/components/udp/form-upload.vue +482 -0
  79. package/src/components/udp/form.vue +112 -0
  80. package/src/components/udp/grid.vue +495 -0
  81. package/src/components/udp/index.ts +10 -0
  82. package/src/components/udp/lov.vue +388 -0
  83. package/src/components/udp/modal-form.vue +189 -0
  84. package/src/components/udp/modal-grid.vue +288 -0
  85. package/src/components/udp/upload.vue +423 -0
  86. package/src/components/udp/utils.ts +447 -0
  87. package/src/directives/permission/index.ts +1 -1
  88. package/src/layout/components/lay-navbar/index.vue +1 -1
  89. package/src/layout/components/lay-panel/index.vue +150 -150
  90. package/src/layout/components/lay-search/index.vue +25 -25
  91. package/src/layout/components/lay-sidebar/breadCrumb.vue +1 -1
  92. package/src/layout/components/lay-tag/index.vue +625 -625
  93. package/src/layout/layoutView.vue +215 -215
  94. package/src/main.ts +25 -14
  95. package/src/plugins/i18n/en.ts +302 -289
  96. package/src/plugins/i18n/zh.ts +348 -337
  97. package/src/plugins/vxe-table/index.ts +53 -46
  98. package/src/plugins/vxe-table/render.tsx +956 -397
  99. package/src/router/index.ts +187 -183
  100. package/src/router/modules/remaining.ts +58 -83
  101. package/src/style/button.scss +85 -78
  102. package/src/style/tailwind.css +1 -68
  103. package/src/style/vxetable.scss +44 -11
  104. package/src/utils/authority/index.ts +1 -1
  105. package/src/utils/{http → udp/http}/index.ts +8 -24
  106. package/src/utils/{http → udp/http}/types.d.ts +8 -5
  107. package/src/utils/udp/useRender.ts +431 -0
  108. package/src/views/login/login-view.vue +2 -2
  109. package/src/views/organization/company/CompanyPanel.vue +259 -259
  110. package/src/views/organization/inv-org/InvOrganization.vue +1 -1
  111. package/src/views/organization/org/Org.vue +9 -5
  112. package/src/views/organization/staff/StaffInfo.vue +0 -30
  113. package/src/views/organization/staff/StaffPanel.vue +4 -3
  114. package/src/views/system/menu/AuthorityPanel.vue +2 -2
  115. package/src/views/system/menu/SystemMenu.vue +183 -191
  116. package/src/views/system/menu/menuInfo.vue +363 -368
  117. package/src/views/system/role/AuthorityInfo.vue +19 -33
  118. package/src/views/system/role/Role.vue +1 -5
  119. package/src/views/system/role/RolePanel.vue +11 -2
  120. package/src/views/system/role/UserInfo.vue +195 -193
  121. package/src/views/system/role-assign/RoleAssign.vue +57 -57
  122. package/src/views/system/role-assign/RolePanel.vue +139 -136
  123. package/src/views/system/sys/sys-config.vue +1 -1
  124. package/src/views/system/sysUser/SysUserPanel.vue +278 -278
  125. package/src/views/uapp/pda/pda-app.vue +208 -176
  126. package/src/views/udev/dict/DictView.vue +118 -106
  127. package/src/views/udev/dict/childView.vue +7 -7
  128. package/src/views/udev/lov/lov-view.vue +91 -91
  129. package/src/views/ufile/aggregation/File.vue +5 -5
  130. package/src/views/ufile/file/water-mark.vue +14 -14
  131. package/src/views/uhome/components/menu-favorite.vue +1 -1
  132. package/src/views/uhome/su-welcome.vue +4 -4
  133. package/src/views/ulogin/login.vue +15 -10
  134. package/src/views/upms/user/login-log.vue +1 -1
  135. package/src/views/urpt/design/DesignPanel.vue +507 -526
  136. package/src/views/urpt/design/ReportDesign.vue +15 -19
  137. package/src/views/urpt/static-resource/resource.vue +3 -3
  138. package/src/views/urpt/template/ReportTemplate.vue +7 -7
  139. package/types/global.d.ts +2 -2
  140. package/vite.config.ts +13 -2
  141. package/dist/AuthorityInfo.vue_vue_type_style_index_0_lang-DbK-f8jH.js +0 -102
  142. package/dist/DictView-bIS5-rK-.js +0 -95
  143. package/dist/Org-kXHSjsgJ.js +0 -35
  144. package/dist/RolePanel.vue_vue_type_script_setup_true_lang-CTIad9_Q.js +0 -126
  145. package/dist/StaffInfo-DJzvBuxy.js +0 -4
  146. package/dist/SysUserPanel.vue_vue_type_script_setup_true_lang-0QUjnhjF.js +0 -289
  147. package/dist/core.umd.js +0 -173
  148. package/dist/index-BKIw8tSn.js +0 -9195
  149. package/dist/pda-app-CRhVGijN.js +0 -2209
  150. package/dist/redirect-DiaNDu8F.js +0 -15
  151. package/src/assets/images/empty.png +0 -0
  152. package/src/assets/images/logo.png +0 -0
  153. package/src/components/ReCountTo/README.md +0 -2
  154. package/src/components/ReCountTo/index.ts +0 -18
  155. package/src/components/ReCountTo/src/normal/index.tsx +0 -165
  156. package/src/components/ReCountTo/src/normal/props.ts +0 -37
  157. package/src/components/ReCountTo/src/rebound/index.tsx +0 -67
  158. package/src/components/ReCountTo/src/rebound/props.ts +0 -14
  159. package/src/components/ReCountTo/src/rebound/rebound.css +0 -77
  160. package/src/components/ReCropper/index.ts +0 -14
  161. package/src/components/ReCropper/src/index.tsx +0 -141
  162. package/src/components/ReFlicker/index.css +0 -39
  163. package/src/components/ReFlicker/index.ts +0 -50
  164. package/src/components/ReFlop/index.ts +0 -14
  165. package/src/components/ReFlop/src/Filpper.tsx +0 -99
  166. package/src/components/ReFlop/src/filpper.css +0 -184
  167. package/src/components/ReFlop/src/index.vue +0 -126
  168. package/src/components/ReFlowChart/index.ts +0 -24
  169. package/src/components/ReFlowChart/src/Control.vue +0 -139
  170. package/src/components/ReFlowChart/src/DataDialog.vue +0 -12
  171. package/src/components/ReFlowChart/src/NodePanel.vue +0 -151
  172. package/src/components/ReFlowChart/src/adpterForTurbo.ts +0 -160
  173. package/src/components/ReFlowChart/src/assets/iconfont/iconfont.css +0 -49
  174. package/src/components/ReFlowChart/src/assets/iconfont/iconfont.eot +0 -0
  175. package/src/components/ReFlowChart/src/assets/iconfont/iconfont.js +0 -61
  176. package/src/components/ReFlowChart/src/assets/iconfont/iconfont.json +0 -58
  177. package/src/components/ReFlowChart/src/assets/iconfont/iconfont.svg +0 -47
  178. package/src/components/ReFlowChart/src/assets/iconfont/iconfont.ttf +0 -0
  179. package/src/components/ReFlowChart/src/assets/iconfont/iconfont.woff +0 -0
  180. package/src/components/ReFlowChart/src/assets/iconfont/iconfont.woff2 +0 -0
  181. package/src/components/ReFlowChart/src/config.ts +0 -62
  182. package/src/components/ReSplitPane/index.css +0 -49
  183. package/src/components/ReSplitPane/index.tsx +0 -119
  184. package/src/components/ReSplitPane/resizer.css +0 -45
  185. package/src/components/ReSplitPane/resizer.tsx +0 -30
  186. package/src/components/SuCommon/card/components/Card.vue +0 -148
  187. package/src/components/SuCommon/card/components/DialogForm.vue +0 -127
  188. package/src/components/SuCommon/card/index.vue +0 -142
  189. package/src/components/SuCommon/icon-select/index.vue +0 -241
  190. package/src/components/SuCommon/table/index.vue +0 -208
  191. package/src/components/SuCommon/utils/index.ts +0 -103
  192. package/src/components/SuCommon/utils/slot.tsx +0 -50
  193. package/src/views/components/contextmenu/basic.vue +0 -74
  194. package/src/views/components/contextmenu/context-menu.vue +0 -40
  195. package/src/views/components/contextmenu/menuDynamic.vue +0 -99
  196. package/src/views/components/contextmenu/menuGroup.vue +0 -71
  197. package/src/views/components/count-to/index.vue +0 -43
  198. package/src/views/components/cropping/index.vue +0 -59
  199. package/src/views/components/cropping/picture.jpeg +0 -0
  200. package/src/views/components/split-pane/index.vue +0 -82
  201. package/src/views/components/video/index.vue +0 -57
@@ -0,0 +1,288 @@
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, merge } from 'xe-utils';
54
+ import { queryAll, query, del, save, footerSumMethod, getToolBarConfig, onCheckMethod, getAttrs } from './utils';
55
+
56
+ // import type { IRecord, IFormItemProps, ITableColProps } from '../../types';
57
+
58
+ export interface IProps {
59
+ checkMethod?: Function;
60
+ columns: Array<ITableColProps>; // 列表行
61
+ defaultValue?: IRecord;
62
+ defaultParams?: IRecord;
63
+ gridOptions?: IRecord;
64
+ auth?: IRecord;
65
+ url?: string; // 查询服务路径
66
+ submitUrl?: string; // 确认
67
+ checkRowKeys?: Array<string>; // 默认选中列表
68
+ items?: Array<IFormItemProps>; // 查询条件
69
+ title?: string; // 标题
70
+ width?: number | string;
71
+ height?: number;
72
+ editable?: boolean; // 可编辑
73
+ needExport?: boolean; // 是否需要导出
74
+ showFooter?: boolean; // 显示底部按钮
75
+ addChild?: boolean; // 可编辑
76
+ autoClose?: boolean; // 组件自主关闭
77
+ autoLoad?: boolean; // 是否自动加载查询数据
78
+ }
79
+ const attrs: IRecord = getAttrs(useAttrs());
80
+
81
+ const props = withDefaults(defineProps<IProps>(), {
82
+ gridOptions: () => {
83
+ return {};
84
+ },
85
+ items: () => [],
86
+ columns: () => [],
87
+ checkRowKeys: () => [],
88
+ addChild: false,
89
+ editable: true,
90
+ showFooter: false,
91
+ autoLoad: true,
92
+ needExport: true,
93
+ autoClose: true,
94
+ width: '520',
95
+ height: 420,
96
+ title: '数据记录',
97
+ url: '',
98
+ submitUrl: ''
99
+ });
100
+
101
+ const showModal = ref(false);
102
+
103
+ const xGrid = ref(null);
104
+ const instance = getCurrentInstance()!;
105
+
106
+ const hasAuthority = instance.appContext.config.globalProperties.$hasAuthority;
107
+ const serviceApi = instance.appContext.config.globalProperties.$serviceApi;
108
+ const $mode = instance.appContext.config.globalProperties.$mode;
109
+
110
+ const { t } = useI18n();
111
+
112
+ /**
113
+ * @description: colum 统一添加国家化
114
+ */
115
+ const getColumns = () => {
116
+ const col = props.columns.map(m => {
117
+ if (!props.editable) {
118
+ m.editRender = { enabled: false };
119
+ } else if (!m.type && !m.editRender && props.editable && !!m.editable) {
120
+ m.editRender = { name: 'VxeInput' };
121
+ }
122
+ return m;
123
+ });
124
+ return i18nColums(col);
125
+ };
126
+
127
+ const getItems = () => {
128
+ if (!props.items.length) return props.items;
129
+ return formatGridItems(clone(props.items, true));
130
+ };
131
+
132
+ /**
133
+ * @description: 根据items 获取必填选
134
+ */
135
+ const getRules = () => {
136
+ if (!props.columns.length) return {};
137
+ return formatRules(props.columns, t);
138
+ };
139
+
140
+ const data = reactive<VxeGridProps>({
141
+ loading: false,
142
+ border: true,
143
+ pagerConfig: {},
144
+ formConfig: {},
145
+ toolbarConfig: { enabled: false },
146
+ height: 'auto',
147
+ editConfig: {},
148
+ rowConfig: { keyField: '_X_ROW_KEY' },
149
+ editRules: getRules(),
150
+ proxyConfig: {
151
+ form: true, // 查询是需要启用表单代理
152
+ autoLoad: props.autoLoad,
153
+ ajax: {
154
+ queryAll: ({ form }) => queryAll(props, serviceApi, form),
155
+ query: ({ page, form }) => query(props, form, page, serviceApi, $mode),
156
+ delete: ({ body: { removeRecords } }) => del(serviceApi, removeRecords, props),
157
+ save: ({ body }) => Promise.all(save(serviceApi, body, props))
158
+ }
159
+ },
160
+ checkboxConfig: {
161
+ checkMethod: ({ row }) => onCheckMethod(row, props),
162
+ checkRowKeys: props.checkRowKeys
163
+ },
164
+ columns: getColumns()
165
+ });
166
+
167
+ // 确认数据
168
+ const onConfirm = async () => {
169
+ let records = null;
170
+ const type = props.columns[0].type;
171
+ if (type === 'checkbox') {
172
+ records = xGrid.value.getCheckboxRecords();
173
+ } else if (type === 'radio') {
174
+ records = xGrid.value.getRadioRecord();
175
+ } else {
176
+ records = xGrid.value.getTableData().fullData;
177
+ }
178
+ if (type === 'checkbox' && !records.length && !props.addChild) {
179
+ return warnMessage(t('message.selectedRecord'));
180
+ } else if (type === 'radio' && !records) {
181
+ return warnMessage(t('message.selectedRecord'));
182
+ }
183
+ if (isFunction(attrs.beforeConfirm) && !attrs.beforeConfirm(records)) return;
184
+ const { submitUrl } = props;
185
+ // 服务submitUrl
186
+ if (submitUrl) {
187
+ showLoading();
188
+ let res;
189
+ try {
190
+ records.forEach(record => Object.assign(record, props.defaultParams));
191
+ res = await serviceApi.post(submitUrl, records);
192
+ } finally {
193
+ res && emit('confirm', res);
194
+ res && successMessage(t('message.operateSuccess'));
195
+ close();
196
+ hiddenLoading();
197
+ }
198
+ } else {
199
+ props.autoClose && close();
200
+ emit('confirm', records);
201
+ }
202
+ };
203
+ // 请求数据
204
+ const refreshData = () => {
205
+ xGrid.value.commitProxy('query');
206
+ };
207
+ const refreshColumn = () => {
208
+ data.editRules = getRules();
209
+ xGrid.value.refreshColumn();
210
+ };
211
+ const getInstance = () => {
212
+ return toRaw(xGrid.value);
213
+ };
214
+ const cellClick = ({ row }) => {
215
+ const type = props.columns[0].type;
216
+ if (type === 'checkbox') {
217
+ xGrid.value.setCheckboxRow(row, true);
218
+ } else if (type === 'radio') {
219
+ xGrid.value.setRadioRow(row);
220
+ }
221
+ };
222
+ // 单元格被激活编辑激活回调
223
+ const onEditActived = data => {
224
+ emit('actived', data);
225
+ };
226
+ const toolbarButtonClick = ({ code }) => {
227
+ emit('buttonClick', code);
228
+ };
229
+ const showLoading = () => {
230
+ data.loading = true;
231
+ };
232
+ const hiddenLoading = () => {
233
+ data.loading = false;
234
+ };
235
+ const emit = defineEmits<{
236
+ (e: 'close'): void;
237
+ (e: 'confirm', record: any): void;
238
+ (e: 'actived', record: any): void;
239
+ (e: 'buttonClick', code: string): void;
240
+ }>();
241
+ // 关闭弹框
242
+ const close = () => {
243
+ if (isFunction(attrs.beforeClose) && !attrs.beforeClose()) return;
244
+ showModal.value = false;
245
+ emit('close');
246
+ };
247
+
248
+ /**
249
+ * @description: 设置grid参数
250
+ */
251
+
252
+ const setGridConfig = () => {
253
+ // 查询
254
+ if (props.items.length) {
255
+ data.formConfig = {
256
+ titleWidth: 100,
257
+ titleAlign: 'right',
258
+ items: getItems(),
259
+ rules: formatRules(props.items, t),
260
+ validConfig: { showMessage: false }
261
+ };
262
+ }
263
+ // tool bar
264
+ const obj = getToolBarConfig(data, props, attrs, hasAuthority);
265
+ Object.assign(data, obj);
266
+
267
+ // 合计方法
268
+ if (attrs.mergeFooter) {
269
+ data.showFooter = true;
270
+ data.footerMethod = ({ columns, data }) => footerSumMethod({ columns, data }, attrs.mergeFooter);
271
+ }
272
+ merge(data, props.gridOptions);
273
+ };
274
+
275
+ // 子组件需对外暴露方法
276
+ defineExpose({
277
+ refreshData,
278
+ refreshColumn,
279
+ getInstance,
280
+ showLoading,
281
+ hiddenLoading,
282
+ close
283
+ });
284
+ onBeforeMount(() => {
285
+ showModal.value = true;
286
+ setGridConfig();
287
+ });
288
+ </script>
@@ -0,0 +1,423 @@
1
+ <!--
2
+ * @Author: wei.li
3
+ * @Date: 2022-06-21 14:50:52
4
+ * @LastEditors: levi7754 levi7754@163.com
5
+ * @LastEditTime: 2025-08-03 16:01:16
6
+ * @Description: excel数据导入
7
+ -->
8
+ <template>
9
+ <vxe-modal v-model="visible" :show-header="false" fullscreen remember @close="onClose">
10
+ <template #default>
11
+ <vxe-grid ref="xgrid" v-bind="gridOptions" v-on="gridEvents">
12
+ <template v-for="col in columns" :key="col.field" #[col.field!]="{ row }">
13
+ <el-select v-if="col.dictCode && !col.disabled" v-model.trim="row[col.field!]" clearable>
14
+ <el-option
15
+ v-for="child in dict[col.dictCode]?.children"
16
+ :key="child.dictCode"
17
+ :value="child.dictCode"
18
+ :label="child.dictName"
19
+ />
20
+ </el-select>
21
+ <el-date-picker
22
+ v-else-if="['date', 'month', 'datetime'].includes(col.dataType) && !col.disabled"
23
+ v-model.trim="row[col.field!]"
24
+ :type="col.dataType"
25
+ value-format="YYYY-MM-DD hh:mm:ss"
26
+ />
27
+ <input v-else-if="!col.da && !col.disabled" v-model.trim="row[col.field!]" class="ut-input" />
28
+ <span v-else-if="!showErrorMsg">{{ row[col.field!] }}</span>
29
+ <span v-else>{{ row[col.field!] }}</span>
30
+ </template>
31
+ <template #pager>
32
+ <vxe-pager
33
+ v-model:current-page="listQuery.currentPage"
34
+ v-model:page-size="listQuery.pageSize"
35
+ :layouts="layouts"
36
+ :page-sizes="[200, 500, 1000, 2000, 5000, 10000]"
37
+ :total="listQuery.total"
38
+ @page-change="handlePageChange"
39
+ /></template>
40
+ </vxe-grid>
41
+ </template>
42
+ </vxe-modal>
43
+ </template>
44
+
45
+ <script lang="ts">
46
+ export default {
47
+ name: 'UtUpload'
48
+ };
49
+ </script>
50
+ <script setup lang="ts">
51
+ import { reactive, ref, watch, getCurrentInstance } from 'vue';
52
+ import { toDateString } from 'xe-utils';
53
+ import { storageLocal, cookies, warnMessage } from '@utogether/utils';
54
+ import Big from 'big.js';
55
+ import { useI18n } from 'vue-i18n';
56
+ // import type { IRecord, ITableColProps } from '../../types';
57
+ import { VxeTableInstance, VxeGridProps, VxeGridListeners } from 'vxe-table';
58
+ import { VxeUI } from 'vxe-pc-ui';
59
+ import type { VxePagerPropTypes, VxePagerEvents } from 'vxe-pc-ui';
60
+
61
+ export interface IProps {
62
+ defaultParams?: IRecord;
63
+ options?: IRecord;
64
+ columns: Array<ITableColProps>;
65
+ templateData?: Array<ITableColProps>;
66
+ serviceCode?: string;
67
+ url?: string;
68
+ sourceList?: string;
69
+ }
70
+
71
+ const props = withDefaults(defineProps<IProps>(), {
72
+ defaultParams: (): IRecord => {
73
+ return {};
74
+ },
75
+ options: (): IRecord => {
76
+ return {
77
+ filename: '数据模板',
78
+ errorField: 'errorMsg',
79
+ errListField: 'list'
80
+ };
81
+ },
82
+ columns: () => [],
83
+ templateData: () => [],
84
+ sourceList: 'list'
85
+ });
86
+
87
+ const instance = getCurrentInstance()!;
88
+ const serviceApi = instance.appContext.config.globalProperties.$serviceApi;
89
+ const visible = defineModel<boolean>('visible');
90
+
91
+ const { t } = useI18n();
92
+
93
+ const showErrorMsg = ref(false);
94
+
95
+ const dict = storageLocal.getItem('kLov');
96
+
97
+ watch(
98
+ () => visible.value,
99
+ nv => {
100
+ if (nv) {
101
+ gridOptions.data = [];
102
+ }
103
+ }
104
+ );
105
+
106
+ const getColumns = () => {
107
+ const columns = props.columns.map(col => {
108
+ col.slots = { default: col.field };
109
+ col.title = col.field;
110
+ return col;
111
+ });
112
+ const col: ITableColProps = {
113
+ type: 'checkbox',
114
+ width: 40,
115
+ align: 'center',
116
+ fixed: 'left'
117
+ };
118
+ columns.unshift(col);
119
+ return columns;
120
+ };
121
+
122
+ const listQuery = ref({ pageSize: 200, currentPage: 1, total: 0 });
123
+
124
+ const layouts: VxePagerPropTypes.Layouts = [
125
+ 'Sizes',
126
+ 'PrevJump',
127
+ 'PrevPage',
128
+ 'Number',
129
+ 'NextPage',
130
+ 'NextJump',
131
+ 'FullJump',
132
+ 'Total'
133
+ ];
134
+
135
+ const height = window.innerHeight - 25;
136
+
137
+ const xgrid = ref<VxeTableInstance>();
138
+ // 导入的所有数据
139
+ let dataList: ITableColProps[] = [];
140
+
141
+ const importConfig = {
142
+ mode: 'covering',
143
+ types: ['csv', 'xlsx'],
144
+ afterImportMethod: onImportMethod
145
+ };
146
+
147
+ const gridOptions = reactive<VxeGridProps>({
148
+ border: true,
149
+ height,
150
+ data: [],
151
+ importConfig,
152
+ showOverflow: true,
153
+ loading: false,
154
+ toolbarConfig: {
155
+ buttons: [
156
+ {
157
+ code: 'import_plus',
158
+ name: t('message.btn.upload'),
159
+ icon: 'ri-upload-2-line',
160
+ status: 'primary'
161
+ },
162
+ {
163
+ code: 'save_plus',
164
+ name: t('message.btn.save'),
165
+ icon: 'ri-save-3-line',
166
+ status: 'success'
167
+ },
168
+ {
169
+ code: 'del_plus',
170
+ name: t('message.btn.delete'),
171
+ icon: 'ri-delete-bin-line',
172
+ status: 'danger'
173
+ },
174
+ {
175
+ code: 'export_plus',
176
+ name: t('message.btn.downloadTemp'),
177
+ icon: 'ri-download-2-line',
178
+ status: 'warning'
179
+ }
180
+ ],
181
+ tools: [
182
+ {
183
+ code: 'question',
184
+ name: t('message.btn.FAQ'),
185
+ status: 'primary',
186
+ icon: 'vxe-icon-info-circle-fill'
187
+ },
188
+ {
189
+ code: 'replay',
190
+ name: t('message.btn.back'),
191
+ status: 'info',
192
+ icon: 'vxe-icon-undo'
193
+ }
194
+ ]
195
+ },
196
+ columns: getColumns()
197
+ });
198
+
199
+ const gridEvents: VxeGridListeners = {
200
+ toolbarButtonClick({ code }) {
201
+ // const $grid = xgrid.value;
202
+ switch (code) {
203
+ case 'import_plus': {
204
+ handleImport();
205
+ break;
206
+ }
207
+ case 'save_plus': {
208
+ handleSave();
209
+ break;
210
+ }
211
+ case 'del_plus': {
212
+ handleDelete();
213
+ break;
214
+ }
215
+ case 'export_plus': {
216
+ handleDownLoadFile();
217
+ break;
218
+ }
219
+ }
220
+ },
221
+ toolbarToolClick({ code }) {
222
+ // const $grid = xgrid.value;
223
+ switch (code) {
224
+ case 'replay': {
225
+ onClose();
226
+ break;
227
+ }
228
+ case 'question': {
229
+ showImportQuestion();
230
+ break;
231
+ }
232
+ }
233
+ }
234
+ };
235
+
236
+ const handleImport = () => {
237
+ dataList = [];
238
+ xgrid.value?.openImport();
239
+ };
240
+ // 导入后获取数据
241
+ function onImportMethod(options: any) {
242
+ dataList = options.$table.getTableData().fullData;
243
+ // 标题会默认导入,删除第一行
244
+ // dataList.splice(0, 1);
245
+ const columns = getColumns().filter(f => !f.type && f.mapField !== props.options.errorField);
246
+ columns.forEach(col => {
247
+ const idx = dataList.findIndex(data => data[col.field!] === col.field);
248
+ idx !== -1 && dataList.splice(idx, 1);
249
+ });
250
+ props.columns.forEach(col => {
251
+ if (col.dateFormatter || col.valueType === 'number') {
252
+ dataList.forEach(data => {
253
+ if (col.dateFormatter) {
254
+ data[col.field!] = toDateString(data[col.field!], col.dateFormatter || 'yyyy-MM-dd HH:mm:ss');
255
+ } else {
256
+ data[col.field!] = Big(data[col.field!]).toFixed(col.decimal || 6);
257
+ }
258
+ });
259
+ }
260
+ });
261
+ listQuery.value.total = dataList.length;
262
+ getDataList();
263
+ }
264
+
265
+ const getDataList = () => {
266
+ const { currentPage, pageSize } = listQuery.value;
267
+ gridOptions.data = dataList.filter(
268
+ (data, idx) => idx < pageSize * currentPage && idx >= pageSize * (currentPage - 1)
269
+ );
270
+ };
271
+ // 切换页数
272
+ const handlePageChange: VxePagerEvents.PageChange = ({ currentPage, pageSize }) => {
273
+ listQuery.value.currentPage = currentPage;
274
+ listQuery.value.pageSize = pageSize;
275
+ getDataList();
276
+ };
277
+ // 模板下载
278
+ const handleDownLoadFile = () => {
279
+ const data: ITableColProps[] = [];
280
+ if (props.templateData.length) {
281
+ data.push(...props.templateData);
282
+ } else {
283
+ const obj: ITableColProps = {};
284
+ getColumns()
285
+ .filter(f => f.type !== 'checkbox')
286
+ .forEach(col => {
287
+ obj[col.field!] = '案例';
288
+ });
289
+ data.push(obj);
290
+ }
291
+ const opt: IRecord = {
292
+ filename: props.options.filename,
293
+ type: 'xlsx',
294
+ columns: getColumns().filter(f => f.mapField !== props.options.errorField && f.type !== 'checkbox'),
295
+ data
296
+ };
297
+ xgrid.value?.exportData(opt);
298
+ };
299
+
300
+ const handleSave = async () => {
301
+ if (!dataList.length) {
302
+ return warnMessage(t('message.importEmpty'));
303
+ }
304
+ const type = await VxeUI.modal.confirm(t('message.importRecord'));
305
+ if (type === 'confirm') {
306
+ gridOptions.loading = true;
307
+ const { url } = props;
308
+ formatterData('toSave');
309
+ serviceApi
310
+ .post(url, dataList)
311
+ .then((res: any) => {
312
+ if (res?.status === 'error' || res?.length) {
313
+ showErrorMsg.value = true;
314
+ setErrorMessage(res?.length ? res : res[props.options.errListField || props.sourceList]);
315
+ VxeUI.modal.message({
316
+ content: t('message.importFailed'),
317
+ status: 'error'
318
+ });
319
+ } else {
320
+ VxeUI.modal.message({
321
+ content: t('message.importSuccess'),
322
+ status: 'success'
323
+ });
324
+ onClose();
325
+ }
326
+ })
327
+ .finally(() => {
328
+ showErrorMsg.value = false;
329
+ gridOptions.loading = false;
330
+ });
331
+ }
332
+ };
333
+
334
+ /**
335
+ * @description:删除行
336
+ */
337
+ const handleDelete = () => {
338
+ const checkboxRecords = xgrid.value?.getCheckboxRecords();
339
+ if (!checkboxRecords?.length) {
340
+ return VxeUI.modal.message({
341
+ content: t('message.selectedRecord'),
342
+ status: 'warning'
343
+ });
344
+ }
345
+ checkboxRecords.forEach(record => {
346
+ const idx = dataList.findIndex(data => data._X_ROW_KEY === record._X_ROW_KEY)!;
347
+ idx !== -1 && dataList.splice(idx, 1);
348
+ });
349
+ gridOptions.data = dataList;
350
+ };
351
+
352
+ const setErrorMessage = (array: ITableColProps[]) => {
353
+ listQuery.value.total = array.length;
354
+ dataList = array.map((item, idx) => {
355
+ item._X_ROW_KEY = idx;
356
+ return item;
357
+ });
358
+ formatterData('toShow');
359
+ getDataList();
360
+ };
361
+ const formatterData = (formatterType: string) => {
362
+ gridOptions.columns!.forEach((col: any) => {
363
+ if (formatterType === 'toSave') {
364
+ const commonParam = cookies.get('kCookies_param') ? JSON.parse(cookies.get('kCookies_param')!) : {};
365
+ dataList.forEach(data => {
366
+ data[col.mapField] = data[col.field];
367
+ Object.assign(data, commonParam, props.defaultParams);
368
+ });
369
+ } else {
370
+ dataList.forEach(data => {
371
+ data[col.field] = data[col.mapField];
372
+ });
373
+ }
374
+ });
375
+ };
376
+
377
+ const showImportQuestion = () => {
378
+ VxeUI.modal.alert(t('message.importTip'), t('message.udp.tip'));
379
+ };
380
+
381
+ const emit = defineEmits<{ (e: 'close'): void }>();
382
+
383
+ const onClose = () => {
384
+ visible.value = false;
385
+ emit('close');
386
+ };
387
+ </script>
388
+
389
+ <style lang="scss" scoped>
390
+ .ut-input {
391
+ box-sizing: border-box;
392
+ box-sizing: border-box;
393
+ display: inline-block;
394
+ width: 100%;
395
+ height: 28px;
396
+ padding: 0 15px;
397
+ font-size: 13px;
398
+ line-height: 28px;
399
+ color: #606266;
400
+ background-color: #fff;
401
+ background-image: none;
402
+ border: 1px solid #dcdfe6;
403
+ border-radius: 4px;
404
+ outline: 0;
405
+ transition: border-color 0.2s cubic-bezier(0.645, 0.045, 0.355, 1);
406
+ transition: border-color 0.2s cubic-bezier(0.645, 0.045, 0.355, 1);
407
+ appearance: none;
408
+
409
+ &:hover {
410
+ border-color: #c0c4cc;
411
+ }
412
+
413
+ &:focus {
414
+ border-color: #409eff;
415
+ outline: 0;
416
+ }
417
+
418
+ &:disabled {
419
+ background-color: #f5f7fa;
420
+ outline: none;
421
+ }
422
+ }
423
+ </style>