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

@@ -96,7 +96,6 @@
// 判断是否已登录 // 判断是否已登录
if (getToken()) { if (getToken()) {
const memberStore: any = useMemberStore() const memberStore: any = useMemberStore()
memberStore.getUserBtnRole()
await memberStore.setToken(getToken(), () => { await memberStore.setToken(getToken(), () => {
if (!uni.getStorageSync('openid')) { if (!uni.getStorageSync('openid')) {
const memberInfo = useMemberStore().info const memberInfo = useMemberStore().info

View File

@@ -64,7 +64,7 @@
</view> </view>
</u-form> </u-form>
<view class="w-full footer"> <view class="w-full footer" v-if="hasPermission('erp_base_customer_add')">
<view class="py-[var(--top-m)] px-[var(--sidebar-m)] footer w-full fixed bottom-0 left-0 right-0 box-border"> <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" <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> @click="handSave" :disabled="loading" :class="{'opacity-50': loading}">{{t('save')}}</button>
@@ -82,8 +82,9 @@
import { addCustomer,getusersList,getWarehouseSelect} from '@/addon/erp/api/base'; import { addCustomer,getusersList,getWarehouseSelect} from '@/addon/erp/api/base';
import { generatedCode } from '@/addon/erp/utils/common'; import { generatedCode } from '@/addon/erp/utils/common';
import { redirect } from '@/utils/common'; import { redirect } from '@/utils/common';
import { checkBtnPermission } from '@/utils/auth';
import useMemberStore from '@/stores/member' import useMemberStore from '@/stores/member'
import usePermission from '@/utils/usePermission'
const { hasPermission } = usePermission()
interface Warehouse { interface Warehouse {
id: number; id: number;
name: string; name: string;
@@ -208,8 +209,6 @@
} }
// 保存 // 保存
const handSave = async() => { const handSave = async() => {
const hasPermission = await checkBtnPermission(memberStore.btnPermission, 'erp_base_customer_add')
if (!hasPermission) return
formRef.value.validate().then(() => { formRef.value.validate().then(() => {
if (loading.value) return if (loading.value) return
loading.value = true loading.value = true

View File

@@ -29,7 +29,7 @@
<view><up-button :text="t('info')" size="mini" <view><up-button :text="t('info')" size="mini"
@click="redirect({ url: '/addon/erp/pages/base/customer/detail',param:{id: item.id} })"></up-button> @click="redirect({ url: '/addon/erp/pages/base/customer/detail',param:{id: item.id} })"></up-button>
</view> </view>
<view><up-button type="error" @click="hanldeDelete(item.id)" :text="t('delete')" <view v-if="hasPermission('erp_base_customer_delete')"><up-button type="error" @click="hanldeDelete(item.id)" :text="t('delete')"
size="mini"></up-button></view> size="mini"></up-button></view>
</view> </view>
</view> </view>
@@ -43,7 +43,7 @@
</mescroll-body> </mescroll-body>
<loading-page :loading="loading"></loading-page> <loading-page :loading="loading"></loading-page>
<view class="fixed bottom-4 right-4 z-2"> <view v-if="hasPermission('erp_base_customer_add')" class="fixed bottom-4 right-4 z-2">
<up-button @click="redirect({ url: '/addon/erp/pages/base/customer/add'})" type="primary" shape="circle" <up-button @click="redirect({ url: '/addon/erp/pages/base/customer/add'})" type="primary" shape="circle"
:customStyle="{borderRadius: '50%',padding: 0,width: '50px',height: '50px'}"> :customStyle="{borderRadius: '50%',padding: 0,width: '50px',height: '50px'}">
<u-icon size="30" color="#fff" name="plus-circle-fill"></u-icon> <u-icon size="30" color="#fff" name="plus-circle-fill"></u-icon>
@@ -63,10 +63,10 @@
import useMescroll from '@/components/mescroll/hooks/useMescroll.js'; import useMescroll from '@/components/mescroll/hooks/useMescroll.js';
import { getCustomerList, deleteCustomer } from '@/addon/erp/api/base'; import { getCustomerList, deleteCustomer } from '@/addon/erp/api/base';
import { onShow, onPageScroll, onReachBottom } from '@dcloudio/uni-app'; import { onShow, onPageScroll, onReachBottom } from '@dcloudio/uni-app';
import usePermission from '@/utils/usePermission'
const { hasPermission } = usePermission()
const { downCallback, mescrollInit, getMescroll } = useMescroll(onPageScroll, onReachBottom); const { downCallback, mescrollInit, getMescroll } = useMescroll(onPageScroll, onReachBottom);
const show = ref(false); const show = ref(false);
// 获取系统状态栏的高度 // 获取系统状态栏的高度

View File

@@ -72,13 +72,13 @@
</view> </view>
</u-form> </u-form>
<view class="w-full footer"> <view v-if="hasPermission('erp_base_supplier_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"> <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" <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> @click="handSave" :disabled="loading" :class="{'opacity-50': loading}">{{t('save')}}</button>
</view> </view>
</view> </view>
<area-select ref="areaRef" @complete="areaSelectComplete" :area-id="0" /> <!-- <area-select ref="areaRef" @complete="areaSelectComplete" :area-id="0" /> -->
</view> </view>
</template> </template>
@@ -91,9 +91,10 @@
import { getProductTypeSelect} from '@/addon/erp/api/product'; import { getProductTypeSelect} from '@/addon/erp/api/product';
import {uploadImage } from '@/app/api/system' import {uploadImage } from '@/app/api/system'
import { redirect } from '@/utils/common'; import { redirect } from '@/utils/common';
import { checkBtnPermission } from '@/utils/auth';
import useMemberStore from '@/stores/member' import useMemberStore from '@/stores/member'
import { img } from '@/utils/common' import { img } from '@/utils/common'
import usePermission from '@/utils/usePermission'
const { hasPermission } = usePermission()
const memberStore = useMemberStore() const memberStore = useMemberStore()
interface FileItem { interface FileItem {
url: string; url: string;
@@ -246,8 +247,6 @@
} }
// 保存 // 保存
const handSave = async() => { const handSave = async() => {
const hasPermission = await checkBtnPermission(memberStore.btnPermission, 'erp_base_supplier_add')
if (!hasPermission) return
formRef.value.validate().then(() => { formRef.value.validate().then(() => {
if (loading.value) return if (loading.value) return
loading.value = true loading.value = true

View File

@@ -28,7 +28,7 @@
<view><up-button :text="t('info')" size="mini" <view><up-button :text="t('info')" size="mini"
@click="redirect({ url: '/addon/erp/pages/base/supplier/detail',param:{id: item.id} })"></up-button> @click="redirect({ url: '/addon/erp/pages/base/supplier/detail',param:{id: item.id} })"></up-button>
</view> </view>
<view><up-button type="error" @click="hanldeDelete(item.id)" :text="t('delete')" <view v-if="hasPermission('erp_base_supplier_delete')"><up-button type="error" @click="hanldeDelete(item.id)" :text="t('delete')"
size="mini"></up-button></view> size="mini"></up-button></view>
</view> </view>
</view> </view>
@@ -42,7 +42,7 @@
</mescroll-body> </mescroll-body>
<loading-page :loading="loading"></loading-page> <loading-page :loading="loading"></loading-page>
<view class="fixed bottom-4 right-4 z-2"> <view v-if="hasPermission('erp_base_supplier_add')" class="fixed bottom-4 right-4 z-2">
<up-button @click="redirect({ url: '/addon/erp/pages/base/supplier/add'})" type="primary" shape="circle" <up-button @click="redirect({ url: '/addon/erp/pages/base/supplier/add'})" type="primary" shape="circle"
:customStyle="{borderRadius: '50%',padding: 0,width: '50px',height: '50px'}"> :customStyle="{borderRadius: '50%',padding: 0,width: '50px',height: '50px'}">
<u-icon size="30" color="#fff" name="plus-circle-fill"></u-icon> <u-icon size="30" color="#fff" name="plus-circle-fill"></u-icon>
@@ -62,6 +62,8 @@
import useMescroll from '@/components/mescroll/hooks/useMescroll.js'; import useMescroll from '@/components/mescroll/hooks/useMescroll.js';
import { getSupplierList, deleteSupplier } from '@/addon/erp/api/base'; import { getSupplierList, deleteSupplier } from '@/addon/erp/api/base';
import { onShow, onPageScroll, onReachBottom } from '@dcloudio/uni-app'; import { onShow, onPageScroll, onReachBottom } from '@dcloudio/uni-app';
import usePermission from '@/utils/usePermission'
const { hasPermission } = usePermission()
const { downCallback, mescrollInit, getMescroll } = useMescroll(onPageScroll, onReachBottom); const { downCallback, mescrollInit, getMescroll } = useMescroll(onPageScroll, onReachBottom);

View File

@@ -29,7 +29,7 @@
</view> </view>
</view> </view>
</u-form> </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"> <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" <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> @click="handSave" :disabled="loading" :class="{'opacity-50': loading}">{{t('save')}}</button>
@@ -46,9 +46,9 @@
import { addWarehouse } from '@/addon/erp/api/base'; import { addWarehouse } from '@/addon/erp/api/base';
import { generatedCode } from '@/addon/erp/utils/common'; import { generatedCode } from '@/addon/erp/utils/common';
import { redirect } from '@/utils/common'; import { redirect } from '@/utils/common';
import { checkBtnPermission } from '@/utils/auth';
import useMemberStore from '@/stores/member' import useMemberStore from '@/stores/member'
import usePermission from '@/utils/usePermission'
const { hasPermission } = usePermission()
const memberStore = useMemberStore() const memberStore = useMemberStore()
const formRef: any = ref(null) const formRef: any = ref(null)
const loading = ref(false) const loading = ref(false)
@@ -92,8 +92,6 @@
// 保存 // 保存
const handSave = async() => { const handSave = async() => {
const hasPermission = await checkBtnPermission(memberStore.btnPermission, 'erp_base_warehouse_add')
if (!hasPermission) return
formRef.value.validate().then(() => { formRef.value.validate().then(() => {
if (loading.value) return if (loading.value) return
loading.value = true loading.value = true

View File

@@ -30,7 +30,7 @@
<view><up-button :text="t('info')" size="mini" <view><up-button :text="t('info')" size="mini"
@click="redirect({ url: '/addon/erp/pages/base/warehouse/detail',param:{id: item.id} })"></up-button> @click="redirect({ url: '/addon/erp/pages/base/warehouse/detail',param:{id: item.id} })"></up-button>
</view> </view>
<view><up-button type="error" @click="hanldeDelete(item.id)" :text="t('delete')" <view v-if="hasPermission('erp_base_warehouse_delete')"><up-button type="error" @click="hanldeDelete(item.id)" :text="t('delete')"
size="mini"></up-button></view> size="mini"></up-button></view>
</view> </view>
</view> </view>
@@ -44,7 +44,7 @@
</mescroll-body> </mescroll-body>
<loading-page :loading="loading"></loading-page> <loading-page :loading="loading"></loading-page>
<view class="fixed bottom-4 right-4 z-2"> <view v-if="hasPermission('erp_base_warehouse_add')" class="fixed bottom-4 right-4 z-2">
<up-button @click="redirect({ url: '/addon/erp/pages/base/warehouse/add'})" type="primary" shape="circle" <up-button @click="redirect({ url: '/addon/erp/pages/base/warehouse/add'})" type="primary" shape="circle"
:customStyle="{borderRadius: '50%',padding: 0,width: '50px',height: '50px'}"> :customStyle="{borderRadius: '50%',padding: 0,width: '50px',height: '50px'}">
<u-icon size="30" color="#fff" name="plus-circle-fill"></u-icon> <u-icon size="30" color="#fff" name="plus-circle-fill"></u-icon>
@@ -63,6 +63,8 @@
import useMescroll from '@/components/mescroll/hooks/useMescroll.js'; import useMescroll from '@/components/mescroll/hooks/useMescroll.js';
import { getWarehouseList, deleteWarehouse } from '@/addon/erp/api/base'; import { getWarehouseList, deleteWarehouse } from '@/addon/erp/api/base';
import { onShow, onPageScroll, onReachBottom } from '@dcloudio/uni-app'; import { onShow, onPageScroll, onReachBottom } from '@dcloudio/uni-app';
import usePermission from '@/utils/usePermission'
const { hasPermission } = usePermission()
const { downCallback, mescrollInit, getMescroll } = useMescroll(onPageScroll, onReachBottom); const { downCallback, mescrollInit, getMescroll } = useMescroll(onPageScroll, onReachBottom);

View File

@@ -51,13 +51,13 @@
</up-form-item> </up-form-item>
</view> </view>
<view class="mt-[16rpx]"> <view class="mt-[16rpx]">
<up-form-item :label="t('warehouseName')" prop="type" required borderBottom> <up-form-item :label="t('warehouseName')" prop="warehouse_id" required borderBottom>
<!-- #ifdef H5 --> <!-- #ifdef H5 -->
<zxz-uni-data-select v-model="formData.warehouse_id" :localdata="warehouseList" dataKey="name" dataValue="id" <zxz-uni-data-select v-model="formData.warehouse_id" :localdata="warehouseList" dataKey="name" dataValue="id"
:clear="false" disabled placeholder="请选择仓库"/> :clear="false" placeholder="请选择仓库" @change="warehouseIdChange"/>
<!-- #endif --> <!-- #endif -->
<!-- #ifdef MP-WEIXIN --> <!-- #ifdef MP-WEIXIN -->
<wht-select v-model="formData.warehouse_id" :options="warehouseList" dataKey="name" dataValue="id" :defaultVal="formData.warehouse_id" disabled placeholder="请选择仓库" backgroundColor="#f5f7fa" :height="38" /> <wht-select v-model="formData.warehouse_id" :options="warehouseList" dataKey="name" dataValue="id" :defaultVal="formData.warehouse_id" placeholder="请选择仓库" :height="38" @change="warehouseIdChange"/>
<!-- #endif --> <!-- #endif -->
</up-form-item> </up-form-item>
</view> </view>
@@ -170,7 +170,7 @@
</view> </view>
</up-form> </up-form>
<view v-if="hasPermission('erp_inbound_return_add')" class="w-full footer"> <view v-if="hasPermission('erp_inbound_return_add')" class="w-full footer">
<view <view
class="py-[var(--top-m)] px-[var(--sidebar-m)] footer w-full fixed bottom-0 left-0 right-0 box-border"> class="py-[var(--top-m)] px-[var(--sidebar-m)] footer w-full fixed bottom-0 left-0 right-0 box-border">
@@ -192,11 +192,11 @@
import { addManualReturn, getOutboundManualSelect,getOutboundManualInfo} from '@/addon/erp/api/sell'; import { addManualReturn, getOutboundManualSelect,getOutboundManualInfo} from '@/addon/erp/api/sell';
import { generatedCode } from '@/addon/erp/utils/common'; import { generatedCode } from '@/addon/erp/utils/common';
import {uploadImage } from '@/app/api/system' import {uploadImage } from '@/app/api/system'
import { redirect } from '@/utils/common';
import { redirect } from '@/utils/common'; import { redirect } from '@/utils/common';
import useMemberStore from '@/stores/member' import useMemberStore from '@/stores/member'
import dayjs from 'dayjs' import dayjs from 'dayjs'
import { img } from '@/utils/common' import { img } from '@/utils/common'
import usePermission from '@/utils/usePermission'
const { hasPermission } = usePermission() const { hasPermission } = usePermission()
const memberStore = useMemberStore() const memberStore = useMemberStore()
@@ -304,6 +304,9 @@
} }
const manualIdChange=(e: any) =>{ const manualIdChange=(e: any) =>{
getOutboundManualInfoFn(e.id) getOutboundManualInfoFn(e.id)
}
const warehouseIdChange=(e: any) =>{
formData.value.warehouse_id = e?.id ?? ''
} }
const getOutboundManualInfoFn = async (id: any) => { const getOutboundManualInfoFn = async (id: any) => {
const data = await (await getOutboundManualInfo(id)).data const data = await (await getOutboundManualInfo(id)).data
@@ -384,8 +387,6 @@
// 保存 // 保存
const handSave = async() => {
const hasPermission = await checkBtnPermission(memberStore.btnPermission, 'erp_inbound_return_add')
const handSave = async() => { const handSave = async() => {
if (loading.value) return if (loading.value) return
if (!formData.value.manual_id) { if (!formData.value.manual_id) {
@@ -413,7 +414,7 @@
} }
addManualReturn(formData.value).then((res : any) => { addManualReturn(formData.value).then((res : any) => {
loading.value = false loading.value = false
if (res.code == 1) { if (res.code == 1) {
redirect({ url: '/addon/erp/pages/index' }) redirect({ url: '/addon/erp/pages/index' })
} }
}).catch((err) => { }).catch((err) => {

View File

@@ -52,19 +52,19 @@
</view> </view>
<view class="foot border-0 border-t-1 border-solid border-[#ddd]"> <view class="foot border-0 border-t-1 border-solid border-[#ddd]">
<view class="flex justify-end p-[20rpx]"> <view class="flex justify-end p-[20rpx]">
<view><up-button v-if="item.status == 1" size="mini" <view v-if="hasPermission('erp_inbound_return_updateStatus')"><up-button v-if="item.status == 1" size="mini"
:customStyle="{padding: 0,width: '130rpx',height: '50rpx',marginRight:'20rpx',fontSize:'20rpx'}" :customStyle="{padding: 0,width: '130rpx',height: '50rpx',marginRight:'20rpx',fontSize:'20rpx'}"
type="primary" text="通过" @click="handleOperateOrder(item,'audit')"></up-button></view> type="primary" text="通过" @click="handleOperateOrder(item,'audit')"></up-button></view>
<view><up-button v-if="item.status == 1" size="mini" <view v-if="hasPermission('erp_inbound_return_updateStatus')"><up-button v-if="item.status == 1" size="mini"
:customStyle="{padding: 0,width: '130rpx',height: '50rpx',marginRight:'20rpx',fontSize:'20rpx'}" :customStyle="{padding: 0,width: '130rpx',height: '50rpx',marginRight:'20rpx',fontSize:'20rpx'}"
type="error" text="拒绝" @click="handleOperateOrder(item,'notAudit')"></up-button></view> type="error" text="拒绝" @click="handleOperateOrder(item,'notAudit')"></up-button></view>
<view><up-button v-if="item.status == 3" size="mini" <view v-if="hasPermission('erp_inbound_return_updateStorageStatus')"><up-button v-if="item.status == 3" size="mini"
:customStyle="{padding: 0,width: '130rpx',height: '50rpx',marginRight:'20rpx',fontSize:'20rpx'}" :customStyle="{padding: 0,width: '130rpx',height: '50rpx',marginRight:'20rpx',fontSize:'20rpx'}"
type="primary" text="立即入库" @click="handleOperateOrder(item,'storage')"></up-button></view> type="primary" text="立即入库" @click="handleOperateOrder(item,'storage')"></up-button></view>
<view><up-button v-if="item.status == 3" size="mini" <view v-if="hasPermission('erp_inbound_return_updateStorageStatus')"><up-button v-if="item.status == 3" size="mini"
:customStyle="{padding: 0,width: '130rpx',height: '50rpx',marginRight:'20rpx',fontSize:'20rpx'}" :customStyle="{padding: 0,width: '130rpx',height: '50rpx',marginRight:'20rpx',fontSize:'20rpx'}"
type="error" text="拒绝入库" @click="handleOperateOrder(item,'notStorage')"></up-button></view> type="error" text="拒绝入库" @click="handleOperateOrder(item,'notStorage')"></up-button></view>
<view><up-button v-if="item.status == 3" size="mini" <view v-if="hasPermission('erp_inbound_return_anti')"><up-button v-if="item.status == 3" size="mini"
:customStyle="{padding: 0,width: '130rpx',height: '50rpx',marginRight:'20rpx',fontSize:'20rpx'}" :customStyle="{padding: 0,width: '130rpx',height: '50rpx',marginRight:'20rpx',fontSize:'20rpx'}"
type="error" text="撤销审核" @click="handleOperateOrder(item,'backout')"></up-button></view> type="error" text="撤销审核" @click="handleOperateOrder(item,'backout')"></up-button></view>
<view><up-button size="mini" <view><up-button size="mini"
@@ -131,9 +131,9 @@
getManualReturnStatus getManualReturnStatus
} from '@/addon/erp/api/sell'; } from '@/addon/erp/api/sell';
import { onShow, onPageScroll, onReachBottom, onLoad } from '@dcloudio/uni-app'; import { onShow, onPageScroll, onReachBottom, onLoad } from '@dcloudio/uni-app';
import { checkBtnPermission } from '@/utils/auth';
import useMemberStore from '@/stores/member' import useMemberStore from '@/stores/member'
import usePermission from '@/utils/usePermission'
const { hasPermission } = usePermission()
interface SellReturnItem { interface SellReturnItem {
id : number; id : number;
} }
@@ -181,24 +181,14 @@
// 操作 // 操作
const handleOperateOrder = async(item : any, type : string) => { const handleOperateOrder = async(item : any, type : string) => {
if (type === 'audit') { if (type === 'audit') {
const hasPermission = await checkBtnPermission(memberStore.btnPermission, 'erp_inbound_return_updateStatus')
if (!hasPermission) return
auditOrderShow.value = true auditOrderShow.value = true
} else if (type === 'notAudit') { } else if (type === 'notAudit') {
const hasPermission = await checkBtnPermission(memberStore.btnPermission, 'erp_inbound_return_updateStatus')
if (!hasPermission) return
notAuditOrderShow.value = true notAuditOrderShow.value = true
} else if (type === 'storage') { } else if (type === 'storage') {
const hasPermission = await checkBtnPermission(memberStore.btnPermission, 'erp_inbound_return_updateStorageStatus')
if (!hasPermission) return
storageOrderShow.value = true storageOrderShow.value = true
} else if (type === 'notStorage') { } else if (type === 'notStorage') {
const hasPermission = await checkBtnPermission(memberStore.btnPermission, 'erp_inbound_return_updateStorageStatus')
if (!hasPermission) return
notStorageOrderShow.value = true notStorageOrderShow.value = true
} else if (type === 'backout') { } else if (type === 'backout') {
const hasPermission = await checkBtnPermission(memberStore.btnPermission, 'erp_inbound_return_anti')
if (!hasPermission) return
backoutOrderShow.value = true backoutOrderShow.value = true
} }
refuseReason.value = "" refuseReason.value = ""

View File

@@ -189,7 +189,7 @@
</up-form> </up-form>
<view class="w-full footer"> <view class="w-full footer" v-if="hasPermission('erp_manual_inbound_add')">
<view <view
class="py-[var(--top-m)] px-[var(--sidebar-m)] footer w-full fixed bottom-0 left-0 right-0 box-border"> 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" <button hover-class="none"
@@ -211,10 +211,10 @@
import { uploadImage } from '@/app/api/system' import { uploadImage } from '@/app/api/system'
import { redirect } from '@/utils/common'; import { redirect } from '@/utils/common';
import dayjs from 'dayjs' import dayjs from 'dayjs'
import { checkBtnPermission} from '@/utils/auth';
import useMemberStore from '@/stores/member' import useMemberStore from '@/stores/member'
import { img } from '@/utils/common' import { img } from '@/utils/common'
import usePermission from '@/utils/usePermission'
const { hasPermission } = usePermission()
const memberStore = useMemberStore() const memberStore = useMemberStore()
@@ -487,8 +487,6 @@
// 保存 // 保存
const handSave = async() => { const handSave = async() => {
const hasPermission =await checkBtnPermission(memberStore.btnPermission, 'erp_manual_inbound_add')
if (!hasPermission) return
if (loading.value) return if (loading.value) return
if (!formData.value.code) { if (!formData.value.code) {
uni.showToast({ icon: 'none', title: t('codePlaceholderNew') }) uni.showToast({ icon: 'none', title: t('codePlaceholderNew') })
@@ -527,7 +525,7 @@
addManual(formData.value).then((res : any) => { addManual(formData.value).then((res : any) => {
loading.value = false loading.value = false
if (res.code == 1) { if (res.code == 1) {
redirect({ url: '/addon/erp/pages/inbound/stockPending/list' }) redirect({ url: '/addon/erp/pages/index' })
} }
}).catch((err) => { }).catch((err) => {
// 如果是4001没有绑定企业账号强制跳转绑定 // 如果是4001没有绑定企业账号强制跳转绑定

View File

@@ -151,7 +151,7 @@
</view> </view>
</view> </view>
</view> </view>
<view class="w-full footer" v-if="formData.storage_status == 2"> <view class="w-full footer" v-if="formData.storage_status == 2 && hasPermission('erp_manual_inbound_takeOutOfStorage')">
<view <view
class="py-[var(--top-m)] px-[var(--sidebar-m)] footer w-full fixed bottom-0 left-0 right-0 box-border"> 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" <button hover-class="none"
@@ -171,6 +171,8 @@
import { onLoad } from '@dcloudio/uni-app'; import { onLoad } from '@dcloudio/uni-app';
import { getManualInfo,putInStorage } from '@/addon/erp/api/purchase'; import { getManualInfo,putInStorage } from '@/addon/erp/api/purchase';
import { img } from '@/utils/common' import { img } from '@/utils/common'
import usePermission from '@/utils/usePermission'
const { hasPermission } = usePermission()
const formRef : any = ref(null) const formRef : any = ref(null)
const formData = reactive({ const formData = reactive({

View File

@@ -69,7 +69,7 @@
</view> </view>
<view class="foot border-0 border-t-1 border-solid border-[#ddd]"> <view class="foot border-0 border-t-1 border-solid border-[#ddd]">
<view class="flex justify-end p-[20rpx]"> <view class="flex justify-end p-[20rpx]">
<view><up-button v-if="item.storage_status == 2" size="mini" <view v-if="hasPermission('erp_manual_inbound_takeOutOfStorage')"><up-button v-if="item.storage_status == 2" size="mini"
:customStyle="{padding: 0,width: '130rpx',height: '50rpx',marginRight:'20rpx'}" :customStyle="{padding: 0,width: '130rpx',height: '50rpx',marginRight:'20rpx'}"
type="primary" text="立即入库" @click="handleEnteringWarehouse(item)"></up-button> type="primary" text="立即入库" @click="handleEnteringWarehouse(item)"></up-button>
</view> </view>
@@ -114,10 +114,11 @@
import useMescroll from '@/components/mescroll/hooks/useMescroll.js'; import useMescroll from '@/components/mescroll/hooks/useMescroll.js';
import { getManualList, getManualStatus, getManualInfo, putInStorage, setManualImg } from '@/addon/erp/api/purchase'; import { getManualList, getManualStatus, getManualInfo, putInStorage, setManualImg } from '@/addon/erp/api/purchase';
import { onShow, onPageScroll, onReachBottom, onLoad } from '@dcloudio/uni-app'; import { onShow, onPageScroll, onReachBottom, onLoad } from '@dcloudio/uni-app';
import { checkBtnPermission } from '@/utils/auth';
import useMemberStore from '@/stores/member' import useMemberStore from '@/stores/member'
import { uploadImage } from '@/app/api/system' import { uploadImage } from '@/app/api/system'
import { img } from '@/utils/common' import { img } from '@/utils/common'
import usePermission from '@/utils/usePermission'
const { hasPermission } = usePermission()
const { downCallback, mescrollInit, getMescroll } = useMescroll(onPageScroll, onReachBottom); const { downCallback, mescrollInit, getMescroll } = useMescroll(onPageScroll, onReachBottom);
interface FileItem { interface FileItem {
url : string; url : string;
@@ -161,8 +162,6 @@
}) })
// 立即入库 // 立即入库
const handleEnteringWarehouse = async (item : any) => { const handleEnteringWarehouse = async (item : any) => {
const hasPermission = await checkBtnPermission(memberStore.btnPermission, 'erp_manual_inbound_takeOutOfStorage')
if (!hasPermission) return
enteringWarehouseShow.value = true enteringWarehouseShow.value = true
enteringWarehouseId.value = item.id enteringWarehouseId.value = item.id
} }

View File

@@ -90,7 +90,7 @@
</up-form> </up-form>
<view class="w-full footer"> <view v-if="hasPermission('erp_inventory_check_add')" class="w-full footer">
<view <view
class="py-[var(--top-m)] px-[var(--sidebar-m)] footer w-full fixed bottom-0 left-0 right-0 box-border"> 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" <button hover-class="none"
@@ -112,9 +112,9 @@
import { addCheck, getCheckTypeList, getCheckProduct } from '@/addon/erp/api/inventory'; import { addCheck, getCheckTypeList, getCheckProduct } from '@/addon/erp/api/inventory';
import { redirect } from '@/utils/common'; import { redirect } from '@/utils/common';
import dayjs from 'dayjs' import dayjs from 'dayjs'
import { checkBtnPermission } from '@/utils/auth';
import useMemberStore from '@/stores/member' import useMemberStore from '@/stores/member'
import usePermission from '@/utils/usePermission'
const { hasPermission } = usePermission()
const memberStore = useMemberStore() const memberStore = useMemberStore()
const formRef : any = ref(null) const formRef : any = ref(null)
@@ -239,8 +239,6 @@
// 保存 // 保存
const handSave = async() => { const handSave = async() => {
const hasPermission = await checkBtnPermission(memberStore.btnPermission,'erp_inventory_check_add')
if (!hasPermission) return
if (loading.value) return if (loading.value) return
if (!formData.value.warehouse_id) { if (!formData.value.warehouse_id) {
uni.showToast({ icon: 'none', title: '请选择仓库' }) uni.showToast({ icon: 'none', title: '请选择仓库' })
@@ -264,7 +262,7 @@
addCheck(formData.value).then((res : any) => { addCheck(formData.value).then((res : any) => {
loading.value = false loading.value = false
if (res.code == 1) { if (res.code == 1) {
redirect({ url: '/addon/erp/pages/inventory/inventory/list' }) redirect({ url: '/addon/erp/pages/index' })
} }
}).catch((err) => { }).catch((err) => {
// 如果是4001没有绑定企业账号强制跳转绑定 // 如果是4001没有绑定企业账号强制跳转绑定

View File

@@ -43,16 +43,14 @@
class="ml-[20rpx] text-[var(--primary-color)]">{{item.surface_num}}</text> class="ml-[20rpx] text-[var(--primary-color)]">{{item.surface_num}}</text>
</view> </view>
<view class="flex justify-start mb-[18rpx] text-[12px] text-[#6a6a6a]"> <view class="flex justify-start mb-[18rpx] text-[12px] text-[#6a6a6a]">
操作数量:<text 操作数量:<text class="ml-[20rpx] text-[var(--primary-color)]">{{item.number}}</text>
class="ml-[20rpx] text-[var(--primary-color)]">{{item.number}}</text>
</view> </view>
<view class="flex justify-start mb-[18rpx] text-[12px] text-[#6a6a6a]"> <view class="flex justify-start mb-[18rpx] text-[12px] text-[#6a6a6a]">
{{ t('realNum') }}:<text {{ t('realNum') }}:<text
class="ml-[20rpx] text-[var(--primary-color)]">{{item.real_num}}</text> class="ml-[20rpx] text-[var(--primary-color)]">{{item.real_num}}</text>
</view> </view>
<view class="flex justify-start mb-[18rpx] text-[12px] text-[#6a6a6a]"> <view class="flex justify-start mb-[18rpx] text-[12px] text-[#6a6a6a]">
状态:<text 状态:<text class="ml-[20rpx] text-[var(--primary-color)]">{{item.status_text}}</text>
class="ml-[20rpx] text-[var(--primary-color)]">{{item.status_text}}</text>
</view> </view>
<view class="flex justify-start mb-[18rpx] text-[12px] text-[#6a6a6a]"> <view class="flex justify-start mb-[18rpx] text-[12px] text-[#6a6a6a]">
@@ -64,9 +62,21 @@
</view> </view>
<view class="foot border-0 border-t-1 border-solid border-[#ddd]"> <view class="foot border-0 border-t-1 border-solid border-[#ddd]">
<view class="flex justify-end p-[20rpx]"> <view class="flex justify-end p-[20rpx]">
<view><up-button v-if="item.status == 0" size="mini" :customStyle="{padding: 0,width: '130rpx',height: '50rpx',marginRight:'20rpx',fontSize:'20rpx'}" type="primary" text="通过" @click="handleOperateOrder(item,'audit')"></up-button></view> <view v-if="hasPermission('erp_inventory_check_updateStatus')"><up-button
<view><up-button v-if="item.status == 0" size="mini" :customStyle="{padding: 0,width: '130rpx',height: '50rpx',marginRight:'20rpx',fontSize:'20rpx'}" type="error" text="拒绝" @click="handleOperateOrder(item,'notAudit')"></up-button></view> v-if="item.status == 0" size="mini"
<view><up-button v-if="item.status == 1" size="mini" :customStyle="{padding: 0,width: '130rpx',height: '50rpx',marginRight:'20rpx',fontSize:'20rpx'}" type="primary" text="立即入库" @click="handleOperateOrder(item,'storage')"></up-button></view> :customStyle="{padding: 0,width: '130rpx',height: '50rpx',marginRight:'20rpx',fontSize:'20rpx'}"
type="primary" text="通过" @click="handleOperateOrder(item,'audit')"></up-button>
</view>
<view v-if="hasPermission('erp_inventory_check_updateStatus')"><up-button
v-if="item.status == 0" size="mini"
:customStyle="{padding: 0,width: '130rpx',height: '50rpx',marginRight:'20rpx',fontSize:'20rpx'}"
type="error" text="拒绝" @click="handleOperateOrder(item,'notAudit')"></up-button>
</view>
<view v-if="hasPermission('erp_inventory_check_putInStorage')"><up-button
v-if="item.status == 1" size="mini"
:customStyle="{padding: 0,width: '130rpx',height: '50rpx',marginRight:'20rpx',fontSize:'20rpx'}"
type="primary" text="立即入库"
@click="handleOperateOrder(item,'storage')"></up-button></view>
</view> </view>
</view> </view>
</view> </view>
@@ -86,16 +96,17 @@
<up-modal :show="auditOrderShow" @confirm="auditOrderConfirm" showCancelButton @cancel="auditOrderShow = false" <up-modal :show="auditOrderShow" @confirm="auditOrderConfirm" showCancelButton @cancel="auditOrderShow = false"
:title="'提示'" :content="'确定要通过审核该数据吗?'" ref="auditOrderModal"></up-modal> :title="'提示'" :content="'确定要通过审核该数据吗?'" ref="auditOrderModal"></up-modal>
<!-- 立即入库模态框 --> <!-- 立即入库模态框 -->
<up-modal :show="storageOrderShow" @confirm="storageOrderConfirm" showCancelButton @cancel="storageOrderShow = false" <up-modal :show="storageOrderShow" @confirm="storageOrderConfirm" showCancelButton
:title="'提示'" :content="'确定要立即入库该数据吗?'" ref="storageOrderModal"></up-modal> @cancel="storageOrderShow = false" :title="'提示'" :content="'确定要立即入库该数据吗?'"
ref="storageOrderModal"></up-modal>
<!-- 拒绝审核模态框 --> <!-- 拒绝审核模态框 -->
<up-modal :show="notAuditOrderShow" @confirm="notAuditOrderConfirm" showCancelButton @cancel="notAuditOrderShow = false" <up-modal :show="notAuditOrderShow" @confirm="notAuditOrderConfirm" showCancelButton
:title="'提示'" ref="notAuditOrderModal"> @cancel="notAuditOrderShow = false" :title="'提示'" ref="notAuditOrderModal">
<view class="slot-content"> <view class="slot-content">
<view>确定要拒绝该数据吗</view> <view>确定要拒绝该数据吗</view>
<u-input fontSize="28rpx" v-model.trim="refuseReason" clearable <u-input fontSize="28rpx" v-model.trim="refuseReason" clearable placeholderStyle="color: #888"
placeholderStyle="color: #888" placeholder="请输入拒绝原因" /> placeholder="请输入拒绝原因" />
</view> </view>
</up-modal> </up-modal>
</view> </view>
</template> </template>
@@ -107,11 +118,11 @@
import MescrollBody from '@/components/mescroll/mescroll-body/mescroll-body.vue'; import MescrollBody from '@/components/mescroll/mescroll-body/mescroll-body.vue';
import MescrollEmpty from '@/components/mescroll/mescroll-empty/mescroll-empty.vue'; import MescrollEmpty from '@/components/mescroll/mescroll-empty/mescroll-empty.vue';
import useMescroll from '@/components/mescroll/hooks/useMescroll.js'; import useMescroll from '@/components/mescroll/hooks/useMescroll.js';
import { getCheckList,getCheckTypeList,updateCheckStatus,putInStorage} from '@/addon/erp/api/inventory'; import { getCheckList, getCheckTypeList, updateCheckStatus, putInStorage } from '@/addon/erp/api/inventory';
import { onShow, onPageScroll, onReachBottom, onLoad } from '@dcloudio/uni-app'; import { onShow, onPageScroll, onReachBottom, onLoad } from '@dcloudio/uni-app';
import { checkBtnPermission } from '@/utils/auth';
import useMemberStore from '@/stores/member' import useMemberStore from '@/stores/member'
import usePermission from '@/utils/usePermission'
const { hasPermission } = usePermission()
const { downCallback, mescrollInit, getMescroll } = useMescroll(onPageScroll, onReachBottom); const { downCallback, mescrollInit, getMescroll } = useMescroll(onPageScroll, onReachBottom);
const memberStore = useMemberStore() const memberStore = useMemberStore()
@@ -120,47 +131,41 @@
const auditOrderShow = ref(false); const auditOrderShow = ref(false);
const notAuditOrderShow = ref(false); const notAuditOrderShow = ref(false);
const storageOrderShow = ref(false); const storageOrderShow = ref(false);
const refuseReason=ref("") const refuseReason = ref("")
const statusList = ref<any[]>([]); const statusList = ref<any[]>([]);
const searchParams = ref<any>({ const searchParams = ref<any>({
status: '增加', status: '增加',
}); });
onLoad(() => { onLoad(() => {
// 获取状态 // 获取状态
getCheckTypeList().then((res:any) => { getCheckTypeList().then((res : any) => {
statusList.value = Object.values(res.data); statusList.value = Object.values(res.data);
}); });
}) })
// 操作 // 操作
const handleOperateOrder= async(item:any,type:string)=>{ const handleOperateOrder = async (item : any, type : string) => {
if (type === 'audit') { if (type === 'audit') {
const hasPermission = await checkBtnPermission(memberStore.btnPermission, 'erp_inventory_check_updateStatus')
if (!hasPermission) return
auditOrderShow.value = true auditOrderShow.value = true
} else if (type === 'notAudit') { } else if (type === 'notAudit') {
const hasPermission = await checkBtnPermission(memberStore.btnPermission,'erp_inventory_check_updateStatus')
if (!hasPermission) return
notAuditOrderShow.value = true notAuditOrderShow.value = true
} else if (type === 'storage') { } else if (type === 'storage') {
const hasPermission = await checkBtnPermission(memberStore.btnPermission, 'erp_inventory_check_putInStorage')
if (!hasPermission) return
storageOrderShow.value = true storageOrderShow.value = true
} }
refuseReason.value="" refuseReason.value = ""
auditOrderItem.value=item auditOrderItem.value = item
} }
// 确认审核 // 确认审核
const auditOrderConfirm = () => { const auditOrderConfirm = () => {
if (!auditOrderItem.value) { if (!auditOrderItem.value) {
uni.showToast({ uni.showToast({
title: '数据不存在', title: '数据不存在',
icon: 'none' icon: 'none'
}); });
return; return;
} }
updateCheckStatus({ id: auditOrderItem.value.id,type: 'pass' }) updateCheckStatus({ id: auditOrderItem.value.id, type: 'pass' })
.then((res:any) => { .then((res : any) => {
if(res.code ===1){ if (res.code === 1) {
getMescroll().resetUpScroll(); getMescroll().resetUpScroll();
auditOrderItem.value = null; auditOrderItem.value = null;
auditOrderShow.value = false; auditOrderShow.value = false;
@@ -170,15 +175,15 @@
// 确认立即入库 // 确认立即入库
const storageOrderConfirm = () => { const storageOrderConfirm = () => {
if (!auditOrderItem.value) { if (!auditOrderItem.value) {
uni.showToast({ uni.showToast({
title: '数据不存在', title: '数据不存在',
icon: 'none' icon: 'none'
}); });
return; return;
} }
putInStorage(auditOrderItem.value.id) putInStorage(auditOrderItem.value.id)
.then((res:any) => { .then((res : any) => {
if(res.code ===1){ if (res.code === 1) {
getMescroll().resetUpScroll(); getMescroll().resetUpScroll();
auditOrderItem.value = null; auditOrderItem.value = null;
storageOrderShow.value = false; storageOrderShow.value = false;
@@ -188,15 +193,15 @@
// 确认拒绝通过审核 // 确认拒绝通过审核
const notAuditOrderConfirm = () => { const notAuditOrderConfirm = () => {
if (!auditOrderItem.value) { if (!auditOrderItem.value) {
uni.showToast({ uni.showToast({
title: '数据不存在', title: '数据不存在',
icon: 'none' icon: 'none'
}); });
return; return;
} }
updateCheckStatus({ id: auditOrderItem.value.id,type: 'reject',reject_reason:refuseReason.value }) updateCheckStatus({ id: auditOrderItem.value.id, type: 'reject', reject_reason: refuseReason.value })
.then((res:any) => { .then((res : any) => {
if(res.code ===1){ if (res.code === 1) {
getMescroll().resetUpScroll(); getMescroll().resetUpScroll();
auditOrderItem.value = null; auditOrderItem.value = null;
notAuditOrderShow.value = false; notAuditOrderShow.value = false;
@@ -205,7 +210,7 @@
} }
// 分段器改变事件 // 分段器改变事件
const handleChange = (index : number) => { const handleChange = (index : number) => {
searchParams.value.status = index===0?'增加':'减少'; searchParams.value.status = index === 0 ? '增加' : '减少';
getMescroll().resetUpScroll(); getMescroll().resetUpScroll();
} }

View File

@@ -202,7 +202,7 @@
</view> </view>
</view> </view>
</up-form> </up-form>
<view v-if="hasPermission('erp_manual_outbound_add')" class="w-full footer"> <view v-if="hasPermission('erp_manual_outbound_add')" class="w-full footer">
<view <view
class="py-[var(--top-m)] px-[var(--sidebar-m)] footer w-full fixed bottom-0 left-0 right-0 box-border"> class="py-[var(--top-m)] px-[var(--sidebar-m)] footer w-full fixed bottom-0 left-0 right-0 box-border">
@@ -224,8 +224,9 @@
import { generatedCode } from '@/addon/erp/utils/common'; import { generatedCode } from '@/addon/erp/utils/common';
import {uploadImage } from '@/app/api/system' import {uploadImage } from '@/app/api/system'
import { redirect } from '@/utils/common'; import { redirect } from '@/utils/common';
import dayjs from 'dayjs'
import dayjs from 'dayjs' import dayjs from 'dayjs'
import useMemberStore from '@/stores/member'
import usePermission from '@/utils/usePermission'
const { hasPermission } = usePermission() const { hasPermission } = usePermission()
interface FileItem { interface FileItem {
url: string; url: string;
@@ -489,9 +490,7 @@
return data; return data;
}); });
// 保存 // 保存
const handSave = async() => {
const hasPermission = await checkBtnPermission(memberStore.btnPermission, 'erp_manual_outbound_add')
const handSave = async() => {s const handSave = async() => {s
if (loading.value) return if (loading.value) return
if (!formData.value.customer_id) { if (!formData.value.customer_id) {
@@ -526,7 +525,7 @@
} }
addManual(formData.value).then((res : any) => { addManual(formData.value).then((res : any) => {
loading.value = false loading.value = false
if (res.code == 1) { if (res.code == 1) {
redirect({ url: '/addon/erp/pages/index' }) redirect({ url: '/addon/erp/pages/index' })
} }
}).catch((err) => { }).catch((err) => {

View File

@@ -134,7 +134,7 @@
</view> </view>
</view> </view>
</view> </view>
<view class="w-full footer" v-if="formData.storage_status == 5"> <view class="w-full footer" v-if="formData.storage_status == 5 && hasPermission('erp_manual_outbound_takeOutOfStorage')">
<view <view
class="py-[var(--top-m)] px-[var(--sidebar-m)] footer w-full fixed bottom-0 left-0 right-0 box-border"> 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" <button hover-class="none"
@@ -154,6 +154,8 @@
import { onLoad } from '@dcloudio/uni-app'; import { onLoad } from '@dcloudio/uni-app';
import { getManualInfo ,takeOutOfStorage} from '@/addon/erp/api/sell'; import { getManualInfo ,takeOutOfStorage} from '@/addon/erp/api/sell';
import { img } from '@/utils/common' import { img } from '@/utils/common'
import usePermission from '@/utils/usePermission'
const { hasPermission } = usePermission()
const formRef : any = ref(null) const formRef : any = ref(null)
const formData = reactive({ const formData = reactive({

View File

@@ -64,7 +64,7 @@
</view> </view>
<view class="foot border-0 border-t-1 border-solid border-[#ddd]"> <view class="foot border-0 border-t-1 border-solid border-[#ddd]">
<view class="flex justify-end p-[20rpx]"> <view class="flex justify-end p-[20rpx]">
<view><up-button v-if="item.storage_status == 5" size="mini" <view v-if="hasPermission('erp_manual_outbound_takeOutOfStorage')"><up-button v-if="item.storage_status == 5" size="mini"
:customStyle="{padding: 0,width: '130rpx',height: '50rpx',marginRight:'20rpx'}" :customStyle="{padding: 0,width: '130rpx',height: '50rpx',marginRight:'20rpx'}"
type="primary" text="立即出库" @click="handleoutWarehouse(item)"></up-button></view> type="primary" text="立即出库" @click="handleoutWarehouse(item)"></up-button></view>
<view><up-button size="mini" <view><up-button size="mini"
@@ -107,12 +107,12 @@
import useMescroll from '@/components/mescroll/hooks/useMescroll.js'; import useMescroll from '@/components/mescroll/hooks/useMescroll.js';
import { getManualList, getManualInfo, takeOutOfStorage, setManualImg } from '@/addon/erp/api/sell'; import { getManualList, getManualInfo, takeOutOfStorage, setManualImg } from '@/addon/erp/api/sell';
import { onShow, onPageScroll, onReachBottom, onLoad } from '@dcloudio/uni-app'; import { onShow, onPageScroll, onReachBottom, onLoad } from '@dcloudio/uni-app';
import { checkBtnPermission } from '@/utils/auth';
import useMemberStore from '@/stores/member' import useMemberStore from '@/stores/member'
import { uploadImage } from '@/app/api/system' import { uploadImage } from '@/app/api/system'
import { img } from '@/utils/common' import { img } from '@/utils/common'
const { downCallback, mescrollInit, getMescroll } = useMescroll(onPageScroll, onReachBottom); const { downCallback, mescrollInit, getMescroll } = useMescroll(onPageScroll, onReachBottom);
import usePermission from '@/utils/usePermission'
const { hasPermission } = usePermission()
interface FileItem { interface FileItem {
url : string; url : string;
status ?: string; status ?: string;
@@ -312,8 +312,6 @@
} }
// 立即出库 // 立即出库
const handleoutWarehouse = async (item : any) => { const handleoutWarehouse = async (item : any) => {
const hasPermission = await checkBtnPermission(memberStore.btnPermission, 'erp_manual_outbound_takeOutOfStorage')
if (!hasPermission) return
outWarehouseShow.value = true outWarehouseShow.value = true
outWarehouseId.value = item.id outWarehouseId.value = item.id
} }

View File

@@ -100,7 +100,7 @@
:safeAreaInsetBottom="true" @close="unitSheetShow = false" @select="updateSexUnit"></u-action-sheet> :safeAreaInsetBottom="true" @close="unitSheetShow = false" @select="updateSexUnit"></u-action-sheet>
<view class="w-full footer"> <view v-if="hasPermission('erp_product_add')" class="w-full footer">
<view <view
class="py-[var(--top-m)] px-[var(--sidebar-m)] footer w-full fixed bottom-0 left-0 right-0 box-border"> 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" <button hover-class="none"
@@ -120,9 +120,9 @@
import { generatedCode } from '@/addon/erp/utils/common'; import { generatedCode } from '@/addon/erp/utils/common';
import {uploadImage } from '@/app/api/system' import {uploadImage } from '@/app/api/system'
import { redirect } from '@/utils/common'; import { redirect } from '@/utils/common';
import { checkBtnPermission } from '@/utils/auth';
import useMemberStore from '@/stores/member' import useMemberStore from '@/stores/member'
import usePermission from '@/utils/usePermission'
const { hasPermission } = usePermission()
const memberStore = useMemberStore() const memberStore = useMemberStore()
interface FileItem { interface FileItem {
url: string; url: string;
@@ -273,8 +273,6 @@
// 保存 // 保存
const handSave = async() => { const handSave = async() => {
const hasPermission = await checkBtnPermission(memberStore.btnPermission, 'erp_product_add')
if (!hasPermission) return
formRef.value.validate().then(() => { formRef.value.validate().then(() => {
if (loading.value) return if (loading.value) return
loading.value = true loading.value = true

View File

@@ -46,7 +46,7 @@
<view><up-button :text="t('info')" size="mini" <view><up-button :text="t('info')" size="mini"
@click="redirect({ url: '/addon/erp/pages/product/product/detail',param:{id: item.id} })"></up-button> @click="redirect({ url: '/addon/erp/pages/product/product/detail',param:{id: item.id} })"></up-button>
</view> </view>
<view><up-button type="error" @click="hanldeDelete(item.id)" :text="t('delete')" <view v-if="hasPermission('erp_product_add')"><up-button type="error" @click="hanldeDelete(item.id)" :text="t('delete')"
size="mini"></up-button></view> size="mini"></up-button></view>
</view> </view>
</view> </view>
@@ -60,7 +60,7 @@
</mescroll-body> </mescroll-body>
<loading-page :loading="loading"></loading-page> <loading-page :loading="loading"></loading-page>
<view class="fixed bottom-4 right-4 z-2"> <view v-if="hasPermission('erp_product_delete')" class="fixed bottom-4 right-4 z-2">
<up-button @click="redirect({ url: '/addon/erp/pages/product/product/add'})" type="primary" shape="circle" <up-button @click="redirect({ url: '/addon/erp/pages/product/product/add'})" type="primary" shape="circle"
:customStyle="{borderRadius: '50%',padding: 0,width: '50px',height: '50px'}"> :customStyle="{borderRadius: '50%',padding: 0,width: '50px',height: '50px'}">
<u-icon size="30" color="#fff" name="plus-circle-fill"></u-icon> <u-icon size="30" color="#fff" name="plus-circle-fill"></u-icon>
@@ -80,7 +80,8 @@
import useMescroll from '@/components/mescroll/hooks/useMescroll.js'; import useMescroll from '@/components/mescroll/hooks/useMescroll.js';
import { getProductList, deleteProduct } from '@/addon/erp/api/product'; import { getProductList, deleteProduct } from '@/addon/erp/api/product';
import { onShow, onPageScroll, onReachBottom } from '@dcloudio/uni-app'; import { onShow, onPageScroll, onReachBottom } from '@dcloudio/uni-app';
import usePermission from '@/utils/usePermission'
const { hasPermission } = usePermission()
const { downCallback, mescrollInit, getMescroll } = useMescroll(onPageScroll, onReachBottom); const { downCallback, mescrollInit, getMescroll } = useMescroll(onPageScroll, onReachBottom);

View File

@@ -15,7 +15,7 @@
</u-form-item> </u-form-item>
</view> </view>
</u-form> </u-form>
<view class="w-full footer"> <view v-if="hasPermission('erp_product_type_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"> <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" <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> @click="handSave" :disabled="loading" :class="{'opacity-50': loading}">{{t('save')}}</button>
@@ -35,9 +35,9 @@
import { onLoad } from '@dcloudio/uni-app'; import { onLoad } from '@dcloudio/uni-app';
import { getProductTypeSelect, getProductTypeInfo, addProductType, editProductType } from '@/addon/erp/api/product'; import { getProductTypeSelect, getProductTypeInfo, addProductType, editProductType } from '@/addon/erp/api/product';
import { redirect } from '@/utils/common'; import { redirect } from '@/utils/common';
import { checkBtnPermission } from '@/utils/auth';
import useMemberStore from '@/stores/member' import useMemberStore from '@/stores/member'
import usePermission from '@/utils/usePermission'
const { hasPermission } = usePermission()
const memberStore = useMemberStore() const memberStore = useMemberStore()
const formRef: any = ref(null) const formRef: any = ref(null)
@@ -107,8 +107,6 @@
// 保存 // 保存
const handSave = async() => { const handSave = async() => {
const hasPermission = await checkBtnPermission(memberStore.btnPermission, 'erp_product_type_add')
if (!hasPermission) return
formRef.value.validate().then(() => { formRef.value.validate().then(() => {
if (loading.value) return if (loading.value) return
loading.value = true loading.value = true

View File

@@ -22,7 +22,7 @@
</mescroll-body> </mescroll-body>
<loading-page :loading="loading"></loading-page> <loading-page :loading="loading"></loading-page>
<view class="fixed bottom-4 right-4 z-2"> <view v-if="hasPermission('erp_product_type_add')" class="fixed bottom-4 right-4 z-2">
<up-button @click="redirect({ url: '/addon/erp/pages/product/type/add'})" type="primary" shape="circle" <up-button @click="redirect({ url: '/addon/erp/pages/product/type/add'})" type="primary" shape="circle"
:customStyle="{borderRadius: '50%',padding: 0,width: '50px',height: '50px'}"> :customStyle="{borderRadius: '50%',padding: 0,width: '50px',height: '50px'}">
<u-icon size="30" color="#fff" name="plus-circle-fill"></u-icon> <u-icon size="30" color="#fff" name="plus-circle-fill"></u-icon>
@@ -41,12 +41,19 @@
import useMescroll from '@/components/mescroll/hooks/useMescroll.js'; import useMescroll from '@/components/mescroll/hooks/useMescroll.js';
import { getProductTypeList, deleteProductType } from '@/addon/erp/api/product'; import { getProductTypeList, deleteProductType } from '@/addon/erp/api/product';
import { onShow, onPageScroll, onReachBottom } from '@dcloudio/uni-app'; import { onShow, onPageScroll, onReachBottom } from '@dcloudio/uni-app';
import usePermission from '@/utils/usePermission'
const { downCallback, mescrollInit, getMescroll } = useMescroll(onPageScroll, onReachBottom); const { downCallback, mescrollInit, getMescroll } = useMescroll(onPageScroll, onReachBottom);
const { hasPermission } = usePermission()
const show = ref(false); const show = ref(false);
interface BtnOption {
text: string;
style: {
backgroundColor: string;
};
}
// 获取系统状态栏的高度 // 获取系统状态栏的高度
let menuButtonInfo : any = {}; let menuButtonInfo : any = {};
// 如果是小程序,获取右上角胶囊的尺寸信息,避免导航栏右侧内容与胶囊重叠(支付宝小程序非本API尚未兼容) // 如果是小程序,获取右上角胶囊的尺寸信息,避免导航栏右侧内容与胶囊重叠(支付宝小程序非本API尚未兼容)
@@ -95,18 +102,28 @@
}) })
} }
const btnOptions = ref([{ const btnOptions = ref<BtnOption[]>([]);
text: t('edit'), const initBtn = () => {
style: { btnOptions.value = []
backgroundColor: '#3c9cff' const hasEdit = hasPermission.value('erp_product_type_edit')
const hasDel = hasPermission.value('erp_product_type_delete')
if (hasEdit) {
btnOptions.value.push({
text: t('edit'),
style: {
backgroundColor: '#3c9cff'
}
})
} }
}, { if (hasDel) {
text: t('delete'), btnOptions.value.push({
style: { text: t('delete'),
backgroundColor: '#f56c6c' style: {
backgroundColor: '#f56c6c'
}
})
} }
}]) }
const swipeActionRefs = ref<any[]>([]); const swipeActionRefs = ref<any[]>([]);
const setSwipeActionRef = (index : number) => (el : any[] | null) => { const setSwipeActionRef = (index : number) => (el : any[] | null) => {
@@ -146,6 +163,7 @@
} }
}).catch(() => { }); }).catch(() => { });
} }
initBtn()
</script> </script>
<style> <style>

View File

@@ -8,7 +8,7 @@
</u-form-item> </u-form-item>
</view> </view>
</u-form> </u-form>
<view class="w-full footer"> <view v-if="hasPermission('erp_product_unit_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"> <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" <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> @click="handSave" :disabled="loading" :class="{'opacity-50': loading}">{{t('save')}}</button>
@@ -28,9 +28,9 @@
import { onLoad } from '@dcloudio/uni-app'; import { onLoad } from '@dcloudio/uni-app';
import { getProductUnitInfo, addProductUnit, editProductUnit } from '@/addon/erp/api/product'; import { getProductUnitInfo, addProductUnit, editProductUnit } from '@/addon/erp/api/product';
import { redirect } from '@/utils/common'; import { redirect } from '@/utils/common';
import { checkBtnPermission } from '@/utils/auth';
import useMemberStore from '@/stores/member' import useMemberStore from '@/stores/member'
import usePermission from '@/utils/usePermission'
const { hasPermission } = usePermission()
const memberStore = useMemberStore() const memberStore = useMemberStore()
const formRef: any = ref(null) const formRef: any = ref(null)
@@ -71,8 +71,6 @@
// 保存 // 保存
const handSave = async() => { const handSave = async() => {
const hasPermission = await checkBtnPermission(memberStore.btnPermission, 'erp_product_unit_add')
if (!hasPermission) return
formRef.value.validate().then(() => { formRef.value.validate().then(() => {
if (loading.value) return if (loading.value) return
loading.value = true loading.value = true

View File

@@ -22,7 +22,7 @@
</mescroll-body> </mescroll-body>
<loading-page :loading="loading"></loading-page> <loading-page :loading="loading"></loading-page>
<view class="fixed bottom-4 right-4 z-2"> <view v-if="hasPermission('erp_product_unit_add')" class="fixed bottom-4 right-4 z-2">
<up-button @click="redirect({ url: '/addon/erp/pages/product/unit/add'})" type="primary" shape="circle" <up-button @click="redirect({ url: '/addon/erp/pages/product/unit/add'})" type="primary" shape="circle"
:customStyle="{borderRadius: '50%',padding: 0,width: '50px',height: '50px'}"> :customStyle="{borderRadius: '50%',padding: 0,width: '50px',height: '50px'}">
<u-icon size="30" color="#fff" name="plus-circle-fill"></u-icon> <u-icon size="30" color="#fff" name="plus-circle-fill"></u-icon>
@@ -41,12 +41,17 @@
import useMescroll from '@/components/mescroll/hooks/useMescroll.js'; import useMescroll from '@/components/mescroll/hooks/useMescroll.js';
import { getProductUnitList, deleteProductUnit } from '@/addon/erp/api/product'; import { getProductUnitList, deleteProductUnit } from '@/addon/erp/api/product';
import { onShow, onPageScroll, onReachBottom } from '@dcloudio/uni-app'; import { onShow, onPageScroll, onReachBottom } from '@dcloudio/uni-app';
import usePermission from '@/utils/usePermission'
const { downCallback, mescrollInit, getMescroll } = useMescroll(onPageScroll, onReachBottom); const { downCallback, mescrollInit, getMescroll } = useMescroll(onPageScroll, onReachBottom);
const { hasPermission } = usePermission()
const show = ref(false); const show = ref(false);
interface BtnOption {
text: string;
style: {
backgroundColor: string;
};
}
// 获取系统状态栏的高度 // 获取系统状态栏的高度
let menuButtonInfo : any = {}; let menuButtonInfo : any = {};
// 如果是小程序,获取右上角胶囊的尺寸信息,避免导航栏右侧内容与胶囊重叠(支付宝小程序非本API尚未兼容) // 如果是小程序,获取右上角胶囊的尺寸信息,避免导航栏右侧内容与胶囊重叠(支付宝小程序非本API尚未兼容)
@@ -95,17 +100,28 @@
}) })
} }
const btnOptions = ref([{ const btnOptions = ref<BtnOption[]>([]);
text: t('edit'), const initBtn = () => {
style: { btnOptions.value = []
backgroundColor: '#3c9cff' const hasEdit = hasPermission.value('erp_product_unit_edit')
const hasDel = hasPermission.value('erp_product_unit_delete')
if (hasEdit) {
btnOptions.value.push({
text: t('edit'),
style: {
backgroundColor: '#3c9cff'
}
})
} }
}, { if (hasDel) {
text: t('delete'), btnOptions.value.push({
style: { text: t('delete'),
backgroundColor: '#f56c6c' style: {
backgroundColor: '#f56c6c'
}
})
} }
}]) }
const swipeActionRefs = ref<any[]>([]); const swipeActionRefs = ref<any[]>([]);
const setSwipeActionRef = (index : number) => (el : any[] | null) => { const setSwipeActionRef = (index : number) => (el : any[] | null) => {
@@ -145,6 +161,7 @@
} }
}).catch(() => { }); }).catch(() => { });
} }
initBtn()
</script> </script>
<style> <style>

View File

@@ -149,7 +149,7 @@
</up-form> </up-form>
<view class="w-full footer"> <view v-if="hasPermission('erp_outbound_return_add')" class="w-full footer">
<view <view
class="py-[var(--top-m)] px-[var(--sidebar-m)] footer w-full fixed bottom-0 left-0 right-0 box-border"> 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" <button hover-class="none"
@@ -171,9 +171,10 @@
import {uploadImage } from '@/app/api/system' import {uploadImage } from '@/app/api/system'
import { redirect } from '@/utils/common'; import { redirect } from '@/utils/common';
import dayjs from 'dayjs' import dayjs from 'dayjs'
import { checkBtnPermission } from '@/utils/auth';
import useMemberStore from '@/stores/member' import useMemberStore from '@/stores/member'
import { img } from '@/utils/common' import { img } from '@/utils/common'
import usePermission from '@/utils/usePermission'
const { hasPermission } = usePermission()
interface FileItem { interface FileItem {
url: string; url: string;
status?: string; status?: string;
@@ -386,10 +387,7 @@
// 保存 // 保存
const handSave = async() => { const handSave = async() => {
const hasPermission = await checkBtnPermission(memberStore.btnPermission, 'erp_outbound_return_add')
if (!hasPermission) return
if (loading.value) return if (loading.value) return
if (!formData.value.supplier_id) { if (!formData.value.supplier_id) {
uni.showToast({ icon: 'none', title: t('supplierIdPlaceholder') }) uni.showToast({ icon: 'none', title: t('supplierIdPlaceholder') })
return false; return false;
@@ -416,7 +414,7 @@
addReturn(formData.value).then((res : any) => { addReturn(formData.value).then((res : any) => {
loading.value = false loading.value = false
if (res.code == 1) { if (res.code == 1) {
redirect({ url: '/addon/erp/pages/purchase/return/list' }) redirect({ url: '/addon/erp/pages/index' })
} }
}).catch((err) => { }).catch((err) => {
// 如果是4001没有绑定企业账号强制跳转绑定 // 如果是4001没有绑定企业账号强制跳转绑定

View File

@@ -56,11 +56,11 @@
</view> </view>
<view class="foot border-0 border-t-1 border-solid border-[#ddd]"> <view class="foot border-0 border-t-1 border-solid border-[#ddd]">
<view class="flex justify-end p-[20rpx]"> <view class="flex justify-end p-[20rpx]">
<view><up-button v-if="item.status == 0" size="mini" :customStyle="{padding: 0,width: '130rpx',height: '50rpx',marginRight:'20rpx',fontSize:'20rpx'}" type="primary" text="通过" @click="handleOperateOrder(item,'audit')"></up-button></view> <view v-if="hasPermission('erp_manual_return_updateStatus')" ><up-button v-if="item.status == 0" size="mini" :customStyle="{padding: 0,width: '130rpx',height: '50rpx',marginRight:'20rpx',fontSize:'20rpx'}" type="primary" text="通过" @click="handleOperateOrder(item,'audit')"></up-button></view>
<view><up-button v-if="item.status == 0" size="mini" :customStyle="{padding: 0,width: '130rpx',height: '50rpx',marginRight:'20rpx',fontSize:'20rpx'}" type="error" text="拒绝" @click="handleOperateOrder(item,'notAudit')"></up-button></view> <view v-if="hasPermission('erp_manual_return_updateStatus')" ><up-button v-if="item.status == 0" size="mini" :customStyle="{padding: 0,width: '130rpx',height: '50rpx',marginRight:'20rpx',fontSize:'20rpx'}" type="error" text="拒绝" @click="handleOperateOrder(item,'notAudit')"></up-button></view>
<view><up-button v-if="item.status == 1" size="mini" :customStyle="{padding: 0,width: '130rpx',height: '50rpx',marginRight:'20rpx',fontSize:'20rpx'}" type="primary" text="确认退货" @click="handleOperateOrder(item,'storage')"></up-button></view> <view v-if="hasPermission('erp_manual_return_confirm')" ><up-button v-if="item.status == 1" size="mini" :customStyle="{padding: 0,width: '130rpx',height: '50rpx',marginRight:'20rpx',fontSize:'20rpx'}" type="primary" text="确认退货" @click="handleOperateOrder(item,'storage')"></up-button></view>
<view><up-button v-if="item.status == 1" size="mini" :customStyle="{padding: 0,width: '130rpx',height: '50rpx',marginRight:'20rpx',fontSize:'20rpx'}" type="error" text="拒绝退货" @click="handleOperateOrder(item,'notStorage')"></up-button></view> <view v-if="hasPermission('erp_manual_return_confirm')" ><up-button v-if="item.status == 1" size="mini" :customStyle="{padding: 0,width: '130rpx',height: '50rpx',marginRight:'20rpx',fontSize:'20rpx'}" type="error" text="拒绝退货" @click="handleOperateOrder(item,'notStorage')"></up-button></view>
<view><up-button v-if="item.status == 1" size="mini" :customStyle="{padding: 0,width: '130rpx',height: '50rpx',marginRight:'20rpx',fontSize:'20rpx'}" type="error" text="撤销审核" @click="handleOperateOrder(item,'backout')"></up-button></view> <view v-if="hasPermission('erp_manual_return_anti')" ><up-button v-if="item.status == 1" size="mini" :customStyle="{padding: 0,width: '130rpx',height: '50rpx',marginRight:'20rpx',fontSize:'20rpx'}" type="error" text="撤销审核" @click="handleOperateOrder(item,'backout')"></up-button></view>
<view><up-button size="mini" :customStyle="{padding: 0,width: '130rpx',height: '50rpx',marginRight:'10rpx'}" type="success" :text="'详情'" @click="redirect({ url: '/addon/erp/pages/purchase/return/detail',param:{id: item.id} })"></up-button></view> <view><up-button size="mini" :customStyle="{padding: 0,width: '130rpx',height: '50rpx',marginRight:'10rpx'}" type="success" :text="'详情'" @click="redirect({ url: '/addon/erp/pages/purchase/return/detail',param:{id: item.id} })"></up-button></view>
</view> </view>
</view> </view>
@@ -98,7 +98,7 @@
placeholderStyle="color: #888" placeholder="请输入拒绝原因" /> placeholderStyle="color: #888" placeholder="请输入拒绝原因" />
</view> </view>
</up-modal> </up-modal>
<view class="fixed bottom-4 right-4 z-2"> <view v-if="hasPermission('erp_outbound_return_add')" class="fixed bottom-4 right-4 z-2">
<up-button @click="redirect({ url: '/addon/erp/pages/purchase/return/add'})" type="primary" shape="circle" <up-button @click="redirect({ url: '/addon/erp/pages/purchase/return/add'})" type="primary" shape="circle"
:customStyle="{borderRadius: '50%',padding: 0,width: '50px',height: '50px'}"> :customStyle="{borderRadius: '50%',padding: 0,width: '50px',height: '50px'}">
<u-icon size="30" color="#fff" name="plus-circle-fill"></u-icon> <u-icon size="30" color="#fff" name="plus-circle-fill"></u-icon>
@@ -117,9 +117,9 @@
import useMescroll from '@/components/mescroll/hooks/useMescroll.js'; import useMescroll from '@/components/mescroll/hooks/useMescroll.js';
import { getReturnList, getReturnStatus,updateReturnStatus,confirmReturned,antiReturnStatus} from '@/addon/erp/api/purchase'; import { getReturnList, getReturnStatus,updateReturnStatus,confirmReturned,antiReturnStatus} from '@/addon/erp/api/purchase';
import { onShow, onPageScroll, onReachBottom, onLoad } from '@dcloudio/uni-app'; import { onShow, onPageScroll, onReachBottom, onLoad } from '@dcloudio/uni-app';
import { checkBtnPermission } from '@/utils/auth';
import useMemberStore from '@/stores/member' import useMemberStore from '@/stores/member'
import usePermission from '@/utils/usePermission'
const { hasPermission } = usePermission()
const { downCallback, mescrollInit, getMescroll } = useMescroll(onPageScroll, onReachBottom); const { downCallback, mescrollInit, getMescroll } = useMescroll(onPageScroll, onReachBottom);
interface RetireItem { interface RetireItem {
id: number; id: number;
@@ -163,24 +163,14 @@
// 操作 // 操作
const handleOperateOrder= async(item:any,type:string)=>{ const handleOperateOrder= async(item:any,type:string)=>{
if (type === 'audit') { if (type === 'audit') {
const hasPermission = await checkBtnPermission(memberStore.btnPermission, 'erp_manual_return_updateStatus')
if (!hasPermission) return
auditOrderShow.value = true auditOrderShow.value = true
} else if (type === 'notAudit') { } else if (type === 'notAudit') {
const hasPermission = await checkBtnPermission(memberStore.btnPermission, 'erp_manual_return_updateStatus')
if (!hasPermission) return
notAuditOrderShow.value = true notAuditOrderShow.value = true
} else if (type === 'storage') { } else if (type === 'storage') {
const hasPermission = await checkBtnPermission(memberStore.btnPermission, 'erp_manual_return_confirm')
if (!hasPermission) return
storageOrderShow.value = true storageOrderShow.value = true
} else if (type === 'notStorage') { } else if (type === 'notStorage') {
const hasPermission = await checkBtnPermission(memberStore.btnPermission, 'erp_manual_return_confirm')
if (!hasPermission) return
notStorageOrderShow.value = true notStorageOrderShow.value = true
} else if (type === 'backout') { } else if (type === 'backout') {
const hasPermission = await checkBtnPermission(memberStore.btnPermission, 'erp_manual_return_anti')
if (!hasPermission) return
backoutOrderShow.value = true backoutOrderShow.value = true
} }
refuseReason.value="" refuseReason.value=""

View File

@@ -9,7 +9,7 @@ interface Member {
token: string | null token: string | null
info: any | null info: any | null
levelList: Array<any> | null levelList: Array<any> | null
btnPermission: Array<any> | null btnPermission: Array<any> | []
} }
const useMemberStore = defineStore('member', { const useMemberStore = defineStore('member', {
@@ -18,13 +18,14 @@ const useMemberStore = defineStore('member', {
token: uni.getStorageSync(import.meta.env.VITE_REQUEST_STORAGE_TOKEN_KEY), token: uni.getStorageSync(import.meta.env.VITE_REQUEST_STORAGE_TOKEN_KEY),
info: null, info: null,
levelList: null, levelList: null,
btnPermission:null btnPermission: uni.getStorageSync('wap_member_btn_permission') || []
} }
}, },
actions: { actions: {
setToken(token: string, callback: any = null) { setToken(token: string, callback: any = null) {
this.token = token this.token = token
setToken(token) setToken(token)
this.getUserBtnRole()
this.getMemberInfo(callback) this.getMemberInfo(callback)
}, },
getMemberInfo(callback: any = null) { getMemberInfo(callback: any = null) {
@@ -75,12 +76,13 @@ const useMemberStore = defineStore('member', {
isRedirect && redirect({ url: '/app/pages/index/index', mode: 'switchTab' }) isRedirect && redirect({ url: '/app/pages/index/index', mode: 'switchTab' })
}) })
}, },
// 获取用户按钮权限
getUserBtnRole() { getUserBtnRole() {
getUserRole().then((res:any) => { getUserRole().then((res:any) => {
this.btnPermission = res.data; this.btnPermission = Object.values(res.data)
uni.setStorageSync('wap_member_btn_permission', this.btnPermission) uni.setStorageSync('wap_member_btn_permission', this.btnPermission)
}).catch((err) => { }).catch((err) => {
this.btnPermission=null this.btnPermission = []
uni.removeStorageSync('wap_member_btn_permission'); uni.removeStorageSync('wap_member_btn_permission');
// 如果是4001没有绑定企业账号强制跳转绑定 // 如果是4001没有绑定企业账号强制跳转绑定
if (err.code == 4001) { if (err.code == 4001) {

View File

@@ -15,38 +15,6 @@ export function checkNeedLogin(route : AnyObject) {
}, 100) }, 100)
} }
} }
/**
* 功能操作权限检查
* @param {string | Array} requiredPermissions 需要检查的权限列表或单个权限
* @param {boolean} [hasMsg=true] 是否显示提示信息
* @param {string} [msg='您没有权限执行此操作'] 提示信息
* @returns {Promise<boolean>}
*/
export async function checkBtnPermission(permissions : any, requiredPermissions : any, hasMsg : boolean = true, msg : any = '你没有权限执行此操作') : Promise<boolean> {
if (!requiredPermissions) {
uni.showToast({ title: '需要检查的权限列表或单个权限不能为空', icon: 'none' })
return false
}
if (!Array.isArray(requiredPermissions)) {
requiredPermissions = [requiredPermissions]
}
if (!Array.isArray(permissions)) {
uni.showToast({ title: '权限错误', icon: 'none' })
return false
}
if (permissions.length === 0) {
return true
}
// 假设 permissions 是一个包含用户所有权限的数组
if (requiredPermissions.every((permission : any) => permissions.includes(`${permission}`))) {
// 有权限,继续执行后续逻辑
return true
} else {
// 没有权限,显示提示信息并终止执行
if (hasMsg) uni.showToast({ title: msg, icon: 'none' })
return false
}
}
// 检查并请求授权 // 检查并请求授权
export function checkAndRequestAuth() { export function checkAndRequestAuth() {
// scope.camera 摄像头 // scope.camera 摄像头

View File

@@ -0,0 +1,20 @@
import useMemberStore from '@/stores/member'
import { storeToRefs } from 'pinia'
import { computed } from 'vue'
export default function usePermission() {
const { btnPermission } = storeToRefs(useMemberStore())
const checkPermission = (code: string | string[]) => {
if (!btnPermission.value?.length) return false
return Array.isArray(code)
? code.some(c => btnPermission.value?.includes(c))
: btnPermission.value.includes(code)
}
const hasPermission = computed(() => (code: string | string[]) => {
return checkPermission(code)
})
return {
checkPermission,
hasPermission
}
}