feat: 添加申请按钮

This commit is contained in:
caiyuchao
2025-07-04 18:05:16 +08:00
parent 8c10085989
commit bb9a082e78
6 changed files with 44 additions and 6 deletions

View File

@@ -21,6 +21,7 @@ export namespace LicenseApi {
approver: number; // 审批人 approver: number; // 审批人
status: number; // 状态 status: number; // 状态
remark: string; // 备注 remark: string; // 备注
action: number; // 操作
} }
} }

View File

@@ -15,5 +15,7 @@
"operation": "Operation", "operation": "Operation",
"list": "License List", "list": "License List",
"checkAll": "Check All", "checkAll": "Check All",
"licenseAdminHelp": "Assigned to persons who have permission to generate licenses" "licenseAdminHelp": "Assigned to persons who have permission to generate licenses and send email reminders",
"apply": "Apply",
"applyAction": "Apply For {0}"
} }

View File

@@ -15,5 +15,7 @@
"operation": "操作", "operation": "操作",
"list": "License列表", "list": "License列表",
"checkAll": "全选", "checkAll": "全选",
"licenseAdminHelp": "指派给有权限生成License的人员" "licenseAdminHelp": "指派给有权限生成License的人员,并且发送邮件提醒",
"apply": "申请",
"applyAction": "申请{0}"
} }

View File

@@ -172,7 +172,12 @@ export function useFormSchema(): VbenFormSchema[] {
fieldName: 'approver', fieldName: 'approver',
label: $t('license.approver'), label: $t('license.approver'),
component: 'ApiSelect', component: 'ApiSelect',
rules: 'required',
help: $t('license.licenseAdminHelp'), help: $t('license.licenseAdminHelp'),
dependencies: {
triggerFields: [''],
show: () => formData.value?.action === 1,
},
componentProps: { componentProps: {
allowClear: true, allowClear: true,
api: async () => { api: async () => {
@@ -441,6 +446,11 @@ export function useGridColumns(
code: 'edit', code: 'edit',
show: hasAccessByCodes(['license:license:update']), show: hasAccessByCodes(['license:license:update']),
}, },
{
code: 'apply',
text: $t('license.apply'),
show: hasAccessByCodes(['license:license:update']),
},
{ {
code: 'delete', code: 'delete',
show: hasAccessByCodes(['license:license:delete']), show: hasAccessByCodes(['license:license:delete']),

View File

@@ -39,6 +39,11 @@ function onCreate() {
formModalApi.setData({}).open(); formModalApi.setData({}).open();
} }
/** 申请License */
function onApply(row: LicenseApi.License) {
formModalApi.setData({ ...row, action: 1 }).open();
}
/** 编辑License */ /** 编辑License */
function onEdit(row: LicenseApi.License) { function onEdit(row: LicenseApi.License) {
formModalApi.setData(row).open(); formModalApi.setData(row).open();
@@ -70,6 +75,10 @@ async function onExport() {
/** 表格操作按钮的回调函数 */ /** 表格操作按钮的回调函数 */
function onActionClick({ code, row }: OnActionClickParams<LicenseApi.License>) { function onActionClick({ code, row }: OnActionClickParams<LicenseApi.License>) {
switch (code) { switch (code) {
case 'apply': {
onApply(row);
break;
}
case 'delete': { case 'delete': {
onDelete(row); onDelete(row);
break; break;

View File

@@ -28,9 +28,20 @@ const state = reactive({
}); });
const getTitle = computed(() => { const getTitle = computed(() => {
return formData.value?.id if (formData.value?.id) {
? $t('ui.actionTitle.edit', ['License']) if (formData.value?.action === 1) {
: $t('ui.actionTitle.create', ['License']); return $t('license.applyAction', ['License']);
}
return $t('ui.actionTitle.edit', ['License']);
} else {
return $t('ui.actionTitle.create', ['License']);
}
});
const getConfirmText = computed(() => {
return formData.value?.action === 1
? $t('license.apply')
: $t('page.action.confirm');
}); });
const [Form, formApi] = useVbenForm({ const [Form, formApi] = useVbenForm({
@@ -98,7 +109,10 @@ const [Modal, modalApi] = useVbenModal({
if (data.id) { if (data.id) {
modalApi.lock(); modalApi.lock();
try { try {
const action = data.action || 0; // 确保 action 字段存在
formData.value = { ...data, action };
data = await getLicense(data.id); data = await getLicense(data.id);
data = { ...data, action }; // 保持 action 字段
} finally { } finally {
modalApi.unlock(); modalApi.unlock();
} }
@@ -116,7 +130,7 @@ const [Modal, modalApi] = useVbenModal({
</script> </script>
<template> <template>
<Modal :title="getTitle" class="w-[800px]"> <Modal :title="getTitle" class="w-[800px]" :confirm-text="getConfirmText">
<Form class="mx-4"> <Form class="mx-4">
<template #neSwitch="slotProps"> <template #neSwitch="slotProps">
<a-row> <a-row>