diff --git a/apps/web-antd/src/api/license/license/index.ts b/apps/web-antd/src/api/license/license/index.ts index 03af844..f831383 100644 --- a/apps/web-antd/src/api/license/license/index.ts +++ b/apps/web-antd/src/api/license/license/index.ts @@ -25,6 +25,7 @@ export namespace LicenseApi { remark: string; // 备注 action: number; // 操作 neCodeList: NeCode[]; // 操作 + oldLicense: License; } export interface NeCode { id: number; // 主键 @@ -56,6 +57,11 @@ export function updateLicense(data: LicenseApi.License) { return requestClient.put('/license/license/update', data); } +/** 重新License */ +export function reapplyLicense(data: LicenseApi.License) { + return requestClient.put('/license/license/reapply', data); +} + /** 申请License */ export function applyLicense(data: LicenseApi.License) { return requestClient.put('/license/license/apply', data); diff --git a/apps/web-antd/src/components/dict-tag/dict-tag-group.vue b/apps/web-antd/src/components/dict-tag/dict-tag-group.vue index 3085925..d3e1def 100644 --- a/apps/web-antd/src/components/dict-tag/dict-tag-group.vue +++ b/apps/web-antd/src/components/dict-tag/dict-tag-group.vue @@ -19,6 +19,7 @@ interface DictTagGroupProps { * 图标 */ icon?: string; + color?: string; } const props = defineProps(); @@ -60,6 +61,9 @@ const dictTag = computed(() => { } } } + if (props.color) { + colorType = props.color; + } dictTagGroup.push({ label: dict.label || '', colorType, diff --git a/apps/web-antd/src/locales/langs/en-US/license.json b/apps/web-antd/src/locales/langs/en-US/license.json index 6e91da6..4c8872e 100644 --- a/apps/web-antd/src/locales/langs/en-US/license.json +++ b/apps/web-antd/src/locales/langs/en-US/license.json @@ -31,5 +31,7 @@ "enterCode": "Please enter Activation Code", "selectNe": "Please select Network Element", "detail": "detail", - "downloadAll": "Download All" + "downloadAll": "Download All", + "reapply": "Reapply", + "reapplyAction": "Reapply For {0}" } diff --git a/apps/web-antd/src/locales/langs/zh-CN/license.json b/apps/web-antd/src/locales/langs/zh-CN/license.json index ef402d1..c1fd20f 100644 --- a/apps/web-antd/src/locales/langs/zh-CN/license.json +++ b/apps/web-antd/src/locales/langs/zh-CN/license.json @@ -31,5 +31,7 @@ "enterCode": "请输入激活码", "selectNe": "请选择网元", "detail": "详情", - "downloadAll": "全部下载" + "downloadAll": "全部下载", + "reapply": "重新申请", + "reapplyAction": "重新申请{0}" } diff --git a/apps/web-antd/src/views/license/license/components/detail.vue b/apps/web-antd/src/views/license/license/components/detail.vue index cebe56e..e576071 100644 --- a/apps/web-antd/src/views/license/license/components/detail.vue +++ b/apps/web-antd/src/views/license/license/components/detail.vue @@ -21,10 +21,10 @@ const props = defineProps<{ const columns = [ { title: '网元', - dataIndex: 'neList', - key: 'neList', + dataIndex: 'neListMap', + key: 'neListMap', customRender: (data: any) => { - return h(DictTagGroup, { + const oldDict = h(DictTagGroup, { type: [ DICT_TYPE.LIC_NE_ALL, DICT_TYPE.LIC_NE_5G, @@ -32,14 +32,53 @@ const columns = [ DICT_TYPE.LIC_NE_23G, DICT_TYPE.LIC_NE_ADD, ], - value: data.value, + value: data.value.old, }); + if (data.value.new) { + const newDict = h(DictTagGroup, { + type: [ + DICT_TYPE.LIC_NE_ALL, + DICT_TYPE.LIC_NE_5G, + DICT_TYPE.LIC_NE_4G, + DICT_TYPE.LIC_NE_23G, + DICT_TYPE.LIC_NE_ADD, + ], + color: 'red', + value: data.value.new, + }); + const after = h( + 'span', + { + style: { + color: 'red', + }, + }, + [` → `, newDict], + ); + return h('div', {}, [oldDict, after]); + } + return oldDict; }, }, { title: '激活码', - dataIndex: 'activationCode', - key: 'activationCode', + dataIndex: 'activationCodeMap', + key: 'activationCodeMap', + customRender: (data) => { + if (data.value.new) { + const after = h( + 'span', + { + style: { + color: 'red', + }, + }, + ` → ${data.value.new}`, + ); + return h('div', {}, [data.value.old, after]); + } + return data.value.old; + }, }, { title: 'License文件', diff --git a/apps/web-antd/src/views/license/license/data.ts b/apps/web-antd/src/views/license/license/data.ts index 2050a34..e32d44e 100644 --- a/apps/web-antd/src/views/license/license/data.ts +++ b/apps/web-antd/src/views/license/license/data.ts @@ -42,6 +42,10 @@ export function useFormSchema(): VbenFormSchema[] { label: $t('license.customer'), rules: 'required', component: 'ApiSelect', + dependencies: { + triggerFields: ['id'], + disabled: (values) => !!values.id, + }, componentProps: { api: async () => { customerList.value = await getCustomerList(); @@ -82,7 +86,8 @@ export function useFormSchema(): VbenFormSchema[] { options: projectList, }; }, - triggerFields: ['customerId'], + triggerFields: ['customerId', 'id'], + disabled: (values) => !!values.id, }, }, { @@ -380,10 +385,11 @@ export function useGridColumns( code: 'detail', text: $t('license.detail'), }, - // { - // code: 'edit', - // show: hasAccessByCodes(['license:license:update']), - // }, + { + code: 'reapply', + text: $t('license.reapply'), + show: hasAccessByCodes(['license:license:apply']), + }, { code: 'generate', text: $t('license.generate'), @@ -430,16 +436,61 @@ export function useDetailSchema(): DescriptionItemSchema[] { field: 'expiryDate', label: $t('license.expiryDate'), content: (data) => { + if (data.oldLicense) { + const after = h( + 'span', + { + style: { + color: 'red', + }, + }, + ` → ${formatDate(data?.expiryDate)}`, + ); + return h('div', {}, [ + formatDate(data.oldLicense.expiryDate) as string, + after, + ]); + } return formatDate(data?.expiryDate) as string; }, }, { field: 'userNumber', label: $t('license.userNumber'), + content: (data) => { + if (data.oldLicense) { + const after = h( + 'span', + { + style: { + color: 'red', + }, + }, + ` → ${data.userNumber}`, + ); + return h('div', {}, [data.oldLicense.userNumber, after]); + } + return data.userNumber; + }, }, { field: 'ranNumber', label: $t('license.ranNumber'), + content: (data) => { + if (data.oldLicense) { + const after = h( + 'span', + { + style: { + color: 'red', + }, + }, + ` → ${data.ranNumber}`, + ); + return h('div', {}, [data.oldLicense.ranNumber, after]); + } + return data.ranNumber; + }, }, { field: 'applicantName', @@ -465,7 +516,7 @@ export function useDetailSchema(): DescriptionItemSchema[] { { field: 'remark', label: $t('license.remark'), - hidden: (data) => data, + hidden: (data) => !data.remark, }, ]; } diff --git a/apps/web-antd/src/views/license/license/index.vue b/apps/web-antd/src/views/license/license/index.vue index 530ae8d..570c32e 100644 --- a/apps/web-antd/src/views/license/license/index.vue +++ b/apps/web-antd/src/views/license/license/index.vue @@ -72,8 +72,8 @@ async function onDownload(row: LicenseApi.License) { downloadFileFromBlobPart({ fileName, source: blob }); } -/** 编辑License */ -function onEdit(row: LicenseApi.License) { +/** 重新申请License */ +function onReapply(row: LicenseApi.License) { formModalApi.setData(row).open(); } @@ -115,14 +115,14 @@ function onActionClick({ code, row }: OnActionClickParams) { onDownload(row); break; } - case 'edit': { - onEdit(row); - break; - } case 'generate': { onGenerate(row); break; } + case 'reapply': { + onReapply(row); + break; + } } } diff --git a/apps/web-antd/src/views/license/license/modules/form.vue b/apps/web-antd/src/views/license/license/modules/form.vue index c719d12..f8ccfd7 100644 --- a/apps/web-antd/src/views/license/license/modules/form.vue +++ b/apps/web-antd/src/views/license/license/modules/form.vue @@ -13,7 +13,7 @@ import { useVbenForm } from '#/adapter/form'; import { createLicense, getLicense, - updateLicense, + reapplyLicense, } from '#/api/license/license'; import { $t } from '#/locales'; import { DICT_TYPE, getDictOptions } from '#/utils'; @@ -35,12 +35,12 @@ const neCodeRef = ref(); const getTitle = computed(() => { return formData.value?.id - ? $t('ui.actionTitle.edit', ['License']) + ? $t('license.reapplyAction', ['License']) : $t('license.applyAction', ['License']); }); const getConfirmText = computed(() => { - return formData.value?.id ? $t('page.action.confirm') : $t('license.apply'); + return formData.value?.id ? $t('license.reapply') : $t('license.apply'); }); const [Form, formApi] = useVbenForm({ @@ -93,7 +93,7 @@ const [Modal, modalApi] = useVbenModal({ data.neList = state.checkedList; data.neCodeList = state.neCodeList; try { - await (formData.value?.id ? updateLicense(data) : createLicense(data)); + await (formData.value?.id ? reapplyLicense(data) : createLicense(data)); // 关闭并提示 await modalApi.close(); emit('success');