@utogether/udp-core 1.0.1-beta.1 → 1.0.1-beta.11
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.
- package/build/plugins.ts +39 -32
- package/dist/{403-Dp617CWX.js → 403-Dsgsr2M-.js} +1 -1
- package/dist/{404-Cz_Axb6Y.js → 404-DmPHEfqM.js} +1 -1
- package/dist/{500-BGCtRNse.js → 500-OYEgHR2a.js} +1 -1
- package/dist/{AuthorityInfo-DGGfm7IS.js → AuthorityInfo-B1H1txG-.js} +1 -1
- package/dist/AuthorityInfo.vue_vue_type_style_index_0_lang-BUlmQtjQ.js +100 -0
- package/dist/{Company-IV3GTnzY.js → Company-C8ojgx93.js} +3 -3
- package/dist/{CompanyPanel-qV-_VtoL.js → CompanyPanel-Dageer1t.js} +16 -16
- package/dist/{Department-B3W-OxW8.js → Department-Dr94_85I.js} +3 -3
- package/dist/{DepartmentPanel-Cw3OWxE7.js → DepartmentPanel-Bc5r1HpT.js} +1 -1
- package/dist/{DesignPanel-BFxR2fHJ.js → DesignPanel-CcWt1Myp.js} +1 -1
- package/dist/{DesignPanel.vue_vue_type_style_index_0_lang-DljbeFba.js → DesignPanel.vue_vue_type_style_index_0_lang-CKA6nx1l.js} +24 -26
- package/dist/DictView-BHj6wexC.js +110 -0
- package/dist/InvOrganization-DP3Le9g-.js +72 -0
- package/dist/Org-BRGHTwsw.js +39 -0
- package/dist/{Preview-BlDMmpdR.js → Preview-CqMaUD_3.js} +1 -1
- package/dist/{ReportDefine-Cub_85LA.js → ReportDefine-PEQdTCOY.js} +1 -1
- package/dist/{ReportDesign-hFhq5UVE.js → ReportDesign-CB4bv8ba.js} +43 -43
- package/dist/{ReportQuery-ChkWEyxT.js → ReportQuery-B7t4lMK0.js} +1 -1
- package/dist/{ReportQueryFrom-KVyD_8Dj.js → ReportQueryFrom-VBxUIMRJ.js} +1 -1
- package/dist/{ReportQueryFrom.vue_vue_type_style_index_0_lang-CLNODquq.js → ReportQueryFrom.vue_vue_type_style_index_0_lang-HeLA4Qs5.js} +1 -1
- package/dist/{ReportTemplate-ag9NDvh2.js → ReportTemplate-DNkv7F5p.js} +28 -28
- package/dist/{Role-_q3lQ8CZ.js → Role-BGfTpZK4.js} +6 -6
- package/dist/{RoleAssign-DZb9IRsm.js → RoleAssign-DrKFWZzA.js} +8 -8
- package/dist/{RolePanel-CsLsz-Ds.js → RolePanel-3lvRh7aS.js} +1 -1
- package/dist/{RolePanel-BQb1LlhD.js → RolePanel-BRI5QYe4.js} +1 -1
- package/dist/RolePanel.vue_vue_type_script_setup_true_lang-BXKZb7yt.js +132 -0
- package/dist/{RolePanel.vue_vue_type_script_setup_true_lang-BrnRgHEk.js → RolePanel.vue_vue_type_script_setup_true_lang-Cci_Ysty.js} +44 -38
- package/dist/{ScrollPanel.vue_vue_type_style_index_0_lang-CaFKRwXu.js → ScrollPanel.vue_vue_type_style_index_0_lang-BmId6zzA.js} +21 -21
- package/dist/{Staff-BSf9Ypbk.js → Staff-Dr0dq3fW.js} +3 -3
- package/dist/{StaffInfo-BNKasyMF.js → StaffInfo-_N9g2hPa.js} +1 -1
- package/dist/{StaffInfo.vue_vue_type_script_setup_true_lang-DDZ7ukd0.js → StaffInfo.vue_vue_type_script_setup_true_lang-DiTJY2ug.js} +11 -11
- package/dist/{StaffPanel-Bpq0WVlH.js → StaffPanel-mxJQiW3G.js} +1 -1
- package/dist/{StaffPanel.vue_vue_type_script_setup_true_lang-BhiJ0Q-Q.js → StaffPanel.vue_vue_type_script_setup_true_lang-GRGn-5t6.js} +2 -2
- package/dist/{SysUser-FAABuNti.js → SysUser-DgA19hZE.js} +2 -2
- package/dist/{SysUserPanel-PxJeOgHm.js → SysUserPanel-Bc85z5_K.js} +1 -1
- package/dist/SysUserPanel.vue_vue_type_script_setup_true_lang-BHDrP1Pk.js +294 -0
- package/dist/{SystemMenu-C-7NAGon.js → SystemMenu-Be-gFIie.js} +26 -26
- package/dist/{UserInfo-ClXKtyGo.js → UserInfo-BCYuwFmr.js} +1 -1
- package/dist/{UserInfo.vue_vue_type_style_index_0_lang-8N7P4Hl7.js → UserInfo.vue_vue_type_style_index_0_lang-B1lgokO6.js} +39 -37
- package/dist/{childView-C_HmDQNd.js → childView-DhcBr1UA.js} +1 -1
- package/dist/{childView-uUlBcTza.js → childView-Dk4zZoXd.js} +1 -1
- package/dist/{childView.vue_vue_type_style_index_0_lang-Ckjmw6wJ.js → childView.vue_vue_type_style_index_0_lang-CVnLnl03.js} +40 -40
- package/dist/{childView.vue_vue_type_style_index_0_lang-y0sDvYx5.js → childView.vue_vue_type_style_index_0_lang-D4GYVhOc.js} +1 -1
- package/dist/{code-rule-AgCVDKFy.js → code-rule-BSwPwuAL.js} +9 -10
- package/dist/core.es.js +14 -11
- package/dist/{cron-task-C6FgQxTi.js → cron-task-T1ztyra7.js} +1 -1
- package/dist/{frameView-BDgISK7N.js → frameView-BDgngiBq.js} +1 -1
- package/dist/img/l_img.svg +1 -1
- package/dist/img/minicolors.png +0 -0
- package/dist/img/v_img.svg +1 -1
- package/dist/index-BSj2AtVL.js +4468 -0
- package/dist/{layoutView-yb3DV2DQ.js → layoutView-i7dLLBzJ.js} +1181 -1176
- package/dist/{login-RRpljbkm.js → login-K5Ludp8x.js} +105 -113
- package/dist/{login-log-CvVnyGi3.js → login-log-kqKzKTto.js} +1 -1
- package/dist/{lov-view-C9-rjzZR.js → lov-view-lAexiucu.js} +2 -2
- package/dist/{menuInfo-CzPQyFhp.js → menuInfo-BaN5YZPp.js} +1 -1
- package/dist/{menuInfo.vue_vue_type_style_index_0_lang-BumXunCg.js → menuInfo.vue_vue_type_style_index_0_lang-yI4QOYxG.js} +100 -97
- package/dist/{pda-app-Dvy3U-b6.js → pda-app-DEtDXFvM.js} +211 -197
- package/dist/{resource-Fy0lFkSV.js → resource-Bztmz7pn.js} +15 -15
- package/dist/{su-welcome-DYvSCUST.js → su-welcome-Bx8nBPi9.js} +109 -110
- package/dist/sys-config-nvrtYGgi.js +290 -0
- package/dist/udp-core.css +2 -2
- package/dist/{utogether-CjmJiHoE.js → utogether-yPnwDAIH.js} +1 -1
- package/index.ts +40 -36
- package/package.json +18 -18
- package/src/App.vue +65 -70
- package/src/api/index.ts +31 -31
- package/src/components/SuCharts/src/UserInfo.vue +78 -78
- package/src/components/SuScrollTree/ScrollPanel.vue +3 -3
- package/src/components/udp/count-down.vue +536 -0
- package/src/components/udp/flip-down/FlipCard/flip-card.vue +251 -0
- package/src/components/udp/flip-down/FlipCard/interfaces.ts +4 -0
- package/src/components/udp/flip-down/FlipClock/flip-clock.vue +113 -0
- package/src/components/udp/form-upload.vue +414 -64
- package/src/components/udp/form.vue +112 -0
- package/src/components/udp/grid.vue +495 -0
- package/src/components/udp/index.ts +10 -4
- package/src/components/udp/lov.vue +388 -0
- package/src/components/udp/modal-form.vue +13 -3
- package/src/components/udp/modal-grid.vue +298 -0
- package/src/components/udp/upload.vue +423 -0
- package/src/components/udp/utils.ts +447 -40
- package/src/directives/permission/index.ts +1 -1
- package/src/layout/components/lay-navbar/index.vue +239 -237
- package/src/layout/components/lay-panel/index.vue +150 -150
- package/src/layout/components/lay-search/index.vue +25 -25
- package/src/layout/components/lay-select-org/index.vue +64 -69
- package/src/layout/components/lay-sidebar/breadCrumb.vue +1 -1
- package/src/layout/components/lay-sidebar/horizontal.vue +190 -191
- package/src/layout/components/lay-sidebar/mixNav.vue +260 -258
- package/src/layout/components/lay-sidebar/sidebar-logo.vue +92 -98
- package/src/layout/components/lay-tag/index.vue +625 -625
- package/src/layout/hooks/useNav.ts +173 -173
- package/src/layout/layoutView.vue +215 -215
- package/src/main.ts +119 -109
- package/src/plugins/i18n/en.ts +302 -289
- package/src/plugins/i18n/zh.ts +349 -337
- package/src/plugins/vxe-table/index.ts +53 -46
- package/src/plugins/vxe-table/render.tsx +956 -817
- package/src/router/index.ts +177 -183
- package/src/router/modules/remaining.ts +58 -83
- package/src/store/modules/permission.ts +1 -4
- package/src/style/button.scss +85 -78
- package/src/style/tailwind.css +1 -68
- package/src/style/vxetable.scss +44 -11
- package/src/utils/authority/index.ts +1 -1
- package/src/utils/{http → udp/http}/index.ts +283 -297
- package/src/utils/{http → udp/http}/types.d.ts +8 -5
- package/src/utils/udp/useRender.ts +17 -6
- package/src/views/login/login-view.vue +300 -314
- package/src/views/organization/company/CompanyPanel.vue +259 -259
- package/src/views/organization/inv-org/InvOrganization.vue +68 -54
- package/src/views/organization/org/Org.vue +9 -5
- package/src/views/system/menu/SystemMenu.vue +183 -197
- package/src/views/system/menu/menuInfo.vue +363 -371
- package/src/views/system/role/AuthorityInfo.vue +19 -15
- package/src/views/system/role/Role.vue +1 -5
- package/src/views/system/role/RolePanel.vue +11 -2
- package/src/views/system/role/UserInfo.vue +195 -193
- package/src/views/system/role-assign/RoleAssign.vue +57 -57
- package/src/views/system/role-assign/RolePanel.vue +139 -136
- package/src/views/system/sys/sys-config.vue +287 -291
- package/src/views/system/sysUser/SysUserPanel.vue +278 -278
- package/src/views/uapp/pda/pda-app.vue +208 -176
- package/src/views/udev/dict/DictView.vue +118 -106
- package/src/views/udev/dict/childView.vue +7 -7
- package/src/views/udev/lov/lov-view.vue +91 -91
- package/src/views/ufile/aggregation/File.vue +5 -5
- package/src/views/ufile/file/water-mark.vue +14 -14
- package/src/views/uhome/su-welcome.vue +3 -3
- package/src/views/ulogin/login.vue +12 -8
- package/src/views/upms/user/login-log.vue +1 -1
- package/src/views/urpt/design/DesignPanel.vue +507 -526
- package/src/views/urpt/design/ReportDesign.vue +15 -19
- package/src/views/urpt/static-resource/resource.vue +3 -3
- package/src/views/urpt/template/ReportTemplate.vue +7 -7
- package/types/global.d.ts +2 -1
- package/vite.config.ts +6 -2
- package/dist/AuthorityInfo.vue_vue_type_style_index_0_lang-BqccGW7v.js +0 -102
- package/dist/DictView-C-i7e4hZ.js +0 -95
- package/dist/InvOrganization-cfT6riGU.js +0 -260
- package/dist/Org-CA7vTDIF.js +0 -35
- package/dist/RolePanel.vue_vue_type_script_setup_true_lang-cmW7zBLu.js +0 -126
- package/dist/SysUserPanel.vue_vue_type_script_setup_true_lang-njefUln5.js +0 -288
- package/dist/index-DzOzUkf6.js +0 -3388
- package/dist/sys-config-DJ1vNQTy.js +0 -277
|
@@ -0,0 +1,298 @@
|
|
|
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>
|
|
@@ -0,0 +1,423 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
* @Author: wei.li
|
|
3
|
+
* @Date: 2022-06-21 14:50:52
|
|
4
|
+
* @LastEditors: levi7754 levi7754@163.com
|
|
5
|
+
* @LastEditTime: 2025-08-03 16:01:16
|
|
6
|
+
* @Description: excel数据导入
|
|
7
|
+
-->
|
|
8
|
+
<template>
|
|
9
|
+
<vxe-modal v-model="visible" :show-header="false" fullscreen remember @close="onClose">
|
|
10
|
+
<template #default>
|
|
11
|
+
<vxe-grid ref="xgrid" v-bind="gridOptions" v-on="gridEvents">
|
|
12
|
+
<template v-for="col in columns" :key="col.field" #[col.field!]="{ row }">
|
|
13
|
+
<el-select v-if="col.dictCode && !col.disabled" v-model.trim="row[col.field!]" clearable>
|
|
14
|
+
<el-option
|
|
15
|
+
v-for="child in dict[col.dictCode]?.children"
|
|
16
|
+
:key="child.dictCode"
|
|
17
|
+
:value="child.dictCode"
|
|
18
|
+
:label="child.dictName"
|
|
19
|
+
/>
|
|
20
|
+
</el-select>
|
|
21
|
+
<el-date-picker
|
|
22
|
+
v-else-if="['date', 'month', 'datetime'].includes(col.dataType) && !col.disabled"
|
|
23
|
+
v-model.trim="row[col.field!]"
|
|
24
|
+
:type="col.dataType"
|
|
25
|
+
value-format="YYYY-MM-DD hh:mm:ss"
|
|
26
|
+
/>
|
|
27
|
+
<input v-else-if="!col.da && !col.disabled" v-model.trim="row[col.field!]" class="ut-input" />
|
|
28
|
+
<span v-else-if="!showErrorMsg">{{ row[col.field!] }}</span>
|
|
29
|
+
<span v-else>{{ row[col.field!] }}</span>
|
|
30
|
+
</template>
|
|
31
|
+
<template #pager>
|
|
32
|
+
<vxe-pager
|
|
33
|
+
v-model:current-page="listQuery.currentPage"
|
|
34
|
+
v-model:page-size="listQuery.pageSize"
|
|
35
|
+
:layouts="layouts"
|
|
36
|
+
:page-sizes="[200, 500, 1000, 2000, 5000, 10000]"
|
|
37
|
+
:total="listQuery.total"
|
|
38
|
+
@page-change="handlePageChange"
|
|
39
|
+
/></template>
|
|
40
|
+
</vxe-grid>
|
|
41
|
+
</template>
|
|
42
|
+
</vxe-modal>
|
|
43
|
+
</template>
|
|
44
|
+
|
|
45
|
+
<script lang="ts">
|
|
46
|
+
export default {
|
|
47
|
+
name: 'UtUpload'
|
|
48
|
+
};
|
|
49
|
+
</script>
|
|
50
|
+
<script setup lang="ts">
|
|
51
|
+
import { reactive, ref, watch, getCurrentInstance } from 'vue';
|
|
52
|
+
import { toDateString } from 'xe-utils';
|
|
53
|
+
import { storageLocal, cookies, warnMessage } from '@utogether/utils';
|
|
54
|
+
import Big from 'big.js';
|
|
55
|
+
import { useI18n } from 'vue-i18n';
|
|
56
|
+
// import type { IRecord, ITableColProps } from '../../types';
|
|
57
|
+
import { VxeTableInstance, VxeGridProps, VxeGridListeners } from 'vxe-table';
|
|
58
|
+
import { VxeUI } from 'vxe-pc-ui';
|
|
59
|
+
import type { VxePagerPropTypes, VxePagerEvents } from 'vxe-pc-ui';
|
|
60
|
+
|
|
61
|
+
export interface IProps {
|
|
62
|
+
defaultParams?: IRecord;
|
|
63
|
+
options?: IRecord;
|
|
64
|
+
columns: Array<ITableColProps>;
|
|
65
|
+
templateData?: Array<ITableColProps>;
|
|
66
|
+
serviceCode?: string;
|
|
67
|
+
url?: string;
|
|
68
|
+
sourceList?: string;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const props = withDefaults(defineProps<IProps>(), {
|
|
72
|
+
defaultParams: (): IRecord => {
|
|
73
|
+
return {};
|
|
74
|
+
},
|
|
75
|
+
options: (): IRecord => {
|
|
76
|
+
return {
|
|
77
|
+
filename: '数据模板',
|
|
78
|
+
errorField: 'errorMsg',
|
|
79
|
+
errListField: 'list'
|
|
80
|
+
};
|
|
81
|
+
},
|
|
82
|
+
columns: () => [],
|
|
83
|
+
templateData: () => [],
|
|
84
|
+
sourceList: 'list'
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
const instance = getCurrentInstance()!;
|
|
88
|
+
const serviceApi = instance.appContext.config.globalProperties.$serviceApi;
|
|
89
|
+
const visible = defineModel<boolean>('visible');
|
|
90
|
+
|
|
91
|
+
const { t } = useI18n();
|
|
92
|
+
|
|
93
|
+
const showErrorMsg = ref(false);
|
|
94
|
+
|
|
95
|
+
const dict = storageLocal.getItem('kLov');
|
|
96
|
+
|
|
97
|
+
watch(
|
|
98
|
+
() => visible.value,
|
|
99
|
+
nv => {
|
|
100
|
+
if (nv) {
|
|
101
|
+
gridOptions.data = [];
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
);
|
|
105
|
+
|
|
106
|
+
const getColumns = () => {
|
|
107
|
+
const columns = props.columns.map(col => {
|
|
108
|
+
col.slots = { default: col.field };
|
|
109
|
+
col.title = col.field;
|
|
110
|
+
return col;
|
|
111
|
+
});
|
|
112
|
+
const col: ITableColProps = {
|
|
113
|
+
type: 'checkbox',
|
|
114
|
+
width: 40,
|
|
115
|
+
align: 'center',
|
|
116
|
+
fixed: 'left'
|
|
117
|
+
};
|
|
118
|
+
columns.unshift(col);
|
|
119
|
+
return columns;
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
const listQuery = ref({ pageSize: 200, currentPage: 1, total: 0 });
|
|
123
|
+
|
|
124
|
+
const layouts: VxePagerPropTypes.Layouts = [
|
|
125
|
+
'Sizes',
|
|
126
|
+
'PrevJump',
|
|
127
|
+
'PrevPage',
|
|
128
|
+
'Number',
|
|
129
|
+
'NextPage',
|
|
130
|
+
'NextJump',
|
|
131
|
+
'FullJump',
|
|
132
|
+
'Total'
|
|
133
|
+
];
|
|
134
|
+
|
|
135
|
+
const height = window.innerHeight - 25;
|
|
136
|
+
|
|
137
|
+
const xgrid = ref<VxeTableInstance>();
|
|
138
|
+
// 导入的所有数据
|
|
139
|
+
let dataList: ITableColProps[] = [];
|
|
140
|
+
|
|
141
|
+
const importConfig = {
|
|
142
|
+
mode: 'covering',
|
|
143
|
+
types: ['csv', 'xlsx'],
|
|
144
|
+
afterImportMethod: onImportMethod
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
const gridOptions = reactive<VxeGridProps>({
|
|
148
|
+
border: true,
|
|
149
|
+
height,
|
|
150
|
+
data: [],
|
|
151
|
+
importConfig,
|
|
152
|
+
showOverflow: true,
|
|
153
|
+
loading: false,
|
|
154
|
+
toolbarConfig: {
|
|
155
|
+
buttons: [
|
|
156
|
+
{
|
|
157
|
+
code: 'import_plus',
|
|
158
|
+
name: t('message.btn.upload'),
|
|
159
|
+
icon: 'ri-upload-2-line',
|
|
160
|
+
status: 'primary'
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
code: 'save_plus',
|
|
164
|
+
name: t('message.btn.save'),
|
|
165
|
+
icon: 'ri-save-3-line',
|
|
166
|
+
status: 'success'
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
code: 'del_plus',
|
|
170
|
+
name: t('message.btn.delete'),
|
|
171
|
+
icon: 'ri-delete-bin-line',
|
|
172
|
+
status: 'danger'
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
code: 'export_plus',
|
|
176
|
+
name: t('message.btn.downloadTemp'),
|
|
177
|
+
icon: 'ri-download-2-line',
|
|
178
|
+
status: 'warning'
|
|
179
|
+
}
|
|
180
|
+
],
|
|
181
|
+
tools: [
|
|
182
|
+
{
|
|
183
|
+
code: 'question',
|
|
184
|
+
name: t('message.btn.FAQ'),
|
|
185
|
+
status: 'primary',
|
|
186
|
+
icon: 'vxe-icon-info-circle-fill'
|
|
187
|
+
},
|
|
188
|
+
{
|
|
189
|
+
code: 'replay',
|
|
190
|
+
name: t('message.btn.back'),
|
|
191
|
+
status: 'info',
|
|
192
|
+
icon: 'vxe-icon-undo'
|
|
193
|
+
}
|
|
194
|
+
]
|
|
195
|
+
},
|
|
196
|
+
columns: getColumns()
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
const gridEvents: VxeGridListeners = {
|
|
200
|
+
toolbarButtonClick({ code }) {
|
|
201
|
+
// const $grid = xgrid.value;
|
|
202
|
+
switch (code) {
|
|
203
|
+
case 'import_plus': {
|
|
204
|
+
handleImport();
|
|
205
|
+
break;
|
|
206
|
+
}
|
|
207
|
+
case 'save_plus': {
|
|
208
|
+
handleSave();
|
|
209
|
+
break;
|
|
210
|
+
}
|
|
211
|
+
case 'del_plus': {
|
|
212
|
+
handleDelete();
|
|
213
|
+
break;
|
|
214
|
+
}
|
|
215
|
+
case 'export_plus': {
|
|
216
|
+
handleDownLoadFile();
|
|
217
|
+
break;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
},
|
|
221
|
+
toolbarToolClick({ code }) {
|
|
222
|
+
// const $grid = xgrid.value;
|
|
223
|
+
switch (code) {
|
|
224
|
+
case 'replay': {
|
|
225
|
+
onClose();
|
|
226
|
+
break;
|
|
227
|
+
}
|
|
228
|
+
case 'question': {
|
|
229
|
+
showImportQuestion();
|
|
230
|
+
break;
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
};
|
|
235
|
+
|
|
236
|
+
const handleImport = () => {
|
|
237
|
+
dataList = [];
|
|
238
|
+
xgrid.value?.openImport();
|
|
239
|
+
};
|
|
240
|
+
// 导入后获取数据
|
|
241
|
+
function onImportMethod(options: any) {
|
|
242
|
+
dataList = options.$table.getTableData().fullData;
|
|
243
|
+
// 标题会默认导入,删除第一行
|
|
244
|
+
// dataList.splice(0, 1);
|
|
245
|
+
const columns = getColumns().filter(f => !f.type && f.mapField !== props.options.errorField);
|
|
246
|
+
columns.forEach(col => {
|
|
247
|
+
const idx = dataList.findIndex(data => data[col.field!] === col.field);
|
|
248
|
+
idx !== -1 && dataList.splice(idx, 1);
|
|
249
|
+
});
|
|
250
|
+
props.columns.forEach(col => {
|
|
251
|
+
if (col.dateFormatter || col.valueType === 'number') {
|
|
252
|
+
dataList.forEach(data => {
|
|
253
|
+
if (col.dateFormatter) {
|
|
254
|
+
data[col.field!] = toDateString(data[col.field!], col.dateFormatter || 'yyyy-MM-dd HH:mm:ss');
|
|
255
|
+
} else {
|
|
256
|
+
data[col.field!] = Big(data[col.field!]).toFixed(col.decimal || 6);
|
|
257
|
+
}
|
|
258
|
+
});
|
|
259
|
+
}
|
|
260
|
+
});
|
|
261
|
+
listQuery.value.total = dataList.length;
|
|
262
|
+
getDataList();
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
const getDataList = () => {
|
|
266
|
+
const { currentPage, pageSize } = listQuery.value;
|
|
267
|
+
gridOptions.data = dataList.filter(
|
|
268
|
+
(data, idx) => idx < pageSize * currentPage && idx >= pageSize * (currentPage - 1)
|
|
269
|
+
);
|
|
270
|
+
};
|
|
271
|
+
// 切换页数
|
|
272
|
+
const handlePageChange: VxePagerEvents.PageChange = ({ currentPage, pageSize }) => {
|
|
273
|
+
listQuery.value.currentPage = currentPage;
|
|
274
|
+
listQuery.value.pageSize = pageSize;
|
|
275
|
+
getDataList();
|
|
276
|
+
};
|
|
277
|
+
// 模板下载
|
|
278
|
+
const handleDownLoadFile = () => {
|
|
279
|
+
const data: ITableColProps[] = [];
|
|
280
|
+
if (props.templateData.length) {
|
|
281
|
+
data.push(...props.templateData);
|
|
282
|
+
} else {
|
|
283
|
+
const obj: ITableColProps = {};
|
|
284
|
+
getColumns()
|
|
285
|
+
.filter(f => f.type !== 'checkbox')
|
|
286
|
+
.forEach(col => {
|
|
287
|
+
obj[col.field!] = '案例';
|
|
288
|
+
});
|
|
289
|
+
data.push(obj);
|
|
290
|
+
}
|
|
291
|
+
const opt: IRecord = {
|
|
292
|
+
filename: props.options.filename,
|
|
293
|
+
type: 'xlsx',
|
|
294
|
+
columns: getColumns().filter(f => f.mapField !== props.options.errorField && f.type !== 'checkbox'),
|
|
295
|
+
data
|
|
296
|
+
};
|
|
297
|
+
xgrid.value?.exportData(opt);
|
|
298
|
+
};
|
|
299
|
+
|
|
300
|
+
const handleSave = async () => {
|
|
301
|
+
if (!dataList.length) {
|
|
302
|
+
return warnMessage(t('message.importEmpty'));
|
|
303
|
+
}
|
|
304
|
+
const type = await VxeUI.modal.confirm(t('message.importRecord'));
|
|
305
|
+
if (type === 'confirm') {
|
|
306
|
+
gridOptions.loading = true;
|
|
307
|
+
const { url } = props;
|
|
308
|
+
formatterData('toSave');
|
|
309
|
+
serviceApi
|
|
310
|
+
.post(url, dataList)
|
|
311
|
+
.then((res: any) => {
|
|
312
|
+
if (res?.status === 'error' || res?.length) {
|
|
313
|
+
showErrorMsg.value = true;
|
|
314
|
+
setErrorMessage(res?.length ? res : res[props.options.errListField || props.sourceList]);
|
|
315
|
+
VxeUI.modal.message({
|
|
316
|
+
content: t('message.importFailed'),
|
|
317
|
+
status: 'error'
|
|
318
|
+
});
|
|
319
|
+
} else {
|
|
320
|
+
VxeUI.modal.message({
|
|
321
|
+
content: t('message.importSuccess'),
|
|
322
|
+
status: 'success'
|
|
323
|
+
});
|
|
324
|
+
onClose();
|
|
325
|
+
}
|
|
326
|
+
})
|
|
327
|
+
.finally(() => {
|
|
328
|
+
showErrorMsg.value = false;
|
|
329
|
+
gridOptions.loading = false;
|
|
330
|
+
});
|
|
331
|
+
}
|
|
332
|
+
};
|
|
333
|
+
|
|
334
|
+
/**
|
|
335
|
+
* @description:删除行
|
|
336
|
+
*/
|
|
337
|
+
const handleDelete = () => {
|
|
338
|
+
const checkboxRecords = xgrid.value?.getCheckboxRecords();
|
|
339
|
+
if (!checkboxRecords?.length) {
|
|
340
|
+
return VxeUI.modal.message({
|
|
341
|
+
content: t('message.selectedRecord'),
|
|
342
|
+
status: 'warning'
|
|
343
|
+
});
|
|
344
|
+
}
|
|
345
|
+
checkboxRecords.forEach(record => {
|
|
346
|
+
const idx = dataList.findIndex(data => data._X_ROW_KEY === record._X_ROW_KEY)!;
|
|
347
|
+
idx !== -1 && dataList.splice(idx, 1);
|
|
348
|
+
});
|
|
349
|
+
gridOptions.data = dataList;
|
|
350
|
+
};
|
|
351
|
+
|
|
352
|
+
const setErrorMessage = (array: ITableColProps[]) => {
|
|
353
|
+
listQuery.value.total = array.length;
|
|
354
|
+
dataList = array.map((item, idx) => {
|
|
355
|
+
item._X_ROW_KEY = idx;
|
|
356
|
+
return item;
|
|
357
|
+
});
|
|
358
|
+
formatterData('toShow');
|
|
359
|
+
getDataList();
|
|
360
|
+
};
|
|
361
|
+
const formatterData = (formatterType: string) => {
|
|
362
|
+
gridOptions.columns!.forEach((col: any) => {
|
|
363
|
+
if (formatterType === 'toSave') {
|
|
364
|
+
const commonParam = cookies.get('kCookies_param') ? JSON.parse(cookies.get('kCookies_param')!) : {};
|
|
365
|
+
dataList.forEach(data => {
|
|
366
|
+
data[col.mapField] = data[col.field];
|
|
367
|
+
Object.assign(data, commonParam, props.defaultParams);
|
|
368
|
+
});
|
|
369
|
+
} else {
|
|
370
|
+
dataList.forEach(data => {
|
|
371
|
+
data[col.field] = data[col.mapField];
|
|
372
|
+
});
|
|
373
|
+
}
|
|
374
|
+
});
|
|
375
|
+
};
|
|
376
|
+
|
|
377
|
+
const showImportQuestion = () => {
|
|
378
|
+
VxeUI.modal.alert(t('message.importTip'), t('message.udp.tip'));
|
|
379
|
+
};
|
|
380
|
+
|
|
381
|
+
const emit = defineEmits<{ (e: 'close'): void }>();
|
|
382
|
+
|
|
383
|
+
const onClose = () => {
|
|
384
|
+
visible.value = false;
|
|
385
|
+
emit('close');
|
|
386
|
+
};
|
|
387
|
+
</script>
|
|
388
|
+
|
|
389
|
+
<style lang="scss" scoped>
|
|
390
|
+
.ut-input {
|
|
391
|
+
box-sizing: border-box;
|
|
392
|
+
box-sizing: border-box;
|
|
393
|
+
display: inline-block;
|
|
394
|
+
width: 100%;
|
|
395
|
+
height: 28px;
|
|
396
|
+
padding: 0 15px;
|
|
397
|
+
font-size: 13px;
|
|
398
|
+
line-height: 28px;
|
|
399
|
+
color: #606266;
|
|
400
|
+
background-color: #fff;
|
|
401
|
+
background-image: none;
|
|
402
|
+
border: 1px solid #dcdfe6;
|
|
403
|
+
border-radius: 4px;
|
|
404
|
+
outline: 0;
|
|
405
|
+
transition: border-color 0.2s cubic-bezier(0.645, 0.045, 0.355, 1);
|
|
406
|
+
transition: border-color 0.2s cubic-bezier(0.645, 0.045, 0.355, 1);
|
|
407
|
+
appearance: none;
|
|
408
|
+
|
|
409
|
+
&:hover {
|
|
410
|
+
border-color: #c0c4cc;
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
&:focus {
|
|
414
|
+
border-color: #409eff;
|
|
415
|
+
outline: 0;
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
&:disabled {
|
|
419
|
+
background-color: #f5f7fa;
|
|
420
|
+
outline: none;
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
</style>
|