@utogether/udp-core 2.0.0-beta.27 → 2.0.0-beta.28

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 (100) hide show
  1. package/dist/{403-gdcH0-Bo.js → 403-CyoOD-Ik.js} +1 -1
  2. package/dist/{404-Se2SF97M.js → 404-Ch_OHTw0.js} +1 -1
  3. package/dist/{500-B6j9AqLo.js → 500-Cf9am7HK.js} +1 -1
  4. package/dist/{AuthorityInfo-CQ8ydZvr.js → AuthorityInfo-BJ427cqG.js} +1 -1
  5. package/dist/{AuthorityInfo.vue_vue_type_style_index_0_lang-C4NRvS8p.js → AuthorityInfo.vue_vue_type_style_index_0_lang-D9y7AwbB.js} +11 -12
  6. package/dist/{Company-BzSVBSC4.js → Company-qo-lKPkv.js} +3 -3
  7. package/dist/{CompanyPanel-DBjZB4aJ.js → CompanyPanel-DkKWAKvY.js} +7 -7
  8. package/dist/{Department-BkgseHo8.js → Department-CHUQByKX.js} +3 -3
  9. package/dist/{DepartmentPanel-Sen93_2M.js → DepartmentPanel-C742dfOO.js} +27 -28
  10. package/dist/{DesignPanel-pqDcwaFC.js → DesignPanel-D9oE5R7m.js} +1 -1
  11. package/dist/{DesignPanel.vue_vue_type_style_index_0_lang-BjtYyEw7.js → DesignPanel.vue_vue_type_style_index_0_lang-hYldVEbo.js} +192 -108
  12. package/dist/{DictView-CJLG4LlE.js → DictView-CrFXprP9.js} +1 -1
  13. package/dist/{InvOrganization-D0Jq1IAa.js → InvOrganization-Cz8SzIgs.js} +6 -7
  14. package/dist/{Org-CO_1WT39.js → Org-Bzt6yKox.js} +9 -10
  15. package/dist/{Preview-DLI4Bwel.js → Preview-jonigfMQ.js} +1 -1
  16. package/dist/{ReportDefine-Cw46OnJ_.js → ReportDefine-BpiM5Ovq.js} +1 -1
  17. package/dist/{ReportDesign-D4sHTXT7.js → ReportDesign-fp09cXJ7.js} +24 -25
  18. package/dist/{ReportQuery-DtOCvQSN.js → ReportQuery-52ZP1PYP.js} +1 -1
  19. package/dist/{ReportQueryFrom-QjL-ETPq.js → ReportQueryFrom-DSYavJb1.js} +1 -1
  20. package/dist/{ReportQueryFrom.vue_vue_type_style_index_0_lang-Dj9ne87n.js → ReportQueryFrom.vue_vue_type_style_index_0_lang-DBGYEp0u.js} +4 -4
  21. package/dist/{ReportTemplate-BxAgc_Aj.js → ReportTemplate-CA_UW0eD.js} +3 -3
  22. package/dist/{Role-Df77BBD-.js → Role-DqOt8Bk0.js} +3 -3
  23. package/dist/{RoleAssign-BrunouML.js → RoleAssign-BdxhefhQ.js} +3 -3
  24. package/dist/{RolePanel-HLA7XBlN.js → RolePanel-2gZ3H0ET.js} +1 -1
  25. package/dist/{RolePanel-DSVwqhiD.js → RolePanel-BsNd0svJ.js} +1 -1
  26. package/dist/{RolePanel.vue_vue_type_script_setup_true_lang-CN0rUxKz.js → RolePanel.vue_vue_type_script_setup_true_lang-DLOwgF99.js} +9 -9
  27. package/dist/{RolePanel.vue_vue_type_script_setup_true_lang-CKlbqRa5.js → RolePanel.vue_vue_type_script_setup_true_lang-DmzD9kab.js} +26 -27
  28. package/dist/{ScrollPanel.vue_vue_type_style_index_0_lang-D_FeSXKv.js → ScrollPanel.vue_vue_type_style_index_0_lang-B9ptUMeI.js} +7 -7
  29. package/dist/{Staff-BeL1xcRf.js → Staff-D3L8fEoY.js} +3 -3
  30. package/dist/{StaffInfo-CIfnltyX.js → StaffInfo-DYRw6ZYJ.js} +1 -1
  31. package/dist/{StaffInfo.vue_vue_type_script_setup_true_lang-DbLFwWfG.js → StaffInfo.vue_vue_type_script_setup_true_lang-xqEOQnMs.js} +1 -1
  32. package/dist/{StaffPanel-BV2CHWac.js → StaffPanel-DkrNH6Px.js} +1 -1
  33. package/dist/{StaffPanel.vue_vue_type_script_setup_true_lang-CvT-Vp2G.js → StaffPanel.vue_vue_type_script_setup_true_lang-BPBMnliy.js} +8 -9
  34. package/dist/{SysUser-DPfNvthk.js → SysUser-Bl1-cIpJ.js} +2 -2
  35. package/dist/{SysUserPanel-CoLKYlQE.js → SysUserPanel-yxNLaBwt.js} +1 -1
  36. package/dist/{SysUserPanel.vue_vue_type_script_setup_true_lang-lcO3Cjbq.js → SysUserPanel.vue_vue_type_script_setup_true_lang-BDcsgSl5.js} +11 -12
  37. package/dist/{SystemMenu-sdj1dRDA.js → SystemMenu-C4_Arn12.js} +9 -10
  38. package/dist/{UserInfo-CTX4hhFl.js → UserInfo-QcNwJCUR.js} +1 -1
  39. package/dist/{UserInfo.vue_vue_type_style_index_0_lang-ClhCd_8z.js → UserInfo.vue_vue_type_style_index_0_lang-DLIeUphX.js} +5 -6
  40. package/dist/{childView-BDmWwJO5.js → childView-B23DEO2u.js} +1 -1
  41. package/dist/{childView-Dx3ACtHa.js → childView-saDZQv9x.js} +1 -1
  42. package/dist/{childView.vue_vue_type_style_index_0_lang-CfKq_0FN.js → childView.vue_vue_type_style_index_0_lang-RsKR6CAC.js} +14 -15
  43. package/dist/{childView.vue_vue_type_style_index_0_lang-DxZNtkhd.js → childView.vue_vue_type_style_index_0_lang-ZFEfavUY.js} +11 -12
  44. package/dist/{code-rule-cvN4gYC_.js → code-rule-2_Ihx_by.js} +12 -13
  45. package/dist/core.es.js +21 -19
  46. package/dist/{cron-task-B0TkxFdp.js → cron-task-BFOPJQIk.js} +3 -4
  47. package/dist/{frameView-5cy5BSgS.js → frameView-f7Ya0Knj.js} +1 -1
  48. package/dist/img/minicolors.png +0 -0
  49. package/dist/{index-C5WRTwvI.js → index-BpdTDaTk.js} +811 -604
  50. package/dist/{layout-home-DrARg-3o.js → layout-home-v3DPJ7rB.js} +12 -13
  51. package/dist/{layoutView-25v_ngk5.js → layoutView-DZHoQDH1.js} +186 -187
  52. package/dist/{log-in-Bmz5Uhbt.js → log-in-BPAMJTwH.js} +4 -5
  53. package/dist/{log-out-B-8m3oNj.js → log-out-DZACF0jg.js} +8 -9
  54. package/dist/{login-Cmp2RvvW.js → login-B8cwozax.js} +22 -23
  55. package/dist/{lov-view-BATtzw2X.js → lov-view-Ba7Y7xy0.js} +4 -5
  56. package/dist/{menuInfo-BIvrE7nm.js → menuInfo-BpRKFYK8.js} +1 -1
  57. package/dist/{menuInfo.vue_vue_type_style_index_0_lang-B6USomit.js → menuInfo.vue_vue_type_style_index_0_lang-DJ5sUC6m.js} +17 -18
  58. package/dist/{pda-app-CzHVyeEa.js → pda-app-C0jJecrL.js} +7 -8
  59. package/dist/{resource-Y5lGB38n.js → resource-BG22Cw4P.js} +4 -4
  60. package/dist/su-welcome-DaxhbrC6.js +879 -0
  61. package/dist/{sys-config-CqO03LeC.js → sys-config-CG2fMtak.js} +22 -23
  62. package/dist/udp-core.css +1 -1
  63. package/dist/{useNav-C-rCgubt.js → useNav-_u2UAQWk.js} +24 -24
  64. package/index.ts +54 -51
  65. package/package.json +21 -21
  66. package/src/api/http.ts +10 -4
  67. package/src/api/index.ts +51 -51
  68. package/src/api/user.ts +64 -64
  69. package/src/components/udp/content/index.vue +93 -93
  70. package/src/components/udp/form-upload/form-upload.vue +496 -496
  71. package/src/components/udp/grid/index.vue +643 -544
  72. package/src/components/udp/index.ts +2 -1
  73. package/src/components/udp/modal-form/index.vue +326 -0
  74. package/src/components/udp/utils.ts +420 -420
  75. package/src/layout/components/lay-navbar/index.vue +240 -240
  76. package/src/layout/components/lay-search/components/SearchModal.vue +185 -185
  77. package/src/layout/components/lay-sidebar/mixNav.vue +261 -261
  78. package/src/layout/components/lay-sidebar/sidebarItem.vue +199 -195
  79. package/src/layout/components/lay-sidebar/vertical.vue +92 -92
  80. package/src/layout/layoutView.vue +1 -0
  81. package/src/main.ts +111 -111
  82. package/src/plugins/i18n/zh.ts +5 -1
  83. package/src/plugins/vxe-table/index.ts +116 -116
  84. package/src/router/index.ts +158 -156
  85. package/src/router/utils.ts +434 -430
  86. package/src/store/modules/permission.ts +1 -1
  87. package/src/store/modules/system.ts +193 -193
  88. package/src/style/print-lock.css +380 -375
  89. package/src/style/suprint.css +990 -985
  90. package/src/utils/authority/index.ts +46 -46
  91. package/src/utils/dataFormat/index.ts +309 -222
  92. package/src/utils/udp/http/index.ts +19 -11
  93. package/src/views/uhome/components/home-todo.vue +15 -3
  94. package/src/views/uhome/dynamic-card.vue +31 -31
  95. package/src/views/uhome/su-welcome.vue +310 -310
  96. package/src/views/ulogin/login.vue +292 -292
  97. package/src/views/urpt/design/DesignPanel.vue +538 -507
  98. package/src/views/urpt/design/print-data.ts +39 -59
  99. package/dist/await-to-js.es5-Bv3Eu4mi.js +0 -10
  100. package/dist/su-welcome-CXA6OzBw.js +0 -878
