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

@@ -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文件',

View File

@@ -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,
},
];
}

View File

@@ -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<LicenseApi.License>) {
onDownload(row);
break;
}
case 'edit': {
onEdit(row);
break;
}
case 'generate': {
onGenerate(row);
break;
}
case 'reapply': {
onReapply(row);
break;
}
}
}

View File

@@ -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');