lilei il y a 2 ans
Parent
commit
6b0c319390

+ 1 - 1
api/login.js

@@ -6,7 +6,7 @@ export const wxlogin = params => {
     url: 'auth/wxlogin',
     data: params,
     method: 'post'
-  })
+  },true)
 };
 // 获取openid
 export const code2Session = params => {

+ 24 - 1
main.js

@@ -9,7 +9,30 @@ Vue.config.productionTip = false
 let vuexStore = require("@/store/$u.mixin.js")
 Vue.mixin(vuexStore)
 
-App.mpType = 'app'
+App.mpType = 'mini'
+
+/**
+ * 权限检查
+ */
+Vue.prototype.$hasPermissions = function (value) {
+ let isExist = false;
+ if(!store.state.hasLogin){
+	 return true
+ }
+ let permissionsStr = uni.getStorageSync('permCodes');
+ // console.log(permissionsStr)
+ if (permissionsStr == undefined || permissionsStr == null || !permissionsStr) {
+  return false;
+ }
+ let has = permissionsStr.find(item => {
+   return item == value
+ })
+ if (has) {
+  isExist = true;
+ }
+ return isExist;
+}
+
 /*
 * 打电话
 */ 

+ 0 - 1
pages/index/index.vue

@@ -22,7 +22,6 @@
 				<view><u-icon name="volume" color="#f2a557" :size="28" :margin-right='15'></u-icon> 您有待取货的货架订单哦!</view> <text class="text">立即处理>></text>
 			</view>
 			<!-- 门店审核不通过 -->
-			{{storeApply.auditStatus=='REFUSE'&&storeApply.readFlag=='0'}}
 			<view class="notices flex align_center" v-if="storeApply.auditStatus=='REFUSE'&&storeApply.readFlag=='0'">
 				<view><u-icon name="volume" color="#f2a557" :size="28" :margin-right='15'></u-icon> 门店认证资料审核不通过,请重新提交审核!</view> <text class="text" @click="toKnow">知道了</text>
 			</view>

+ 12 - 12
pages/morePage/morePage.vue

@@ -1,55 +1,55 @@
 <template>
 	<view class="morePages">
-		<view class="list-box">
+		<view class="list-box" v-if="$hasPermissions('M_stockQueryList_mini')||$hasPermissions('M_stockPut_mini')">
 			<view class="list-title">
 				<u-icon size="38" name="bag"></u-icon> <text>货品管理</text>
 			</view>
 			<u-cell-group :border="false">
-				<u-cell-item title="库存查询" @click="toPage('/pages/stockQuery/stockQuery')" :title-style="{fontSize:'1em'}">
+				<u-cell-item title="库存查询" v-if="$hasPermissions('M_stockQueryList_mini')" @click="toPage('/pages/stockQuery/stockQuery')" :title-style="{fontSize:'1em'}">
 					<text slot="icon"></text>
 				</u-cell-item>
-				<u-cell-item title="补货记录" @click="toPage('/pages/digitalShelf/stockPut')" :title-style="{fontSize:'1em'}">
+				<u-cell-item title="补货记录" v-if="$hasPermissions('M_stockPut_mini')" @click="toPage('/pages/digitalShelf/stockPut')" :title-style="{fontSize:'1em'}">
 					<text slot="icon"></text>
 				</u-cell-item>
 			</u-cell-group>
 		</view>
-		<view class="list-box">
+		<view class="list-box" v-if="$hasPermissions('M_shelfOrder_mini')||$hasPermissions('M_tempShelfOrder_mini')">
 			<view class="list-title">
 				<u-icon size="34" name="order"></u-icon> <text>订单管理</text>
 			</view>
 			<u-cell-group :border="false">
-				<u-cell-item title="货架订单" @click="toPage('/pages/digitalShelf/orderList')" :title-style="{fontSize:'1em'}">
+				<u-cell-item title="货架订单" v-if="$hasPermissions('M_shelfOrder_mini')" @click="toPage('/pages/digitalShelf/orderList')" :title-style="{fontSize:'1em'}">
 					<text slot="icon"></text>
 				</u-cell-item>
-				<u-cell-item title="临配订单" @click="toPage('/pages/digitalShelf/tempOrderList/tempOrderList')" :title-style="{fontSize:'1em'}">
+				<u-cell-item title="临配订单" v-if="$hasPermissions('M_tempShelfOrder_mini')" @click="toPage('/pages/digitalShelf/tempOrderList/tempOrderList')" :title-style="{fontSize:'1em'}">
 					<text slot="icon"></text>
 				</u-cell-item>
 			</u-cell-group>
 		</view>
-		<view class="list-box">
+		<view class="list-box" v-if="$hasPermissions('M_settlementRecord_mini')||$hasPermissions('M_settlementManage_mini')">
 			<view class="list-title">
 				<u-icon size="36" name="rmb-circle"></u-icon> <text>结算管理</text>
 			</view>
 			<u-cell-group :border="false">
-				<u-cell-item title="结算记录" @click="toPage('/pages/digitalShelf/settlementRecord/settlementRecord')" :title-style="{fontSize:'1em'}">
+				<u-cell-item title="结算记录" v-if="$hasPermissions('M_settlementRecord_mini')" @click="toPage('/pages/digitalShelf/settlementRecord/settlementRecord')" :title-style="{fontSize:'1em'}">
 					<text slot="icon"></text>
 				</u-cell-item>
-				<u-cell-item title="付款结算" @click="toPage('/pages/digitalShelf/settlementManage/settlementManage')" :title-style="{fontSize:'1em'}">
+				<u-cell-item title="付款结算" v-if="$hasPermissions('M_settlementManage_mini')" @click="toPage('/pages/digitalShelf/settlementManage/settlementManage')" :title-style="{fontSize:'1em'}">
 					<text slot="icon"></text>
 				</u-cell-item>
 			</u-cell-group>
 		</view>
-		<view class="list-box">
+		<view class="list-box" v-if="$hasPermissions('M_employee_mini')||$hasPermissions('M_roleSetting_mini')">
 			<view class="list-title">
 				<u-icon size="32" name="home"></u-icon> <text>门店管理</text>
 			</view>
 			<u-cell-group :border="false">
-				<u-cell-item title="员工管理" @click="toPage('/pages/storeManage/personnel')" :title-style="{fontSize:'1em'}">
+				<u-cell-item title="员工管理" v-if="$hasPermissions('M_employee_mini')" @click="toPage('/pages/storeManage/personnel')" :title-style="{fontSize:'1em'}">
 					<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'}">
+				<u-cell-item title="岗位权限" v-if="$hasPermissions('M_roleSetting_mini')" @click="toPage('/pages/storeManage/roleSetting/roleSetting')" :title-style="{fontSize:'1em'}">
 					<text slot="icon"></text>
 				</u-cell-item>
 			</u-cell-group>

+ 61 - 3
pages/storeManage/addPerson.vue

@@ -21,26 +21,53 @@
 							</u-radio-group>
 						</view>
 					</evanFormItem>
+					<evanFormItem label="岗位" prop="roleNames">
+						<u-input type="select" style="width:100%" input-align="right" placeholder="请选择岗位" @click="showRoles=true" v-model="formData.roleNames"/>
+						<u-popup v-model="showRoles" mode="bottom">
+							<view style="padding: 1rem;width: 100%;">
+								<view style="position: relative;padding: 0.5rem;width: 100%;text-align: center;">
+									<text style="color:#066cff;position: absolute;left:0;top:0;">新增岗位</text>
+									选择岗位
+								</view>
+								<view v-if="roleList.length">
+									<u-radio-group v-model="formData.roleIds" @change="radioGroupChange">
+										<u-radio 
+											v-for="(item, index) in roleList" :key="item.id" 
+											:name="item.name"
+											:disabled="!item.isEnable"
+										>
+											{{item.name}}
+										</u-radio>
+									</u-radio-group>
+								</view>
+								<view style="color: #999;text-align: center;" v-else>
+									暂无岗位信息,请点击“新增岗位”
+								</view>
+							</view>
+						</u-popup>
+					</evanFormItem>
 				</evanForm>
 			</view>
 			<view class="form-footer-btn flex align_center justify_between">
-				<u-button shape="circle"  @click="cancel()" :custom-style="{width:'300rpx' }">取消</u-button>
+				<u-button shape="circle"  @click="delPerson()" :custom-style="{width:'300rpx' }">删除</u-button>
 				<u-button shape="circle" type="info" :custom-style="{ background: '#066cff', color: '#fff',width:'300rpx' }" @click="save('formData')">保存</u-button>
 			</view>
 	</view>
 </template>
 
 <script>
-	import {saveEmployee } from '@/api/employee'
+	import {saveEmployee, delEmployee } from '@/api/employee'
+	import { getRoleList } from '@/api/powerRole-md.js'
 	import evanForm from '@/components/evan-form/evan-form.vue'
 	import evanFormItem from '@/components/evan-form-item/evan-form-item.vue'
 	export default{
 		components:{
 			evanForm,
-			evanFormItem
+			evanFormItem,
 		},
 		data(){
 			return{
+				showRoles: false,
 				roleList: [],  //  角色  数据列表
 				roleArr: [],  //  当前所选角色
 				formData:{
@@ -52,6 +79,7 @@
 					name: [{ required: true, message: '请输入员工姓名'}],
 					mobile: [{required: true, min:11, message: '请输入正确手机号码'}],
 					sex: [{ required: true, message: '请选择性别' }],
+					roleNames: [{ required: true, message: '请选择岗位' }]
 				},
 				sexList: [
 					{
@@ -71,6 +99,7 @@
 		},
 		onLoad() {
 			this.init()
+			this.getRole()
 		},
 		methods:{
 			//  初始化数据
@@ -88,6 +117,15 @@
 					title: !!data ? "编辑员工" : '新增员工'
 				})
 			},
+			// 获取角色
+			getRole(){
+				getRoleList().then(res => {
+					this.roleList = res.data || []
+				})
+			},
+			radioGroupChange(e) {
+				console.log(e);
+			},
 			//  保存
 			save(name){
 				let data=this.formData
@@ -108,6 +146,26 @@
 				}
 				})
 			},
