@utogether/udp-core 1.0.1-beta.15 → 1.0.1-beta.17

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 (126) hide show
  1. package/build/plugins.ts +39 -39
  2. package/dist/{403-DpJevH-h.js → 403-C3cfjZIT.js} +1 -1
  3. package/dist/{404-BpqJK3YD.js → 404-Bg3j7QIo.js} +1 -1
  4. package/dist/{500-DyvRbMD_.js → 500-CMT7Zyy7.js} +1 -1
  5. package/dist/{AuthorityInfo-Cyu4XHXx.js → AuthorityInfo-B1mvqs4x.js} +1 -1
  6. package/dist/{AuthorityInfo.vue_vue_type_style_index_0_lang-BxmnEEFq.js → AuthorityInfo.vue_vue_type_style_index_0_lang-DwoW7QWO.js} +3 -3
  7. package/dist/{Company-BLygcYrI.js → Company-qTguidK8.js} +3 -3
  8. package/dist/{CompanyPanel-D5Tgw6LF.js → CompanyPanel-BBC-o-k3.js} +17 -17
  9. package/dist/{Department-qI9OninZ.js → Department-C3mKZOnK.js} +3 -3
  10. package/dist/{DepartmentPanel-P-P8fPZQ.js → DepartmentPanel-CNdpOHBT.js} +25 -25
  11. package/dist/{DesignPanel-BxjD0AZi.js → DesignPanel-D9jrRCoG.js} +1 -1
  12. package/dist/{DesignPanel.vue_vue_type_style_index_0_lang-DN_OKxCu.js → DesignPanel.vue_vue_type_style_index_0_lang-A-Aj1Hl0.js} +6 -6
  13. package/dist/{DictView-PWL_Vf0T.js → DictView-CgdVkSiP.js} +15 -16
  14. package/dist/{InvOrganization-JXBXyn3G.js → InvOrganization-RE7s3vBq.js} +1 -1
  15. package/dist/{Org-DcTJn6YQ.js → Org-wXDGvTrS.js} +3 -3
  16. package/dist/{Preview-IKvbHI8a.js → Preview-Pvt1__BV.js} +1 -1
  17. package/dist/{ReportDefine-_G7ts7Ch.js → ReportDefine-xEQsgFyv.js} +1 -1
  18. package/dist/{ReportDesign-7h5oFklh.js → ReportDesign-jOSuEFH9.js} +9 -9
  19. package/dist/{ReportQuery-dj0BQUyi.js → ReportQuery-DxEmmGiN.js} +1 -1
  20. package/dist/{ReportQueryFrom-6WaZPg9i.js → ReportQueryFrom-CFlxfS5M.js} +1 -1
  21. package/dist/{ReportQueryFrom.vue_vue_type_style_index_0_lang-ChhcBPqa.js → ReportQueryFrom.vue_vue_type_style_index_0_lang-iHpiYz8f.js} +1 -1
  22. package/dist/{ReportTemplate-DIvJ3RrB.js → ReportTemplate-Dtz3aet7.js} +11 -11
  23. package/dist/{Role-ia_3qAZU.js → Role-B_NsHIyE.js} +3 -3
  24. package/dist/{RoleAssign-D0zVl4y3.js → RoleAssign-C9wm4zq4.js} +8 -8
  25. package/dist/{RolePanel-CQxOiAzj.js → RolePanel-BlHidBR0.js} +1 -1
  26. package/dist/{RolePanel-BiGGmP2w.js → RolePanel-DWM9mfNs.js} +1 -1
  27. package/dist/{RolePanel.vue_vue_type_script_setup_true_lang-BYDLRS_x.js → RolePanel.vue_vue_type_script_setup_true_lang-Cn4RRzXm.js} +1 -1
  28. package/dist/{RolePanel.vue_vue_type_script_setup_true_lang-Dwv5LFbf.js → RolePanel.vue_vue_type_script_setup_true_lang-DVQ9aqb1.js} +9 -9
  29. package/dist/{ScrollPanel.vue_vue_type_style_index_0_lang-gPP4duO8.js → ScrollPanel.vue_vue_type_style_index_0_lang-CCm-_i8O.js} +8 -8
  30. package/dist/{Staff-Bf_oUqF6.js → Staff-BfDc61QS.js} +3 -3
  31. package/dist/{StaffInfo-D5aisjx2.js → StaffInfo-BaJFo4mg.js} +1 -1
  32. package/dist/{StaffInfo.vue_vue_type_script_setup_true_lang-6PX7Bx6A.js → StaffInfo.vue_vue_type_script_setup_true_lang-Bwj4x1wu.js} +7 -7
  33. package/dist/{StaffPanel--zKzd4rt.js → StaffPanel-B6I2ZS6A.js} +1 -1
  34. package/dist/{StaffPanel.vue_vue_type_script_setup_true_lang-BWZSIFpq.js → StaffPanel.vue_vue_type_script_setup_true_lang-vbyS4w3V.js} +2 -2
  35. package/dist/{SysUser-BelbESLR.js → SysUser-B_r9LYc5.js} +2 -2
  36. package/dist/{SysUserPanel-BixKqQcA.js → SysUserPanel-C4ajcHPV.js} +1 -1
  37. package/dist/{SysUserPanel.vue_vue_type_script_setup_true_lang-BhaWZEfo.js → SysUserPanel.vue_vue_type_script_setup_true_lang-8Q0VvC9B.js} +41 -37
  38. package/dist/{SystemMenu-D40tzcSj.js → SystemMenu-CyPG23uP.js} +10 -10
  39. package/dist/{UserInfo-DTyk071j.js → UserInfo-BkoGt4ib.js} +1 -1
  40. package/dist/{UserInfo.vue_vue_type_style_index_0_lang-p9MByikC.js → UserInfo.vue_vue_type_style_index_0_lang-DrzF1YYG.js} +10 -10
  41. package/dist/{childView-so5qSxr0.js → childView-9vEO8ymO.js} +1 -1
  42. package/dist/{childView-xL3iE1yN.js → childView-Dh0NyiQe.js} +1 -1
  43. package/dist/{childView.vue_vue_type_style_index_0_lang-CKcXpSqa.js → childView.vue_vue_type_style_index_0_lang-BOeoZuAK.js} +7 -7
  44. package/dist/{childView.vue_vue_type_style_index_0_lang-DK1ei5uM.js → childView.vue_vue_type_style_index_0_lang-CMOjfXBX.js} +1 -1
  45. package/dist/{code-rule-DC35y76w.js → code-rule-C7jI_1gJ.js} +6 -6
  46. package/dist/core.es.js +17 -12
  47. package/dist/{cron-task-BhjQ4S68.js → cron-task-Dg9DJXvv.js} +11 -11
  48. package/dist/{frameView-G_zhG9pf.js → frameView-CeR-_hjB.js} +1 -1
  49. package/dist/{index-C6ehxLLO.js → index-Bb7gIEvu.js} +739 -496
  50. package/dist/{layoutView-CO2U8qCQ.js → layoutView-wsLHrEeX.js} +1347 -1346
  51. package/dist/login-CluzzdqH.js +249 -0
  52. package/dist/{lov-view-Cr929NMD.js → lov-view-BvQCvwbW.js} +5 -5
  53. package/dist/{menuInfo-BWuROp7u.js → menuInfo-B8RLelIC.js} +1 -1
  54. package/dist/{menuInfo.vue_vue_type_style_index_0_lang-9nouHUjO.js → menuInfo.vue_vue_type_style_index_0_lang-DvkapEZr.js} +7 -7
  55. package/dist/{pda-app-CQP1sMAI.js → pda-app-D3LNmD9a.js} +19 -19
  56. package/dist/{resource-BDQLrMpK.js → resource-D8JA_03-.js} +7 -7
  57. package/dist/{su-welcome-CZysrZQ1.js → su-welcome-BjxeEKSo.js} +88 -88
  58. package/dist/{sys-config-BiGNMYSA.js → sys-config-sbeLk9bP.js} +6 -6
  59. package/dist/udp-core.css +1 -9
  60. package/dist/utogether-MlnyYtNS.js +4 -0
  61. package/index.ts +48 -40
  62. package/package.json +1 -1
  63. package/src/App.vue +65 -65
  64. package/src/components/SuCharts/src/UserInfo.vue +78 -78
  65. package/src/components/SuScrollTree/ScrollPanel.vue +170 -175
  66. package/src/components/udp/{grid.vue → grid/index.vue} +27 -24
  67. package/src/components/udp/index.ts +2 -9
  68. package/src/components/udp/utils.ts +60 -107
  69. package/src/layout/components/lay-navbar/index.vue +239 -239
  70. package/src/layout/components/lay-panel/index.vue +150 -150
  71. package/src/layout/components/lay-search/index.vue +25 -25
  72. package/src/layout/components/lay-select-org/index.vue +64 -64
  73. package/src/layout/components/lay-sidebar/horizontal.vue +190 -190
  74. package/src/layout/components/lay-sidebar/mixNav.vue +260 -260
  75. package/src/layout/components/lay-sidebar/sidebar-logo.vue +92 -92
  76. package/src/layout/components/lay-tag/index.vue +20 -48
  77. package/src/layout/hooks/useNav.ts +173 -173
  78. package/src/layout/hooks/useTag.ts +223 -233
  79. package/src/layout/types.ts +3 -2
  80. package/src/main.ts +117 -113
  81. package/src/plugins/i18n/en.ts +302 -302
  82. package/src/plugins/i18n/zh.ts +356 -354
  83. package/src/plugins/vxe-table/index.ts +116 -53
  84. package/src/plugins/vxe-table/render.tsx +956 -956
  85. package/src/router/index.ts +186 -177
  86. package/src/router/modules/remaining.ts +58 -58
  87. package/src/router/utils.ts +393 -377
  88. package/src/store/modules/app.ts +1 -3
  89. package/src/store/modules/multiTags.ts +110 -109
  90. package/src/store/modules/permission.ts +113 -100
  91. package/src/style/button.scss +85 -85
  92. package/src/style/login.css +1 -1
  93. package/src/style/vxetable.scss +25 -2
  94. package/src/utils/index.ts +3 -1
  95. package/src/views/organization/company/CompanyPanel.vue +259 -259
  96. package/src/views/organization/department/DepartmentPanel.vue +269 -283
  97. package/src/views/system/menu/SystemMenu.vue +183 -183
  98. package/src/views/system/menu/menuInfo.vue +363 -363
  99. package/src/views/system/role/UserInfo.vue +195 -195
  100. package/src/views/system/role-assign/RoleAssign.vue +57 -57
  101. package/src/views/system/role-assign/RolePanel.vue +139 -139
  102. package/src/views/system/sys/sys-config.vue +336 -336
  103. package/src/views/system/sysUser/SysUserPanel.vue +279 -278
  104. package/src/views/uapp/pda/pda-app.vue +208 -208
  105. package/src/views/udev/dict/DictView.vue +118 -118
  106. package/src/views/udev/dict/childView.vue +1 -1
  107. package/src/views/udev/lov/lov-view.vue +91 -91
  108. package/src/views/ulogin/login.vue +2 -2
  109. package/src/views/upms/interface/log-out.vue +101 -101
  110. package/src/views/urpt/design/DesignPanel.vue +507 -507
  111. package/types/global.d.ts +2 -8
  112. package/dist/login-DzyK2soP.js +0 -278
  113. package/dist/utogether-BRirriOz.js +0 -182
  114. package/src/components/udp/count-down.vue +0 -536
  115. package/src/components/udp/flip-down/FlipCard/flip-card.vue +0 -251
  116. package/src/components/udp/flip-down/FlipCard/interfaces.ts +0 -4
  117. package/src/components/udp/flip-down/FlipClock/flip-clock.vue +0 -113
  118. package/src/components/udp/form-upload.vue +0 -482
  119. package/src/components/udp/form.vue +0 -112
  120. package/src/components/udp/lov.vue +0 -388
  121. package/src/components/udp/modal-form.vue +0 -190
  122. package/src/components/udp/modal-grid.vue +0 -298
  123. package/src/components/udp/upload.vue +0 -423
  124. package/src/utils/udp/http/index.ts +0 -294
  125. package/src/utils/udp/http/types.d.ts +0 -49
  126. package/src/utils/udp/useRender.ts +0 -431
@@ -1,298 +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, 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
- querySuccess: response => callback('querySuccess', response),
159
- queryError: response => callback('queryError', response),
160
- deleteSuccess: response => callback('deleteSuccess', response),
161
- deleteError: response => callback('deleteError', response),
162
- saveSuccess: response => callback('saveSuccess', response),
163
- saveError: response => callback('saveError', response)
164
- }
165
- },
166
- checkboxConfig: {
167
- checkMethod: ({ row }) => onCheckMethod(row, props),
168
- checkRowKeys: props.checkRowKeys
169
- },
170
- columns: getColumns()
171
- });
172
-
173
- const callback = (cb, response) => {
174
- attrs?.callback && attrs?.callback[cb] && attrs?.callback[cb](response);
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
- merge(data, props.gridOptions);
283
- };
284
-
285
- // 子组件需对外暴露方法
286
- defineExpose({
287
- refreshData,
288
- refreshColumn,
289
- getInstance,
290
- showLoading,
291
- hiddenLoading,
292
- close
293
- });
294
- onBeforeMount(() => {
295
- showModal.value = true;
296
- setGridConfig();
297
- });
298
- </script>
@@ -1,423 +0,0 @@
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>