feat: license操作按钮调整

This commit is contained in:
caiyuchao
2025-08-04 18:46:15 +08:00
parent 77bdf1df47
commit f2ef4e5491
3 changed files with 56 additions and 87 deletions

View File

@@ -26,6 +26,7 @@ export namespace LicenseApi {
action: number; // 操作 action: number; // 操作
neCodeList: NeCode[]; // 操作 neCodeList: NeCode[]; // 操作
oldLicense: License; oldLicense: License;
hasHistory: boolean;
} }
export interface NeCode { export interface NeCode {
id: number; // 主键 id: number; // 主键

View File

@@ -369,59 +369,8 @@ export function useGridColumns(
field: 'operation', field: 'operation',
title: $t('license.operation'), title: $t('license.operation'),
minWidth: 200, minWidth: 200,
align: 'center',
fixed: 'right', fixed: 'right',
headerAlign: 'center', slots: { default: 'actions' },
showOverflow: false,
cellRender: {
attrs: {
nameField: 'serialNo',
nameTitle: 'License',
onClick: onActionClick,
},
name: 'CellOperation',
options: [
{
code: 'detail',
text: $t('license.detail'),
},
{
code: 'history',
text: $t('license.history'),
},
{
code: 'reapply',
text: $t('license.reapply'),
show: (values: LicenseApi.License) => {
return (
hasAccessByCodes(['license:license:apply']) &&
values.status === 3
);
},
},
{
code: 'generate',
text: $t('license.generate'),
show: (values: LicenseApi.License) => {
return (
hasAccessByCodes(['license:license:generate']) &&
(values.status === 1 || values.status === 4)
);
},
},
{
code: 'download',
text: $t('license.download'),
show: (values: LicenseApi.License) => {
return values.status === 3;
},
},
{
code: 'delete',
show: hasAccessByCodes(['license:license:delete']),
},
],
},
}, },
]; ];
} }

View File

@@ -1,8 +1,5 @@
<script lang="ts" setup> <script lang="ts" setup>
import type { import type { VxeTableGridOptions } from '#/adapter/vxe-table';
OnActionClickParams,
VxeTableGridOptions,
} from '#/adapter/vxe-table';
import type { LicenseApi } from '#/api/license/license'; import type { LicenseApi } from '#/api/license/license';
import { useRouter } from 'vue-router'; import { useRouter } from 'vue-router';
@@ -111,36 +108,6 @@ async function onExport() {
downloadFileFromBlobPart({ fileName: 'License.xls', source: data }); downloadFileFromBlobPart({ fileName: 'License.xls', source: data });
} }
/** 表格操作按钮的回调函数 */
function onActionClick({ code, row }: OnActionClickParams<LicenseApi.License>) {
switch (code) {
case 'delete': {
onDelete(row);
break;
}
case 'detail': {
onDetail(row);
break;
}
case 'download': {
onDownload(row);
break;
}
case 'generate': {
onGenerate(row);
break;
}
case 'history': {
onHistory(row);
break;
}
case 'reapply': {
onReapply(row);
break;
}
}
}
const [Grid, gridApi] = useVbenVxeGrid({ const [Grid, gridApi] = useVbenVxeGrid({
formOptions: { formOptions: {
collapsed: true, collapsed: true,
@@ -148,7 +115,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
schema: useGridFormSchema(), schema: useGridFormSchema(),
}, },
gridOptions: { gridOptions: {
columns: useGridColumns(onActionClick), columns: useGridColumns(),
height: 'auto', height: 'auto',
pagerConfig: { pagerConfig: {
enabled: true, enabled: true,
@@ -206,6 +173,58 @@ const [Grid, gridApi] = useVbenVxeGrid({
]" ]"
/> />
</template> </template>
<template #actions="{ row }">
<TableAction
:actions="[
{
label: $t('license.detail'),
type: 'link',
onClick: onDetail.bind(null, row),
},
{
label: $t('license.generate'),
type: 'link',
ifShow: row.status === 1 || row.status === 4,
auth: ['license:license:generate'],
onClick: onGenerate.bind(null, row),
},
{
label: $t('license.download'),
type: 'link',
ifShow: row.status === 3,
auth: ['license:license:query'],
onClick: onDownload.bind(null, row),
},
{
label: $t('common.delete'),
type: 'link',
danger: true,
auth: ['license:license:delete'],
popConfirm: {
title: $t('ui.actionMessage.deleteConfirm', [row.serialNo]),
confirm: onDelete.bind(null, row),
},
},
]"
:drop-down-actions="[
{
label: $t('license.reapply'),
type: 'link',
ifShow: row.status === 3,
auth: ['license:license:query'],
onClick: onReapply.bind(null, row),
},
{
label: $t('license.history'),
type: 'link',
ifShow: row.hasHistory,
auth: ['license:license:query'],
onClick: onHistory.bind(null, row),
},
]"
/>
</template>
</Grid> </Grid>
</Page> </Page>
</template> </template>