lilei 2 年之前
父节点
当前提交
cef76049f8

+ 0 - 9
api/employee.js

@@ -63,12 +63,3 @@ export const setManager = params => {
     method: 'POST'
   })
 }
-
-// 重置密码
-export const resetPSD = params => {
-  return request({
-    url: 'employee/restPWD',
-    data: params,
-    method: 'POST'
-  })
-}

+ 67 - 0
api/powerRole-md.js

@@ -0,0 +1,67 @@
+import request from './request';
+// 获取列表数据
+export const getPowerRoleList = params => {
+  let url = `mdrole/queryLike/${params.pageNo}/${params.pageSize}`
+  delete params.pageNo
+  delete params.pageSize
+  return request({
+    url: url,
+    data: params,
+    method: 'POST'
+  }).then( res => res)
+}
+
+// 改变权限状态接口 flag 0:禁用 1:启用
+export const updateEnableStatus = params => {
+  return request({
+    url: `mdrole/enable/${params.id}/${params.flag}`,
+    data: {},
+    method: 'get'
+  })
+}
+
+// 删除用户接口
+export const delectRolePower = params => {
+  return request({
+    url: `mdrole/delete/${params.id}`,
+    data: {},
+    method: 'get'
+  })
+}
+
+// 新增/编辑保存接口
+export const saveRolePower = params => {
+  return request({
+    url: 'mdrole/save',
+    data: params,
+    method: 'POST'
+  })
+}
+
+// 获取菜单树数据
+export const getMenuList = params => {
+  const url = `mdrole/findAllMenu/${params.id}`
+  return request({
+    url: url,
+    method: 'get'
+  })
+}
+
+// 保存权限分配
+export const addMenuPower = params => {
+  const url = `mdrole/saveRoleMenu`
+  return request({
+    url: url,
+    data: params,
+    method: 'post'
+  })
+}
+
+// 获取角色列表接口
+export const getRoleList = params => {
+  return request({
+    url: 'mdrole/findAll',
+    data: params,
+    method: 'POST'
+  })
+}

+ 5 - 5
api/xprh.js