@@ -1,544 +1,643 @@
1
- <!--
2
- * @Author: wei.li
3
- * @Date: 2021-11-17 16:33:37
4
- * @LastEditors: levi7754 levi7754@163.com
5
- * @LastEditTime: 2026-04-16 10:09:53
6
- * @Description: file content
7
- -->
8
- <template>
9
- <div style="width: 100%; height: 100%">
10
- <vxe-grid
11
- ref="xgrid"
12
- v-bind="data"
13
- class="ut-grid-wrapper"
14
- v-on="attrs.events || {}"
15
- @toolbarButtonClick="toolbarButtonClick"
16
- @toolbarToolClick="toolbarButtonClick"
17
- @cell-click="cellClick"
18
- @cell-dblclick="cellDbclick"
19
- @edit-activated="editEctivated"
20
- @form-reset="onReset"
21
- />
22
- <!-- <SearchScheme
23
- v-if="showModal && props.url"
24
- :items="items"
25
- :view="viewCode"
26
- @search="onSearch"
27
- @close="showModal = false"
28
- /> -->
29
- </div>
30
- </template>
31
-
32
- <script lang="ts" setup>
33
- // @ts-nocheck
34
- import { useI18n } from 'vue-i18n';
35
- import { ref, onBeforeMount, reactive, getCurrentInstance, toRaw, useAttrs, onUnmounted, nextTick } from 'vue';
36
- import { VxeGridProps } from 'vxe-table';
37
- import Sortable from 'sortablejs';
38
- import { clone, isObject, merge } from 'xe-utils';
39
- import { i18nColums, formatRules, errorMessage, dbstorage, warnMessage } from '@utogether/utils';
40
- // import { http } from '../../../utils/udp/http';
41
- import { formatGridItems } from '../../../utils/dataFormat';
42
- import {
43
- queryAll,
44
- query,
45
- del,
46
- save,
47
- footerSumMethod,
48
- getToolBarConfig,
49
- defaultColums,
50
- onCheckMethod,
51
- getAttrs
52
- } from '../utils';
53
- // import SearchScheme from '../components/SuSearch.vue';
54
-
55
- defineOptions({
56
- name: 'UtGrid'
57
- });
58
-
59
- export interface IProps {
60
- checkMethod?: Function;
61
- serviceCode?: IRecord;
62
- defaultValue?: IRecord;
63
- defaultParams?: IRecord;
64
- url?: string | IRecord;
65
- columns: Array<ITableColProps>;
66
- items?: Array<IFormItemProps>;
67
- editable?: boolean;
68
- needExport?: boolean; // 是否需要导出
69
- autoLoad?: boolean; // 自动加载查询数据
70
- }
71
-
72
- const attrs: IRecord = getAttrs(useAttrs());
73
-
74
- const kSTORECOLUM = 'U_TABLE_COLUMNN_SORT';
75
- let storeColums;
76
- const cacheColumns = {};
77
-
78
- // console.log(attrs);
79
- const instance = getCurrentInstance()!;
80
- const hasAuthority = instance.appContext.config.globalProperties.$hasAuthority;
81
-
82
- const viewCode = instance.parent.type.name;
83
- const $mode = instance.appContext.config.globalProperties.$mode;
84
-
85
- const props = withDefaults(defineProps<IProps>(), {
86
- /**
87
- * @deprecated 2.10.0版本失效,
88
- * */
89
- serviceCode: (): IRecord => {
90
- return {};
91
- },
92
- items: () => [],
93
- columns: () => [],
94
- editable: true,
95
- autoLoad: true,
96
- needExport: true
97
- });
98
-
99
- const { t } = useI18n();
100
-
101
- const xgrid = ref(null);
102
- const showModal = ref(false);
103
-
104
- const serviceApi = instance.appContext.config.globalProperties.$serviceApi;
105
-
106
- const favorite = {
107
- icon: 'vxe-icon-setting',
108
- name: 'favorite',
109
- events: {
110
- click: (e, option) => {
111
- if (option.name === 'favorite') {
112
- showModal.value = true;
113
- }
114
- }
115
- }
116
- };
117
-
118
- /**
119
- * @description: 根据items 获取必填选
120
- */
121
- const getRules = () => {
122
- if (!props.columns.length) return {};
123
- return formatRules(props.columns, t);
124
- };
125
- /**
126
- * @description: colum 统一添加国家化
127
- */
128
- const getColumns = () => {
129
- const columns = props.columns;
130
- if (attrs.gridId) {
131
- const cols = defaultColums
132
- .filter(f => !columns.some(s => s.field === f.field))
133
- .map(col => {
134
- if (attrs.format && ['lastUpdateDate', 'creationDate'].includes(col.field)) {
135
- col.formatter = attrs.format;
136
- col.width = 90;
137
- }
138
- return col;
139
- });
140
- const idx = columns.findIndex(s => s.field === 'operate');
141
- if (idx !== -1) {
142
- columns.splice(idx, 0, ...cols);
143
- } else {
144
- columns.push(...cols);
145
- }
146
- }
147
- const act_columns = attrs.gridId ? formatColums(columns) : columns;
148
-
149
- return i18nColums(act_columns, attrs.sortable);
150
- };
151
-
152
- dbstorage.getItem(kSTORECOLUM).then(value => {
153
- storeColums = value;
154
- data.columns = getColumns();
155
- });
156
-
157
- const data = reactive<VxeGridProps>({
158
- border: true,
159
- pagerConfig: { pageSize: attrs.pageSize || 20 },
160
- editConfig: {},
161
- editRules: getRules(),
162
- formConfig: {},
163
- columnConfig: { useKey: true },
164
- toolbarConfig: { enabled: false },
165
- sortConfig: { multiple: true, trigger: 'cell' },
166
- height: $mode ? undefined : window.innerHeight - 92,
167
-
168
- checkboxConfig: {
169
- checkMethod: ({ row }) => onCheckMethod(row, props),
170
- checkRowKeys: props.checkRowKeys
171
- },
172
- loading: false,
173
- footerRowClassName: 'ut-grid-footer',
174
- proxyConfig: {
175
- form: true, // 查询是需要启用表单代理
176
- autoLoad: props.autoLoad,
177
- showResponseMsgvxe: false,
178
- showActionMsgvxe: false,
179
- // 接收 Promise
180
- ajax: {
181
- queryAll: ({ form }) => queryAll(props, serviceApi, form),
182
- query: ({ page, form, code }) => {
183
- return query(props, form, page, serviceApi, code, $mode);
184
- },
185
- delete: ({ body: { removeRecords } }) => del(serviceApi, removeRecords, props),
186
- save: ({ body }) => Promise.all(save(serviceApi, body, props)),
187
- querySuccess: ({ response }) => callback('querySuccess', response),
188
- queryError: ({ response }) => callback('queryError', response),
189
- deleteSuccess: ({ response }) => callback('deleteSuccess', response),
190
- deleteError: ({ response }) => callback('deleteError', response),
191
- saveSuccess: ({ response }) => callback('saveSuccess', response),
192
- saveError: ({ response }) => callback('saveError', response)
193
- }
194
- },
195
- columns: !attrs.gridId ? getColumns() : [],
196
- ...attrs
197
- });
198
-
199
- /**
200
- * @description: 预处理查询form
201
- * @return {*} items
202
- */
203
- const getItems = () => {
204
- if (!props.items.length) return props.items;
205
- return formatGridItems(clone(props.items, true), viewCode && props.url ? favorite : viewCode);
206
- };
207
-
208
- /**
209
- * @description 格式化column
210
- * @return {*} columns
211
- */
212
- function formatColums(columns) {
213
- const customSort = storeColums ? storeColums[attrs.gridId] : {};
214
- if (!customSort) return columns;
215
- return columns
216
- .map((col, idx) => {
217
- const sort = (idx + 1) * 10;
218
- col._sort = customSort[col.field] || sort;
219
- // 缓存列索引数据
220
- cacheColumns[col.field] = col._sort;
221
- return col;
222
- })
223
- .sort((a, b) => a._sort - b._sort);
224
- }
225
-
226
- /**
227
- * @description: 设置grid参数
228
- */
229
- const setGridConfig = () => {
230
- // 查询
231
- if (props.items.length) {
232
- // data.formConfig = {};
233
- data.formConfig = {
234
- titleWidth: 100,
235
- titleAlign: 'right',
236
- items: getItems(),
237
- rules: formatRules(props.items, t),
238
- validConfig: { showMessage: false }
239
- };
240
- }
241
- // tool bar
242
- const obj = getToolBarConfig(data, props, attrs, hasAuthority);
243
- Object.assign(data, obj);
244
- // 表格id,用于自定义列
245
- if (attrs.gridId) {
246
- data.id = attrs.gridId;
247
- data.customConfig = {
248
- storage: true,
249
- mode: 'popup',
250
- checkMethod({ column }) {
251
- return column.field === 'operate' || ['checkbox', 'radio'].includes(column.type) ? false : true;
252
- },
253
- modalOptions: {
254
- width: 750,
255
- height: '75%'
256
- }
257
- };
258
- }
259
- if (attrs.mergeFooter) {
260
- // 合计方法
261
- data.showFooter = true;
262
- data.footerMethod = ({ columns, data }) => footerSumMethod({ columns, data }, attrs.mergeFooter);
263
- }
264
- };
265
- /**
266
- * @description 手动调用查询方法
267
- */
268
- const refreshData = () => {
269
- xgrid.value.commitProxy('query');
270
- };
271
- /**
272
- * @description 刷新列数据
273
- */
274
- const refreshColumn = () => {
275
- data.editRules = getRules();
276
- return xgrid.value.refreshColumn();
277
- };
278
- /**
279
- * @description 显示加载框
280
- */
281
- const showLoading = () => {
282
- data.loading = true;
283
- };
284
- /**
285
- * @description 隐藏加载框
286
- */
287
- const hiddenLoading = () => {
288
- data.loading = false;
289
- };
290
- /**
291
- * @description 获取实例方法
292
- * @return vxe-grid实例的方法
293
- */
294
- const getInstance = () => {
295
- return toRaw(xgrid.value);
296
- };
297
- /**
298
- * @description 获取表格全量数据方法
299
- * @return vxe-grid表格全量数据
300
- */
301
- const getTableData = () => {
302
- return xgrid.value.getTableData().fullData;
303
- };
304
- /**
305
- * @description 获取表格选中的行
306
- * @return vxe-grid表格勾选行
307
- */
308
- const getSelectRecords = (isFull = false) => {
309
- const columnType = props.columns[0].type;
310
- const checkRecords =
311
- columnType === 'radio' ? xgrid.value.getRadioRecord(isFull) : xgrid.value.getCheckboxRecords(isFull);
312
- if (columnType === 'checkbox' && !checkRecords.length) {
313
- warnMessage(t('message.tip_selectedRecord'));
314
- return [];
315
- } else if (columnType === 'radio' && !checkRecords) {
316
- warnMessage(t('message.tip_selectedRecord'));
317
- return null;
318
- }
319
- return checkRecords;
320
- };
321
-
322
- const callback = (cb, response) => {
323
- attrs?.callback && attrs?.callback[cb] && attrs?.callback[cb](response);
324
- };
325
-
326
- const onReset = async e => {
327
- console.log(e);
328
- const data = e.data;
329
- const items = props.items.filter(f => f.itemRender?.props?.multiple);
330
- console.log(items);
331
- items.forEach(item => {
332
- if (item.itemRender.props.defaultValue) {
333
- data[`_${item.field}`] = item.itemRender.props.defaultValue.split(',');
334
- data[`${item.field}`] = item.itemRender.props.defaultValue;
335
- } else {
336
- data[`_${item.field}`] = [];
337
- }
338
- });
339
- if (items.length) {
340
- // 多选时,重新查询一次
341
- setTimeout(() => {
342
- refreshData();
343
- }, 200);
344
- }
345
- };
346
-
347
- let sortable2: any;
348
- const columnDrop = () => {
349
- const $grid = xgrid.value;
350
- sortable2 = Sortable.create($grid.$el.querySelector('.vxe-table--header .vxe-header--row'), {
351
- disabled: !attrs.gridId,
352
- handle: '.vxe-header--column',
353
- onEnd: async sortableEvent => {
354
- const targetThElem = sortableEvent.item;
355
- const newIndex = sortableEvent.newIndex as number;
356
- const oldIndex = sortableEvent.oldIndex as number;
357
- const { fullColumn, tableColumn } = $grid.getTableColumn();
358
- const wrapperElem = targetThElem.parentNode as HTMLElement;
359
- const newColumn = fullColumn[newIndex];
360
- const item = fullColumn[oldIndex];
361
- let nodrag = false;
362
- let msg = '固定列';
363
- if (newColumn.fixed) {
364
- nodrag = false;
365
- } else if (newIndex === 0 || ['checkbox', 'radio'].includes(item.type)) {
366
- msg = '勾选列';
367
- nodrag = true;
368
- } else if (item.field === 'operate' || newIndex === fullColumn.length - 1) {
369
- nodrag = true;
370
- msg = '操作列';
371
- }
372
- if (nodrag) {
373
- // 错误的移动
374
- const oldThElem = wrapperElem.children[oldIndex] as HTMLElement;
375
- if (newIndex > oldIndex) {
376
- wrapperElem.insertBefore(targetThElem, oldThElem);
377
- } else {
378
- wrapperElem.insertBefore(targetThElem, oldThElem ? oldThElem.nextElementSibling : oldThElem);
379
- }
380
- return errorMessage(msg + '不允许拖动!');
381
- }
382
- // 获取列索引 columnIndex > fullColumn
383
- const oldColumnIndex = $grid.getColumnIndex(tableColumn[oldIndex]);
384
- const newColumnIndex = $grid.getColumnIndex(tableColumn[newIndex]);
385
- // 移动到目标列
386
- const currRow = fullColumn.splice(oldColumnIndex, 1)[0];
387
- fullColumn.splice(newColumnIndex, 0, currRow);
388
-
389
- // 拖拽方向 1: 右 -1: 左
390
- const direction = newColumnIndex - oldColumnIndex > 0 ? 1 : -1;
391
-
392
- // 获取新列
393
- const newSort = (newColumnIndex + 1) * 10;
394
- const oldSort = (oldColumnIndex + 1) * 10;
395
- // 目标列索引+1,方便后续计算
396
- const comparisonVal = newSort + 1 * direction;
397
- for (const key in cacheColumns) {
398
- const cacheValue = cacheColumns[key];
399
- if (direction > 0 && cacheValue < comparisonVal && cacheValue > oldSort) {
400
- // 大于拖拽列且小于目标列的索引,均向前移动一个单位
401
- cacheColumns[key] = cacheValue - 10 * direction;
402
- } else if (direction < 0 && cacheValue > comparisonVal && cacheValue < oldSort) {
403
- // 小于拖拽列且大于目标列的索引, 均向后移动一个单位
404
- cacheColumns[key] = cacheValue - 10 * direction;
405
- }
406
- }
407
-
408
- cacheColumns[currRow.field] = newSort;
409
-
410
- dbstorage.setItem(kSTORECOLUM, { [attrs.gridId]: cacheColumns });
411
- $grid.loadColumn(fullColumn);
412
- }
413
- });
414
- };
415
-
416
- /**
417
- * @description 常用查询面板确认查询
418
- * @param data 常用查询条件
419
- */
420
- // const onSearch = data => {
421
- // showModal.value = false;
422
- // const { form } = xgrid.value.getProxyInfo();
423
- // Object.assign(form, data);
424
- // refreshData();
425
- // };
426
-
427
- const reloadGrid = () => {
428
- setGridConfig();
429
- };
430
-
431
- /**
432
- * @description Vue实例对外暴露的相关方法或属性
433
- */
434
- defineExpose({
435
- getTableData,
436
- getSelectRecords,
437
- refreshData,
438
- refreshColumn,
439
- getInstance,
440
- showLoading,
441
- hiddenLoading,
442
- reloadGrid
443
- });
444
-
445
- const toolbarButtonClick = ({ code }) => {
446
- emit('buttonClick', code);
447
- };
448
- const cellClick = e => {
449
- emit('cellClick', e);
450
- };
451
- const cellDbclick = e => {
452
- emit('cellDbclick', e);
453
- };
454
- const editEctivated = e => {
455
- emit('editEctivated', e);
456
- };
457
-
458
- /**
459
- * @description: 监听窗口变化,动态改变表格的高度
460
- */
461
- const addResizeListener = () => {
462
- window.onresize = () => {
463
- return (() => {
464
- setHeight();
465
- })();
466
- };
467
- };
468
-
469
- const setHeight = () => {
470
- let height = attrs?.height || window.innerHeight - 90;
471
- if (attrs.mode !== 'inline' && !attrs?.height) {
472
- height = window.innerHeight - 180;
473
- }
474
- // 14寸电脑适配
475
- if (window.innerHeight < 800) {
476
- data.height = 520;
477
- }
478
- data.height = attrs.fixedHeight === false && height < 600 ? 600 : height;
479
- };
480
-
481
- let initTime: any;
482
- nextTick(() => {
483
- // 加载完成之后在绑定拖动事件
484
- initTime = setTimeout(() => {
485
- columnDrop();
486
- }, 500);
487
- });
488
- // function gerServiceURL() {
489
- // const whiteList = ['/uums/', '/upfm/', '/urpt/', '/usch/'];
490
- // if (debugModel && props?.url && !whiteList.some(str => props.url.includes(str))) {
491
- // return instance.appContext.config.globalProperties.$debuggerApi;
492
- // }
493
- // return instance.appContext.config.globalProperties.$serviceApi;
494
- // }
495
- /**
496
- * @description Vue实例卸载
497
- */
498
- onUnmounted(() => {
499
- clearTimeout(initTime);
500
- sortable2 && sortable2.destroy();
501
- });
502
- /**
503
- * @description Vue实例挂载
504
- */
505
- onBeforeMount(() => {
506
- setGridConfig();
507
- // 合并自定义属性
508
- isObject(attrs) && merge(data, attrs || {});
509
- attrs?.height && setHeight();
510
- addResizeListener();
511
- });
512
-
513
- const emit = defineEmits<{
514
- (e: 'buttonClick', code: string): void;
515
- (e: 'cellClick', data: any): void;
516
- (e: 'cellDbclick', data: any): void;
517
- (e: 'editEctivated', data: any): void;
518
- }>();
519
- </script>
520
-
521
- <style lang="scss">
522
- .ut-grid-wrapper {
523
- padding: 5px;
524
- background-color: #fff;
525
-
526
- .vxe-form--item {
527
- padding: 0.1em 0.8em 0.1em 0 !important;
528
-
529
- .el-select {
530
- .el-input {
531
- height: 26px;
532
- }
533
-
534
- .el-select__tags-text {
535
- color: #000;
536
- }
537
- }
538
- }
539
-
540
- .vxe-grid--layout-body-content-wrapper {
541
- overflow: hidden;
542
- }
543
- }
544
- </style>
1
+ <!--
2
+ * @Author: wei.li
3
+ * @Date: 2021-11-17 16:33:37
4
+ * @LastEditors: levi7754 levi7754@163.com
5
+ * @LastEditTime: 2026-08-06 10:54:45
6
+ * @Description: file content
7
+ -->
8
+ <template>
9
+ <div style="width: 100%; height: 100%">
10
+ <vxe-grid
11
+ ref="xgrid"
12
+ v-bind="data"
13
+ class="ut-grid-wrapper"
14
+ v-on="attrs.events || {}"
15
+ @toolbarButtonClick="toolbarButtonClick"
16
+ @toolbarToolClick="toolbarButtonClick"
17
+ @cell-click="cellClick"
18
+ @cell-dblclick="cellDbclick"
19
+ @edit-activated="editEctivated"
20
+ @form-reset="onReset"
21
+ @column-dragend="onColumnDragend"
22
+ />
23
+ <!-- <SearchScheme
24
+ v-if="showFavorite && props.url"
25
+ :items="items"
26
+ :view="viewCode"
27
+ @search="onSearch"
28
+ @close="showFavorite = false"
29
+ /> -->
30
+
31
+ <!-- 表单模式 -->
32
+ <ut-modal-form
33
+ v-if="modalOptions.show"
34
+ ref="xform"
35
+ v-bind="modalOptions"
36
+ @close="modalOptions.show = false"
37
+ @confirm="e => onConfirm(e, 'modal')"
38
+ />
39
+
40
+ <!-- 弹框表格模式1 -->
41
+ <ut-modal-grid
42
+ v-if="modalGridOptions.show"
43
+ ref="ygrid"
44
+ :need-export="false"
45
+ v-bind="modalGridOptions"
46
+ @buttonClick="code => onModalButtonClick(code, 'ygrid')"
47
+ @close="modalGridOptions.show = false"
48
+ @confirm="e => onConfirm(e, 'ygrid')"
49
+ />
50
+
51
+ <!-- 弹框表格模式2 -->
52
+ <ut-modal-grid
53
+ v-if="subModalGridOptions.show"
54
+ ref="zgrid"
55
+ :need-export="false"
56
+ v-bind="subModalGridOptions"
57
+ @buttonClick="code => onModalButtonClick(code, 'zgrid')"
58
+ @close="subModalGridOptions.show = false"
59
+ @confirm="e => onConfirm(e, 'zgrid')"
60
+ />
61
+
62
+ <!-- 导入功能 -->
63
+ <ut-upload
64
+ v-if="importOptions.show"
65
+ v-model:visible="importOptions.show"
66
+ v-bind="importOptions"
67
+ @close="onCloseImport"
68
+ />
69
+ </div>
70
+ </template>
71
+
72
+ <script lang="ts" setup>
73
+ // @ts-nocheck
74
+ import { useI18n } from 'vue-i18n';
75
+ import { ref, onBeforeMount, reactive, getCurrentInstance, toRaw, useAttrs } from 'vue';
76
+ import { VxeGridProps } from 'vxe-table';
77
+ import { clone, isObject, merge } from 'xe-utils';
78
+ import { i18nColums, formatRules, dbstorage, warnMessage } from '@utogether/utils';
79
+ import { formatGridItems } from '../../../utils/dataFormat';
80
+ import utUpload from '../upload/index.vue';
81
+
82
+ import {
83
+ queryAll,
84
+ query,
85
+ del,
86
+ save,
87
+ footerSumMethod,
88
+ getToolBarConfig,
89
+ defaultColums,
90
+ onCheckMethod,
91
+ getAttrs
92
+ } from '../utils';
93
+ // import SearchScheme from '../components/SuSearch.vue';
94
+
95
+ defineOptions({
96
+ name: 'UtGrid'
97
+ });
98
+
99
+ export interface IProps {
100
+ checkMethod?: Function;
101
+ serviceCode?: IRecord;
102
+ defaultValue?: IRecord;
103
+ defaultParams?: IRecord;
104
+ url?: string | IRecord;
105
+ columns: Array<ITableColProps>;
106
+ items?: Array<IFormItemProps>;
107
+ editable?: boolean;
108
+ needExport?: boolean; // 是否需要导出
109
+ autoLoad?: boolean; // 自动加载查询数据
110
+ }
111
+
112
+ const attrs: IRecord = getAttrs(useAttrs());
113
+
114
+ const kSTORECOLUM = 'U_TABLE_COLUMNN_SORT';
115
+ let storeColums;
116
+ const cacheColumns = {};
117
+
118
+ // console.log(attrs);
119
+ const instance = getCurrentInstance()!;
120
+ const hasAuthority = instance.appContext.config.globalProperties.$hasAuthority;
121
+
122
+ const viewCode = instance.parent.type.name;
123
+ const $mode = instance.appContext.config.globalProperties.$mode;
124
+
125
+ const props = withDefaults(defineProps<IProps>(), {
126
+ /**
127
+ * @deprecated 2.10.0版本失效,
128
+ * */
129
+ serviceCode: (): IRecord => {
130
+ return {};
131
+ },
132
+ items: () => [],
133
+ columns: () => [],
134
+ editable: true,
135
+ autoLoad: true,
136
+ needExport: true
137
+ });
138
+
139
+ const { t } = useI18n();
140
+
141
+ const importOptions = ref<any>({});
142
+
143
+ const modalOptions = ref<any>({});
144
+ const modalGridOptions = ref<any>({});
145
+
146
+ const subModalGridOptions = ref<any>({});
147
+
148
+ const xgrid = ref(null);
149
+ const ygrid = ref(null);
150
+ const zgrid = ref(null);
151
+
152
+ const showFavorite = ref(false);
153
+
154
+ const serviceApi = instance.appContext.config.globalProperties.$serviceApi;
155
+
156
+ const favorite = {
157
+ icon: 'vxe-icon-setting',
158
+ name: 'favorite',
159
+ events: {
160
+ click: (e, option) => {
161
+ if (option.name === 'favorite') {
162
+ showFavorite.value = true;
163
+ }
164
+ }
165
+ }
166
+ };
167
+
168
+ /**
169
+ * @description: 根据items 获取必填选
170
+ */
171
+ const getRules = () => {
172
+ if (!props.columns.length) return {};
173
+ return formatRules(props.columns, t);
174
+ };
175
+ /**
176
+ * @description: colum 统一添加国家化
177
+ */
178
+ const getColumns = () => {
179
+ const columns = props.columns;
180
+ if (attrs.gridId) {
181
+ const cols = defaultColums
182
+ .filter(f => !columns.some(s => s.field === f.field))
183
+ .map(col => {
184
+ if (attrs.format && ['lastUpdateDate', 'creationDate'].includes(col.field)) {
185
+ col.formatter = attrs.format;
186
+ col.width = 90;
187
+ }
188
+ return col;
189
+ });
190
+ const idx = columns.findIndex(s => s.field === 'operate');
191
+ if (idx !== -1) {
192
+ columns.splice(idx, 0, ...cols);
193
+ } else {
194
+ columns.push(...cols);
195
+ }
196
+ }
197
+ const act_columns = attrs.gridId ? formatColums(columns) : columns;
198
+
199
+ return i18nColums(act_columns, attrs.sortable, attrs.gridId ? 20 : 0);
200
+ };
201
+
202
+ dbstorage.getItem(kSTORECOLUM).then(value => {
203
+ storeColums = value;
204
+ data.columns = getColumns();
205
+ });
206
+
207
+ const data = reactive<VxeGridProps>({
208
+ border: true,
209
+ pagerConfig: { pageSize: attrs.pageSize || 20 },
210
+ editConfig: {},
211
+ editRules: getRules(),
212
+ formConfig: {},
213
+ columnConfig: { useKey: true, drag: !!attrs.gridId },
214
+ columnDragConfig: {
215
+ visibleMethod: ({ column }) => {
216
+ return column.field !== 'operate' && !['checkbox', 'radio'].includes(column.type);
217
+ }
218
+ },
219
+ toolbarConfig: { enabled: false },
220
+ sortConfig: { multiple: true, trigger: 'cell' },
221
+ height: $mode ? undefined : window.innerHeight - 92,
222
+
223
+ checkboxConfig: {
224
+ checkMethod: ({ row }) => onCheckMethod(row, props),
225
+ checkRowKeys: props.checkRowKeys
226
+ },
227
+ loading: false,
228
+ footerRowClassName: 'ut-grid-footer',
229
+ proxyConfig: {
230
+ form: true, // 查询是需要启用表单代理
231
+ autoLoad: props.autoLoad,
232
+ showResponseMsgvxe: false,
233
+ showActionMsgvxe: false,
234
+ // 接收 Promise
235
+ ajax: {
236
+ queryAll: ({ form }) => queryAll(props, serviceApi, form),
237
+ query: ({ page, form, code }) => {
238
+ return query(props, form, page, serviceApi, code, $mode);
239
+ },
240
+ delete: ({ body: { removeRecords } }) => del(serviceApi, removeRecords, props),
241
+ save: ({ body }) => Promise.all(save(serviceApi, body, props)),
242
+ querySuccess: ({ response }) => callback('querySuccess', response),
243
+ queryError: ({ response }) => callback('queryError', response),
244
+ deleteSuccess: ({ response }) => callback('deleteSuccess', response),
245
+ deleteError: ({ response }) => callback('deleteError', response),
246
+ saveSuccess: ({ response }) => callback('saveSuccess', response),
247
+ saveError: ({ response }) => callback('saveError', response)
248
+ }
249
+ },
250
+ columns: !attrs.gridId ? getColumns() : [],
251
+ ...attrs
252
+ });
253
+
254
+ /**
255
+ * @description: 预处理查询form
256
+ * @return {*} items
257
+ */
258
+ const getItems = () => {
259
+ if (!props.items.length) return props.items;
260
+ const options = {
261
+ favorite: viewCode && props.url ? favorite : viewCode,
262
+ callback: () => {
263
+ refreshData();
264
+ }
265
+ };
266
+ return formatGridItems(clone(props.items, true), options);
267
+ };
268
+
269
+ /**
270
+ * @description 格式化column
271
+ * @return {*} columns
272
+ */
273
+ function formatColums(columns) {
274
+ const customSort = storeColums ? storeColums[attrs.gridId] : {};
275
+ if (!customSort) return columns;
276
+ return columns
277
+ .map((col, idx) => {
278
+ const sort = (idx + 1) * 10;
279
+ col._sort = customSort[col.field] || sort;
280
+ // 缓存列索引数据
281
+ cacheColumns[col.field] = col._sort;
282
+ return col;
283
+ })
284
+ .sort((a, b) => a._sort - b._sort);
285
+ }
286
+
287
+ /**
288
+ * @description: 设置grid参数
289
+ */
290
+ const setGridConfig = () => {
291
+ // 查询
292
+ if (props.items.length) {
293
+ // data.formConfig = {};
294
+ data.formConfig = {
295
+ titleWidth: 100,
296
+ titleAlign: 'right',
297
+ items: getItems(),
298
+ rules: formatRules(props.items, t),
299
+ validConfig: { showMessage: false }
300
+ };
301
+ }
302
+ // tool bar
303
+ const obj = getToolBarConfig(data, props, attrs, hasAuthority);
304
+ Object.assign(data, obj);
305
+ // 表格id,用于自定义列
306
+ if (attrs.gridId) {
307
+ data.id = attrs.gridId;
308
+ data.customConfig = {
309
+ storage: true,
310
+ showSortDragButton: false,
311
+ mode: 'popup',
312
+ checkMethod({ column }) {
313
+ return column.field === 'operate' || ['checkbox', 'radio'].includes(column.type) ? false : true;
314
+ },
315
+ modalOptions: {
316
+ width: 750,
317
+ height: '75%'
318
+ }
319
+ };
320
+ }
321
+ if (attrs.mergeFooter) {
322
+ // 合计方法
323
+ data.showFooter = true;
324
+ data.footerMethod = ({ columns, data }) => footerSumMethod({ columns, data }, attrs.mergeFooter);
325
+ }
326
+ };
327
+ /**
328
+ * @description 手动调用查询方法
329
+ */
330
+ const refreshData = () => {
331
+ xgrid.value.commitProxy('query');
332
+ };
333
+ /**
334
+ * @description 刷新列数据
335
+ */
336
+ const refreshColumn = () => {
337
+ data.editRules = getRules();
338
+ return xgrid.value.refreshColumn();
339
+ };
340
+ /**
341
+ * @description 显示加载框
342
+ */
343
+ const showLoading = () => {
344
+ data.loading = true;
345
+ };
346
+ /**
347
+ * @description 隐藏加载框
348
+ */
349
+ const hiddenLoading = () => {
350
+ data.loading = false;
351
+ };
352
+ /**
353
+ * @description 获取实例方法
354
+ * @return vxe-grid实例的方法
355
+ */
356
+ const getInstance = () => {
357
+ return toRaw(xgrid.value);
358
+ };
359
+ /**
360
+ * @description 获取表格全量数据方法
361
+ * @return vxe-grid表格全量数据
362
+ */
363
+ const getTableData = () => {
364
+ return xgrid.value.getTableData().fullData;
365
+ };
366
+ /**
367
+ * @description 获取表格选中的行
368
+ * @return vxe-grid表格勾选行
369
+ */
370
+ const getSelectRecords = (isFull = false) => {
371
+ const columnType = props.columns[0].type;
372
+ const checkRecords =
373
+ columnType === 'radio' ? xgrid.value.getRadioRecord(isFull) : xgrid.value.getCheckboxRecords(isFull);
374
+ if (columnType === 'checkbox' && !checkRecords.length) {
375
+ warnMessage(t('message.tip_selectedRecord'));
376
+ return [];
377
+ } else if (columnType === 'radio' && !checkRecords) {
378
+ warnMessage(t('message.tip_selectedRecord'));
379
+ return null;
380
+ }
381
+ return checkRecords;
382
+ };
383
+
384
+ const callback = (cb, response) => {
385
+ attrs?.callback && attrs?.callback[cb] && attrs?.callback[cb](response);
386
+ };
387
+
388
+ const onReset = async e => {
389
+ console.log(e);
390
+ const data = e.data;
391
+ const items = props.items.filter(f => f.itemRender?.props?.multiple);
392
+ console.log(items);
393
+ items.forEach(item => {
394
+ if (item.itemRender.props.defaultValue) {
395
+ data[`_${item.field}`] = item.itemRender.props.defaultValue.split(',');
396
+ data[`${item.field}`] = item.itemRender.props.defaultValue;
397
+ } else {
398
+ data[`_${item.field}`] = [];
399
+ }
400
+ });
401
+ if (items.length) {
402
+ // 多选时,重新查询一次
403
+ setTimeout(() => {
404
+ refreshData();
405
+ }, 200);
406
+ }
407
+ };
408
+
409
+ const onColumnDragend = ({ dragColumn }) => {
410
+ console.table(cacheColumns);
411
+ // 拖拽方向 1: 右 -1: 左
412
+ const direction = dragColumn.renderSortNumber - dragColumn.sortNumber > 0 ? 1 : -1;
413
+
414
+ // 获取新列
415
+ const newSort = (dragColumn.renderSortNumber + 1) * 10;
416
+ const oldSort = (dragColumn.sortNumber + 1) * 10;
417
+
418
+ // 目标列索引+1,方便后续计算
419
+ const comparisonVal = newSort + 1 * direction;
420
+ for (const key in cacheColumns) {
421
+ const cacheValue = cacheColumns[key];
422
+ if (direction > 0 && cacheValue < comparisonVal && cacheValue > oldSort) {
423
+ // 大于拖拽列且小于目标列的索引,均向前移动一个单位
424
+ cacheColumns[key] = cacheValue - 10 * direction;
425
+ } else if (direction < 0 && cacheValue > comparisonVal && cacheValue < oldSort) {
426
+ // 小于拖拽列且大于目标列的索引, 均向后移动一个单位
427
+ cacheColumns[key] = cacheValue - 10 * direction;
428
+ }
429
+ }
430
+
431
+ cacheColumns[dragColumn.field] = newSort;
432
+
433
+ dbstorage.setItem(kSTORECOLUM, { [attrs.gridId]: cacheColumns });
434
+ };
435
+
436
+ /**
437
+ * @description 常用查询面板确认查询
438
+ * @param data 常用查询条件
439
+ */
440
+ // const onSearch = data => {
441
+ // showFavorite.value = false;
442
+ // const { form } = xgrid.value.getProxyInfo();
443
+ // Object.assign(form, data);
444
+ // refreshData();
445
+ // };
446
+
447
+ /***************** upload start *********************** */
448
+
449
+ const showImport = options => {
450
+ options.method = options.method || 'put';
451
+ options.sourceList = options.sourceList || 'targetList';
452
+
453
+ importOptions.value = options;
454
+ importOptions.value.show = true;
455
+ };
456
+
457
+ const onCloseImport = () => {
458
+ importOptions.value.show = false;
459
+ refreshData();
460
+ };
461
+
462
+ /***************** upload end ********************* */
463
+
464
+ /***************** modal *********************** */
465
+
466
+ /**
467
+ * 显示模态框
468
+ * @description: columns存在时,优先显示表格模态框,否则显示表单模态框
469
+ * @param options
470
+ */
471
+ const showModal = options => {
472
+ let modalOptions = getOptionField(options);
473
+ if (modalOptions.value.show) {
474
+ // 最多支持2级弹框
475
+ return warnMessage(t('message.tip.dialog2Level'));
476
+ }
477
+ console.log('modalOptions', modalOptions);
478
+ if (options.columns?.length) {
479
+ options.editable = options.editable || options.status !== 'detail';
480
+ modalOptions.value = options;
481
+ modalOptions.value.show = true;
482
+ } else {
483
+ modalOptions.value = options;
484
+ modalOptions.value.record = clone(options.data || {});
485
+ modalOptions.value.dataStatus = options.status || 'edit';
486
+ modalOptions.value.show = true;
487
+ }
488
+ };
489
+
490
+ const hiddenModal = () => {
491
+ modalOptions.value.showModal = false;
492
+ };
493
+
494
+ const getOptionField = options => {
495
+ if (options.columns?.length) {
496
+ return modalGridOptions.value.show ? subModalGridOptions : modalGridOptions;
497
+ } else {
498
+ return modalOptions;
499
+ }
500
+ };
501
+
502
+ const onConfirm = (data: any, type: string) => {
503
+ let options = {};
504
+ if (type === 'modal') {
505
+ if (modalGridOptions.value.show) {
506
+ // 子表单模态框确认, 刷新子表数据
507
+ modalGridOptions.value.url && ygrid.value.refreshData();
508
+ options = getGridOptions('ygrid');
509
+ } else if (subModalGridOptions.value.show) {
510
+ // 子表单模态框确认, 刷新子表数据
511
+ modalGridOptions.value.url && zgrid.value.refreshData();
512
+ options = getGridOptions('zgrid');
513
+ } else {
514
+ modalOptions.value.url && refreshData();
515
+ }
516
+ } else {
517
+ options = getGridOptions(type);
518
+ }
519
+ emit('confirm', data, options);
520
+ };
521
+
522
+ /**
523
+ * 表格模态框按钮点击
524
+ * @description 若表格的模式为form且存在子表配置,则显示子表单模态框
525
+ */
526
+ const onModalButtonClick = (code: string, type: string) => {
527
+ const options = getGridOptions(type);
528
+ emit('buttonClick', code, options);
529
+ };
530
+
531
+ const getGridOptions = () => {
532
+ return {
533
+ type,
534
+ options: type === 'ygrid' ? modalGridOptions : subModalGridOptions,
535
+ instance: type === 'ygrid' ? ygrid : zgrid
536
+ };
537
+ };
538
+
539
+ const getModalItems = () => {
540
+ return modalOptions.value.items;
541
+ };
542
+
543
+ /************************************************ */
544
+
545
+ const reloadGrid = () => {
546
+ setGridConfig();
547
+ };
548
+
549
+ /**
550
+ * @description Vue实例对外暴露的相关方法或属性
551
+ */
552
+ defineExpose({
553
+ getTableData,
554
+ getSelectRecords,
555
+ refreshData,
556
+ refreshColumn,
557
+ getInstance,
558
+ showLoading,
559
+ hiddenLoading,
560
+ reloadGrid,
561
+ showImport,
562
+ showModal,
563
+ hiddenModal,
564
+ getModalItems
565
+ });
566
+
567
+ const toolbarButtonClick = ({ code }) => {
568
+ emit('buttonClick', code);
569
+ };
570
+ const cellClick = e => {
571
+ emit('cellClick', e);
572
+ };
573
+ const cellDbclick = e => {
574
+ emit('cellDbclick', e);
575
+ };
576
+ const editEctivated = e => {
577
+ emit('editEctivated', e);
578
+ };
579
+
580
+ /**
581
+ * @description: 监听窗口变化,动态改变表格的高度
582
+ */
583
+ const addResizeListener = () => {
584
+ window.onresize = () => {
585
+ return (() => setHeight())();
586
+ };
587
+ };
588
+
589
+ const setHeight = () => {
590
+ let height = attrs?.height || window.innerHeight - 90;
591
+ if (attrs.mode !== 'inline' && !attrs?.height) {
592
+ height = window.innerHeight - 180;
593
+ }
594
+ // 14寸电脑适配
595
+ if (window.innerHeight < 800) {
596
+ data.height = 520;
597
+ }
598
+ data.height = attrs.fixedHeight === false && height < 600 ? 600 : height;
599
+ };
600
+
601
+ /**
602
+ * @description Vue实例挂载
603
+ */
604
+ onBeforeMount(() => {
605
+ setGridConfig();
606
+ // 合并自定义属性
607
+ isObject(attrs) && merge(data, attrs || {});
608
+ attrs?.height && setHeight();
609
+ addResizeListener();
610
+ });
611
+
612
+ const emit = defineEmits<{
613
+ (e: 'buttonClick', code: string): void;
614
+ (e: 'cellClick', data: any): void;
615
+ (e: 'cellDbclick', data: any): void;
616
+ (e: 'editEctivated', data: any): void;
617
+ }>();
618
+ </script>
619
+
620
+ <style lang="scss">
621
+ .ut-grid-wrapper {
622
+ padding: 5px;
623
+ background-color: #fff;
624
+
625
+ .vxe-form--item {
626
+ padding: 0.1em 0.8em 0.1em 0 !important;
627
+
628
+ .el-select {
629
+ .el-input {
630
+ height: 26px;
631
+ }
632
+
633
+ .el-select__tags-text {
634
+ color: #000;
635
+ }
636
+ }
637
+ }
638
+
639
+ .vxe-grid--layout-body-content-wrapper {
640
+ overflow: hidden;
641
+ }
642
+ }
643
+ </style>