+			// 删除员工
+			delPerson(){
+				let _this = this
+				const item = this.formData
+				uni.showModal({
+					title: '提示',
+					content: '数据删除后无法恢复, 确认删除吗?',
+					success: (ret) => {
+					  if(ret.confirm||ret.index==0){
+						  // 删除数据
+						  delEmployee({id: item.id}).then(res=>{
+						  	if(res.status == 200){
+						  		this.cancel()
+						  	}
+						  	uni.showToast({icon: 'none', title: res.message})
+						  })
+					  }
+					}
+				})
+			},
 			cancel(){
 			 setTimeout(function(){
 				 uni.navigateBack()

+ 3 - 3
pages/storeManage/personnel.vue

@@ -50,13 +50,13 @@
 				swiperCurrent: 0,
 				// 查询条件
 				pageNo: 1,
-				pageSize: 10,
+				pageSize: 20,
 				list: [],
 				total: 0,
 			}
 		},
-		onLoad() {
-			this.getRow()
+		onShow() {
+			this.getRow(1)
 		},
 		// 判断员工身份权限
 		filters:{

+ 56 - 41
pages/storeManage/roleSetting/addRole.vue

@@ -1,24 +1,27 @@
 <template>
-	<view class="container">
-		<evan-form ref="formData" :rules="ruleValidate" :model="formData">
-			<evan-form-item prop="name">
-				<u-input class="form-input" :maxlength="30" style="width: 100%;" placeholder="请填写岗位名称(最多30个字符)" v-model="formData.name" />
-			</evan-form-item>
-			<view class="role-box">
-				<view>岗位权限:</view>
-				<roleAuthSet ref="roleSet"></roleAuthSet>
-			</view>
-			<view class="form-footer-btn flex align_center justify_center">
-				<u-button shape="circle" v-if="!formData.isEnable"  @click="delRole()" :custom-style="{width:'300rpx' }">删除</u-button>
-				<u-button shape="circle" type="info" :custom-style="{ background: '#066cff', color: '#fff',width:'300rpx',marginLeft:'20rpx' }" @click="save('formData')">保存</u-button>
-			</view>
-		</evan-form>
+	<view class="container flex flex_column">
+		<view style="flex-grow: 1;">
+			<evan-form ref="formData" :rules="ruleValidate" :model="formData">
+				<evan-form-item label="岗位名称:" prop="name">
+					<u-input class="form-input" :maxlength="30" style="width: 100%;" placeholder="请填写岗位名称(最多30个字符)" v-model="formData.name" />
+				</evan-form-item>
+				<view class="role-box flex">
+					<view style="color: #666;padding-top:0.5rem;"><text style="color:red;margin-right: 0.5rem;">*</text> 岗位权限:</view>
+					<view style="flex-grow: 1;">
+						<roleAuthSet ref="roleSet"></roleAuthSet>
+					</view>
+				</view>
+			</evan-form>
+		</view>
+		<view class="form-footer-btn flex align_center justify_center">
+			<u-button shape="circle" v-if="type=='edit'"  @click="delRole()" :custom-style="{width:'300rpx' }">删除</u-button>
+			<u-button shape="circle" type="info" :custom-style="{ background: '#066cff', color: '#fff',width:'300rpx',marginLeft:'20rpx' }" @click="save('formData')">保存</u-button>
+		</view>
 	</view>
 </template>
 
 <script>
 	import roleAuthSet from './roleAuthSet.vue'
-	import { clzConfirm } from '@/libs/tools.js'
 	import {saveRoleMenu, delectRolePower} from '@/api/powerRole-md.js'
 	export default{
 		name:"formData",
@@ -80,16 +83,23 @@
 					  this.loading = true
 					  const menusIds = this.$refs.roleSet.getSelMenu()
 					  console.log(menusIds,'menus--')
-					  const params = Object.assign(this.formData,menusIds)
-					  saveRoleMenu(this.formData).then(res=>{
-					  	if(res.status == 200){
-					  		this.cancel()
-					  	}
-					  	uni.showToast({icon: 'none', title: res.message})
-					  	this.loading = false
-					  }).catch(err=>{
-					  	this.loading = false
-					  })
+					  if(!menusIds){
+						  uni.showToast({
+						  	icon: 'none',
+						  	title:  '请先选择权限'
+						  })
+					  }else{
+						  const params = Object.assign(this.formData,menusIds)
+						  saveRoleMenu(this.formData).then(res=>{
+						  	if(res.status == 200){
+						  		this.cancel()
+						  	}
+						  	uni.showToast({icon: 'none', title: res.message})
+						  	this.loading = false
+						  }).catch(err=>{
+						  	this.loading = false
+						  })
+					  }
 				  }
 				})
 			},
