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 menuIconTypeOptions = transformRecordToOption(menuIconTypeRecord);
|
||||||
|
|
||||||
export const roleTypeRecord: Record<string, string> = {
|
export const roleTypeRecord: Record<number, string> = {
|
||||||
'1': 'R_USER',
|
1: 'R_USER',
|
||||||
'2': 'R_ADMIN'
|
2: 'R_ADMIN'
|
||||||
};
|
};
|
||||||
|
|
||||||
export const podsType: Record<Api.Dashboard.DashboardPodsType, App.I18n.I18nKey> = {
|
export const podsType: Record<Api.Dashboard.DashboardPodsType, App.I18n.I18nKey> = {
|
||||||
|
@ -9,10 +9,10 @@ export function useAuth() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (typeof codes === 'string') {
|
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 {
|
return {
|
||||||
|
@ -12,7 +12,7 @@ export function getUserInfo() {
|
|||||||
username: '',
|
username: '',
|
||||||
userName: '',
|
userName: '',
|
||||||
mode: '',
|
mode: '',
|
||||||
role: '',
|
role: 1,
|
||||||
roles: [],
|
roles: [],
|
||||||
buttons: [],
|
buttons: [],
|
||||||
namespaceIds: []
|
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;
|
||||||
userName: string;
|
userName: string;
|
||||||
mode: string;
|
mode: string;
|
||||||
role: string;
|
role: number;
|
||||||
roles: string[];
|
roles: string[];
|
||||||
buttons: string[];
|
buttons: string[];
|
||||||
namespaceIds: NamespaceId[];
|
namespaceIds: NamespaceId[];
|
||||||
|
@ -125,13 +125,18 @@ const { columns, columnChecks, data, getData, loading, mobilePagination, searchP
|
|||||||
title: $t('common.operate'),
|
title: $t('common.operate'),
|
||||||
align: 'center',
|
align: 'center',
|
||||||
width: 130,
|
width: 130,
|
||||||
render: row => (
|
render: row => {
|
||||||
<div class="flex-center gap-8px">
|
if (hasAuth('R_USER')) {
|
||||||
<NButton type="primary" ghost size="small" onClick={() => edit(row.id!)}>
|
return <></>;
|
||||||
{$t('common.edit')}
|
}
|
||||||
</NButton>
|
return (
|
||||||
</div>
|
<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 { blockStrategyRecord, taskTypeRecord, triggerTypeRecord } from '@/constants/business';
|
||||||
import StatusSwitch from '@/components/common/status-switch.vue';
|
import StatusSwitch from '@/components/common/status-switch.vue';
|
||||||
import { useRouterPush } from '@/hooks/common/router';
|
import { useRouterPush } from '@/hooks/common/router';
|
||||||
|
import { useAuth } from '@/hooks/business/auth';
|
||||||
import JobTaskOperateDrawer from './modules/job-task-operate-drawer.vue';
|
import JobTaskOperateDrawer from './modules/job-task-operate-drawer.vue';
|
||||||
import JobTaskSearch from './modules/job-task-search.vue';
|
import JobTaskSearch from './modules/job-task-search.vue';
|
||||||
import JobTaskDetailDrawer from './modules/job-task-detail-drawer.vue';
|
import JobTaskDetailDrawer from './modules/job-task-detail-drawer.vue';
|
||||||
|
const { hasAuth } = useAuth();
|
||||||
|
|
||||||
const appStore = useAppStore();
|
const appStore = useAppStore();
|
||||||
const { routerPushByKey } = useRouterPush();
|
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!)}>
|
<NButton type="primary" ghost size="small" onClick={() => edit(row.id!)}>
|
||||||
{$t('common.edit')}
|
{$t('common.edit')}
|
||||||
</NButton>
|
</NButton>
|
||||||
<NPopconfirm onPositiveClick={() => handleDelete(row.id!)}>
|
{hasAuth('R_ADMIN') ? (
|
||||||
{{
|
<NPopconfirm onPositiveClick={() => handleDelete(row.id!)}>
|
||||||
default: () => $t('common.confirmDelete'),
|
{{
|
||||||
trigger: () => (
|
default: () => $t('common.confirmDelete'),
|
||||||
<NButton type="error" ghost size="small">
|
trigger: () => (
|
||||||
{$t('common.delete')}
|
<NButton type="error" ghost size="small">
|
||||||
</NButton>
|
{$t('common.delete')}
|
||||||
)
|
</NButton>
|
||||||
}}
|
)
|
||||||
</NPopconfirm>
|
}}
|
||||||
|
</NPopconfirm>
|
||||||
|
) : (
|
||||||
|
''
|
||||||
|
)}
|
||||||
|
|
||||||
<NPopconfirm onPositiveClick={() => handleTriggerJob(row.id!)}>
|
<NPopconfirm onPositiveClick={() => handleTriggerJob(row.id!)}>
|
||||||
{{
|
{{
|
||||||
default: () => $t('common.confirmExecute'),
|
default: () => $t('common.confirmExecute'),
|
||||||
|
@ -8,9 +8,11 @@ import { useAppStore } from '@/store/modules/app';
|
|||||||
import { useTable, useTableOperate } from '@/hooks/common/table';
|
import { useTable, useTableOperate } from '@/hooks/common/table';
|
||||||
import { alarmTypeRecord } from '@/constants/business';
|
import { alarmTypeRecord } from '@/constants/business';
|
||||||
import { tagColor } from '@/utils/common';
|
import { tagColor } from '@/utils/common';
|
||||||
|
import { useAuth } from '@/hooks/business/auth';
|
||||||
import NotifyRecipientOperateDrawer from './modules/notify-recipient-operate-drawer.vue';
|
import NotifyRecipientOperateDrawer from './modules/notify-recipient-operate-drawer.vue';
|
||||||
import NotifyRecipientSearch from './modules/notify-recipient-search.vue';
|
import NotifyRecipientSearch from './modules/notify-recipient-search.vue';
|
||||||
import NotifyRecipientDetailDrawer from './modules/notify-recipient-detail-drawer.vue';
|
import NotifyRecipientDetailDrawer from './modules/notify-recipient-detail-drawer.vue';
|
||||||
|
const { hasAuth } = useAuth();
|
||||||
|
|
||||||
const appStore = useAppStore();
|
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!)}>
|
<NButton type="primary" ghost size="small" onClick={() => edit(row.id!)}>
|
||||||
{$t('common.edit')}
|
{$t('common.edit')}
|
||||||
</NButton>
|
</NButton>
|
||||||
<NPopconfirm onPositiveClick={() => handleDelete(row.id!)}>
|
{hasAuth('R_ADMIN') ? (
|
||||||
{{
|
<NPopconfirm onPositiveClick={() => handleDelete(row.id!)}>
|
||||||
default: () => $t('common.confirmDelete'),
|
{{
|
||||||
trigger: () => (
|
default: () => $t('common.confirmDelete'),
|
||||||
<NButton type="error" ghost size="small">
|
trigger: () => (
|
||||||
{$t('common.delete')}
|
<NButton type="error" ghost size="small">
|
||||||
</NButton>
|
{$t('common.delete')}
|
||||||
)
|
</NButton>
|
||||||
}}
|
)
|
||||||
</NPopconfirm>
|
}}
|
||||||
|
</NPopconfirm>
|
||||||
|
) : (
|
||||||
|
''
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,8 @@ import NotifyConfigDetailDrawer from '@/views/notify/scene/modules/notify-config
|
|||||||
import StatusSwitch from '@/components/common/status-switch.vue';
|
import StatusSwitch from '@/components/common/status-switch.vue';
|
||||||
import { jobNotifyScene, retryNotifyScene, systemTaskType, workflowNotifyScene } from '@/constants/business';
|
import { jobNotifyScene, retryNotifyScene, systemTaskType, workflowNotifyScene } from '@/constants/business';
|
||||||
import { tagColor } from '@/utils/common';
|
import { tagColor } from '@/utils/common';
|
||||||
|
import { useAuth } from '@/hooks/business/auth';
|
||||||
|
const { hasAuth } = useAuth();
|
||||||
|
|
||||||
const appStore = useAppStore();
|
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!)}>
|
<NButton type="primary" ghost size="small" onClick={() => edit(row.id!)}>
|
||||||
{$t('common.edit')}
|
{$t('common.edit')}
|
||||||
</NButton>
|
</NButton>
|
||||||
<NPopconfirm onPositiveClick={() => handleDelete(row.id!)}>
|
{hasAuth('R_ADMIN') ? (
|
||||||
{{
|
<NPopconfirm onPositiveClick={() => handleDelete(row.id!)}>
|
||||||
default: () => $t('common.confirmDelete'),
|
{{
|
||||||
trigger: () => (
|
default: () => $t('common.confirmDelete'),
|
||||||
<NButton type="error" ghost size="small">
|
trigger: () => (
|
||||||
{$t('common.delete')}
|
<NButton type="error" ghost size="small">
|
||||||
</NButton>
|
{$t('common.delete')}
|
||||||
)
|
</NButton>
|
||||||
}}
|
)
|
||||||
</NPopconfirm>
|
}}
|
||||||
|
</NPopconfirm>
|
||||||
|
) : (
|
||||||
|
''
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,9 @@ import { useTable, useTableOperate } from '@/hooks/common/table';
|
|||||||
import { triggerTypeRecord } from '@/constants/business';
|
import { triggerTypeRecord } from '@/constants/business';
|
||||||
import StatusSwitch from '@/components/common/status-switch.vue';
|
import StatusSwitch from '@/components/common/status-switch.vue';
|
||||||
import { tagColor } from '@/utils/common';
|
import { tagColor } from '@/utils/common';
|
||||||
|
import { useAuth } from '@/hooks/business/auth';
|
||||||
import WorkflowSearch from './modules/workflow-search.vue';
|
import WorkflowSearch from './modules/workflow-search.vue';
|
||||||
|
const { hasAuth } = useAuth();
|
||||||
|
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const appStore = useAppStore();
|
const appStore = useAppStore();
|
||||||
@ -125,48 +127,55 @@ const { columns, columnChecks, data, getData, loading, mobilePagination, searchP
|
|||||||
title: $t('common.operate'),
|
title: $t('common.operate'),
|
||||||
align: 'center',
|
align: 'center',
|
||||||
fixed: 'right',
|
fixed: 'right',
|
||||||
width: 300,
|
width: 200,
|
||||||
render: row => (
|
render: row => {
|
||||||
<div class="flex-center gap-8px">
|
return (
|
||||||
<NButton type="warning" ghost size="small" onClick={() => edit(row.id!)}>
|
<div class="flex-center gap-8px">
|
||||||
{$t('common.edit')}
|
<NButton type="warning" ghost size="small" onClick={() => edit(row.id!)}>
|
||||||
</NButton>
|
{$t('common.edit')}
|
||||||
<NPopconfirm onPositiveClick={() => handleDelete(row.id!)}>
|
</NButton>
|
||||||
{{
|
{hasAuth('R_ADMIN') ? (
|
||||||
default: () => $t('common.confirmDelete'),
|
<NPopconfirm onPositiveClick={() => handleDelete(row.id!)}>
|
||||||
trigger: () => (
|
{{
|
||||||
<NButton type="error" ghost size="small">
|
default: () => $t('common.confirmDelete'),
|
||||||
{$t('common.delete')}
|
trigger: () => (
|
||||||
</NButton>
|
<NButton type="error" ghost size="small">
|
||||||
)
|
{$t('common.delete')}
|
||||||
}}
|
|
||||||
</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>
|
||||||
<NButton type="primary" ghost size="small" onClick={() => copy(row.id!)}>
|
)
|
||||||
{$t('common.copy')}
|
}}
|
||||||
</NButton>
|
</NPopconfirm>
|
||||||
<NButton type="success" ghost size="small" onClick={() => batch(row.id!)}>
|
) : (
|
||||||
{$t('common.batchList')}
|
''
|
||||||
</NButton>
|
)}
|
||||||
</NButtonGroup>
|
|
||||||
</div>
|
<NPopover trigger="click" placement="bottom" raw show-arrow={false} class="b-rd-6px bg-#fff dark:bg-#000">
|
||||||
)
|
{{
|
||||||
}}
|
trigger: () => (
|
||||||
</NPopover>
|
<NButton type="primary" ghost size="small">
|
||||||
</div>
|
更多
|
||||||
)
|
</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