feat: license管理模块添加
This commit is contained in:
58
apps/web-antd/src/api/license/license/index.ts
Normal file
58
apps/web-antd/src/api/license/license/index.ts
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
import type { Dayjs } from 'dayjs';
|
||||||
|
|
||||||
|
import type { PageParam, PageResult } from '@vben/request';
|
||||||
|
|
||||||
|
import { requestClient } from '#/api/request';
|
||||||
|
|
||||||
|
export namespace LicenseApi {
|
||||||
|
/** License信息 */
|
||||||
|
export interface License {
|
||||||
|
id: number; // 主键
|
||||||
|
customerId?: number; // 客户ID
|
||||||
|
projectId?: number; // 项目ID
|
||||||
|
sn?: string; // sn
|
||||||
|
expirationTime: Dayjs | string; // 到期时间
|
||||||
|
neSwitch: string; // 网元开关
|
||||||
|
userNum: number; // 用户数
|
||||||
|
baseStationNum: number; // 基站数
|
||||||
|
activationCode: string; // 激活码
|
||||||
|
licenseContent: string; // License内容
|
||||||
|
applicant: number; // 申请人
|
||||||
|
approver: number; // 审批人
|
||||||
|
status: number; // 状态
|
||||||
|
remark: string; // 备注
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 查询License分页 */
|
||||||
|
export function getLicensePage(params: PageParam) {
|
||||||
|
return requestClient.get<PageResult<LicenseApi.License>>(
|
||||||
|
'/license/license/page',
|
||||||
|
{ params },
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 查询License详情 */
|
||||||
|
export function getLicense(id: number) {
|
||||||
|
return requestClient.get<LicenseApi.License>(`/license/license/get?id=${id}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 新增License */
|
||||||
|
export function createLicense(data: LicenseApi.License) {
|
||||||
|
return requestClient.post('/license/license/create', data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 修改License */
|
||||||
|
export function updateLicense(data: LicenseApi.License) {
|
||||||
|
return requestClient.put('/license/license/update', data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 删除License */
|
||||||
|
export function deleteLicense(id: number) {
|
||||||
|
return requestClient.delete(`/license/license/delete?id=${id}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 导出License */
|
||||||
|
export function exportLicense(params: any) {
|
||||||
|
return requestClient.download('/license/license/export-excel', params);
|
||||||
|
}
|
||||||
@@ -83,5 +83,6 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"customer": "Customer Management",
|
"customer": "Customer Management",
|
||||||
"project": "Project Management"
|
"project": "Project Management",
|
||||||
|
"license": "License Management"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -83,5 +83,6 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"customer": "客户管理",
|
"customer": "客户管理",
|
||||||
"project": "项目管理"
|
"project": "项目管理",
|
||||||
|
"license": "License管理"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -222,6 +222,8 @@ enum DICT_TYPE {
|
|||||||
// ========== LICENSE 模块 ==========
|
// ========== LICENSE 模块 ==========
|
||||||
LIC_BUSINESS_STATUS = 'lic_business_status', // 商务状态
|
LIC_BUSINESS_STATUS = 'lic_business_status', // 商务状态
|
||||||
LIC_CUSTOMER_TYPE = 'lic_customer_type', // 客户类型
|
LIC_CUSTOMER_TYPE = 'lic_customer_type', // 客户类型
|
||||||
|
LIC_LICENSE_STATUS = 'lic_license_status', // License 状态
|
||||||
|
LIC_NE_SWITCH = 'lic_ne_switch', // NE 开关
|
||||||
LIC_PROJECT_STATUS = 'lic_project_status', // 项目状态
|
LIC_PROJECT_STATUS = 'lic_project_status', // 项目状态
|
||||||
MEMBER_EXPERIENCE_BIZ_TYPE = 'member_experience_biz_type', // 会员经验业务类型
|
MEMBER_EXPERIENCE_BIZ_TYPE = 'member_experience_biz_type', // 会员经验业务类型
|
||||||
// ========== Member 会员模块 ==========
|
// ========== Member 会员模块 ==========
|
||||||
|
|||||||
381
apps/web-antd/src/views/license/license/data.ts
Normal file
381
apps/web-antd/src/views/license/license/data.ts
Normal file
@@ -0,0 +1,381 @@
|
|||||||
|
import type { VbenFormSchema } from '#/adapter/form';
|
||||||
|
import type { OnActionClickFn, VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||||
|
import type { LicenseApi } from '#/api/license/license';
|
||||||
|
|
||||||
|
import { useAccess } from '@vben/access';
|
||||||
|
|
||||||
|
import { DICT_TYPE, getDictOptions, getRangePickerDefaultProps } from '#/utils';
|
||||||
|
|
||||||
|
const { hasAccessByCodes } = useAccess();
|
||||||
|
|
||||||
|
/** 新增/修改的表单 */
|
||||||
|
export function useFormSchema(): VbenFormSchema[] {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
fieldName: 'id',
|
||||||
|
component: 'Input',
|
||||||
|
dependencies: {
|
||||||
|
triggerFields: [''],
|
||||||
|
show: () => false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'customerId',
|
||||||
|
label: '客户ID',
|
||||||
|
rules: 'required',
|
||||||
|
component: 'Input',
|
||||||
|
componentProps: {
|
||||||
|
placeholder: '请输入客户ID',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'projectId',
|
||||||
|
label: '项目ID',
|
||||||
|
rules: 'required',
|
||||||
|
component: 'Input',
|
||||||
|
componentProps: {
|
||||||
|
placeholder: '请输入项目ID',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'sn',
|
||||||
|
label: 'sn',
|
||||||
|
rules: 'required',
|
||||||
|
component: 'Input',
|
||||||
|
componentProps: {
|
||||||
|
placeholder: '请输入sn',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'expirationTime',
|
||||||
|
label: '到期时间',
|
||||||
|
component: 'DatePicker',
|
||||||
|
componentProps: {
|
||||||
|
showTime: true,
|
||||||
|
format: 'YYYY-MM-DD HH:mm:ss',
|
||||||
|
valueFormat: 'x',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'neSwitch',
|
||||||
|
label: '网元开关',
|
||||||
|
component: 'CheckboxGroup',
|
||||||
|
componentProps: {
|
||||||
|
options: getDictOptions(DICT_TYPE.LIC_NE_SWITCH, 'string'),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'userNum',
|
||||||
|
label: '用户数',
|
||||||
|
component: 'Input',
|
||||||
|
componentProps: {
|
||||||
|
placeholder: '请输入用户数',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'baseStationNum',
|
||||||
|
label: '基站数',
|
||||||
|
component: 'Input',
|
||||||
|
componentProps: {
|
||||||
|
placeholder: '请输入基站数',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'activationCode',
|
||||||
|
label: '激活码',
|
||||||
|
component: 'Textarea',
|
||||||
|
componentProps: {
|
||||||
|
placeholder: '请输入激活码',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'licenseContent',
|
||||||
|
label: 'License内容',
|
||||||
|
component: 'Textarea',
|
||||||
|
componentProps: {
|
||||||
|
placeholder: '请输入License内容',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'applicant',
|
||||||
|
label: '申请人',
|
||||||
|
component: 'Select',
|
||||||
|
componentProps: {
|
||||||
|
options: [],
|
||||||
|
placeholder: '请选择申请人',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'approver',
|
||||||
|
label: '审批人',
|
||||||
|
component: 'Select',
|
||||||
|
componentProps: {
|
||||||
|
options: [],
|
||||||
|
placeholder: '请选择审批人',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'status',
|
||||||
|
label: '状态',
|
||||||
|
component: 'Select',
|
||||||
|
componentProps: {
|
||||||
|
options: getDictOptions(DICT_TYPE.LIC_LICENSE_STATUS, 'number'),
|
||||||
|
buttonStyle: 'solid',
|
||||||
|
optionType: 'button',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'remark',
|
||||||
|
label: '备注',
|
||||||
|
component: 'Textarea',
|
||||||
|
componentProps: {
|
||||||
|
placeholder: '请输入备注',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 列表的搜索表单 */
|
||||||
|
export function useGridFormSchema(): VbenFormSchema[] {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
fieldName: 'customerId',
|
||||||
|
label: '客户ID',
|
||||||
|
component: 'Input',
|
||||||
|
componentProps: {
|
||||||
|
allowClear: true,
|
||||||
|
placeholder: '请输入客户ID',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'projectId',
|
||||||
|
label: '项目ID',
|
||||||
|
component: 'Input',
|
||||||
|
componentProps: {
|
||||||
|
allowClear: true,
|
||||||
|
placeholder: '请输入项目ID',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'sn',
|
||||||
|
label: 'sn',
|
||||||
|
component: 'Input',
|
||||||
|
componentProps: {
|
||||||
|
allowClear: true,
|
||||||
|
placeholder: '请输入sn',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'expirationTime',
|
||||||
|
label: '到期时间',
|
||||||
|
component: 'RangePicker',
|
||||||
|
componentProps: {
|
||||||
|
...getRangePickerDefaultProps(),
|
||||||
|
allowClear: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'neSwitch',
|
||||||
|
label: '网元开关',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'userNum',
|
||||||
|
label: '用户数',
|
||||||
|
component: 'Input',
|
||||||
|
componentProps: {
|
||||||
|
allowClear: true,
|
||||||
|
placeholder: '请输入用户数',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'baseStationNum',
|
||||||
|
label: '基站数',
|
||||||
|
component: 'Input',
|
||||||
|
componentProps: {
|
||||||
|
allowClear: true,
|
||||||
|
placeholder: '请输入基站数',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'activationCode',
|
||||||
|
label: '激活码',
|
||||||
|
component: 'Input',
|
||||||
|
componentProps: {
|
||||||
|
allowClear: true,
|
||||||
|
placeholder: '请输入激活码',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'licenseContent',
|
||||||
|
label: 'License内容',
|
||||||
|
component: 'Input',
|
||||||
|
componentProps: {
|
||||||
|
allowClear: true,
|
||||||
|
placeholder: '请输入License内容',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'applicant',
|
||||||
|
label: '申请人',
|
||||||
|
component: 'Select',
|
||||||
|
componentProps: {
|
||||||
|
allowClear: true,
|
||||||
|
options: [],
|
||||||
|
placeholder: '请选择申请人',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'approver',
|
||||||
|
label: '审批人',
|
||||||
|
component: 'Select',
|
||||||
|
componentProps: {
|
||||||
|
allowClear: true,
|
||||||
|
options: [],
|
||||||
|
placeholder: '请选择审批人',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'status',
|
||||||
|
label: '状态',
|
||||||
|
component: 'Select',
|
||||||
|
componentProps: {
|
||||||
|
allowClear: true,
|
||||||
|
options: getDictOptions(DICT_TYPE.LIC_LICENSE_STATUS, 'number'),
|
||||||
|
placeholder: '请选择状态',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'remark',
|
||||||
|
label: '备注',
|
||||||
|
component: 'Input',
|
||||||
|
componentProps: {
|
||||||
|
allowClear: true,
|
||||||
|
placeholder: '请输入备注',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'createTime',
|
||||||
|
label: '创建时间',
|
||||||
|
component: 'RangePicker',
|
||||||
|
componentProps: {
|
||||||
|
...getRangePickerDefaultProps(),
|
||||||
|
allowClear: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 列表的字段 */
|
||||||
|
export function useGridColumns(
|
||||||
|
onActionClick?: OnActionClickFn<LicenseApi.License>,
|
||||||
|
): VxeTableGridOptions<LicenseApi.License>['columns'] {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
field: 'customerId',
|
||||||
|
title: '客户ID',
|
||||||
|
minWidth: 120,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'projectId',
|
||||||
|
title: '项目ID',
|
||||||
|
minWidth: 120,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'sn',
|
||||||
|
title: 'sn',
|
||||||
|
minWidth: 120,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'expirationTime',
|
||||||
|
title: '到期时间',
|
||||||
|
minWidth: 120,
|
||||||
|
formatter: 'formatDateTime',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'neSwitch',
|
||||||
|
title: '网元开关',
|
||||||
|
minWidth: 120,
|
||||||
|
cellRender: {
|
||||||
|
name: 'CellDict',
|
||||||
|
props: { type: DICT_TYPE.LIC_NE_SWITCH },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'userNum',
|
||||||
|
title: '用户数',
|
||||||
|
minWidth: 120,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'baseStationNum',
|
||||||
|
title: '基站数',
|
||||||
|
minWidth: 120,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'activationCode',
|
||||||
|
title: '激活码',
|
||||||
|
minWidth: 120,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'licenseContent',
|
||||||
|
title: 'License内容',
|
||||||
|
minWidth: 120,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'applicant',
|
||||||
|
title: '申请人',
|
||||||
|
minWidth: 120,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'approver',
|
||||||
|
title: '审批人',
|
||||||
|
minWidth: 120,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'status',
|
||||||
|
title: '状态',
|
||||||
|
minWidth: 120,
|
||||||
|
cellRender: {
|
||||||
|
name: 'CellDict',
|
||||||
|
props: { type: DICT_TYPE.LIC_LICENSE_STATUS },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'remark',
|
||||||
|
title: '备注',
|
||||||
|
minWidth: 120,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'createTime',
|
||||||
|
title: '创建时间',
|
||||||
|
minWidth: 120,
|
||||||
|
formatter: 'formatDateTime',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'operation',
|
||||||
|
title: '操作',
|
||||||
|
minWidth: 200,
|
||||||
|
align: 'center',
|
||||||
|
fixed: 'right',
|
||||||
|
headerAlign: 'center',
|
||||||
|
showOverflow: false,
|
||||||
|
cellRender: {
|
||||||
|
attrs: {
|
||||||
|
nameField: 'id',
|
||||||
|
nameTitle: 'License',
|
||||||
|
onClick: onActionClick,
|
||||||
|
},
|
||||||
|
name: 'CellOperation',
|
||||||
|
options: [
|
||||||
|
{
|
||||||
|
code: 'edit',
|
||||||
|
show: hasAccessByCodes(['license:license:update']),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
code: 'delete',
|
||||||
|
show: hasAccessByCodes(['license:license:delete']),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
142
apps/web-antd/src/views/license/license/index.vue
Normal file
142
apps/web-antd/src/views/license/license/index.vue
Normal file
@@ -0,0 +1,142 @@
|
|||||||
|
<script lang="ts" setup>
|
||||||
|
import type {
|
||||||
|
OnActionClickParams,
|
||||||
|
VxeTableGridOptions,
|
||||||
|
} from '#/adapter/vxe-table';
|
||||||
|
import type { LicenseApi } from '#/api/license/license';
|
||||||
|
|
||||||
|
import { h } from 'vue';
|
||||||
|
|
||||||
|
import { Page, useVbenModal } from '@vben/common-ui';
|
||||||
|
import { Download, Plus } from '@vben/icons';
|
||||||
|
import { downloadFileFromBlobPart } from '@vben/utils';
|
||||||
|
|
||||||
|
import { Button, message } from 'ant-design-vue';
|
||||||
|
|
||||||
|
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||||
|
import {
|
||||||
|
deleteLicense,
|
||||||
|
exportLicense,
|
||||||
|
getLicensePage,
|
||||||
|
} from '#/api/license/license';
|
||||||
|
import { $t } from '#/locales';
|
||||||
|
|
||||||
|
import { useGridColumns, useGridFormSchema } from './data';
|
||||||
|
import Form from './modules/form.vue';
|
||||||
|
|
||||||
|
const [FormModal, formModalApi] = useVbenModal({
|
||||||
|
connectedComponent: Form,
|
||||||
|
destroyOnClose: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
/** 刷新表格 */
|
||||||
|
function onRefresh() {
|
||||||
|
gridApi.query();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 创建License */
|
||||||
|
function onCreate() {
|
||||||
|
formModalApi.setData({}).open();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 编辑License */
|
||||||
|
function onEdit(row: LicenseApi.License) {
|
||||||
|
formModalApi.setData(row).open();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 删除License */
|
||||||
|
async function onDelete(row: LicenseApi.License) {
|
||||||
|
const hideLoading = message.loading({
|
||||||
|
content: $t('ui.actionMessage.deleting', [row.id]),
|
||||||
|
duration: 0,
|
||||||
|
key: 'action_process_msg',
|
||||||
|
});
|
||||||
|
try {
|
||||||
|
await deleteLicense(row.id as number);
|
||||||
|
message.success($t('ui.actionMessage.deleteSuccess', [row.id]));
|
||||||
|
onRefresh();
|
||||||
|
} catch {
|
||||||
|
hideLoading();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 导出表格 */
|
||||||
|
async function onExport() {
|
||||||
|
const data = await exportLicense(await gridApi.formApi.getValues());
|
||||||
|
downloadFileFromBlobPart({ fileName: 'License.xls', source: data });
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 表格操作按钮的回调函数 */
|
||||||
|
function onActionClick({ code, row }: OnActionClickParams<LicenseApi.License>) {
|
||||||
|
switch (code) {
|
||||||
|
case 'delete': {
|
||||||
|
onDelete(row);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'edit': {
|
||||||
|
onEdit(row);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const [Grid, gridApi] = useVbenVxeGrid({
|
||||||
|
formOptions: {
|
||||||
|
schema: useGridFormSchema(),
|
||||||
|
},
|
||||||
|
gridOptions: {
|
||||||
|
columns: useGridColumns(onActionClick),
|
||||||
|
height: 'auto',
|
||||||
|
pagerConfig: {
|
||||||
|
enabled: true,
|
||||||
|
},
|
||||||
|
proxyConfig: {
|
||||||
|
ajax: {
|
||||||
|
query: async ({ page }, formValues) => {
|
||||||
|
return await getLicensePage({
|
||||||
|
pageNo: page.currentPage,
|
||||||
|
pageSize: page.pageSize,
|
||||||
|
...formValues,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
rowConfig: {
|
||||||
|
keyField: 'id',
|
||||||
|
isHover: true,
|
||||||
|
},
|
||||||
|
toolbarConfig: {
|
||||||
|
refresh: { code: 'query' },
|
||||||
|
search: true,
|
||||||
|
},
|
||||||
|
} as VxeTableGridOptions<LicenseApi.License>,
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<Page auto-content-height>
|
||||||
|
<FormModal @success="onRefresh" />
|
||||||
|
|
||||||
|
<Grid table-title="License列表">
|
||||||
|
<template #toolbar-tools>
|
||||||
|
<Button
|
||||||
|
:icon="h(Plus)"
|
||||||
|
type="primary"
|
||||||
|
@click="onCreate"
|
||||||
|
v-access:code="['license:license:create']"
|
||||||
|
>
|
||||||
|
{{ $t('ui.actionTitle.create', ['License']) }}
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
:icon="h(Download)"
|
||||||
|
type="primary"
|
||||||
|
class="ml-2"
|
||||||
|
@click="onExport"
|
||||||
|
v-access:code="['license:license:export']"
|
||||||
|
>
|
||||||
|
{{ $t('ui.actionTitle.export') }}
|
||||||
|
</Button>
|
||||||
|
</template>
|
||||||
|
</Grid>
|
||||||
|
</Page>
|
||||||
|
</template>
|
||||||
89
apps/web-antd/src/views/license/license/modules/form.vue
Normal file
89
apps/web-antd/src/views/license/license/modules/form.vue
Normal file
@@ -0,0 +1,89 @@
|
|||||||
|
<script lang="ts" setup>
|
||||||
|
import type { LicenseApi } from '#/api/license/license';
|
||||||
|
|
||||||
|
import { computed, ref } from 'vue';
|
||||||
|
|
||||||
|
import { useVbenModal } from '@vben/common-ui';
|
||||||
|
|
||||||
|
import { message } from 'ant-design-vue';
|
||||||
|
|
||||||
|
import { useVbenForm } from '#/adapter/form';
|
||||||
|
import {
|
||||||
|
createLicense,
|
||||||
|
getLicense,
|
||||||
|
updateLicense,
|
||||||
|
} from '#/api/license/license';
|
||||||
|
import { $t } from '#/locales';
|
||||||
|
|
||||||
|
import { useFormSchema } from '../data';
|
||||||
|
|
||||||
|
const emit = defineEmits(['success']);
|
||||||
|
const formData = ref<LicenseApi.License>();
|
||||||
|
const getTitle = computed(() => {
|
||||||
|
return formData.value?.id
|
||||||
|
? $t('ui.actionTitle.edit', ['License'])
|
||||||
|
: $t('ui.actionTitle.create', ['License']);
|
||||||
|
});
|
||||||
|
|
||||||
|
const [Form, formApi] = useVbenForm({
|
||||||
|
commonConfig: {
|
||||||
|
componentProps: {
|
||||||
|
class: 'w-full',
|
||||||
|
},
|
||||||
|
formItemClass: 'col-span-2',
|
||||||
|
labelWidth: 80,
|
||||||
|
},
|
||||||
|
layout: 'horizontal',
|
||||||
|
schema: useFormSchema(),
|
||||||
|
showDefaultActions: false,
|
||||||
|
});
|
||||||
|
|
||||||
|
const [Modal, modalApi] = useVbenModal({
|
||||||
|
async onConfirm() {
|
||||||
|
const { valid } = await formApi.validate();
|
||||||
|
if (!valid) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
modalApi.lock();
|
||||||
|
// 提交表单
|
||||||
|
const data = (await formApi.getValues()) as LicenseApi.License;
|
||||||
|
try {
|
||||||
|
await (formData.value?.id ? updateLicense(data) : createLicense(data));
|
||||||
|
// 关闭并提示
|
||||||
|
await modalApi.close();
|
||||||
|
emit('success');
|
||||||
|
message.success($t('ui.actionMessage.operationSuccess'));
|
||||||
|
} finally {
|
||||||
|
modalApi.unlock();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
async onOpenChange(isOpen: boolean) {
|
||||||
|
if (!isOpen) {
|
||||||
|
formData.value = undefined;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// 加载数据
|
||||||
|
let data = modalApi.getData<LicenseApi.License>();
|
||||||
|
if (!data) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (data.id) {
|
||||||
|
modalApi.lock();
|
||||||
|
try {
|
||||||
|
data = await getLicense(data.id);
|
||||||
|
} finally {
|
||||||
|
modalApi.unlock();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 设置到 values
|
||||||
|
formData.value = data;
|
||||||
|
await formApi.setValues(formData.value);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<Modal :title="getTitle">
|
||||||
|
<Form class="mx-4" />
|
||||||
|
</Modal>
|
||||||
|
</template>
|
||||||
Reference in New Issue
Block a user