refactor: 支持改变字典颜色

This commit is contained in:
caiyuchao
2025-08-01 18:15:43 +08:00
parent 4c32fa05ee
commit 2c0601a46b
8 changed files with 128 additions and 24 deletions

View File

@@ -25,6 +25,7 @@ export namespace LicenseApi {
remark: string; // 备注 remark: string; // 备注
action: number; // 操作 action: number; // 操作
neCodeList: NeCode[]; // 操作 neCodeList: NeCode[]; // 操作
oldLicense: License;
} }
export interface NeCode { export interface NeCode {
id: number; // 主键 id: number; // 主键
@@ -56,6 +57,11 @@ export function updateLicense(data: LicenseApi.License) {
return requestClient.put('/license/license/update', data); return requestClient.put('/license/license/update', data);
} }
/** 重新License */
export function reapplyLicense(data: LicenseApi.License) {
return requestClient.put('/license/license/reapply', data);
}
/** 申请License */ /** 申请License */
export function applyLicense(data: LicenseApi.License) { export function applyLicense(data: LicenseApi.License) {
return requestClient.put('/license/license/apply', data); return requestClient.put('/license/license/apply', data);

View File

@@ -19,6 +19,7 @@ interface DictTagGroupProps {
* 图标 * 图标
*/ */
icon?: string; icon?: string;
color?: string;
} }
const props = defineProps<DictTagGroupProps>(); const props = defineProps<DictTagGroupProps>();
@@ -60,6 +61,9 @@ const dictTag = computed(() => {
} }
} }
} }
if (props.color) {
colorType = props.color;
}
dictTagGroup.push({ dictTagGroup.push({
label: dict.label || '', label: dict.label || '',
colorType, colorType,

View File

@@ -31,5 +31,7 @@
"enterCode": "Please enter Activation Code", "enterCode": "Please enter Activation Code",
"selectNe": "Please select Network Element", "selectNe": "Please select Network Element",
"detail": "detail", "detail": "detail",
"downloadAll": "Download All" "downloadAll": "Download All",
"reapply": "Reapply",
"reapplyAction": "Reapply For {0}"
} }

View File

@@ -31,5 +31,7 @@
"enterCode": "请输入激活码", "enterCode": "请输入激活码",
"selectNe": "请选择网元", "selectNe": "请选择网元",
"detail": "详情", "detail": "详情",
"downloadAll": "全部下载" "downloadAll": "全部下载",
"reapply": "重新申请",
"reapplyAction": "重新申请{0}"
} }

View File

