增加员工收银权限设置
This commit is contained in:
parent
5e6646b574
commit
db05de04a5
|
|
@ -2,4 +2,5 @@ export default {
|
|||
'JEEPAY_BASE_URL': 'http://192.168.1.31/', // 请求URL(生产环境)
|
||||
'JEEPAY_BASE_URL_H5': 'http://192.168.1.31/',
|
||||
'JEEPAY_BASE_URL_WSS': 'ws://192.168.1.31:2348' ,// sockets
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
import http from '@/http/http.js'
|
||||
const request = http.request
|
||||
|
||||
/**
|
||||
* 获取所有页面路径
|
||||
* @returns
|
||||
*/
|
||||
export function getshopPagePermission(data, urlType = 'account') {
|
||||
return request({
|
||||
url: `${urlType}/admin/shopPagePermission`,
|
||||
method: "GET",
|
||||
data: {
|
||||
...data
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取员工拥有页面路径
|
||||
* @returns
|
||||
*/
|
||||
export function getshopPagePermissionDetail(data, urlType = 'account') {
|
||||
return request({
|
||||
url: `${urlType}/admin/shopPagePermission/detail`,
|
||||
method: "GET",
|
||||
data: {
|
||||
...data
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
@ -44,6 +44,13 @@
|
|||
<view @tap="show=true" style="height: 50rpx;font-size: 28rpx;color: #999999;margin-top: 24rpx;">{{datas.rolesdata }}</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="h7">收银机权限设置</view>
|
||||
<view class="contentBottom" style="display: flex;flex-wrap: wrap;">
|
||||
<up-checkbox shape='circle' :customStyle="{marginBottom: '8px',marginRight: '30rpx'}" v-model:checked="ele.hasPermission"
|
||||
usedAlone v-for="(ele, index) in datas.shopPagePermission" :key="index" :label="ele.name"
|
||||
:labelColor="ele.isImportant==1?'#e66c6d':''" style="margin-right: 40rpx;font-size: 28rpx;">
|
||||
</up-checkbox>
|
||||
</view>
|
||||
<view class="h7">员工权限设置</view>
|
||||
<view class="contentBottom" v-for="item in datas.permissions" :key="item.id">
|
||||
<view> {{item.label}} </view>
|
||||
|
|
@ -74,6 +81,7 @@
|
|||
import { shopStaffDetail,getShopStaffPermission,shopStaffAdd,shopStaffPut } from "@/http/api/staff.js"
|
||||
import { getShopPermission } from "@/http/api/index.js"
|
||||
import { getRoleList } from "@/http/api/role.js"
|
||||
import { getshopPagePermission, getshopPagePermissionDetail } from "@/http/api/shopPagePermission.js"
|
||||
|
||||
const props = defineProps({
|
||||
type: {
|
||||
|
|
@ -86,6 +94,7 @@
|
|||
let datas = reactive({
|
||||
formData: {
|
||||
shopPermissionIds: [],
|
||||
pagePathIdList: [],
|
||||
maxDiscountAmount: 0,
|
||||
discountType: 0
|
||||
},
|
||||
|
|
@ -93,7 +102,8 @@
|
|||
rolesList: [],
|
||||
permissions: [],
|
||||
columns: [],
|
||||
rolesdata: '请选择角色'
|
||||
rolesdata: '请选择角色',
|
||||
shopPagePermission: []
|
||||
})
|
||||
const columns = reactive([
|
||||
[]
|
||||
|
|
@ -111,6 +121,8 @@
|
|||
let res = await getShopPermission()
|
||||
datas.permissions = res
|
||||
Object.assign(datas.permissions, res)
|
||||
let resDetail = await getshopPagePermission()
|
||||
datas.shopPagePermission = resDetail
|
||||
if (props.type == 'edit') {
|
||||
uni.setNavigationBarTitle({
|
||||
title: '编辑员工'
|
||||
|
|
@ -118,6 +130,8 @@
|
|||
// 调用id查询接口和编辑接口
|
||||
getShopStaffDetail(props.id)
|
||||
getStaffPermission(props.id)
|
||||
getPagePermissionDetail(props.id)
|
||||
|
||||
} else {
|
||||
datas.isPassword = true;
|
||||
}
|
||||
|
|
@ -140,7 +154,6 @@
|
|||
*/
|
||||
function getStaffPermission(id) {
|
||||
getShopStaffPermission({id: id}).then((res2) => {
|
||||
|
||||
datas.permissions.forEach(ele => {
|
||||
ele.children.forEach(res => {
|
||||
res2.forEach(v => {
|
||||
|
|
@ -153,6 +166,20 @@
|
|||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取收银机权限列表列表
|
||||
*/
|
||||
function getPagePermissionDetail(id) {
|
||||
getshopPagePermissionDetail({staffId: id}).then((res2) => {
|
||||
datas.shopPagePermission.forEach(ele => {
|
||||
res2.forEach(v => {
|
||||
if (ele.id == v.id ) {
|
||||
ele.hasPermission = 1
|
||||
}
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户详情
|
||||
|
|
@ -184,26 +211,35 @@
|
|||
if(datas.permissions){
|
||||
datas.permissions.forEach(ele => {
|
||||
ele.children.forEach(res => {
|
||||
|
||||
if (res.hasPermission) {
|
||||
console.log(res)
|
||||
console.log(datas.formData.shopPermissionIds)
|
||||
res.hasPermission = 1
|
||||
datas.formData.shopPermissionIds.push(res.id)
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
if(datas.shopPagePermission){
|
||||
datas.shopPagePermission.forEach(ele => {
|
||||
if (ele.hasPermission) {
|
||||
ele.hasPermission = 1
|
||||
datas.formData.pagePathIdList.push(ele.id)
|
||||
}
|
||||
})
|
||||
}
|
||||
if ( !datas.isPassword ) {
|
||||
delete datas.formData.accountPwd;
|
||||
}
|
||||
let res;
|
||||
if( props.type == 'add'){
|
||||
res = await shopStaffAdd({...datas.formData})
|
||||
uni.$utils.showToast("添加成功")
|
||||
} else {
|
||||
res = await shopStaffPut({...datas.formData})
|
||||
uni.$utils.showToast("编辑成功")
|
||||
}
|
||||
go.back()
|
||||
setTimeout(()=>{
|
||||
uni.navigateBack()
|
||||
},1500)
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue