feat: 导入License功能调整
This commit is contained in:
@@ -12,9 +12,12 @@ import { formatDate, formatDateTime } from '@vben/utils';
|
|||||||
import dayjs, { Dayjs } from 'dayjs';
|
import dayjs, { Dayjs } from 'dayjs';
|
||||||
|
|
||||||
import { z } from '#/adapter/form';
|
import { z } from '#/adapter/form';
|
||||||
import { getLicenseCustomerList } from '#/api/license/customer';
|
import {
|
||||||
|
getCustomerList,
|
||||||
|
getLicenseCustomerList,
|
||||||
|
} from '#/api/license/customer';
|
||||||
import { isLicenseSnUnique } from '#/api/license/license';
|
import { isLicenseSnUnique } from '#/api/license/license';
|
||||||
import { getLicenseProjectList } from '#/api/license/project';
|
import { getLicenseProjectList, getProjectList } from '#/api/license/project';
|
||||||
import { getLicenseAdminList, getSimpleUserList } from '#/api/system/user';
|
import { getLicenseAdminList, getSimpleUserList } from '#/api/system/user';
|
||||||
import { DictTag } from '#/components/dict-tag';
|
import { DictTag } from '#/components/dict-tag';
|
||||||
import { $t } from '#/locales';
|
import { $t } from '#/locales';
|
||||||
@@ -39,16 +42,22 @@ export function useFormSchema(): VbenFormSchema[] {
|
|||||||
fieldName: 'customerId',
|
fieldName: 'customerId',
|
||||||
label: $t('license.customer'),
|
label: $t('license.customer'),
|
||||||
rules: 'required',
|
rules: 'required',
|
||||||
component: 'ApiSelect',
|
component: 'Select',
|
||||||
dependencies: {
|
dependencies: {
|
||||||
triggerFields: ['id'],
|
triggerFields: ['id'],
|
||||||
disabled: (values) => !!values.id,
|
disabled: (values) => !!values.id,
|
||||||
|
componentProps: async (values) => {
|
||||||
|
customerList.value = await (values.id
|
||||||
|
? getCustomerList()
|
||||||
|
: getLicenseCustomerList());
|
||||||
|
|
||||||
|
return {
|
||||||
|
options: customerList,
|
||||||
|
};
|
||||||
|
},
|
||||||
},
|
},
|
||||||
componentProps: {
|
componentProps: {
|
||||||
api: async () => {
|
options: customerList,
|
||||||
customerList.value = await getLicenseCustomerList();
|
|
||||||
return customerList.value;
|
|
||||||
},
|
|
||||||
allowClear: true,
|
allowClear: true,
|
||||||
fieldNames: { label: 'name', value: 'id' },
|
fieldNames: { label: 'name', value: 'id' },
|
||||||
showSearch: true,
|
showSearch: true,
|
||||||
@@ -71,15 +80,23 @@ export function useFormSchema(): VbenFormSchema[] {
|
|||||||
},
|
},
|
||||||
dependencies: {
|
dependencies: {
|
||||||
componentProps: async (values) => {
|
componentProps: async (values) => {
|
||||||
projectList.value = await getLicenseProjectList({
|
projectList.value = await (values.id
|
||||||
customerId: values.customerId,
|
? getProjectList({
|
||||||
});
|
customerId: values.customerId,
|
||||||
const hasProject = projectList.value.find((project) => {
|
})
|
||||||
return project.id === values.projectId;
|
: getLicenseProjectList({
|
||||||
});
|
customerId: values.customerId,
|
||||||
if (!hasProject) {
|
}));
|
||||||
values.projectId = '';
|
|
||||||
|
if (!values.id) {
|
||||||
|
const hasProject = projectList.value.find((project) => {
|
||||||
|
return project.id === values.projectId;
|
||||||
|
});
|
||||||
|
if (!hasProject) {
|
||||||
|
values.projectId = '';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
options: projectList,
|
options: projectList,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import { useVbenModal } from '@vben/common-ui';
|
|||||||
// import { InboxOutlined } from '@vben/icons';
|
// import { InboxOutlined } from '@vben/icons';
|
||||||
import { downloadFileFromBlobPart } from '@vben/utils';
|
import { downloadFileFromBlobPart } from '@vben/utils';
|
||||||
|
|
||||||
import { Button, message, UploadDragger } from 'ant-design-vue';
|
import { Button, notification, UploadDragger } from 'ant-design-vue';
|
||||||
|
|
||||||
import { useVbenForm } from '#/adapter/form';
|
import { useVbenForm } from '#/adapter/form';
|
||||||
import { importLicense, importTemplate } from '#/api/license/license';
|
import { importLicense, importTemplate } from '#/api/license/license';
|
||||||
@@ -41,40 +41,42 @@ const [Modal, modalApi] = useVbenModal({
|
|||||||
await modalApi.close();
|
await modalApi.close();
|
||||||
emit('success');
|
emit('success');
|
||||||
let failuresMsg: any;
|
let failuresMsg: any;
|
||||||
if (result.creates && result.creates.length > 0) {
|
const createsLength = result.creates ? result.creates.length : 0;
|
||||||
failuresMsg = h(
|
const updatesLength = result.updates ? result.updates.length : 0;
|
||||||
'div',
|
const total = result.total || 0;
|
||||||
{
|
const failuresLength = total - createsLength - updatesLength;
|
||||||
style: {
|
const resultMsg = `总共${total}条,新增成功${createsLength}条, 更新成功${updatesLength}条, 导入失败${failuresLength}条`;
|
||||||
color: 'green',
|
|
||||||
},
|
failuresMsg = h(
|
||||||
|
'div',
|
||||||
|
{
|
||||||
|
style: {
|
||||||
|
color: 'blue',
|
||||||
},
|
},
|
||||||
[failuresMsg, `新增成功:${result.creates.join(',')}`],
|
},
|
||||||
);
|
[failuresMsg, resultMsg],
|
||||||
}
|
);
|
||||||
if (result.updates && result.updates.length > 0) {
|
for (const key in result.failureMap) {
|
||||||
failuresMsg = h(
|
|
||||||
'div',
|
|
||||||
{
|
|
||||||
style: {
|
|
||||||
color: 'blue',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
[failuresMsg, `更新成功:${result.updates.join(',')}`],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
for (const key in result.failures) {
|
|
||||||
failuresMsg = h(
|
failuresMsg = h(
|
||||||
'div',
|
'div',
|
||||||
{
|
{
|
||||||
style: {
|
style: {
|
||||||
color: 'red',
|
color: 'red',
|
||||||
|
overflowY: 'auto',
|
||||||
|
maxHeight: '600px',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
[failuresMsg, `导入失败:${key},失败原因:${result.failures[key]}`],
|
[failuresMsg, `导入失败SN(${key}):${result.failureMap[key]}`],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
message.info(failuresMsg, 10);
|
notification.open({
|
||||||
|
message: '导入结果',
|
||||||
|
description: failuresMsg,
|
||||||
|
style: {
|
||||||
|
color: failuresLength > 0 ? 'red' : 'green',
|
||||||
|
},
|
||||||
|
duration: 0,
|
||||||
|
});
|
||||||
} finally {
|
} finally {
|
||||||
modalApi.unlock();
|
modalApi.unlock();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"welcomeBack": "欢迎回来",
|
"welcomeBack": "欢迎回来",
|
||||||
"pageTitle": "",
|
"pageTitle": "智维通管理系统",
|
||||||
"pageDesc": "",
|
"pageDesc": "智:智能管理lic,维:项目运维管理, 通:客户沟通商务协调",
|
||||||
"loginSuccess": "登录成功",
|
"loginSuccess": "登录成功",
|
||||||
"loginSuccessDesc": "欢迎回来",
|
"loginSuccessDesc": "欢迎回来",
|
||||||
"loginSubtitle": "请输入您的LDAP账号以开始管理您的项目",
|
"loginSubtitle": "请输入您的LDAP账号以开始管理您的项目",
|
||||||
|
|||||||
Reference in New Issue
Block a user