diff --git a/apps/web-antd/src/api/license/customer/index.ts b/apps/web-antd/src/api/license/customer/index.ts index 21a34f5..dc11683 100644 --- a/apps/web-antd/src/api/license/customer/index.ts +++ b/apps/web-antd/src/api/license/customer/index.ts @@ -26,7 +26,7 @@ export function getCustomerPage(params: PageParam) { ); } -/** 查询客户分页 */ +/** 查询客户列表 */ export function getCustomerList() { return requestClient.get('/license/customer/list'); } diff --git a/apps/web-antd/src/api/license/project/index.ts b/apps/web-antd/src/api/license/project/index.ts index c90733b..64193b8 100644 --- a/apps/web-antd/src/api/license/project/index.ts +++ b/apps/web-antd/src/api/license/project/index.ts @@ -8,7 +8,7 @@ export namespace ProjectApi { /** 项目信息 */ export interface Project { id: number; // 主键 - projectId?: number; // 项目ID + customerId?: number; // 客户ID name?: string; // 项目名称 code?: string; // 项目编号 contractCode?: string; // 合同编号 @@ -35,6 +35,13 @@ export function getProjectPage(params: PageParam) { ); } +/** 查询项目列表 */ +export function getProjectList(params: any) { + return requestClient.get('/license/project/list', { + params, + }); +} + /** 查询项目详情 */ export function getProject(id: number) { return requestClient.get(`/license/project/get?id=${id}`); diff --git a/apps/web-antd/src/locales/langs/en-US/license.json b/apps/web-antd/src/locales/langs/en-US/license.json new file mode 100644 index 0000000..677a759 --- /dev/null +++ b/apps/web-antd/src/locales/langs/en-US/license.json @@ -0,0 +1,17 @@ +{ + "customer": "Customer", + "project": "Project", + "expirationTime": "Expiration Time", + "neSwitch": "NE Switch", + "userNum": "User Count", + "baseStationNum": "Base Station Count", + "activationCode": "Activation Code", + "licenseContent": "License Content", + "applicant": "Applicant", + "approver": "License Administrator", + "status": "Status", + "remark": "Remark", + "creationTime": "Creation Time", + "operation": "Operation", + "list": "License List" +} diff --git a/apps/web-antd/src/locales/langs/zh-CN/license.json b/apps/web-antd/src/locales/langs/zh-CN/license.json new file mode 100644 index 0000000..b60c887 --- /dev/null +++ b/apps/web-antd/src/locales/langs/zh-CN/license.json @@ -0,0 +1,17 @@ +{ + "customer": "客户", + "project": "项目", + "expirationTime": "有效期", + "neSwitch": "网元开关", + "userNum": "用户数", + "baseStationNum": "基站数", + "activationCode": "激活码", + "licenseContent": "License内容", + "applicant": "申请人", + "approver": "License管理员", + "status": "状态", + "remark": "备注", + "creationTime": "创建时间", + "operation": "操作", + "list": "License列表" +} diff --git a/apps/web-antd/src/views/license/license/data.ts b/apps/web-antd/src/views/license/license/data.ts index 6bc95ea..f341276 100644 --- a/apps/web-antd/src/views/license/license/data.ts +++ b/apps/web-antd/src/views/license/license/data.ts @@ -4,9 +4,14 @@ import type { LicenseApi } from '#/api/license/license'; import { useAccess } from '@vben/access'; +import { getCustomerList } from '#/api/license/customer'; +import { getProjectList } from '#/api/license/project'; +import { $t } from '#/locales'; import { DICT_TYPE, getDictOptions, getRangePickerDefaultProps } from '#/utils'; const { hasAccessByCodes } = useAccess(); +let projectList = await getProjectList({}); +const customerList = await getCustomerList(); /** 新增/修改的表单 */ export function useFormSchema(): VbenFormSchema[] { @@ -21,34 +26,71 @@ export function useFormSchema(): VbenFormSchema[] { }, { fieldName: 'customerId', - label: '客户ID', + label: $t('license.customer'), rules: 'required', - component: 'Input', + component: 'Select', componentProps: { - placeholder: '请输入客户ID', + options: customerList, + fieldNames: { label: 'name', value: 'id' }, + showSearch: true, + filterOption: (input: string, option: any) => + option.label.toLowerCase().includes(input.toLowerCase()), }, }, { fieldName: 'projectId', - label: '项目ID', + label: $t('license.project'), rules: 'required', - component: 'Input', + component: 'Select', componentProps: { - placeholder: '请输入项目ID', + options: projectList, + fieldNames: { label: 'name', value: 'id' }, + showSearch: true, + filterOption: (input: string, option: any) => + option.label.toLowerCase().includes(input.toLowerCase()), + }, + dependencies: { + componentProps: async (values) => { + projectList = await getProjectList({ + customerId: values.customerId, + }); + const hasProject = projectList.find((project) => { + return project.id === values.projectId; + }); + if (!hasProject) { + values.projectId = ''; + } + return { + options: projectList, + }; + }, + triggerFields: ['customerId'], }, }, { fieldName: 'sn', label: 'sn', - rules: 'required', component: 'Input', componentProps: { - placeholder: '请输入sn', + disabled: true, + }, + dependencies: { + trigger(values, form) { + const projectCode = projectList.find((project) => { + return project.id === values.projectId; + })?.code; + const customerCode = customerList.find((customer) => { + return customer.id === values.customerId; + })?.code; + form.setFieldValue('sn', `${customerCode || ''}${projectCode || ''}`); + }, + // 只有指定的字段改变时,才会触发 + triggerFields: ['customerId', 'projectId'], }, }, { fieldName: 'expirationTime', - label: '到期时间', + label: $t('license.expirationTime'), component: 'DatePicker', componentProps: { showTime: true, @@ -58,65 +100,51 @@ export function useFormSchema(): VbenFormSchema[] { }, { fieldName: 'neSwitch', - label: '网元开关', + label: $t('license.neSwitch'), component: 'CheckboxGroup', componentProps: { - options: getDictOptions(DICT_TYPE.LIC_NE_SWITCH, 'string'), + options: getDictOptions(DICT_TYPE.LIC_NE_SWITCH, 'number'), }, }, { fieldName: 'userNum', - label: '用户数', + label: $t('license.userNum'), component: 'Input', - componentProps: { - placeholder: '请输入用户数', - }, }, { fieldName: 'baseStationNum', - label: '基站数', + label: $t('license.baseStationNum'), component: 'Input', - componentProps: { - placeholder: '请输入基站数', - }, }, { fieldName: 'activationCode', - label: '激活码', + label: $t('license.activationCode'), component: 'Textarea', - componentProps: { - placeholder: '请输入激活码', - }, }, { fieldName: 'licenseContent', - label: 'License内容', + label: $t('license.licenseContent'), component: 'Textarea', - componentProps: { - placeholder: '请输入License内容', - }, }, { fieldName: 'applicant', - label: '申请人', + label: $t('license.applicant'), component: 'Select', componentProps: { options: [], - placeholder: '请选择申请人', }, }, { fieldName: 'approver', - label: '审批人', + label: $t('license.approver'), component: 'Select', componentProps: { options: [], - placeholder: '请选择审批人', }, }, { fieldName: 'status', - label: '状态', + label: $t('license.status'), component: 'Select', componentProps: { options: getDictOptions(DICT_TYPE.LIC_LICENSE_STATUS, 'number'), @@ -126,11 +154,8 @@ export function useFormSchema(): VbenFormSchema[] { }, { fieldName: 'remark', - label: '备注', + label: $t('license.remark'), component: 'Textarea', - componentProps: { - placeholder: '请输入备注', - }, }, ]; } @@ -140,20 +165,18 @@ export function useGridFormSchema(): VbenFormSchema[] { return [ { fieldName: 'customerId', - label: '客户ID', + label: $t('license.customer'), component: 'Input', componentProps: { allowClear: true, - placeholder: '请输入客户ID', }, }, { fieldName: 'projectId', - label: '项目ID', + label: $t('license.project'), component: 'Input', componentProps: { allowClear: true, - placeholder: '请输入项目ID', }, }, { @@ -162,100 +185,91 @@ export function useGridFormSchema(): VbenFormSchema[] { component: 'Input', componentProps: { allowClear: true, - placeholder: '请输入sn', }, }, { fieldName: 'expirationTime', - label: '到期时间', + label: $t('license.expirationTime'), component: 'RangePicker', componentProps: { ...getRangePickerDefaultProps(), allowClear: true, }, }, - { - fieldName: 'neSwitch', - label: '网元开关', - }, + // { + // fieldName: 'neSwitch', + // label: $t('license.neSwitch'), + // }, { fieldName: 'userNum', - label: '用户数', + label: $t('license.userNum'), component: 'Input', componentProps: { allowClear: true, - placeholder: '请输入用户数', }, }, { fieldName: 'baseStationNum', - label: '基站数', + label: $t('license.baseStationNum'), component: 'Input', componentProps: { allowClear: true, - placeholder: '请输入基站数', }, }, { fieldName: 'activationCode', - label: '激活码', + label: $t('license.activationCode'), component: 'Input', componentProps: { allowClear: true, - placeholder: '请输入激活码', }, }, { fieldName: 'licenseContent', - label: 'License内容', + label: $t('license.licenseContent'), component: 'Input', componentProps: { allowClear: true, - placeholder: '请输入License内容', }, }, { fieldName: 'applicant', - label: '申请人', + label: $t('license.applicant'), component: 'Select', componentProps: { allowClear: true, options: [], - placeholder: '请选择申请人', }, }, { fieldName: 'approver', - label: '审批人', + label: $t('license.approver'), component: 'Select', componentProps: { allowClear: true, options: [], - placeholder: '请选择审批人', }, }, { fieldName: 'status', - label: '状态', + label: $t('license.status'), component: 'Select', componentProps: { allowClear: true, options: getDictOptions(DICT_TYPE.LIC_LICENSE_STATUS, 'number'), - placeholder: '请选择状态', }, }, { fieldName: 'remark', - label: '备注', + label: $t('license.remark'), component: 'Input', componentProps: { allowClear: true, - placeholder: '请输入备注', }, }, { fieldName: 'createTime', - label: '创建时间', + label: $t('license.creationTime'), component: 'RangePicker', componentProps: { ...getRangePickerDefaultProps(), @@ -271,13 +285,13 @@ export function useGridColumns( ): VxeTableGridOptions['columns'] { return [ { - field: 'customerId', - title: '客户ID', + field: 'customerName', + title: $t('license.customer'), minWidth: 120, }, { - field: 'projectId', - title: '项目ID', + field: 'projectName', + title: $t('license.project'), minWidth: 120, }, { @@ -287,13 +301,13 @@ export function useGridColumns( }, { field: 'expirationTime', - title: '到期时间', + title: $t('license.expirationTime'), minWidth: 120, formatter: 'formatDateTime', }, { field: 'neSwitch', - title: '网元开关', + title: $t('license.neSwitch'), minWidth: 120, cellRender: { name: 'CellDict', @@ -302,37 +316,37 @@ export function useGridColumns( }, { field: 'userNum', - title: '用户数', + title: $t('license.userNum'), minWidth: 120, }, { field: 'baseStationNum', - title: '基站数', + title: $t('license.baseStationNum'), minWidth: 120, }, { field: 'activationCode', - title: '激活码', + title: $t('license.activationCode'), minWidth: 120, }, { field: 'licenseContent', - title: 'License内容', + title: $t('license.licenseContent'), minWidth: 120, }, { field: 'applicant', - title: '申请人', + title: $t('license.applicant'), minWidth: 120, }, { field: 'approver', - title: '审批人', + title: $t('license.approver'), minWidth: 120, }, { field: 'status', - title: '状态', + title: $t('license.status'), minWidth: 120, cellRender: { name: 'CellDict', @@ -341,18 +355,18 @@ export function useGridColumns( }, { field: 'remark', - title: '备注', + title: $t('license.remark'), minWidth: 120, }, { field: 'createTime', - title: '创建时间', + title: $t('license.creationTime'), minWidth: 120, formatter: 'formatDateTime', }, { field: 'operation', - title: '操作', + title: $t('license.operation'), minWidth: 200, align: 'center', fixed: 'right', diff --git a/apps/web-antd/src/views/license/license/index.vue b/apps/web-antd/src/views/license/license/index.vue index 19132e7..097a939 100644 --- a/apps/web-antd/src/views/license/license/index.vue +++ b/apps/web-antd/src/views/license/license/index.vue @@ -117,7 +117,7 @@ const [Grid, gridApi] = useVbenVxeGrid({ - +