@@ -21,10 +21,10 @@ const props = defineProps<{
const columns = [ const columns = [
{ {
title: '网元', title: '网元',
dataIndex: 'neList', dataIndex: 'neListMap',
key: 'neList', key: 'neListMap',
customRender: (data: any) => { customRender: (data: any) => {
return h(DictTagGroup, { const oldDict = h(DictTagGroup, {
type: [ type: [
DICT_TYPE.LIC_NE_ALL, DICT_TYPE.LIC_NE_ALL,
DICT_TYPE.LIC_NE_5G, DICT_TYPE.LIC_NE_5G,
@@ -32,14 +32,53 @@ const columns = [
DICT_TYPE.LIC_NE_23G, DICT_TYPE.LIC_NE_23G,
DICT_TYPE.LIC_NE_ADD, 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: '激活码', title: '激活码',
dataIndex: 'activationCode', dataIndex: 'activationCodeMap',
key: 'activationCode', 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文件', title: 'License文件',

View File

@@ -42,6 +42,10 @@ export function useFormSchema(): VbenFormSchema[] {
label: $t('license.customer'), label: $t('license.customer'),
rules: 'required', rules: 'required',
component: 'ApiSelect', component: 'ApiSelect',
dependencies: {
triggerFields: ['id'],
disabled: (values) => !!values.id,
},
componentProps: { componentProps: {
api: async () => { api: async () => {
customerList.value = await getCustomerList(); customerList.value = await getCustomerList();
@@ -82,7 +86,8 @@ export function useFormSchema(): VbenFormSchema[] {
options: projectList, options: projectList,
}; };
}, },
triggerFields: ['customerId'], triggerFields: ['customerId', 'id'],
disabled: (values) => !!values.id,
}, },
}, },
{ {
@@ -380,10 +385,11 @@ export function useGridColumns(
code: 'detail', code: 'detail',
text: $t('license.detail'), text: $t('license.detail'),
}, },
// { {
// code: 'edit', code: 'reapply',
// show: hasAccessByCodes(['license:license:update']), text: $t('license.reapply'),
// }, show: hasAccessByCodes(['license:license:apply']),
},
{ {
code: 'generate', code: 'generate',
text: $t('license.generate'), text: $t('license.generate'),
@@ -430,16 +436,61 @@ export function useDetailSchema(): DescriptionItemSchema[] {
field: 'expiryDate', field: 'expiryDate',
label: $t('license.expiryDate'), label: $t('license.expiryDate'),
content: (data) => { 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; return formatDate(data?.expiryDate) as string;
}, },
}, },
{ {
field: 'userNumber', field: 'userNumber',
label: $t('license.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', field: 'ranNumber',
label: $t('license.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', field: 'applicantName',
@@ -465,7 +516,7 @@ export function useDetailSchema(): DescriptionItemSchema[] {
{ {
field: 'remark', field: 'remark',
label: $t('license.remark'), label: $t('license.remark'),
hidden: (data) => data, hidden: (data) => !data.remark,
}, },
]; ];
} }

View File

@@ -72,8 +72,8 @@ async function onDownload(row: LicenseApi.License) {
downloadFileFromBlobPart({ fileName, source: blob }); downloadFileFromBlobPart({ fileName, source: blob });
} }
/** 编辑License */ /** 重新申请License */
function onEdit(row: LicenseApi.License) { function onReapply(row: LicenseApi.License) {
formModalApi.setData(row).open(); formModalApi.setData(row).open();
} }
@@ -115,14 +115,14 @@ function onActionClick({ code, row }: OnActionClickParams<LicenseApi.License>) {
onDownload(row); onDownload(row);
break; break;
} }
case 'edit': {
onEdit(row);
break;
}
case 'generate': { case 'generate': {
onGenerate(row); onGenerate(row);
break; break;
} }
case 'reapply': {
onReapply(row);
break;
}
} }
} }

View File

@@ -13,7 +13,7 @@ import { useVbenForm } from '#/adapter/form';
import { import {
createLicense, createLicense,
getLicense, getLicense,
updateLicense, reapplyLicense,
} from '#/api/license/license'; } from '#/api/license/license';
import { $t } from '#/locales'; import { $t } from '#/locales';
import { DICT_TYPE, getDictOptions } from '#/utils'; import { DICT_TYPE, getDictOptions } from '#/utils';
@@ -35,12 +35,12 @@ const neCodeRef = ref();
const getTitle = computed(() => { const getTitle = computed(() => {
return formData.value?.id return formData.value?.id
? $t('ui.actionTitle.edit', ['License']) ? $t('license.reapplyAction', ['License'])
: $t('license.applyAction', ['License']); : $t('license.applyAction', ['License']);
}); });
const getConfirmText = computed(() => { 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({ const [Form, formApi] = useVbenForm({
@@ -93,7 +93,7 @@ const [Modal, modalApi] = useVbenModal({
data.neList = state.checkedList; data.neList = state.checkedList;
data.neCodeList = state.neCodeList; data.neCodeList = state.neCodeList;
try { try {
await (formData.value?.id ? updateLicense(data) : createLicense(data)); await (formData.value?.id ? reapplyLicense(data) : createLicense(data));
// 关闭并提示 // 关闭并提示
await modalApi.close(); await modalApi.close();
emit('success'); emit('success');