@utogether/udp-core 1.0.1-beta.6 → 1.0.1-beta.8

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 (90) hide show
  1. package/dist/{403-Co4hnzlW.js → 403-Cjzd1bv9.js} +1 -1
  2. package/dist/{404-BsseeBQQ.js → 404-CJ-3SXgP.js} +1 -1
  3. package/dist/{500-DtKz7MA4.js → 500-CQ65MvIK.js} +1 -1
  4. package/dist/{AuthorityInfo-iWYEWOmC.js → AuthorityInfo-BdISFrap.js} +1 -1
  5. package/dist/AuthorityInfo.vue_vue_type_style_index_0_lang-DsLG5slc.js +100 -0
  6. package/dist/{Company-CK8Zkcv3.js → Company-Mj-z1hNb.js} +3 -3
  7. package/dist/{CompanyPanel-DL4UrYYG.js → CompanyPanel-BNXZ7ER3.js} +1 -1
  8. package/dist/{Department-BPHn8to4.js → Department-C4ygVbSP.js} +3 -3
  9. package/dist/{DepartmentPanel-Bqraa_NB.js → DepartmentPanel-Bk96mDlD.js} +1 -1
  10. package/dist/{DesignPanel-CFOIOZme.js → DesignPanel-Bwx2QwMM.js} +1 -1
  11. package/dist/{DesignPanel.vue_vue_type_style_index_0_lang-H0FNG35Z.js → DesignPanel.vue_vue_type_style_index_0_lang-B3OjJTHG.js} +24 -26
  12. package/dist/{DictView-CaD1yHQS.js → DictView-DE3jnxnq.js} +19 -18
  13. package/dist/{InvOrganization-CoO0_wsY.js → InvOrganization-Drce3xUC.js} +1 -1
  14. package/dist/Org-C42D9lDj.js +39 -0
  15. package/dist/{Preview-B-K_bxDG.js → Preview-CCXoRvWF.js} +1 -1
  16. package/dist/{ReportDefine-DElbukSL.js → ReportDefine-BWsExcQU.js} +1 -1
  17. package/dist/{ReportDesign-DvUHOKDK.js → ReportDesign-BTzpUpGj.js} +26 -26
  18. package/dist/{ReportQuery-BcSYRNT3.js → ReportQuery-eoSmPXzc.js} +1 -1
  19. package/dist/{ReportQueryFrom-BGEA4Pqk.js → ReportQueryFrom-D4YlI5jl.js} +1 -1
  20. package/dist/{ReportQueryFrom.vue_vue_type_style_index_0_lang-B-KEPnfY.js → ReportQueryFrom.vue_vue_type_style_index_0_lang-DPDGKW9a.js} +1 -1
  21. package/dist/{ReportTemplate-DnPtEoxn.js → ReportTemplate-BTa2YWq0.js} +1 -1
  22. package/dist/{Role-CMKkWZil.js → Role-BTGB91P1.js} +6 -6
  23. package/dist/{RoleAssign-BToNzG9a.js → RoleAssign-BBSY6bYM.js} +3 -3
  24. package/dist/{RolePanel-BikZ-D2u.js → RolePanel-BaTuyeVC.js} +1 -1
  25. package/dist/{RolePanel-BNqd7-M6.js → RolePanel-DNDI7e0g.js} +1 -1
  26. package/dist/RolePanel.vue_vue_type_script_setup_true_lang-BCwAp_1a.js +132 -0
  27. package/dist/{RolePanel.vue_vue_type_script_setup_true_lang-Nngq860f.js → RolePanel.vue_vue_type_script_setup_true_lang-QUeAQHrg.js} +44 -38
  28. package/dist/{ScrollPanel.vue_vue_type_style_index_0_lang-BDRDD2FX.js → ScrollPanel.vue_vue_type_style_index_0_lang-nqrbOaQP.js} +1 -1
  29. package/dist/{Staff-DBFATgM_.js → Staff-4dbkOqzl.js} +3 -3
  30. package/dist/{StaffInfo-CrfwZcEL.js → StaffInfo-xFAMTWgD.js} +1 -1
  31. package/dist/{StaffInfo.vue_vue_type_script_setup_true_lang-CE3_NJF_.js → StaffInfo.vue_vue_type_script_setup_true_lang-CocRlLsO.js} +1 -1
  32. package/dist/{StaffPanel-D54Rl_Bg.js → StaffPanel-Cx-8MHBz.js} +1 -1
  33. package/dist/{StaffPanel.vue_vue_type_script_setup_true_lang-B8wtuSZD.js → StaffPanel.vue_vue_type_script_setup_true_lang-B3wfpxel.js} +2 -2
  34. package/dist/{SysUser-CsuovBei.js → SysUser-BHpgPXsI.js} +2 -2
  35. package/dist/{SysUserPanel-DNUwWEVp.js → SysUserPanel-DH79Lsnm.js} +1 -1
  36. package/dist/{SysUserPanel.vue_vue_type_script_setup_true_lang-CY6mhBV0.js → SysUserPanel.vue_vue_type_script_setup_true_lang-BONl2R1a.js} +104 -100
  37. package/dist/{SystemMenu-oLmwvaqT.js → SystemMenu-C2JbVgyr.js} +2 -2
  38. package/dist/{UserInfo-LyrDwBG1.js → UserInfo-Efo-_yRo.js} +1 -1
  39. package/dist/{UserInfo.vue_vue_type_style_index_0_lang-vinrRyOG.js → UserInfo.vue_vue_type_style_index_0_lang-DnjjBjMU.js} +39 -37
  40. package/dist/{childView-DGKp87fT.js → childView-D7U7qh_A.js} +1 -1
  41. package/dist/{childView-SmYl4G6c.js → childView-wFMGHGiX.js} +1 -1
  42. package/dist/{childView.vue_vue_type_style_index_0_lang-wVoPvyRY.js → childView.vue_vue_type_style_index_0_lang-Bshn4N8Y.js} +1 -1
  43. package/dist/{childView.vue_vue_type_style_index_0_lang-DU-Uun5d.js → childView.vue_vue_type_style_index_0_lang-w2CkZij-.js} +1 -1
  44. package/dist/{code-rule-CfbGjmOs.js → code-rule-B5dIxV6g.js} +1 -1
  45. package/dist/core.es.js +1 -1
  46. package/dist/{cron-task-DMfwGfms.js → cron-task-DWGtihrw.js} +1 -1
  47. package/dist/{frameView-D-hu_pqQ.js → frameView-DF2mXAwO.js} +1 -1
  48. package/dist/{index-ADANSV-q.js → index-VU6c04nN.js} +1562 -1309
  49. package/dist/{layoutView-D3SikBPr.js → layoutView-DUUKW0KX.js} +2 -2
  50. package/dist/{login-CQ1yBBdY.js → login-ByEoQ2HH.js} +11 -11
  51. package/dist/{lov-view-CSobDBH7.js → lov-view-DqD__3-w.js} +2 -2
  52. package/dist/{menuInfo-mFuM30f1.js → menuInfo-a7jPwS1r.js} +1 -1
  53. package/dist/{menuInfo.vue_vue_type_style_index_0_lang-BsIPzYg0.js → menuInfo.vue_vue_type_style_index_0_lang-ZzGrkylA.js} +2 -2
  54. package/dist/{pda-app-CIGFsvrX.js → pda-app-EP9d0Ypd.js} +201 -189
  55. package/dist/{resource-mbd4LPi-.js → resource-eughqxkP.js} +1 -1
  56. package/dist/{su-welcome-DruLsVvu.js → su-welcome-98GLKyZM.js} +1 -1
  57. package/dist/{sys-config-TXb5cJM4.js → sys-config-gs16tgwA.js} +1 -1
  58. package/dist/udp-core.css +2 -2
  59. package/dist/{utogether-Cv0UXnEX.js → utogether-C4Dd2epc.js} +1 -1
  60. package/package.json +1 -1
  61. package/src/App.vue +1 -6
  62. package/src/components/SuCharts/src/UserInfo.vue +78 -78
  63. package/src/components/udp/grid.vue +2 -18
  64. package/src/components/udp/index.ts +2 -2
  65. package/src/components/udp/modal-grid.vue +288 -297
  66. package/src/components/udp/utils.ts +11 -18
  67. package/src/main.ts +10 -2
  68. package/src/plugins/i18n/en.ts +24 -13
  69. package/src/plugins/i18n/zh.ts +348 -342
  70. package/src/plugins/vxe-table/index.ts +1 -1
  71. package/src/plugins/vxe-table/render.tsx +92 -17
  72. package/src/style/vxetable.scss +293 -287
  73. package/src/views/organization/org/Org.vue +9 -5
  74. package/src/views/system/menu/SystemMenu.vue +4 -18
  75. package/src/views/system/menu/menuInfo.vue +4 -17
  76. package/src/views/system/role/AuthorityInfo.vue +19 -15
  77. package/src/views/system/role/Role.vue +1 -5
  78. package/src/views/system/role/RolePanel.vue +11 -2
  79. package/src/views/system/role/UserInfo.vue +195 -193
  80. package/src/views/system/role-assign/RolePanel.vue +139 -136
  81. package/src/views/system/sysUser/SysUserPanel.vue +278 -282
  82. package/src/views/uapp/pda/pda-app.vue +36 -11
  83. package/src/views/udev/dict/DictView.vue +6 -1
  84. package/src/views/udev/dict/childView.vue +1 -6
  85. package/src/views/ulogin/login.vue +1 -5
  86. package/src/views/urpt/design/DesignPanel.vue +507 -526
  87. package/src/views/urpt/design/ReportDesign.vue +7 -11
  88. package/dist/AuthorityInfo.vue_vue_type_style_index_0_lang-BWp7PKyH.js +0 -102
  89. package/dist/Org-BU3oaFx3.js +0 -35
  90. package/dist/RolePanel.vue_vue_type_script_setup_true_lang-DYP3u1Nv.js +0 -126
