feat(sj_1.0.0): 权限添加
This commit is contained in:
parent
cc20d97c2f
commit
aaee519909
@ -40,9 +40,9 @@ export const menuIconTypeRecord: Record<Api.SystemManage.IconType, App.I18n.I18n
|
||||
|
||||
export const menuIconTypeOptions = transformRecordToOption(menuIconTypeRecord);
|
||||
|
||||
export const roleTypeRecord: Record<string, string> = {
|
||||
'1': 'R_USER',
|
||||
'2': 'R_ADMIN'
|
||||
export const roleTypeRecord: Record<number, string> = {
|
||||
1: 'R_USER',
|
||||
2: 'R_ADMIN'
|
||||
};
|
||||
|
||||
export const podsType: Record<Api.Dashboard.DashboardPodsType, App.I18n.I18nKey> = {
|
||||
|
@ -9,10 +9,10 @@ export function useAuth() {
|
||||
}
|
||||
|
||||
if (typeof codes === 'string') {
|
||||
return authStore.userInfo.buttons.includes(codes);
|
||||
return authStore.userInfo.roles.includes(codes);
|
||||
}
|
||||
|
||||
return codes.some(code => authStore.userInfo.buttons.includes(code));
|
||||
return codes.some(code => authStore.userInfo.roles.includes(code));
|
||||
}
|
||||
|
||||
return {
|
||||
|
@ -12,7 +12,7 @@ export function getUserInfo() {
|
||||
username: '',
|
||||
userName: '',
|
||||
mode: '',
|
||||
role: '',
|
||||
role: 1,
|
||||
roles: [],
|
||||
buttons: [],
|
||||
namespaceIds: []
|
||||
|
2
src/typings/api.d.ts
vendored
2
src/typings/api.d.ts
vendored
@ -117,7 +117,7 @@ declare namespace Api {
|
||||
username: string;
|
||||
userName: string;
|
||||
mode: string;
|
||||
role: string;
|
||||
role: number;
|
||||
roles: string[];
|
||||
buttons: string[];
|
||||
namespaceIds: NamespaceId[];
|
||||
|
@ -125,13 +125,18 @@ const { columns, columnChecks, data, getData, loading, mobilePagination, searchP
|
||||
title: $t('common.operate'),
|
||||
align: 'center',
|
||||
width: 130,
|
||||
render: row => (
|
||||
<div class="flex-center gap-8px">
|
||||
<NButton type="primary" ghost size="small" onClick={() => edit(row.id!)}>
|
||||
{$t('common.edit')}
|
||||
</NButton>
|
||||
</div>
|
||||
)
|
||||
render: row => {
|
||||
if (hasAuth('R_USER')) {
|
||||
return <></>;
|
||||
}
|
||||
return (
|
||||
<div class="flex-center gap-8px">
|
||||
<NButton type="primary" ghost size="small" onClick={() => edit(row.id!)}>
|
||||
{$t('common.edit')}
|
||||
</NButton>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
]
|
||||
});
|
||||
|
@ -9,9 +9,11 @@ import { useTable, useTableOperate } from '@/hooks/common/table';
|
||||
import { blockStrategyRecord, taskTypeRecord, triggerTypeRecord } from '@/constants/business';
|
||||
import StatusSwitch from '@/components/common/status-switch.vue';
|
||||
import { useRouterPush } from '@/hooks/common/router';
|
||||
import { useAuth } from '@/hooks/business/auth';
|
||||
import JobTaskOperateDrawer from './modules/job-task-operate-drawer.vue';
|
||||
import JobTaskSearch from './modules/job-task-search.vue';
|
||||
import JobTaskDetailDrawer from './modules/job-task-detail-drawer.vue';
|
||||
const { hasAuth } = useAuth();
|
||||
|
||||
const appStore = useAppStore();
|
||||
const { routerPushByKey } = useRouterPush();
|
||||
@ -172,16 +174,21 @@ const { columnChecks, columns, data, getData, loading, mobilePagination, searchP
|
||||
<NButton type="primary" ghost size="small" onClick={() => edit(row.id!)}>
|
||||
{$t('common.edit')}
|
||||
</NButton>
|
||||
<NPopconfirm onPositiveClick={() => handleDelete(row.id!)}>
|
||||
{{
|
||||
default: () => $t('common.confirmDelete'),
|
||||
trigger: () => (
|
||||
<NButton type="error" ghost size="small">
|
||||
{$t('common.delete')}
|
||||
</NButton>
|
||||
)
|
||||
}}
|
||||
</NPopconfirm>
|
||||
{hasAuth('R_ADMIN') ? (
|
||||
<NPopconfirm onPositiveClick={() => handleDelete(row.id!)}>
|
||||
{{
|
||||
default: () => $t('common.confirmDelete'),
|
||||
trigger: () => (
|
||||
<NButton type="error" ghost size="small">
|
||||
{$t('common.delete')}
|
||||
</NButton>
|
||||
)
|
||||
}}
|
||||
</NPopconfirm>
|
||||
) : (
|
||||
''
|
||||
)}
|
||||
|
||||
<NPopconfirm onPositiveClick={() => handleTriggerJob(row.id!)}>
|
||||
{{
|
||||
default: () => $t('common.confirmExecute'),
|
||||
|
@ -8,9 +8,11 @@ import { useAppStore } from '@/store/modules/app';
|
||||
import { useTable, useTableOperate } from '@/hooks/common/table';
|
||||
import { alarmTypeRecord } from '@/constants/business';
|
||||
import { tagColor } from '@/utils/common';
|
||||
import { useAuth } from '@/hooks/business/auth';
|
||||
import NotifyRecipientOperateDrawer from './modules/notify-recipient-operate-drawer.vue';
|
||||
import NotifyRecipientSearch from './modules/notify-recipient-search.vue';
|
||||
import NotifyRecipientDetailDrawer from './modules/notify-recipient-detail-drawer.vue';
|
||||
const { hasAuth } = useAuth();
|
||||
|
||||
const appStore = useAppStore();
|
||||
|
||||
@ -85,16 +87,20 @@ const { columns, columnChecks, data, getData, loading, mobilePagination, searchP
|
||||
<NButton type="primary" ghost size="small" onClick={() => edit(row.id!)}>
|
||||
{$t('common.edit')}
|
||||
</NButton>
|
||||
<NPopconfirm onPositiveClick={() => handleDelete(row.id!)}>
|
||||
{{
|
||||
default: () => $t('common.confirmDelete'),
|
||||
trigger: () => (
|
||||
<NButton type="error" ghost size="small">
|
||||
{$t('common.delete')}
|
||||
</NButton>
|
||||
)
|
||||
}}
|
||||
</NPopconfirm>
|
||||
{hasAuth('R_ADMIN') ? (
|
||||
<NPopconfirm onPositiveClick={() => handleDelete(row.id!)}>
|
||||
{{
|
||||
default: () => $t('common.confirmDelete'),
|
||||
trigger: () => (
|
||||
<NButton type="error" ghost size="small">
|
||||
{$t('common.delete')}
|
||||
</NButton>
|
||||
)
|
||||
}}
|
||||
</NPopconfirm>
|
||||
) : (
|
||||
''
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
@ -12,6 +12,8 @@ import NotifyConfigDetailDrawer from '@/views/notify/scene/modules/notify-config
|
||||
import StatusSwitch from '@/components/common/status-switch.vue';
|
||||
import { jobNotifyScene, retryNotifyScene, systemTaskType, workflowNotifyScene } from '@/constants/business';
|
||||
import { tagColor } from '@/utils/common';
|
||||
import { useAuth } from '@/hooks/business/auth';
|
||||
const { hasAuth } = useAuth();
|
||||
|
||||
const appStore = useAppStore();
|
||||
|
||||
@ -156,16 +158,20 @@ const { columns, columnChecks, data, getData, loading, mobilePagination, searchP
|
||||
<NButton type="primary" ghost size="small" onClick={() => edit(row.id!)}>
|
||||
{$t('common.edit')}
|
||||
</NButton>
|
||||
<NPopconfirm onPositiveClick={() => handleDelete(row.id!)}>
|
||||
{{
|
||||
default: () => $t('common.confirmDelete'),
|
||||
trigger: () => (
|
||||
<NButton type="error" ghost size="small">
|
||||
{$t('common.delete')}
|
||||
</NButton>
|
||||
)
|
||||
}}
|
||||
</NPopconfirm>
|
||||
{hasAuth('R_ADMIN') ? (
|
||||
<NPopconfirm onPositiveClick={() => handleDelete(row.id!)}>
|
||||
{{
|
||||
default: () => $t('common.confirmDelete'),
|
||||
trigger: () => (
|
||||
<NButton type="error" ghost size="small">
|
||||
{$t('common.delete')}
|
||||
</NButton>
|
||||
)
|
||||
}}
|
||||
</NPopconfirm>
|
||||
) : (
|
||||
''
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
@ -13,7 +13,9 @@ import { useTable, useTableOperate } from '@/hooks/common/table';
|
||||
import { triggerTypeRecord } from '@/constants/business';
|
||||
import StatusSwitch from '@/components/common/status-switch.vue';
|
||||
import { tagColor } from '@/utils/common';
|
||||
import { useAuth } from '@/hooks/business/auth';
|
||||
import WorkflowSearch from './modules/workflow-search.vue';
|
||||
const { hasAuth } = useAuth();
|
||||
|
||||
const router = useRouter();
|
||||
const appStore = useAppStore();
|
||||
@ -125,48 +127,55 @@ const { columns, columnChecks, data, getData, loading, mobilePagination, searchP
|
||||
title: $t('common.operate'),
|
||||
align: 'center',
|
||||
fixed: 'right',
|
||||
width: 300,
|
||||
render: row => (
|
||||
<div class="flex-center gap-8px">
|
||||
<NButton type="warning" ghost size="small" onClick={() => edit(row.id!)}>
|
||||
{$t('common.edit')}
|
||||
</NButton>
|
||||
<NPopconfirm onPositiveClick={() => handleDelete(row.id!)}>
|
||||
{{
|
||||
default: () => $t('common.confirmDelete'),
|
||||
trigger: () => (
|
||||
<NButton type="error" ghost size="small">
|
||||
{$t('common.delete')}
|
||||
</NButton>
|
||||
)
|
||||
}}
|
||||
</NPopconfirm>
|
||||
<NPopover trigger="click" placement="bottom" raw show-arrow={false} class="b-rd-6px bg-#fff dark:bg-#000">
|
||||
{{
|
||||
trigger: () => (
|
||||
<NButton type="primary" ghost size="small">
|
||||
更多
|
||||
</NButton>
|
||||
),
|
||||
default: () => (
|
||||
<div>
|
||||
<NButtonGroup vertical>
|
||||
<NButton type="primary" ghost size="small" onClick={() => execute(row.id!)}>
|
||||
{$t('common.execute')}
|
||||
width: 200,
|
||||
render: row => {
|
||||
return (
|
||||
<div class="flex-center gap-8px">
|
||||
<NButton type="warning" ghost size="small" onClick={() => edit(row.id!)}>
|
||||
{$t('common.edit')}
|
||||
</NButton>
|
||||
{hasAuth('R_ADMIN') ? (
|
||||
<NPopconfirm onPositiveClick={() => handleDelete(row.id!)}>
|
||||
{{
|
||||
default: () => $t('common.confirmDelete'),
|
||||
trigger: () => (
|
||||
<NButton type="error" ghost size="small">
|
||||
{$t('common.delete')}
|
||||
</NButton>
|
||||
<NButton type="primary" ghost size="small" onClick={() => copy(row.id!)}>
|
||||
{$t('common.copy')}
|
||||
</NButton>
|
||||
<NButton type="success" ghost size="small" onClick={() => batch(row.id!)}>
|
||||
{$t('common.batchList')}
|
||||
</NButton>
|
||||
</NButtonGroup>
|
||||
</div>
|
||||
)
|
||||
}}
|
||||
</NPopover>
|
||||
</div>
|
||||
)
|
||||
)
|
||||
}}
|
||||
</NPopconfirm>
|
||||
) : (
|
||||
''
|
||||
)}
|
||||
|
||||
<NPopover trigger="click" placement="bottom" raw show-arrow={false} class="b-rd-6px bg-#fff dark:bg-#000">
|
||||
{{
|
||||
trigger: () => (
|
||||
<NButton type="primary" ghost size="small">
|
||||
更多
|
||||
</NButton>
|
||||
),
|
||||
default: () => (
|
||||
<div>
|
||||
<NButtonGroup vertical>
|
||||
<NButton type="primary" ghost size="small" onClick={() => execute(row.id!)}>
|
||||
{$t('common.execute')}
|
||||
</NButton>
|
||||
<NButton type="primary" ghost size="small" onClick={() => copy(row.id!)}>
|
||||
{$t('common.copy')}
|
||||
</NButton>
|
||||
<NButton type="success" ghost size="small" onClick={() => batch(row.id!)}>
|
||||
{$t('common.batchList')}
|
||||
</NButton>
|
||||
</NButtonGroup>
|
||||
</div>
|
||||
)
|
||||
}}
|
||||
</NPopover>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
]
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user