|
@@ -1,4 +1,4 @@
|
|
|
-import { MenuItem } from "@/common/components/contextMenu/interface";
|
|
|
|
|
|
|
+import { BtnClassName, BtnList } from '@/common/components/buttonList/interface';
|
|
|
import { ModalName } from '@/common/constants/modalName';
|
|
import { ModalName } from '@/common/constants/modalName';
|
|
|
import { OperationTabMenu } from '@/services/go/commonService/interface';
|
|
import { OperationTabMenu } from '@/services/go/commonService/interface';
|
|
|
import { sessionStorageUtil } from "@/utils/storage";
|
|
import { sessionStorageUtil } from "@/utils/storage";
|
|
@@ -6,7 +6,24 @@ import { inject, onUnmounted, Ref, ref } from "vue";
|
|
|
import { MenuType } from "../buttonPermission/interface";
|
|
import { MenuType } from "../buttonPermission/interface";
|
|
|
import { openModal } from "../modal";
|
|
import { openModal } from "../modal";
|
|
|
|
|
|
|
|
-export function getBtnList(menuType: keyof MenuType) {
|
|
|
|
|
|
|
+/**
|
|
|
|
|
+ * 获取class 名
|
|
|
|
|
+ * @param val
|
|
|
|
|
+ * @returns
|
|
|
|
|
+ */
|
|
|
|
|
+function getClassName(val: string): BtnClassName {
|
|
|
|
|
+ let result: BtnClassName = 'btnDeafault'
|
|
|
|
|
+ if (val.includes('disable') || val.includes('cancle') || val.includes('delete')) {
|
|
|
|
|
+ result = 'btnDanger'
|
|
|
|
|
+ } else if (val === '') {
|
|
|
|
|
+ result = 'btnDeafault'
|
|
|
|
|
+ } else {
|
|
|
|
|
+ result = 'btnPrimary'
|
|
|
|
|
+ }
|
|
|
|
|
+ return result
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+export function getBtnList(menuType: keyof MenuType, hasDetail: boolean) {
|
|
|
// 获取 数据
|
|
// 获取 数据
|
|
|
const permissionData = inject('thirdMenuList') as Ref<OperationTabMenu[]>;
|
|
const permissionData = inject('thirdMenuList') as Ref<OperationTabMenu[]>;
|
|
|
const name = 'permissionData'
|
|
const name = 'permissionData'
|
|
@@ -14,8 +31,8 @@ export function getBtnList(menuType: keyof MenuType) {
|
|
|
const data: OperationTabMenu[] = permissionData.value.length ? permissionData.value : sessionStorageUtil.getItem(name)
|
|
const data: OperationTabMenu[] = permissionData.value.length ? permissionData.value : sessionStorageUtil.getItem(name)
|
|
|
sessionStorageUtil.setItem(name, permissionData.value)
|
|
sessionStorageUtil.setItem(name, permissionData.value)
|
|
|
|
|
|
|
|
- const commonBtn = ref<MenuItem[]>([]); // 通用按钮列表,不用选中数据才显示
|
|
|
|
|
- const forDataBtn = ref<MenuItem[]>([]); // 针对数据按钮列表,选中某条数据才显示
|
|
|
|
|
|
|
+ const commonBtn = ref<BtnList[]>([]); // 通用按钮列表,不用选中数据才显示
|
|
|
|
|
+ const forDataBtn = ref<BtnList[]>([]); // 针对数据按钮列表,选中某条数据才显示
|
|
|
|
|
|
|
|
const list = data.find((e) => e.code === menuType);
|
|
const list = data.find((e) => e.code === menuType);
|
|
|
if (list && list.children) {
|
|
if (list && list.children) {
|
|
@@ -23,7 +40,7 @@ export function getBtnList(menuType: keyof MenuType) {
|
|
|
const { code, type, title } = e;
|
|
const { code, type, title } = e;
|
|
|
if (type === 2) { // 按钮类型
|
|
if (type === 2) { // 按钮类型
|
|
|
const { openAction } = openModal(code as keyof ModalName);
|
|
const { openAction } = openModal(code as keyof ModalName);
|
|
|
- const item = { lable: title, callback: openAction }
|
|
|
|
|
|
|
+ const item = { lable: title, callback: openAction, className: getClassName(code) }
|
|
|
const commonName = ['新增'] // 目前通用的按钮只要新增,需要添加其它的时候需要往这里添加
|
|
const commonName = ['新增'] // 目前通用的按钮只要新增,需要添加其它的时候需要往这里添加
|
|
|
if (commonName.includes(title)) { //
|
|
if (commonName.includes(title)) { //
|
|
|
commonBtn.value.push(item)
|
|
commonBtn.value.push(item)
|
|
@@ -35,9 +52,12 @@ export function getBtnList(menuType: keyof MenuType) {
|
|
|
} else {
|
|
} else {
|
|
|
console.warn(`menuType: ${menuType}未找到`)
|
|
console.warn(`menuType: ${menuType}未找到`)
|
|
|
}
|
|
}
|
|
|
- // 详情(所有页面都可以看到,没有权限之分)
|
|
|
|
|
- const { openAction } = openModal('detail')
|
|
|
|
|
- forDataBtn.value.push({ lable: '详情', callback: openAction })
|
|
|
|
|
|
|
+ // 详情
|
|
|
|
|
+ if (hasDetail) {
|
|
|
|
|
+ const { openAction } = openModal('detail')
|
|
|
|
|
+ forDataBtn.value.push({ lable: '详情', callback: openAction, className: getClassName('') })
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
|
|
|
onUnmounted(() => {
|
|
onUnmounted(() => {
|
|
|
sessionStorageUtil.removeItem(name)
|
|
sessionStorageUtil.removeItem(name)
|