fix: 删除多余申请代码

This commit is contained in:
caiyuchao
2025-08-01 12:06:52 +08:00
parent f9b2a8fdf3
commit 4c32fa05ee
3 changed files with 7 additions and 49 deletions

View File

@@ -182,10 +182,6 @@ export function useFormSchema(): VbenFormSchema[] {
component: 'ApiSelect',
rules: 'required',
help: $t('license.licenseAdminHelp'),
dependencies: {
triggerFields: [''],
show: () => formData.value?.action === 1,
},
componentProps: {
allowClear: true,
api: async () => {
@@ -388,16 +384,6 @@ export function useGridColumns(
// code: 'edit',
// show: hasAccessByCodes(['license:license:update']),
// },
{
code: 'apply',
text: $t('license.apply'),
show: (values: LicenseApi.License) => {
return (
hasAccessByCodes(['license:license:apply']) &&
values.status === 0
);
},
},
{
code: 'generate',
text: $t('license.generate'),

View File

@@ -43,12 +43,7 @@ function onRefresh() {
/** 创建License */
function onCreate() {
formModalApi.setData({ action: 1 }).open();
}
/** 申请License */
function onApply(row: LicenseApi.License) {
formModalApi.setData({ ...row, action: 1 }).open();
formModalApi.setData({}).open();
}
/** 生成License */
@@ -108,10 +103,6 @@ async function onExport() {
/** 表格操作按钮的回调函数 */
function onActionClick({ code, row }: OnActionClickParams<LicenseApi.License>) {
switch (code) {
case 'apply': {
onApply(row);
break;
}
case 'delete': {
onDelete(row);
break;

View File

@@ -11,7 +11,6 @@ import { message } from 'ant-design-vue';
import { useVbenForm } from '#/adapter/form';
import {
applyLicense,
createLicense,
getLicense,
updateLicense,
@@ -35,20 +34,13 @@ const state = reactive({
const neCodeRef = ref();
const getTitle = computed(() => {
if (formData.value?.id) {
if (formData.value?.action === 1) {
return $t('license.applyAction', ['License']);
}
return $t('ui.actionTitle.edit', ['License']);
} else {
return $t('license.applyAction', ['License']);
}
return formData.value?.id
? $t('ui.actionTitle.edit', ['License'])
: $t('license.applyAction', ['License']);
});
const getConfirmText = computed(() => {
return formData.value?.action === 1
? $t('license.apply')
: $t('page.action.confirm');
return formData.value?.id ? $t('page.action.confirm') : $t('license.apply');
});
const [Form, formApi] = useVbenForm({
@@ -100,21 +92,12 @@ const [Modal, modalApi] = useVbenModal({
const data = (await formApi.getValues()) as LicenseApi.License;
data.neList = state.checkedList;
data.neCodeList = state.neCodeList;
const action = formData.value?.action || 0;
try {
if (formData.value?.id) {
await (action === 1 ? applyLicense(data) : updateLicense(data));
} else {
await createLicense(data);
}
await (formData.value?.id ? updateLicense(data) : createLicense(data));
// 关闭并提示
await modalApi.close();
emit('success');
if (action === 1) {
message.success($t('license.applySuccess'), 3);
} else {
message.success($t('ui.actionMessage.operationSuccess'));
}
message.success($t('license.applySuccess'), 3);
} finally {
modalApi.unlock();
}
@@ -132,8 +115,6 @@ 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);
} finally {
modalApi.unlock();