增加员工收银权限设置
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user