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', component: 'ApiSelect',
rules: 'required', 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 () => {
@@ -388,16 +384,6 @@ export function useGridColumns(
// code: 'edit', // code: 'edit',
// show: hasAccessByCodes(['license:license:update']), // 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', code: 'generate',
text: $t('license.generate'), text: $t('license.generate'),

View File

@@ -43,12 +43,7 @@ function onRefresh() {
/** 创建License */ /** 创建License */
function onCreate() { function onCreate() {
formModalApi.setData({ action: 1 }).open(); formModalApi.setData({}).open();
}
/** 申请License */
function onApply(row: LicenseApi.License) {
formModalApi.setData({ ...row, action: 1 }).open();
} }
/** 生成License */ /** 生成License */
@@ -108,10 +103,6 @@ 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

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