@@ -97,21 +107,20 @@
 			delRole(){
 				let _this = this
 				const item = this.formData
-				clzConfirm({
-					title: "提示",
-					content: "数据删除后无法恢复, 确认删除吗?",
-					showCancel: true,
-					success: function(e){
-						if(e.confirm||e.index == 0){
-							// 删除数据
-							delectRolePower({id: item.id}).then(res=>{
-								if(res.status == 200){
-									this.cancel()
-								}
-								uni.showToast({icon: 'none', title: res.message})
-							})
-						}
-					},
+				uni.showModal({
+					title: '提示',
+					content: '数据删除后无法恢复, 确认删除吗?',
+					success: (ret) => {
+					  if(ret.confirm||ret.index==0){
+						  // 删除数据
+						  delectRolePower({id: item.id}).then(res=>{
+						  	if(res.status == 200){
+						  		this.cancel()
+						  	}
+						  	uni.showToast({icon: 'none', title: res.message})
+						  })
+					  }
+					}
 				})
 			},
 			// 取消
@@ -131,11 +140,17 @@
 	}
 	.container{
 		margin: 0 30rpx;
+		height: 100vh;
 		.form-input-placeholder{
 			text-align: right;
 		}
 		.role-box{
-			padding: 20rpx 0;
+			padding: 10rpx 0 20rpx 0;
+			flex-grow: 1;
+		}
+		.form-footer-btn{
+			padding: 20rpx;
+			background: #FFFFFF;
 		}
 	}
 </style>

+ 1 - 6
pages/storeManage/roleSetting/roleAuthSet.vue

@@ -113,10 +113,6 @@
 			  this.checkedIds[0] = []
 			  this.getIds(this.authList,0)
 			  if (this.checkedIds[0].length == 0) {
-				uni.showToast({
-					icon: 'none',
-					title:  '请先选择权限'
-				})
 			    return false
 			  }
 			  let checkeNodes = []
@@ -140,8 +136,7 @@
 			overflow: auto;
 			height: 100%;
 			.leve_0{
-				padding:0 20upx;
-				margin-top: 20upx;
+				padding:0;
 				.leve_1{
 					padding: 15upx;
 					border-bottom: 1px solid #eee;

+ 1 - 1
pages/storeManage/roleSetting/roleSetting.vue

@@ -11,7 +11,7 @@
 			 </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" />
+				 <!-- <u-loadmore v-if="(total>=roleList.length&&roleList.length)||status=='loading'" :status="status" /> -->
 			 </view>
 		</view>
 		<view class="footer">

+ 5 - 1
store/index.js

@@ -71,18 +71,22 @@ const store = new Vuex.Store({
 			// VISITOR:游客,EMPLOYEE:雇员
 			data.auth_user['identifyType'] = data.sysUserFlag == '0' ? 'VISITOR' : 'EMPLOYEE';
 			data.auth_user['sysUserFlag'] = data.sysUserFlag;
+			const permCodes = data.auth_user.permCodes.filter(item => item.indexOf("_mini")>=0);
 			uni.setStorageSync('token', data.access_token);
 			uni.setStorageSync('userInfo', data.auth_user);
+			state.vuex_permCodes = permCodes;
+			uni.setStorageSync('permCodes', permCodes);
         },
         logout(state) {
 			console.log(state,'----logout------')
             state.hasLogin = false;
 			uni.removeStorageSync('token')
 			uni.removeStorageSync('userInfo')
+			uni.removeStorageSync('permCodes')
 			state.vuex_userInfo = null
+			state.vuex_permCodes = null
         },
 		openId(state,id) {
-			console.log(id,'----openId------')
 			state.vuex_openid = id
 			uni.setStorageSync('openid', id);
 		},