@@ -1,297 +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 } from 'xe-utils';
54
- import {
55
- queryAll,
56
- query,
57
- del,
58
- save,
59
- footerSumMethod,
60
- getToolBarConfig,
61
- onCheckMethod,
62
- getAttrs
63
- } from './utils';
64
-
65
- // import type { IRecord, IFormItemProps, ITableColProps } from '../../types';
66
-
67
- export interface IProps {
68
- checkMethod?: Function;
69
- columns: Array<ITableColProps>; // 列表行
70
- defaultValue?: IRecord;
71
- defaultParams?: IRecord;
72
- gridOptions?: IRecord;
73
- auth?: IRecord;
74
- url?: string; // 查询服务路径
75
- submitUrl?: string; // 确认
76
- checkRowKeys?: Array<string>; // 默认选中列表
77
- items?: Array<IFormItemProps>; // 查询条件
78
- title?: string; // 标题
79
- width?: number | string;
80
- height?: number;
81
- editable?: boolean; // 可编辑
82
- needExport?: boolean; // 是否需要导出
83
- showFooter?: boolean; // 显示底部按钮
84
- addChild?: boolean; // 可编辑
85
- autoClose?: boolean; // 组件自主关闭
86
- autoLoad?: boolean; // 是否自动加载查询数据
87
- }
88
- const attrs: IRecord = getAttrs(useAttrs());
89
-
90
- const props = withDefaults(defineProps<IProps>(), {
91
- gridOptions: () => {
92
- return {};
93
- },
94
- items: () => [],
95
- columns: () => [],
96
- checkRowKeys: () => [],
97
- addChild: false,
98
- editable: true,
99
- showFooter: false,
100
- autoLoad: true,
101
- needExport: true,
102
- autoClose: true,
103
- width: '520',
104
- height: 420,
105
- title: '数据记录',
106
- url: '',
107
- submitUrl: ''
108
- });
109
-
110
- const showModal = ref(false);
111
-
112
- const xGrid = ref(null);
113
- const instance = getCurrentInstance()!;
114
-
115
- const hasAuthority = instance.appContext.config.globalProperties.$hasAuthority;
116
- const serviceApi = instance.appContext.config.globalProperties.$serviceApi;
117
- const $mode = instance.appContext.config.globalProperties.$mode;
118
-
119
- const { t } = useI18n();
120
-
121
- /**
122
- * @description: colum 统一添加国家化
123
- */
124
- const getColumns = () => {
125
- const col = props.columns.map(m => {
126
- if (!props.editable) {
127
- m.editRender = { enabled: false };
128
- } else if (!m.type && !m.editRender && props.editable && !!m.editable) {
129
- m.editRender = { name: 'VxeInput' };
130
- }
131
- return m;
132
- });
133
- return i18nColums(col);
134
- };
135
-
136
- const getItems = () => {
137
- if (!props.items.length) return props.items;
138
- return formatGridItems(clone(props.items, true));
139
- };
140
-
141
- /**
142
- * @description: 根据items 获取必填选
143
- */
144
- const getRules = () => {
145
- if (!props.columns.length) return {};
146
- return formatRules(props.columns, t);
147
- };
148
-
149
- const data = reactive<VxeGridProps>({
150
- loading: false,
151
- border: true,
152
- pagerConfig: {},
153
- formConfig: {},
154
- toolbarConfig: { enabled: false },
155
- height: 'auto',
156
- editConfig: {},
157
- rowConfig: { keyField: '_X_ROW_KEY' },
158
- editRules: getRules(),
159
- proxyConfig: {
160
- form: true, // 查询是需要启用表单代理
161
- autoLoad: props.autoLoad,
162
- ajax: {
163
- queryAll: ({ form }) => queryAll(props, serviceApi, form),
164
- query: ({ page, form }) => query(props, form, page, serviceApi, $mode),
165
- delete: ({ body: { removeRecords } }) => del(serviceApi, removeRecords, props),
166
- save: ({ body }) => Promise.all(save(serviceApi, body, props))
167
- }
168
- },
169
- checkboxConfig: {
170
- checkMethod: ({ row }) => onCheckMethod(row, props),
171
- checkRowKeys: props.checkRowKeys
172
- },
173
- columns: getColumns(),
174
- ...props.gridOptions
175
- });
176
-
177
- // 确认数据
178
- const onConfirm = async () => {
179
- let records = null;
180
- const type = props.columns[0].type;
181
- if (type === 'checkbox') {
182
- records = xGrid.value.getCheckboxRecords();
183
- } else if (type === 'radio') {
184
- records = xGrid.value.getRadioRecord();
185
- } else {
186
- records = xGrid.value.getTableData().fullData;
187
- }
188
- if (type === 'checkbox' && !records.length && !props.addChild) {
189
- return warnMessage(t('message.selectedRecord'));
190
- } else if (type === 'radio' && !records) {
191
- return warnMessage(t('message.selectedRecord'));
192
- }
193
- if (isFunction(attrs.beforeConfirm) && !attrs.beforeConfirm(records)) return;
194
- const { submitUrl } = props;
195
- // 服务submitUrl
196
- if (submitUrl) {
197
- showLoading();
198
- let res;
199
- try {
200
- records.forEach(record => Object.assign(record, props.defaultParams));
201
- res = await serviceApi.post(submitUrl, records);
202
- } finally {
203
- res && emit('confirm', res);
204
- res && successMessage(t('message.operateSuccess'));
205
- close();
206
- hiddenLoading();
207
- }
208
- } else {
209
- props.autoClose && close();
210
- emit('confirm', records);
211
- }
212
- };
213
- // 请求数据
214
- const refreshData = () => {
215
- xGrid.value.commitProxy('query');
216
- };
217
- const refreshColumn = () => {
218
- data.editRules = getRules();
219
- xGrid.value.refreshColumn();
220
- };
221
- const getInstance = () => {
222
- return toRaw(xGrid.value);
223
- };
224
- const cellClick = ({ row }) => {
225
- const type = props.columns[0].type;
226
- if (type === 'checkbox') {
227
- xGrid.value.setCheckboxRow(row, true);
228
- } else if (type === 'radio') {
229
- xGrid.value.setRadioRow(row);
230
- }
231
- };
232
- // 单元格被激活编辑激活回调
233
- const onEditActived = data => {
234
- emit('actived', data);
235
- };
236
- const toolbarButtonClick = ({ code }) => {
237
- emit('buttonClick', code);
238
- };
239
- const showLoading = () => {
240
- data.loading = true;
241
- };
242
- const hiddenLoading = () => {
243
- data.loading = false;
244
- };
245
- const emit = defineEmits<{
246
- (e: 'close'): void;
247
- (e: 'confirm', record: any): void;
248
- (e: 'actived', record: any): void;
249
- (e: 'buttonClick', code: string): void;
250
- }>();
251
- // 关闭弹框
252
- const close = () => {
253
- if (isFunction(attrs.beforeClose) && !attrs.beforeClose()) return;
254
- showModal.value = false;
255
- emit('close');
256
- };
257
-
258
- /**
259
- * @description: 设置grid参数
260
- */
261
-
262
- const setGridConfig = () => {
263
- // 查询
264
- if (props.items.length) {
265
- data.formConfig = {
266
- titleWidth: 100,
267
- titleAlign: 'right',
268
- items: getItems(),
269
- rules: formatRules(props.items, t),
270
- validConfig: { showMessage: false }
271
- };
272
- }
273
- // tool bar
274
- const obj = getToolBarConfig(data, props, attrs, hasAuthority);
275
- Object.assign(data, obj);
276
-
277
- // 合计方法
278
- if (attrs.mergeFooter) {
279
- data.showFooter = true;
280
- data.footerMethod = ({ columns, data }) => footerSumMethod({ columns, data }, attrs.mergeFooter);
281
- }
282
- };
283
-
284
- // 子组件需对外暴露方法
285
- defineExpose({
286
- refreshData,
287
- refreshColumn,
288
- getInstance,
289
- showLoading,
290
- hiddenLoading,
291
- close
292
- });
293
- onBeforeMount(() => {
294
- showModal.value = true;
295
- setGridConfig();
296
- });
297
- </script>
1
+ <!--
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>