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; // 审批人
status: number; // 状态
remark: string; // 备注
action: number; // 操作
}
}

View File

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

View File

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

View File

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

View File

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