增加员工权限校验

This commit is contained in:
gyq 2024-10-21 13:48:57 +08:00
parent 9d73a49a06
commit db8c41fd16
7 changed files with 126 additions and 47 deletions

View File

@ -1,4 +1,5 @@
import request from "@/utils/request.js";
import { ElMessage } from "element-plus";
export function login(data) {
return request({
@ -50,3 +51,31 @@ export function queryShopInfo() {
},
});
}
/**
* 查询员工是否拥有权限
* @param {*} params
* @returns
*/
export async function staffPermission(code) {
let userInfo = JSON.parse(localStorage.getItem("userInfo"));
if (userInfo.isStaff) {
const res = await request({
method: "get",
url: "/staffPermission",
params: {
staffId: userInfo.staffId,
code: code,
},
});
if (res) {
return Promise.resolve();
} else {
ElMessage.error("无权操作");
return Promise.reject('无权操作');
}
} else {
return Promise.resolve();
}
}

View File

@ -25,7 +25,8 @@
</el-icon>
<el-text class="t">赠送</el-text>
</div>
<div class="item" :class="{ disabled: props.item.isPack == 'true' }" @click="giftPackHandle('isPack')">
<div class="item" :class="{ disabled: props.item.isPack == 'true' }" @click="giftPackHandle('isPack')"
v-if="JSON.parse(shopStore.info.eatModel).some(item => item == 'take-out')">
<el-icon class="icon">
<Box />
</el-icon>
@ -59,6 +60,10 @@
import { ref } from 'vue'
import takeFoodCode from '@/components/takeFoodCode.vue'
import skuModal from '@/components/skuModal.vue'
import { useShop } from '@/store/shop.js'
const shopStore = useShop()
const props = defineProps({
item: {
type: Object,

View File

@ -168,19 +168,15 @@ import { Search } from '@element-plus/icons-vue'
import { onMounted, ref } from 'vue'
import _ from 'lodash'
import useStorage from "@/utils/useStorage";
import skuModal from '@/components/skuModal.vue'
import { queryCategory, queryNewCommodityInfo, queryProductSku, productStatus, productStock } from '@/api/product'
import { useUser } from "@/store/user.js"
import { Swiper, SwiperSlide } from 'swiper/vue'
import "swiper/swiper-bundle.css";
import { staffPermission } from '@/api/user.js'
import { useGlobal } from '@/store/global.js'
const global = useGlobal()
const global = useGlobal()
const store = useUser()
@ -243,16 +239,21 @@ function showMoreMenu() {
}
// /
function showEditorChange() {
if (showEditor.value) {
showEditor.value = false
goodsList.value.map(item => {
item.map(val => {
val.showMore = false
async function showEditorChange() {
try {
await staffPermission('yun_xu_xiu_gai_shang_pin')
if (showEditor.value) {
showEditor.value = false
goodsList.value.map(item => {
item.map(val => {
val.showMore = false
})
})
})
} else {
showEditor.value = true
} else {
showEditor.value = true
}
} catch (error) {
console.log(error);
}
}
@ -506,12 +507,21 @@ const goodEditorEmun = ref({
})
//
function goodEditor(item, t) {
goodEditorItem.value = item
if (item.isPauseSale == 1) {
} else {
goodEditorType.value = t
showGoodEditor.value = true
async function goodEditor(item, t) {
try {
if (t == 0) {
await staffPermission('yun_xu_shang_xia_jia_shang_pin')
} else if (t == 1) {
await staffPermission('yun_xu_shou_qing_shang_pin')
}
goodEditorItem.value = item
if (item.isPauseSale == 1) {
} else {
goodEditorType.value = t
showGoodEditor.value = true
}
} catch (error) {
console.log(error);
}
}
@ -544,9 +554,14 @@ async function closeSellHandle() {
const showPutaway = ref(false)
const showPutawayLoading = ref(false)
function showPutawayHandle(item) {
goodEditorItem.value = item
showPutaway.value = true
async function showPutawayHandle(item) {
try {
await staffPermission('yun_xu_shang_xia_jia_shang_pin')
goodEditorItem.value = item
showPutaway.value = true
} catch (error) {
console.log(error);
}
}
async function putawayHandle(item) {
@ -599,7 +614,7 @@ const goodsEditorStockItem = ref(0)
const showGoodsEditorStock = ref(false)
const goodsEditorStockNumber = ref(0)
const goodsEditorStockLoading = ref(false)
function goodStockNumberHandle(item) {
async function goodStockNumberHandle(item) {
// if (item.isDistribute == 0 && item.typeEnum == 'sku') {
// ElMessage({
// type: 'warning',
@ -612,10 +627,14 @@ function goodStockNumberHandle(item) {
// goodsEditorStockNumber.value = item.stockNumber
// showGoodsEditorStock.value = true
// }
goodsEditorStockItem.value = item
goodsEditorStockNumber.value = item.stockNumber
showGoodsEditorStock.value = true
try {
await staffPermission('yun_xu_xiu_gai_shang_pin_ku_cun')
goodsEditorStockItem.value = item
goodsEditorStockNumber.value = item.stockNumber
showGoodsEditorStock.value = true
} catch (error) {
console.log(error);
}
}
//

View File

@ -106,6 +106,8 @@ import receiptPrint from "@/components/lodop/receiptPrint.js";
import { useGlobal } from '@/store/global.js'
import { usePrint } from '@/store/print.js'
import { staffPermission } from '@/api/user.js'
const global = useGlobal()
const printStore = usePrint()
@ -156,15 +158,21 @@ const isPrint = ref(true);
const discountLoading = ref(false)
//
async function showStaffDiscountHandle() {
discountLoading.value = true
await getStaffDiscountAjax()
discountLoading.value = false
if (staffDiscount.value <= 0) {
ElMessage.error('暂无折扣,请稍后再试')
} else {
showStaffDiscount.value = true
try {
discountLoading.value = true
await staffPermission('yun_xu_da_zhe')
await getStaffDiscountAjax()
discountLoading.value = false
global.updateData(false)
if (staffDiscount.value <= 0) {
ElMessage.error('暂无折扣,请稍后再试')
} else {
showStaffDiscount.value = true
discountLoading.value = false
global.updateData(false)
}
} catch (error) {
discountLoading.value = false
console.log(error);
}
}

View File

@ -85,7 +85,8 @@
</div>
<div class="footer">
<div class="top">
<div class="left" @click="allSelectedHandle">
<div class="left" @click="allSelectedHandle"
v-if="JSON.parse(shopStore.info.eatModel).some(item => item == 'take-out')">
<div class="selected">
<div class="selected_round" v-if="!allSelected"></div>
<el-icon class="icon" v-else>
@ -94,6 +95,7 @@
</div>
<el-text class="t">打包({{ cartInfo.packAmount || 0 }})</el-text>
</div>
<div class="left" v-else></div>
<div class="num-wrap">
<!-- {{ cartInfo.productNum || 0 }}种商品 -->
<el-text>{{
@ -180,7 +182,7 @@ import {
createOrder,
} from "@/api/product";
import { queryShopInfo } from '@/api/user.js'
import { queryShopInfo, staffPermission } from '@/api/user.js'
//
import goods from "@/views/home/components/goods.vue";
@ -226,6 +228,7 @@ const pendingCartNum = ref(0);
async function createOrderHandle(t = 0) {
try {
createOrderLoading.value = true;
await staffPermission('yun_xu_xia_dan')
const res = await createOrder({
masterId: masterId.value,
shopId: store.userInfo.shopId,

View File

@ -59,7 +59,7 @@ import { onMounted, reactive, ref } from 'vue'
import { dayjs, ElMessage } from 'element-plus'
import { formatDecimal } from '@/utils/index'
import { returnFlow, memberqueryMemberAccount } from '@/api/member/index.js'
import { queryPwdInfo } from '@/api/user.js'
import { queryPwdInfo, staffPermission } from '@/api/user.js'
import takeFoodCode from "@/components/takeFoodCode.vue";
const memberId = ref('')
@ -111,10 +111,15 @@ const loading = ref(false)
const refundItem = ref({})
const formRef = ref(null)
function showRefundHandle(item) {
refundItem.value = item
form.amount = item.amount
showDialog.value = true
async function showRefundHandle(item) {
try {
await staffPermission('yun_xu_tui_kuan')
refundItem.value = item
form.amount = item.amount
showDialog.value = true
} catch (error) {
console.log(error);
}
}
// 线退

View File

@ -148,7 +148,7 @@
orderDetaildata.orderType != 'return' &&
(orderDetaildata.status == 'refund' ||
orderDetaildata.status == 'closed')
" type="primary" @click="recharge = true">退单</el-button>
" type="primary" @click="returnOrderHandle">退单</el-button>
</div>
<div class="orderbox_right_buttonbutton">
<el-button style="flex: 1" :loading="invoiceLoading" @click="invoiveHandle" v-if="
@ -324,7 +324,7 @@ import {
cloudPrinterprint,
sendMessage,
} from "@/api/order/index.js";
import { queryPwdInfo } from '@/api/user.js'
import { queryPwdInfo, staffPermission } from '@/api/user.js'
import add from "@/views/order/components/add.vue";
import cashTable from "@/views/order/components/cashTable.vue";
import { clearNoNum, formatDecimal } from "@/utils";
@ -385,6 +385,16 @@ function dateConfirm(time) {
asyncorderfindOrder();
}
// 退
async function returnOrderHandle() {
try {
await staffPermission('yun_xu_tui_kuan')
recharge.value = true
} catch (error) {
console.log(error);
}
}
// 线退
const isOnline = ref(true)
//