<script lang="ts" setup>
|
import { computed, reactive, ref, toRefs, unref } from 'vue';
|
|
import { BasicPopup, usePopupInner } from '@jnpf/ui/popup';
|
|
import { $t } from '#/locales';
|
|
import CommonAuth from '../auth/components/CommonAuth.vue';
|
import MenuAuth from '../auth/components/MenuAuth.vue';
|
|
interface State {
|
title: string;
|
id: string;
|
menuType: string;
|
key: number;
|
}
|
|
const permissionTypeList: any[] = [
|
{ id: 'Menu', fullName: '菜单权限' },
|
{ id: 'Flow', fullName: '流程权限' },
|
{ id: 'Print', fullName: '打印文件' },
|
];
|
const [registerPopup] = usePopupInner(init);
|
const menuAuthRef = ref<any>(null);
|
const commonAuthRef = ref<any>(null);
|
const state = reactive<State>({
|
title: '',
|
id: '',
|
menuType: 'Menu',
|
key: 0,
|
});
|
const { title, menuType } = toRefs(state);
|
|
const getBindValues = computed(() => ({ id: state.id, objectType: 'permissionGroup', type: state.menuType, key: state.key }));
|
const getRealRef = computed(() => (state.menuType == 'Menu' ? unref(menuAuthRef) : unref(commonAuthRef)));
|
|
function init(data) {
|
state.id = data.id;
|
state.title = data.title;
|
state.menuType = 'Menu';
|
state.key = Date.now();
|
}
|
function onMenuTypeChange() {
|
state.key = Date.now();
|
}
|
function handlePrev() {
|
unref(getRealRef)?.handlePrev();
|
}
|
function handleNext() {
|
unref(getRealRef)?.handleNext();
|
}
|
function handleCheckAll(boo) {
|
unref(getRealRef)?.handleCheckAll(boo);
|
}
|
function handleExpandAll(boo) {
|
unref(getRealRef)?.handleExpandAll(boo);
|
}
|
function handleSubmit() {
|
unref(getRealRef)?.handleSubmit();
|
}
|
</script>
|
<template>
|
<BasicPopup v-bind="$attrs" @register="registerPopup" class="full-popup auth-container" :title="title" destroy-on-close>
|
<a-tabs v-model:active-key="menuType" class="jnpf-content-wrapper-tabs" @change="onMenuTypeChange">
|
<a-tab-pane :key="item.id" :tab="item.fullName" v-for="item in permissionTypeList" />
|
<template #rightExtra>
|
<div class="tool-container">
|
<a-button type="text" :disabled="unref(getRealRef)?.loading" @click="handleExpandAll(true)">展开全部</a-button>
|
<a-button type="text" :disabled="unref(getRealRef)?.loading" @click="handleExpandAll(false)">折叠全部</a-button>
|
<a-button type="text" :disabled="unref(getRealRef)?.loading" @click="handleCheckAll(true)">全部勾选</a-button>
|
<a-button type="text" :disabled="unref(getRealRef)?.loading" @click="handleCheckAll(false)">取消全选</a-button>
|
<a-divider type="vertical" class="!h-7" />
|
<a-space :size="10">
|
<template v-if="menuType == 'Menu'">
|
<a-button @click="handlePrev" :disabled="unref(getRealRef)?.activeStep <= 0 || unref(getRealRef)?.loading">{{ $t('common.prev') }}</a-button>
|
<a-button @click="handleNext" :disabled="unref(getRealRef)?.activeStep >= unref(getRealRef)?.maxStep || unref(getRealRef)?.loading">
|
{{ $t('common.next') }}
|
</a-button>
|
</template>
|
<a-button
|
type="primary"
|
@click="handleSubmit()"
|
:disabled="unref(getRealRef)?.activeStep < unref(getRealRef)?.maxStep || unref(getRealRef)?.loading"
|
:loading="unref(getRealRef)?.btnLoading">
|
{{ $t('common.saveText') }}
|
</a-button>
|
</a-space>
|
</div>
|
</template>
|
</a-tabs>
|
<div class="main-container">
|
<MenuAuth v-bind="getBindValues" ref="menuAuthRef" v-if="menuType === 'Menu'" />
|
<CommonAuth v-bind="getBindValues" ref="commonAuthRef" v-else />
|
</div>
|
</BasicPopup>
|
</template>
|
<style lang="scss">
|
.auth-container {
|
display: flex;
|
flex-direction: column;
|
height: 100%;
|
|
.main-container {
|
flex: 1;
|
height: calc(100% - 46px);
|
overflow: hidden;
|
|
.auth-main-container {
|
display: flex;
|
flex-direction: column;
|
height: 100%;
|
}
|
}
|
}
|
</style>
|