chore: role
This commit is contained in:
parent
d965ea6d1e
commit
a7aeb5ae63
@ -1,6 +1,7 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import type { Recordable } from '@vben/types';
|
import type { Recordable } from '@vben/types';
|
||||||
|
|
||||||
|
import { ref } from 'vue';
|
||||||
import { useRouter } from 'vue-router';
|
import { useRouter } from 'vue-router';
|
||||||
|
|
||||||
import { useAccess } from '@vben/access';
|
import { useAccess } from '@vben/access';
|
||||||
@ -10,6 +11,7 @@ import {
|
|||||||
useVbenModal,
|
useVbenModal,
|
||||||
type VbenFormProps,
|
type VbenFormProps,
|
||||||
} from '@vben/common-ui';
|
} from '@vben/common-ui';
|
||||||
|
import { getPopupContainer } from '@vben/utils';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
Dropdown,
|
Dropdown,
|
||||||
@ -89,7 +91,19 @@ const gridOptions: VxeGridProps = {
|
|||||||
showOverflow: true,
|
showOverflow: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
const [BasicTable, tableApi] = useVbenVxeGrid({ formOptions, gridOptions });
|
const checked = ref(false);
|
||||||
|
const [BasicTable, tableApi] = useVbenVxeGrid({
|
||||||
|
formOptions,
|
||||||
|
gridOptions,
|
||||||
|
gridEvents: {
|
||||||
|
checkboxChange: (e: any) => {
|
||||||
|
checked.value = e.records.length > 0;
|
||||||
|
},
|
||||||
|
checkboxAll: (e: any) => {
|
||||||
|
checked.value = e.records.length > 0;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
const [RoleDrawer, drawerApi] = useVbenDrawer({
|
const [RoleDrawer, drawerApi] = useVbenDrawer({
|
||||||
connectedComponent: roleDrawer,
|
connectedComponent: roleDrawer,
|
||||||
});
|
});
|
||||||
@ -106,7 +120,7 @@ async function handleEdit(record: Recordable<any>) {
|
|||||||
|
|
||||||
async function handleDelete(row: Recordable<any>) {
|
async function handleDelete(row: Recordable<any>) {
|
||||||
await roleRemove(row.roleId);
|
await roleRemove(row.roleId);
|
||||||
await tableApi.reload();
|
await tableApi.query();
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleMultiDelete() {
|
function handleMultiDelete() {
|
||||||
@ -118,7 +132,7 @@ function handleMultiDelete() {
|
|||||||
content: `确认删除选中的${ids.length}条记录吗?`,
|
content: `确认删除选中的${ids.length}条记录吗?`,
|
||||||
onOk: async () => {
|
onOk: async () => {
|
||||||
await roleRemove(ids);
|
await roleRemove(ids);
|
||||||
await tableApi.reload();
|
await tableApi.query();
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -155,9 +169,10 @@ function handleAssignRole(record: Recordable<any>) {
|
|||||||
{{ $t('pages.common.export') }}
|
{{ $t('pages.common.export') }}
|
||||||
</a-button>
|
</a-button>
|
||||||
<a-button
|
<a-button
|
||||||
|
:disabled="!checked"
|
||||||
danger
|
danger
|
||||||
type="primary"
|
type="primary"
|
||||||
v-access:code="['system:role:delete']"
|
v-access:code="['system:role:remove']"
|
||||||
@click="handleMultiDelete"
|
@click="handleMultiDelete"
|
||||||
>
|
>
|
||||||
{{ $t('pages.common.delete') }}
|
{{ $t('pages.common.delete') }}
|
||||||
@ -180,11 +195,11 @@ function handleAssignRole(record: Recordable<any>) {
|
|||||||
row.roleKey === 'admin' ||
|
row.roleKey === 'admin' ||
|
||||||
!hasAccessByCodes(['system:role:edit'])
|
!hasAccessByCodes(['system:role:edit'])
|
||||||
"
|
"
|
||||||
:reload="() => tableApi.reload()"
|
:reload="() => tableApi.query()"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
<template #action="{ row }">
|
<template #action="{ row }">
|
||||||
<Space v-if="row.roleId !== 1">
|
<template v-if="row.roleId !== 1">
|
||||||
<a-button
|
<a-button
|
||||||
size="small"
|
size="small"
|
||||||
type="link"
|
type="link"
|
||||||
@ -202,13 +217,16 @@ function handleAssignRole(record: Recordable<any>) {
|
|||||||
danger
|
danger
|
||||||
size="small"
|
size="small"
|
||||||
type="link"
|
type="link"
|
||||||
v-access:code="['system:role:delete']"
|
v-access:code="['system:role:remove']"
|
||||||
@click.stop=""
|
@click.stop=""
|
||||||
>
|
>
|
||||||
{{ $t('pages.common.delete') }}
|
{{ $t('pages.common.delete') }}
|
||||||
</a-button>
|
</a-button>
|
||||||
</Popconfirm>
|
</Popconfirm>
|
||||||
<Dropdown>
|
<Dropdown
|
||||||
|
:get-popup-container="getPopupContainer"
|
||||||
|
placement="bottomRight"
|
||||||
|
>
|
||||||
<template #overlay>
|
<template #overlay>
|
||||||
<Menu>
|
<Menu>
|
||||||
<MenuItem key="1" @click="handleAuthEdit(row)">
|
<MenuItem key="1" @click="handleAuthEdit(row)">
|
||||||
@ -221,10 +239,10 @@ function handleAssignRole(record: Recordable<any>) {
|
|||||||
</template>
|
</template>
|
||||||
<a-button size="small" type="link">更多</a-button>
|
<a-button size="small" type="link">更多</a-button>
|
||||||
</Dropdown>
|
</Dropdown>
|
||||||
</Space>
|
</template>
|
||||||
</template>
|
</template>
|
||||||
</BasicTable>
|
</BasicTable>
|
||||||
<RoleDrawer @reload="tableApi.reload()" />
|
<RoleDrawer @reload="tableApi.query()" />
|
||||||
<RoleAuthModal @reload="tableApi.reload()" />
|
<RoleAuthModal @reload="tableApi.query()" />
|
||||||
</Page>
|
</Page>
|
||||||
</template>
|
</template>
|
||||||
|
Loading…
Reference in New Issue
Block a user