|
@@ -1,12 +1,11 @@
|
|
|
import { BtnClassName, BtnListType } from '@/common/components/btnList/interface';
|
|
import { BtnClassName, BtnListType } from '@/common/components/btnList/interface';
|
|
|
import { EnumRouterName } from '@/common/constants/enumRouterName';
|
|
import { EnumRouterName } from '@/common/constants/enumRouterName';
|
|
|
-import { ModalName } from '@/common/constants/modalName';
|
|
|
|
|
import { OperationTabMenu, OperationTabMenuAuth } from '@/services/go/commonService/interface';
|
|
import { OperationTabMenu, OperationTabMenuAuth } from '@/services/go/commonService/interface';
|
|
|
import { sessionStorageUtil } from "@/utils/storage";
|
|
import { sessionStorageUtil } from "@/utils/storage";
|
|
|
import { inject, ref, Ref, toRaw, unref } from 'vue';
|
|
import { inject, ref, Ref, toRaw, unref } from 'vue';
|
|
|
|
|
+import { useRoute } from 'vue-router';
|
|
|
import { openModal } from "../modal";
|
|
import { openModal } from "../modal";
|
|
|
import { ButtonListKey } from './interface';
|
|
import { ButtonListKey } from './interface';
|
|
|
-import { useRoute } from 'vue-router';
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 获取class 名
|
|
* 获取class 名
|
|
@@ -269,24 +268,40 @@ export function getTableButton(codes: string[]): BtnListType[] {
|
|
|
const { meta } = useRoute();
|
|
const { meta } = useRoute();
|
|
|
const auth = meta.auth as OperationTabMenuAuth[];
|
|
const auth = meta.auth as OperationTabMenuAuth[];
|
|
|
|
|
|
|
|
- // 根据code权限获取按钮列表
|
|
|
|
|
- return codes.reduce((result, code) => {
|
|
|
|
|
- if (code === 'detail') {
|
|
|
|
|
- result.push({
|
|
|
|
|
- lable: '详情',
|
|
|
|
|
- code: 'detail',
|
|
|
|
|
- className: getClassName(''),
|
|
|
|
|
- });
|
|
|
|
|
- } else {
|
|
|
|
|
- const item = auth.find((val) => val.code === code);
|
|
|
|
|
- if (item) {
|
|
|
|
|
- result.push({
|
|
|
|
|
- lable: item.label,
|
|
|
|
|
- code: item.code,
|
|
|
|
|
- className: getClassName(item.code),
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ // 标准化 按钮 数据
|
|
|
|
|
+ const useBtn = (lable: string, code: string, className: string) => {
|
|
|
|
|
+ return { lable, code, className: getClassName(className) }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (codes.length === 0) {
|
|
|
|
|
+ // 不传入 code 参数,默认返回全部按钮数据
|
|
|
|
|
+ return auth.map(el => {
|
|
|
|
|
+ return useBtn(el.label, el.code, el.code)
|
|
|
|
|
+ })
|
|
|
|
|
+ } else {
|
|
|
|
|
+ // 转 map 已空间换时间
|
|
|
|
|
+ const authMap = new Map<string, OperationTabMenuAuth>()
|
|
|
|
|
+ auth.forEach(el => {
|
|
|
|
|
+ const { code } = el
|
|
|
|
|
+ if (authMap.has(code)) {
|
|
|
|
|
+ console.warn('按钮权限列表配置重复的code,请开发人员查看!!!')
|
|
|
|
|
+ } else {
|
|
|
|
|
+ authMap.set(code, el)
|
|
|
}
|
|
}
|
|
|
- }
|
|
|
|
|
- return result;
|
|
|
|
|
- }, [] as BtnListType[]);
|
|
|
|
|
|
|
+ })
|
|
|
|
|
+ // 根据 传入的 code 返回 code对应的配置数据
|
|
|
|
|
+ return codes.reduce((result, code) => {
|
|
|
|
|
+ // 详情 特殊处理,因为详情界面未配置权限,需要手动处理
|
|
|
|
|
+ if (code === 'detail') {
|
|
|
|
|
+ result.push(useBtn('详情', 'detail', ''))
|
|
|
|
|
+ } else {
|
|
|
|
|
+ const item = authMap.get(code)
|
|
|
|
|
+ if (item) {
|
|
|
|
|
+ const { code, label } = item
|
|
|
|
|
+ result.push(useBtn(label, code, code))
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ return result
|
|
|
|
|
+ }, [] as BtnListType[])
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|