刘光辉
8 小时以前 0dfe84494048ce27ba8449831782128412d3eb13
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
<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>