feat: 🚀 按钮权限

This commit is contained in:
2025-07-15 10:44:49 +08:00
parent 12fd39b5af
commit fcfc0c8768
19 changed files with 229 additions and 56 deletions

1
src/components.d.ts vendored
View File

@@ -49,5 +49,6 @@ declare module 'vue' {
IEpSwitchButton: typeof import('~icons/ep/switch-button')['default']
RouterLink: typeof import('vue-router')['RouterLink']
RouterView: typeof import('vue-router')['RouterView']
Synchronous: typeof import('./components/ListBtns/components/Synchronous.vue')['default']
}
}

View File

@@ -1,10 +1,12 @@
<template>
<div class="common-btn-box1 font12" @click="handleBtnClick()" style="">
<div class="common-btn-box1 font12" @click="handleBtnClick()" v-if="isBtnShow[routeName]">
<span>新增</span>
</div>
</template>
<script setup lang="ts">
import { useAuthStore } from "@/stores/modules/auth";
const authStore = useAuthStore();
const $router = useRouter();
const routeName: string = $router.currentRoute.value.name as string;
const props = defineProps<{
@@ -25,6 +27,16 @@ const handleBtnClick = () => {
query: { sjtag: Math.random() * 36, type: "add", data: null }
});
};
//渲染按钮
const isBtnShow = computed(() => {
const btnShowObj: any = {
boxMarkIndex: false,
subscriptionIndex: false
};
let btnName = routeName + "Add";
btnShowObj[routeName] = authStore.btnsAuthList.includes(btnName);
return btnShowObj;
});
</script>
<style scoped>

View File

