diff --git a/env/env.development.js b/env/env.development.js index 1894dbe..deb8a5b 100644 --- a/env/env.development.js +++ b/env/env.development.js @@ -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 + } \ No newline at end of file diff --git a/http/api/shopPagePermission.js b/http/api/shopPagePermission.js new file mode 100644 index 0000000..6bf5ac7 --- /dev/null +++ b/http/api/shopPagePermission.js @@ -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 + } + }) +} diff --git a/pageStaff/addstaff.vue b/pageStaff/addstaff.vue index 71656b3..fd519d2 100644 --- a/pageStaff/addstaff.vue +++ b/pageStaff/addstaff.vue @@ -44,6 +44,13 @@ {{datas.rolesdata }} + 收银机权限设置 + + + + 员工权限设置 {{item.label}} @@ -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) }