@@ -2,7 +2,7 @@ import request from './request';
 // 门店认证
 export const xprhStoreApply = (params) => {
   return request({
-    url: `xprh/apply/create`,
+    url: `org/apply/create`,
     data: params,
     method: 'post'
   })
@@ -10,28 +10,28 @@ export const xprhStoreApply = (params) => {
 // 门店认证详情
 export const xprhStoreApplyDetail = (params) => {
   return request({
-    url: `xprh/findBySn/${params.sn}`,
+    url: `org/findBySn/${params.sn}`,
     method: 'get'
   })
 }
 // 查询用户最新申请
 export const xprhStoreApplyFindLast = (params) => {
   return request({
-    url: `xprh/apply/findLast/${params.contactPhone}`,
+    url: `org/apply/findLast/${params.contactPhone}`,
     method: 'get'
   })
 }
 // 已读
 export const xprhStoreApplyRead = (params) => {
   return request({
-    url: `xprh/apply/read/${params.sn}`,
+    url: `org/apply/read/${params.sn}`,
     method: 'get'
   })
 }
 // 查询汽配商
 export const xprhFindDealer = (params) => {
   return request({
-    url: `xprh/apply/findDealer/${params.inviteCode}`,
+    url: `org/apply/findDealer/${params.inviteCode}`,
     method: 'get'
   })
 }

+ 16 - 0
pages.json

@@ -97,6 +97,22 @@
                 "enablePullDownRefresh": false
             }
             
+        },{
+            "path" : "pages/storeManage/roleSetting/roleSetting",
+            "style" :                                                                                    
+            {
+                "navigationBarTitleText": "岗位权限",
+                "enablePullDownRefresh": false
+            }
+            
+        },{
+            "path" : "pages/storeManage/roleSetting/addRole",
+            "style" :                                                                                    
+            {
+                "navigationBarTitleText": "新增岗位",
+                "enablePullDownRefresh": false
+            }
+            
         },{
             "path" : "pages/stockQuery/stockQuery",
             "style" :                                                                                    

+ 1 - 1
pages/digitalShelf/tempOrderList/tempOrderList.vue

@@ -61,7 +61,7 @@
 
 <script>
 	import carNo from '@/components/carNo.vue'
-	import { getShelfTempBillList, shelfGetTotalWaitQty, shelfTempTotalWaitQty } from '@/api/shelf.js'
+	import { getShelfTempBillList, shelfTempTotalWaitQty } from '@/api/shelf.js'
 	import moment from 'moment'
 	export default {
 		components: {carNo},

+ 5 - 0
pages/morePage/morePage.vue

@@ -48,6 +48,11 @@
 					<text slot="icon"></text>
 				</u-cell-item>
 			</u-cell-group>
+			<u-cell-group :border="false">
+				<u-cell-item title="岗位权限" @click="toPage('/pages/storeManage/roleSetting/roleSetting')" :title-style="{fontSize:'1em'}">
+					<text slot="icon"></text>
+				</u-cell-item>
+			</u-cell-group>
 		</view>
 		<view class="list-box" v-if="hasLogin&&dealerPhone">
 			<view class="list-title flex justify_center phone" @click="call">

+ 154 - 0
pages/storeManage/roleSetting/addRole.vue

@@ -0,0 +1,154 @@
+<template>
+	<view class="container">
+		<evan-form ref="formData" :rules="ruleValidate" :model="formData">
+			<evan-form-item label="角色名称" prop="name">
+				<input class="form-input" :maxlength="30" placeholder-class="form-input-placeholder" placeholder="请输入角色名称(最多30个字符)" v-model="formData.name" />
+			</evan-form-item>
+			<evan-form-item label="角色描述" prop="remarks">
+				<textarea placeholder-class="form-input-placeholder" :maxlength="500" placeholder="请输入描述(最多500个字符)" v-model="formData.remarks"/>
+			</evan-form-item>
+			<evan-form-item label="状态" prop="roleState">
+				<view style="width: 100%;display:flex;justify-content: flex-end;">
+					<u-radio-group v-model="formData.isEnable">
+						<u-radio 
+							v-for="(item, index) in list" :key="index" 
+							:name="item.value"
+							shape="circle"
+						>
+							{{item.name}}
+						</u-radio>
+					</u-radio-group>
+				</view>
+			</evan-form-item>
+			<view class="form-footer-btn">
+				<button  @click="cancel()">取消</button>
+				<button type="primary" :loading="loading" :style="{background:$config('buttonColors')}" @click="save('formData')">保存</button>
+			</view>
+		</evan-form>
+	</view>
+</template>
+
+<script>
+	import {saveRolePower} from '@/api/powerRole-md.js'
+	export default{
+		name:"formData",
+		data(){
+			return{
+				loading: false,
+				formData:{
+					name:'',
+					isEnable:'',
+					remarks:''
+				},
+				type: '', //  edit 编辑页  add  新增页
+				list: [
+					{
+						value: 1,
+						name: '启用',
+						disabled: false,
+					},
+					{
+						value: 0,
+						name: '禁用',
+						disabled: false
+						
+					}
+				],
+				ruleValidate: {
+					name: [
+						{ required: true, message: '请输入角色名称', trigger: 'change' },
+						{
+							validator: (rule, value, callback) => {
+								let reg = /^[^<|>]{1,30}$/
+								if(reg.test(value)){
+									callback()
+								}else{
+									callback(new Error('请输入不含<或>的字符,最多30个字符'))
+								}
+							}
+						}
+					],
+					isEnable: [
+						{
+						  required: true, type:'string',message: '请选择状态', trigger: 'blur'
+						}
+					],
+				},
+			}
+		},
+		onLoad(options) {
+			console.log(options)
+			this.type = options.type
+			uni.setNavigationBarTitle({
+				title: this.type=="add" ? '添加角色' : '编辑角色'
+			})
+			this.init()
+		},
+		methods:{
+			// 初始化数据
+			init(){
+				if(this.type=='edit'){
+					let data = this.$store.state.vuex_nowRoleInfo
+					console.log(data)	
+					this.formData.name = data.name
+					this.formData.isEnable = data.isEnable
+					this.formData.remarks = data.remarks || ''
+					this.formData.id = data.id
+				}else{
+					this.formData.name =''
+					this.formData.isEnable = 0
+					this.formData.remarks =''
+					this.formData.id  =''
+				}
+			},
+			// 保存
+			save(name){
+				let data=this.formData
+				this.formData.isEnable = String(this.formData.isEnable)
+				console.log(data)
+				this.$refs[name].validate((valid) => {
+				  if (valid) {
+					this.loading = true
+					saveRolePower(data).then(res=>{
+						// console.log(res)
+						if(res.status == 200){
+							uni.showToast({icon: 'none', title: res.message})
+							this.cancel()
+						}else{
+							uni.showToast({icon: 'none', title: res.message})
+						}
+						this.loading = false
+					}).catch(err=>{
+						this.loading = false
+					})
+				}
+				})
+			},
+			// 取消
+			cancel(){
+				setTimeout(function(){
+					uni.navigateBack()
+				}, 300)
+			}
+		}
+	}
+</script>
+
+<style lang="less">
+	page{
+		height: 100%;
+		background: #FFFFFF;
+	}
+	.container{
+		margin: 0 30rpx;
+		.form-input-placeholder{
+			text-align: right;
+		}
+		textarea {
+			text-align: right;
+			margin: 20upx;
+			height: 100upx;
+			width: 95%;
+		}
+	}
+</style>

+ 201 - 0
pages/storeManage/roleSetting/roleAuthSet.vue

@@ -0,0 +1,201 @@
+<template>
+	<view class="auth_page">
+		<view class="auth_list">
+			<view class="leve_0" v-if="authList.length" v-for="(item,index) in authList" :key="item.id">
+				<view class="leve_1">
+					<label @click="checkParent(item)">
+					<checkbox :value="String(item.id)" :checked="item.checked" /> {{item.name}}
+					</label>
+				</view>
+				<view>
+					<checkbox-group :data-pid="String(item.id)" class="leve_2" @change="checkboxChange">
+						<label class="leve_3" v-for="citem in item.children" :key="citem.id">
+							<checkbox :value="String(citem.id)" :checked="citem.checked" /> 
+							{{citem.name}}
+						</label>
+					</checkbox-group>
+				</view>
+			</view>
+		</view>
+		<view class="form-footer-btn">
+			<button type="primary" :style="{background:$config('buttonColors')}" :disabled="loading" :loading="loading" @click="handleSubmit()">保存</button>
+		</view>
+	</view>
+</template>
+
+<script>
+	import { getMenuList, addMenuPower } from '@/api/powerRole-md.js'
+	export default {
+		data() {
+			return {
+				id:'',
+				menuData: {},
+				authList: [], // app 权限菜单
+				checkedIds: [[],[],[]], // 已选的ids
+				loading: false
+			}
+		},
+		onLoad(options) {
+			this.id = options.id
+			this.getMenuList()
+		},
+		methods: {
+			// 获取菜单树列表
+			getMenuList () {
+			  let _this = this
+			  getMenuList({id: this.id}).then(res => {
+			    if (res.status == 200) {
+			       _this.menuData = res.data
+			       if (_this.menuData.role.menuIds) {
+			         const arr = _this.menuData.role.menuIds.split(',')
+			         // 勾选已选的
+			         _this.findLeaf(_this.menuData.allMenuList, arr)
+					 _this.getIds(_this.menuData.allMenuList[0].children,0)
+					 _this.getIds(_this.menuData.allMenuList[1].children,1)
+			       }
+				   // app 菜单
+				   _this.authList = _this.menuData.allMenuList[2].children
+			    }
+				console.log(_this.menuData,'_this.menuData')
+			  })
+			},
+			// 勾选已选的
+			findLeaf (data, arr) {
+			  for (let i = 0; i < data.length; i++) {
+			    const node = data[i]
+			    const hasNode = this.hasSelNode(node.id, arr)
+				this.$set(node, 'checked', !!hasNode)
+			    if (node.children){
+			      this.$set(node, 'expand', !!hasNode)
+			      this.findLeaf(node.children, arr)
+			    }
+			  }
+			},
+			hasSelNode (id, arr){
+			  const hasNode = arr.find(item => {
+			    return item == id
+			  })
+			  return hasNode
+			},
+			// 获取选中的ids, index 那个菜单
+			getIds (data,index){
+			   let _this = this
+			   for (let i = 0; i < data.length; i++) {
+			     const node = data[i]
+			     if(node.checked){
+					 _this.checkedIds[index].push(node.id)
+				 }
+				 if (node.children){
+				   _this.getIds(node.children,index)
+				 }
+			   }
+			},
+			// 选择一级菜单
+			checkParent(item){
+				console.log(item)
+				if(item.children){
+					item.children.map(k=>{
+						this.$set(k, 'checked', !item.checked)
+					})
+				}
+				this.$set(item, 'checked', !item.checked)
+			},
+			// 选择复选框
+			checkboxChange(e){
+				console.log(e)
+				let pid = e.currentTarget.dataset.pid
+				let ids = e.detail.value
+				let pc = this.authList.find(item=> item.id == pid)
+				if(pc.children&&pc.children.length){
+					 pc.children.map(k=>{
+						 this.$set(k, 'checked', !!ids.find(a=>a==k.id))
+					 })
+				}
+				this.$set(pc, 'checked', ids.length>0)
+			},
+			// 保存提交
+			handleSubmit () {
+			  const _this = this
+			  // 获取已选的项
+			  this.checkedIds[2] = []
+			  this.getIds(this.authList,2)
+			  if (this.checkedIds[2].length == 0) {
+				uni.showToast({
+					icon: 'none',
+					title:  '请先选择菜单'
+				})
+			    return false
+			  }
+			  let checkeNodes = []
+			  checkeNodes = checkeNodes.concat(this.checkedIds[0])
+			  checkeNodes = checkeNodes.concat(this.checkedIds[1])
+			  checkeNodes = checkeNodes.concat(this.checkedIds[2])
+			  console.log(checkeNodes, 'checkeNodes')
+			  uni.showLoading({
+			  	title: "正在提交..."
+			  })
+			  this.loading = true
+			  addMenuPower({ id: this.id, menuIds: checkeNodes.join(',') }).then(res => {
+			    console.log(res, 'res--save')
+				uni.showToast({
+					icon: 'none',
+					title:  res.message
+				})
+			    if (res.status + '' === '200') {
+			      setTimeout(function () {
+			        _this.cancel()
+			      }, 300)
+			    }
+				uni.hideLoading()
+				this.loading = false
+			  })
+			},
+			cancel(){
+				uni.navigateBack()
+			}
+		},
+	}
+</script>
+
+<style lang="scss">
+	page{
+		height: 100%;
+		background: #FFFFFF;
+	}
+	.auth_page{
+		display: flex;
+		flex-direction: column;
+		height: 100%;
+		.auth_list{
+			flex-grow: 1;
+			overflow: auto;
+			height: 100%;
+			.leve_0{
+				padding:0 20upx;
+				margin-top: 20upx;
+				.leve_1{
+					padding: 15upx;
+					border-bottom: 1px solid #eee;
+					uni-label{
+						display: block;
+					}
+				}
+				.leve_2{
+					padding: 10upx 10upx 10upx 0;
+					display: flex;
+					flex-wrap: wrap;
+					.leve_3{
+						margin: 20upx 5%;
+					}
+				}
+			}
+		}
+		.form-footer-btn{
+			margin: 20upx;
+			uni-button{
+				font-size: 30upx;
+			}
+		}
+	}
+	
+</style>

+ 181 - 0
pages/storeManage/roleSetting/roleSetting.vue

@@ -0,0 +1,181 @@
+<template>
+	<view class="container">
+		<view class="md-scroll">
+		 <view class="roleContent" v-for="(item,index) in roleList" :key="item.id">
+		 	<view class="roleItem">
+		 		<view style="width: 80%;">{{item.name}}</view>
+		 		<view @click="editItem(item)">
+		 			<u-icon size="34" name="edit-pen"></u-icon>
+		 		</view>
+		 	</view>
+		 </view>
+		 <view style="padding:0 30upx 30upx;">
+			 <u-empty :src="`/static/nodata.png`" icon-size="180" :text="noDataText" img-width="120" v-if="roleList.length==0 && status!='loading'" mode="list"></u-empty>
+			 <u-loadmore v-if="(total>=roleList.length&&roleList.length)||status=='loading'" :status="status" />
+		 </view>
+		</view>
+	</view>
+</template>
+
+<script>
+	import { getPowerRoleList,delectRolePower, updateEnableStatus } from '@/api/powerRole-md.js'
+	import { clzConfirm } from '@/libs/tools.js'
+	export default{
+		data(){
+			return{
+				status: 'loadmore',
+				noDataText: '暂无数据',
+				// 查询参数
+				queryParam: {
+				  name: '',
+				  isEnable: ''
+				},
+				pageSize: 100,
+				pageNo: 1,
+				roleList:[],
+				checked:true,
+				nowId: '',	 // 当前员工 id
+				loading:false,
+				total:''	// 获取数据总数
+			}
+		},
+		onLoad() {
+		},
+		onShow() {
+			this.pageNo = 1
+			this.getRoleList()
+		},
+		// 下一页
+		onReachBottom() {
+			console.log('next page')
+			if(this.roleList.length < this.total){
+				this.pageNo += 1
+				this.getRoleList()
+			}else{
+				this.status = "nomore"
+			}
+		},
+		methods:{
+			// 获取列表数据
+			getRoleList(){
+				let _this = this
+				this.status = "loading"
+				 getPowerRoleList(Object.assign({pageNo: this.pageNo, pageSize: this.pageSize}, this.queryParam)).then(res => {
+				   if (res.code == 200 || res.status == 204 || res.status == 200) {
+				     if(_this.pageNo>1){
+				   	  _this.roleList = _this.roleList.concat(res.data.list || [])
+				     }else{
+				   	  _this.roleList = res.data.list || []
+				     }
+				     _this.total = res.data.count || 0
+					 _this.roleList.map(item => {
+					 	item.roleState = item.isEnable == 1
+					 })
+				   } else {
+				     _this.roleList = []
+				     _this.total = 0
+				     _this.noDataText = res.message
+				   }
+				   _this.status = "loadmore"
+				 })
+			},
+			//  更改启用禁用状态
+			roleStatusChange(item,index){
+				const data={
+					id:item.id,
+					flag: item.roleState == true ? 1 :0
+				}
+				updateEnableStatus(data).then(res=>{
+					if(res.status==200){
+						item.roleState = data.flag == 1
+						this.roleList.splice(index,1,item)
+						console.log(this.roleList,data)
+					}
+					uni.showToast({icon: 'none', title: res.message})
+				})
+			},
+			// 添加角色
+			add(){
+				uni.navigateTo({
+					url:'/pages/roleSetting/addRole?type=add'
+				})
+			},
+			// 删除角色
+			delItem(item,index){
+				let _this = this
+				clzConfirm({
+					title: "提示",
+					content: "数据删除后无法恢复, 确认删除吗?",
+					showCancel: true,
+					success: function(e){
+						if(e.confirm||e.index == 0){
+							// 删除数据
+							delectRolePower({id: item.id}).then(res=>{
+								if(res.status == 200){
+									uni.showToast({
+										icon:'none',
+										title:res.message
+									})
+									if(_this.roleList.length>_this.pageSize){
+										// 刷新列表
+										_this.roleList.splice(index,1)
+									}else{
+										_this.pageNo = 1
+									}
+									_this.total = _this.roleList.length
+								}else{
+									uni.showToast({icon: 'none', title: res.message})
+								}
+							})
+						}
+					},
+				})
+			},
+			// 编辑修改
+			editItem(item){
+				this.$store.state.vuex_nowRoleInfo=item
+				uni.navigateTo({
+					url:'/pages/storeManage/roleSetting/addRole?type=edit'
+				})
+			},
+			// 设置权限
+			setAuths(item){
+				uni.navigateTo({
+					url:'/pages/storeManage/roleSetting/roleAuthSet?id='+item.id
+				})
+			},
+			// 返回
+			goBack(){
+				uni.navigateBack()
+			},
+		}
+	}
+</script>
+
+<style lang="less" scoped>
+	.container{
+		width:100%;
+		.md-scroll{
+			flex-grow: 1;
+			overflow: auto;
+			.roleContent{
+				background-color: #fff;
+				font-size: 28upx;
+				margin: 20rpx;
+				border-radius: 20upx;
+				box-shadow: 1px 1px 3px #EEEEEE;
+				.roleItem{
+					padding:35upx 30upx;
+					color: #666;
+					border-bottom: 1px dashed #F8F8F8;
+					display: flex;
+					justify-content: space-between;
+					align-items: center;
+				}
+				.uni-icons{
+					margin-right: 6upx;
+				}
+			}
+		}
+	}
+</style>

+ 4 - 2
store/index.js

@@ -49,7 +49,8 @@ const store = new Vuex.Store({
 		vuex_shelfChoosePart: [], // 数字货架临配选择配件
 		vuex_allLookUp: [],  //  数据字典
 		vuex_paymentTypeList: [], // 支付方式
-		vuex_userInfo: null,
+		vuex_userInfo: null, // 用户信息
+		vuex_permCodes: [], // 权限码
 		vuex_openid: "",
 		vuex_nowStaffData: null, // 员工临时数据
 		vuex_vinScanNums:null, // 扫描次数
@@ -65,9 +66,10 @@ const store = new Vuex.Store({
         login(state, data) {
 			console.log(data,'-----loginSucees-----')
             state.hasLogin = true;
-			state.vuex_userInfo = data.auth_user
+			state.vuex_userInfo = data.auth_user;
 			// VISITOR:游客,EMPLOYEE:雇员
 			data.auth_user['identifyType'] = data.sysUserFlag == '0' ? 'VISITOR' : 'EMPLOYEE';
+			data.auth_user['sysUserFlag'] = data.sysUserFlag;
 			uni.setStorageSync('token', data.access_token);
 			uni.setStorageSync('userInfo', data.auth_user);
         },