@@ -1,5 +1,5 @@
<template>
<div class="common-btn-box font12" @click="handleBtnClick()">
<div class="common-btn-box font12" @click="handleBtnClick()" v-if="isBtnShow[routeName]">
<span>删除</span>
</div>
</template>
@@ -8,7 +8,10 @@
import { ElMessageBox } from "element-plus";
import { useMsg } from "@/hooks/useMsg";
import { commitListApi } from "@/api/modules/global";
import { useAuthStore } from "@/stores/modules/auth";
const authStore = useAuthStore();
const $router = useRouter();
const routeName: string = $router.currentRoute.value.name as string;
// 接口地址映射
const URLS: Record<string, string> = {
boxMarkIndex: "BoxMark/delete", //入库任务列表
@@ -39,7 +42,6 @@ const handleBtnClick = () => {
type: "warning"
})
.then(async () => {
const routeName: string = $router.currentRoute.value.name as string;
const result = await commitListApi(URLS[routeName], { ids: ids });
if (result.status === 200) {
useMsg("success", "删除成功 ");
@@ -52,6 +54,16 @@ const handleBtnClick = () => {
})
.catch(() => {});
};
//渲染按钮
const isBtnShow = computed(() => {
const btnShowObj: any = {
boxMarkIndex: false,
subscriptionIndex: false
};
let btnName = routeName + "Del";
btnShowObj[routeName] = authStore.btnsAuthList.includes(btnName);
return btnShowObj;
});
</script>
<style scoped>

View File

@@ -1,5 +1,5 @@
<template>
<div class="common-btn-box font12" @click="handleBtnClick()">
<div class="common-btn-box font12" @click="handleBtnClick()" v-if="isBtnShow[routeName]">
<span>导出</span>
</div>
</template>
@@ -7,23 +7,19 @@
<script setup lang="ts">
import { useMsg } from "@/hooks/useMsg";
import { commitListApi } from "@/api/modules/global";
import { useAuthStore } from "@/stores/modules/auth";
const authStore = useAuthStore();
const $router = useRouter();
const routeName: string = $router.currentRoute.value.name as string;
const props = defineProps<{
selectionList?: any[];
handleChildBtnCallback?: () => void;
ruleForm: any;
}>();
// console.log(props.selectionList);
// const emits = defineEmits<{
// (e: "handleChildBtnCallback", result: Record<string, any>): void;
// }>();
// 接口地址映射
const URLS: Record<string, string> = {
ofInboundInstructionsList: "InStockTask/Export", //入库单任务列表
outboundOrderList: "OutStock/Export", //出库单列表
// outboundTaskList: "OutStockTask/Export", //出库单任务列表
warehouseReceiptList: "InStock/Export", //入库单列表
boxModificationsList: "ChangeBoxRecord/Export", //改箱列表
movingBoxesList: "MoveBoxRecord/Export", //移箱列表
@@ -37,20 +33,35 @@ const URLS: Record<string, string> = {
// 提交事件
const handleBtnClick = async () => {
const routeName: string = $router.currentRoute.value.name as string;
// 根据不同的路由进行不同的参数解构
console.log(props.ruleForm);
// 内部处理好了请求后的数据再返回到父页面;
const result = await commitListApi(URLS[routeName], { ...props.ruleForm });
if (result.status === 200) {
useMsg("success", "导出成功请前往导出列表中进行下载 ");
// emits("handleChildBtnCallback", {
// type: "Retransmission"
// });
} else {
useMsg("warning", "导出失败,请稍后重试 ");
}
};
//渲染按钮
const isBtnShow = computed(() => {
const btnShowObj: any = {
ofInboundInstructionsListExport: false, //入库单任务列表
outboundOrderListExport: false, //出库单列表
warehouseReceiptListExport: false, //入库单列表
boxModificationsListExport: false, //改箱列表
movingBoxesListExport: false, //移箱列表
inventoryListExport: false, //盘点列表
inboundOutboundRollbackListExport: false, //出入库回退列表
immediatelyExport: false, //即时库存
materialExport: false, //物料收发
boxStorageExport: false, //箱库存查询
finishedProductIndexExport: false //成品即时仓库
};
let btnName = routeName + "Export";
btnShowObj[routeName] = authStore.btnsAuthList.includes(btnName);
return btnShowObj;
});
</script>
<style scoped>

View File

@@ -1,5 +1,5 @@
<template>
<el-dropdown>
<el-dropdown v-if="isBtnShow[routeName]">
<div class="common-btn-box font12" style="border: none">导出</div>
<template #dropdown>
<el-dropdown-menu>
@@ -13,13 +13,16 @@
<script setup lang="ts" name="Exprots">
import { useMsg } from "@/hooks/useMsg";
import { commitListApi } from "@/api/modules/global";
import { useAuthStore } from "@/stores/modules/auth";
const authStore = useAuthStore();
const $router = useRouter();
const props = defineProps<{
selectionList: any[];
handleChildBtnCallback?: () => void;
ruleForm: any;
}>();
const routeName: any = ref($router.currentRoute.value.name);
// const routeName: any = ref($router.currentRoute.value.name);
const routeName: string = $router.currentRoute.value.name as string;
const emits = defineEmits<{
(e: "handleChildBtnCallback", result: Record<string, any>): void;
}>();
@@ -35,7 +38,7 @@ const URLS1: Record<string, string> = {
const handleBtnClick = async () => {
// 根据不同的路由进行不同的参数解构
// 内部处理好了请求后的数据再返回到父页面;
const result = await commitListApi(URLS[routeName.value], { ...props.ruleForm });
const result = await commitListApi(URLS[routeName], { ...props.ruleForm });
if (result.status === 200) {
useMsg("success", "导出成功请前往导出列表中进行下载 ");
emits("handleChildBtnCallback", {
@@ -54,7 +57,7 @@ const handleBtnClick1 = async () => {
props.selectionList.forEach((item: any) => {
ids.push(item.id);
});
const result = await commitListApi(URLS1[routeName.value], { ...props.ruleForm, ids: ids });
const result = await commitListApi(URLS1[routeName], { ...props.ruleForm, ids: ids });
if (result.status === 200) {
useMsg("success", "导出成功请前往导出列表中进行下载 ");
emits("handleChildBtnCallback", {
@@ -64,6 +67,15 @@ const handleBtnClick1 = async () => {
useMsg("warning", "导出失败,请稍后重试 ");
}
};
//渲染按钮
const isBtnShow = computed(() => {
const btnShowObj: any = {
outboundTaskList: false
};
let btnName = routeName + "Export";
btnShowObj[routeName] = authStore.btnsAuthList.includes(btnName);
return btnShowObj;
});
</script>
<style scoped>

View File

@@ -1,5 +1,5 @@
<template>
<div class="common-btn-box font12" @click="handleBtnClick()">
<div class="common-btn-box font12" @click="handleBtnClick()" v-if="isBtnShow[routeName]">
<span>合并</span>
</div>
</template>
@@ -7,8 +7,10 @@
<script setup lang="ts">
import { useMsg } from "@/hooks/useMsg";
import { commitListApi } from "@/api/modules/global";
import { useAuthStore } from "@/stores/modules/auth";
const authStore = useAuthStore();
const $router = useRouter();
const routeName: string = $router.currentRoute.value.name as string;
const props = defineProps<{
selectionList: any[];
handleChildBtnCallback?: () => void;
@@ -25,7 +27,6 @@ const URLS: Record<string, string> = {
// 提交事件
const handleBtnClick = async () => {
const routeName: string = $router.currentRoute.value.name as string;
if (!props.selectionList.length) {
useMsg("warning", "请选择对应的数据后进行操作 ");
return;
@@ -49,6 +50,15 @@ const handleBtnClick = async () => {
useMsg("error", result.message);
}
};
//渲染按钮
const isBtnShow = computed(() => {
const btnShowObj: any = {
outboundTaskList: false
};
let btnName = routeName + "Merge";
btnShowObj[routeName] = authStore.btnsAuthList.includes(btnName);
return btnShowObj;
});
</script>
<style scoped>

View File

@@ -1,11 +1,16 @@
<template>
<div class="common-btn-box font12" @click="handleBtnClick()">
<div class="common-btn-box font12" @click="handleBtnClick()" v-if="isBtnShow[routeName]">
<span>打印</span>
</div>
</template>
<script setup lang="ts">
import { useAuthStore } from "@/stores/modules/auth";
import { useMsg } from "@/hooks/useMsg";
const authStore = useAuthStore();
const $router = useRouter();
const routeName: string = $router.currentRoute.value.name as string;
const props: any = defineProps<{
selectionList?: any[];
handleChildBtnCallback?: () => void;
@@ -25,6 +30,15 @@ const handleBtnClick = () => {
type: "Print"
});
};
//渲染按钮
const isBtnShow = computed(() => {
const btnShowObj: any = {
boxMarkIndex: false
};
let btnName = routeName + "Print";
btnShowObj[routeName] = authStore.btnsAuthList.includes(btnName);
return btnShowObj;
});
</script>
<style scoped>

View File

@@ -1,5 +1,5 @@
<template>
<div class="common-btn-box font12" @click="handleBtnClick()">
<div class="common-btn-box font12" @click="handleBtnClick()" v-if="isBtnShow[routeName]">
<span>刷新</span>
</div>
</template>
@@ -7,8 +7,10 @@
<script setup lang="ts">
import { useMsg } from "@/hooks/useMsg";
import { commitListApi } from "@/api/modules/global";
import { useAuthStore } from "@/stores/modules/auth";
const authStore = useAuthStore();
const $router = useRouter();
const routeName: string = $router.currentRoute.value.name as string;
const props = defineProps<{
selectionList: any[];
handleChildBtnCallback?: () => void;
@@ -26,15 +28,6 @@ const URLS: Record<string, string> = {
// 提交事件
const handleBtnClick = async () => {
const routeName: string = $router.currentRoute.value.name as string;
// if (!props.selectionList.length) {
// useMsg("warning", "请选择对应的数据后进行操作 ");
// return;
// }
// if (props.selectionList.length > 10) {
// useMsg("warning", "一次最多刷新10条数据 ");
// return;
// }
let ids: number[] = [];
props.selectionList.forEach((item: any) => {
ids.push(item.id);
@@ -55,6 +48,16 @@ const handleBtnClick = async () => {
useMsg("error", result.message);
}
};
//渲染按钮
const isBtnShow = computed(() => {
const btnShowObj: any = {
ofInboundInstructionsList: false,
outboundTaskList: false
};
let btnName = routeName + "Refresh";
btnShowObj[routeName] = authStore.btnsAuthList.includes(btnName);
return btnShowObj;
});
</script>
<style scoped>

View File

@@ -1,5 +1,5 @@
<template>
<div class="common-btn-box font12" @click="handleBtnClick()">
<div class="common-btn-box font12" @click="handleBtnClick()" v-if="isBtnShow[routeName]">
<span>重传</span>
</div>
</template>
@@ -7,8 +7,10 @@
<script setup lang="ts">
import { useMsg } from "@/hooks/useMsg";
import { commitListApi } from "@/api/modules/global";
import { useAuthStore } from "@/stores/modules/auth";
const authStore = useAuthStore();
const $router = useRouter();
const routeName: string = $router.currentRoute.value.name as string;
const props = defineProps<{
selectionList: any[];
handleChildBtnCallback?: () => void;
@@ -27,7 +29,6 @@ const URLS: Record<string, string> = {
// 提交事件
const handleBtnClick = async () => {
const routeName: string = $router.currentRoute.value.name as string;
if (!props.selectionList.length) {
useMsg("warning", "请选择需要重传的数据 ");
return false;
@@ -37,10 +38,11 @@ const handleBtnClick = async () => {
return false;
}
let some = props.selectionList.some((item: any) => {
return item.successSync == "成功";
return item.successSync === "成功" || item.successSync === "--";
});
if (some) {
useMsg("warning", "请选择正确的数据 ");
useMsg("warning", "请选择同步结果为“同步失败和同步中”的数据进行重传 ");
return false;
}
let ids: any[] = [];
@@ -64,6 +66,17 @@ const handleBtnClick = async () => {
useMsg("error", result.message);
}
};
//渲染按钮
const isBtnShow = computed(() => {
const btnShowObj: any = {
outboundOrderList: false,
warehouseReceiptList: false,
inventoryList: false
};
let btnName = routeName + "Retransmission";
btnShowObj[routeName] = authStore.btnsAuthList.includes(btnName);
return btnShowObj;
});
</script>
<style scoped>

View File

@@ -1,5 +1,5 @@
<template>
<div class="font12" @click="handleBtnClick()" style="display: flex; align-items: center">
<div v-if="isBtnShow[routeName]" class="font12" @click="handleBtnClick()" style="display: flex; align-items: center">
<div style="margin-right: 4px">
<span>打印份数设置</span>
<el-tooltip class="box-item" effect="dark" content="默认打印2份,关闭打印1份" placement="top">
@@ -13,6 +13,10 @@
<script setup lang="ts">
import { QuestionFilled } from "@element-plus/icons-vue";
import { useAuthStore } from "@/stores/modules/auth";
const authStore = useAuthStore();
const $router = useRouter();
const routeName: string = $router.currentRoute.value.name as string;
const props: any = defineProps<{
selectionList?: any[];
handleChildBtnCallback?: () => void;
@@ -27,15 +31,20 @@ const emits = defineEmits<{
// 提交事件
const handleBtnClick = () => {
// if (!props.selectionList.length) {
// useMsg("warning", "请选择需要打印的数据 ");
// return false;
// }
emits("handleChildBtnCallback", {
type: "Switch",
data: switchValue.value ? 2 : 1
});
};
//渲染按钮
const isBtnShow = computed(() => {
const btnShowObj: any = {
boxMarkIndex: false
};
let btnName = routeName + "Switch";
btnShowObj[routeName] = authStore.btnsAuthList.includes(btnName);
return btnShowObj;
});
</script>
<style scoped>

View File

@@ -0,0 +1,53 @@
<template>
<div class="common-btn-box font12" @click="handleBtnClick()" v-if="isBtnShow[routeName]">
<span>同步成功</span>
</div>
</template>
<script setup lang="ts">
import { useMsg } from "@/hooks/useMsg";
import { useAuthStore } from "@/stores/modules/auth";
const authStore = useAuthStore();
const $router = useRouter();
const routeName: string = $router.currentRoute.value.name as string;
const props = defineProps<{
selectionList: any[];
handleChildBtnCallback?: () => void;
}>();
const emits = defineEmits<{
(e: "handleChildBtnCallback", result: Record<string, any>): void;
}>();
// 提交事件
const handleBtnClick = async () => {
if (!props.selectionList.length) {
useMsg("warning", "请选择需要修改状态的数据 ");
return;
}
let isSuccess = props.selectionList.some((item: any) => {
return item.successSyncStatus == 1;
});
if (isSuccess) {
useMsg("warning", "请选择同步结果为“同步失败和同步中”的数据修改同步结果 ");
return false;
}
emits("handleChildBtnCallback", {
type: "Synchronous"
});
};
//渲染按钮
const isBtnShow = computed(() => {
const btnShowObj: any = {
warehouseReceiptList: false
};
let btnName = routeName + "Synchronous";
btnShowObj[routeName] = authStore.btnsAuthList.includes(btnName);
return btnShowObj;
});
</script>
<style scoped>
@import "../index.scss";
</style>

View File

@@ -1,5 +1,5 @@
<template>
<div class="common-btn-box font12" @click="handleBtnClick()">
<div class="common-btn-box font12" @click="handleBtnClick()" v-if="isBtnShow[routeName]">
<span>作废</span>
</div>
</template>
@@ -8,7 +8,10 @@
import { ElMessageBox } from "element-plus";
import { useMsg } from "@/hooks/useMsg";
import { commitListApi } from "@/api/modules/global";
import { useAuthStore } from "@/stores/modules/auth";
const authStore = useAuthStore();
const $router = useRouter();
const routeName: string = $router.currentRoute.value.name as string;
const props = defineProps<{
selectionList: any[];
@@ -27,8 +30,6 @@ const URLS: Record<string, string> = {
// 提交事件
const handleBtnClick = async () => {
const routeName: string = $router.currentRoute.value.name as string;
console.log(props.selectionList, "=props.selectionList=");
if (!props.selectionList.length) {
useMsg("warning", "请选择对应的数据后进行操作 ");
return;
@@ -73,6 +74,16 @@ const handleBtnClick = async () => {
// });
});
};
//渲染按钮
const isBtnShow = computed(() => {
const btnShowObj: any = {
outboundTaskList: false, //出库任务列表
ofInboundInstructionsList: false //入库任务列表
};
let btnName = routeName + "ToVoid";
btnShowObj[routeName] = authStore.btnsAuthList.includes(btnName);
return btnShowObj;
});
</script>
<style scoped>

View File

@@ -1,5 +1,5 @@
<template>
<div class="common-btn-box font12" @click="handleBtnClick()">
<div class="common-btn-box font12" @click="handleBtnClick()" v-if="isBtnShow[routeName]">
<span>反作废</span>
</div>
</template>
@@ -8,8 +8,10 @@
import { ElMessageBox } from "element-plus";
import { useMsg } from "@/hooks/useMsg";
import { commitListApi } from "@/api/modules/global";
import { useAuthStore } from "@/stores/modules/auth";
const authStore = useAuthStore();
const $router = useRouter();
const routeName: string = $router.currentRoute.value.name as string;
const props = defineProps<{
selectionList: any[];
handleChildBtnCallback?: () => void;
@@ -30,7 +32,6 @@ const WARNS: Record<string, string> = {
};
// 提交事件
const handleBtnClick = async () => {
const routeName: string = $router.currentRoute.value.name as string;
console.log(props.selectionList, "=props.selectionList=");
if (!props.selectionList.length) {
useMsg("warning", "请选择对应的数据后进行操作 ");
@@ -78,6 +79,16 @@ const handleBtnClick = async () => {
// });
});
};
//渲染按钮
const isBtnShow = computed(() => {
const btnShowObj: any = {
outboundTaskList: false,
ofInboundInstructionsList: false
};
let btnName = routeName + "NoToVoid";
btnShowObj[routeName] = authStore.btnsAuthList.includes(btnName);
return btnShowObj;
});
</script>
<style scoped>

View File

@@ -24,7 +24,9 @@ import Del from "./components/Del.vue";
import Print from "./components/Print.vue";
import Switch from "./components/Switch.vue";
import noToVoid from "./components/noToVoid.vue";
import Synchronous from "./components/Synchronous.vue";
const $router = useRouter();
const routeName: any = ref($router.currentRoute.value.name);
const props = defineProps<{
@@ -38,7 +40,7 @@ const emits = defineEmits<{
}>();
const BTNS_ROUTE: any = {
ofInboundInstructionsList: [ToVoid, noToVoid, Export, Refresh],
warehouseReceiptList: [Retransmission, Export],
warehouseReceiptList: [Retransmission, Export, Synchronous],
outboundOrderList: [Export],
outboundTaskList: [Merge, ToVoid, noToVoid, Refresh, ExprotSelect],
inboundOutboundRollbackList: [Export],

View File

@@ -105,7 +105,6 @@ const props = withDefaults(defineProps<ProTableProps>(), {
let ruleFormParams = ref(props.ruleForm);
const $router = useRouter();
const routeName: any = ref($router.currentRoute.value.name);
console.log(routeName.value, "=routerName=");
// 表格 DOM 元素
const tableRef = ref<InstanceType<typeof ElTable>>();
// 清空选中数据列表

View File

@@ -36,7 +36,7 @@ const router = useRouter();
const authStore = useAuthStore();
// const menuList = computed(() => authStore.flatMenuListGet.filter(item => !item.hidden));
const menuList = computed(() =>
authStore.flatMenuListGet.filter(item => {
authStore.flatMenuListGet.filter((item: any) => {
const ON_PATH = ["收货入库", "发货出库", "盘点", "报表", "其他库内操作"];
return !item.hidden && !ON_PATH.includes(item.meta.title);
})

View File

@@ -84,7 +84,7 @@ const tabsDrop = () => {
// 初始化需要固定的 tabs
const initTabs = () => {
authStore.flatMenuListGet.forEach(item => {
authStore.flatMenuListGet.forEach((item: any) => {
if (item.meta.isAffix && !item.hidden && !item.meta.isFull) {
const tabsParams = {
icon: item.meta.icon,

View File

@@ -73,7 +73,7 @@ router.beforeEach(async (to, from, next) => {
* */
export const resetRouter = () => {
const authStore = useAuthStore();
authStore.flatMenuListGet.forEach(route => {
authStore.flatMenuListGet.forEach((route: any) => {
const { name } = route;
if (name && router.hasRoute(name)) router.removeRoute(name);
});

View File

@@ -32,7 +32,7 @@ export const initDynamicRouter = async () => {
}
// 3.添加动态路由
authStore.flatMenuListGet.forEach(item => {
authStore.flatMenuListGet.forEach((item: any) => {
item.children && delete item.children;
if (item.component && typeof item.component == "string") {
item.component = modules["/src/views" + item.component + ".vue"];