refactor权限控制逻辑

- 移除全局方法getUserBtnRole
- 使用hasPermission函数替代checkBtnPermission
- 优化权限判断逻辑,减少冗余代码
- 统一权限控制的实现方式
This commit is contained in:
郑彪辉
2025-04-26 09:50:55 +08:00
parent 07ac63b5bb
commit 69af422128
28 changed files with 238 additions and 239 deletions

View File

@@ -29,7 +29,7 @@
</view>
</view>
</u-form>
<view class="w-full footer">
<view v-if="hasPermission('erp_base_warehouse_add')" class="w-full footer">
<view class="py-[var(--top-m)] px-[var(--sidebar-m)] footer w-full fixed bottom-0 left-0 right-0 box-border">
<button hover-class="none" class="!bg-[var(--primary-color)] text-[#fff] h-[80rpx] leading-[80rpx] rounded-[100rpx] text-[26rpx] font-500"
@click="handSave" :disabled="loading" :class="{'opacity-50': loading}">{{t('save')}}</button>
@@ -46,9 +46,9 @@
import { addWarehouse } from '@/addon/erp/api/base';
import { generatedCode } from '@/addon/erp/utils/common';
import { redirect } from '@/utils/common';
import { checkBtnPermission } from '@/utils/auth';
import useMemberStore from '@/stores/member'
import usePermission from '@/utils/usePermission'
const { hasPermission } = usePermission()
const memberStore = useMemberStore()
const formRef: any = ref(null)
const loading = ref(false)
@@ -92,8 +92,6 @@
// 保存
const handSave = async() => {
const hasPermission = await checkBtnPermission(memberStore.btnPermission, 'erp_base_warehouse_add')
if (!hasPermission) return
formRef.value.validate().then(() => {
if (loading.value) return
loading.value = true