From bb9a082e780ad0dfcdc52e164d0db27e992c996e Mon Sep 17 00:00:00 2001 From: caiyuchao Date: Fri, 4 Jul 2025 18:05:16 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E7=94=B3=E8=AF=B7?= =?UTF-8?q?=E6=8C=89=E9=92=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../web-antd/src/api/license/license/index.ts | 1 + .../src/locales/langs/en-US/license.json | 4 +++- .../src/locales/langs/zh-CN/license.json | 4 +++- .../src/views/license/license/data.ts | 10 +++++++++ .../src/views/license/license/index.vue | 9 ++++++++ .../views/license/license/modules/form.vue | 22 +++++++++++++++---- 6 files changed, 44 insertions(+), 6 deletions(-) diff --git a/apps/web-antd/src/api/license/license/index.ts b/apps/web-antd/src/api/license/license/index.ts index 1c1a266..e267eb0 100644 --- a/apps/web-antd/src/api/license/license/index.ts +++ b/apps/web-antd/src/api/license/license/index.ts @@ -21,6 +21,7 @@ export namespace LicenseApi { approver: number; // 审批人 status: number; // 状态 remark: string; // 备注 + action: number; // 操作 } } 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 a39d1ea..696e29b 100644 --- a/apps/web-antd/src/locales/langs/en-US/license.json +++ b/apps/web-antd/src/locales/langs/en-US/license.json @@ -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}" } 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 31b2762..808a290 100644 --- a/apps/web-antd/src/locales/langs/zh-CN/license.json +++ b/apps/web-antd/src/locales/langs/zh-CN/license.json @@ -15,5 +15,7 @@ "operation": "操作", "list": "License列表", "checkAll": "全选", - "licenseAdminHelp": "指派给有权限生成License的人员" + "licenseAdminHelp": "指派给有权限生成License的人员,并且发送邮件提醒", + "apply": "申请", + "applyAction": "申请{0}" } diff --git a/apps/web-antd/src/views/license/license/data.ts b/apps/web-antd/src/views/license/license/data.ts index 03eae36..dbbce63 100644 --- a/apps/web-antd/src/views/license/license/data.ts +++ b/apps/web-antd/src/views/license/license/data.ts @@ -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']), diff --git a/apps/web-antd/src/views/license/license/index.vue b/apps/web-antd/src/views/license/license/index.vue index 50196cb..24d4449 100644 --- a/apps/web-antd/src/views/license/license/index.vue +++ b/apps/web-antd/src/views/license/license/index.vue @@ -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) { switch (code) { + case 'apply': { + onApply(row); + break; + } case 'delete': { onDelete(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 f734a98..30971f7 100644 --- a/apps/web-antd/src/views/license/license/modules/form.vue +++ b/apps/web-antd/src/views/license/license/modules/form.vue @@ -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({