lilei 2 anni fa
parent
commit
677105b966

+ 0 - 7
api/employee.js

@@ -55,13 +55,6 @@ export const searchEmployee = params => {
     method: 'post'
   })
 }
-// 获取员工信息
-export const getEmployeeInfo = param => {
-  return request({
-    url: `zycar-mgr/employee/findByUserId/${param.id}`,
-    method: 'get'
-  })
-}
 // 设置为负责人setManager
 export const setManager = params => {
   return request({

+ 18 - 0
pages.json

@@ -158,6 +158,24 @@
             }
             
         }
+        ,{
+            "path" : "pages/storeManage/editIsManage",
+            "style" :                                                                                    
+            {
+                "navigationBarTitleText": "选择新负责人",
+                "enablePullDownRefresh": false
+            }
+            
+        }
+        ,{
+            "path" : "pages/storeManage/editAdminAuth",
+            "style" :                                                                                    
+            {
+                "navigationBarTitleText": "设置岗位",
+                "enablePullDownRefresh": false
+            }
+            
+        }
     ],
 	"subPackages":[{
 		"root": "pagesA",

+ 1 - 0
pages/index/index.vue

@@ -298,6 +298,7 @@
 					if(res.data){
 						this.$store.state.vuex_userInfo.userNameCN = res.data.name;
 						this.$store.state.vuex_userInfo.mobile = res.data.mobile;
+						this.$store.state.vuex_userInfo.adminId = res.data.id;
 						this.$store.state.vuex_userPhoto = res.data.photo;
 						uni.setStorageSync('userPhoto', res.data.photo);
 					}

+ 194 - 0
pages/storeManage/editAdminAuth.vue

@@ -0,0 +1,194 @@
+<template>
+	<view class="container flex flex_column">
+		<view class="md-scroll">
+			<view class="userInfo">
+				设置<text>{{userInfo.name}}</text>为新的负责人后,您将不再是门店负责人,
+				请为自己选择一个新的岗位
+			</view>
+			 <view class="check-order-list">
+				<u-radio-group wrap @change="radioGroupChange">
+					<u-radio 
+						v-model="item.checked" 
+						v-for="(item, index) in roleList" :key="item.id" 
+						:name="item.id"
+					>
+					<view class="u-name">
+						{{item.name}}
+					</view>
+					</u-radio>
+				</u-radio-group>
+			 </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>
+			 </view>
+		</view>
+		<view class="footer">
+			<u-button @click="save" :loading="loading" :throttle-time="100" :custom-style="{ background: '#066cff', color: '#fff',width:'400rpx' }" shape="circle" type="info">
+				确定
+			</u-button>
+		</view>
+	</view>
+</template>
+
+<script>
+	import { getPowerRoleList } from '@/api/powerRole-md.js'
+	import {saveEmployee,setManager} from '@/api/employee'
+	export default{
+		data(){
+			return{
+				status: 'loadmore',
+				noDataText: '暂无数据',
+				// 查询参数
+				queryParam: {
+				  name: '',
+				  isEnable: ''
+				},
+				formData:{},
+				pageSize: 100,
+				pageNo: 1,
+				roleList:[],
+				checked:true,
+				nowId: '',	 // 当前员工 id
+				loading:false,
+				total:''	,// 获取数据总数
+				userInfo: null,
+			}
+		},
+		onLoad(opts) {
+			this.userInfo = this.$store.state.vuex_nowStaffData
+			this.formData = Object.assign({},this.formData,this.userInfo)
+		},
+		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:{
+			radioGroupChange(e){
+				this.formData.roleIds = e;
+				const roleNames = this.roleList.find(item => item.id == e);
+				this.formData.roleNames = roleNames?roleNames.name:'';
+			},
+			// 获取列表数据
+			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"
+				 })
+			},
+			//  保存
+			save(name){
+				if(!this.formData.roleIds){
+					uni.showToast({icon: 'none', title: '请选择岗位'})
+				}else{
+					this.loading = true
+					// 先更换负责人
+					setManager({id: this.userInfo.id}).then(res => {
+					  console.log(res)
+					  if (res.status == 200){
+						  this.saveRole()
+					  }else{
+						  uni.showToast({
+						  	title:res.message
+						  })
+						  this.loading = false
+					  }
+					})
+				}
+			},
+			// 设置岗位
+			saveRole(){
+				saveEmployee(this.formData).then(res=>{
+					console.log(res)
+					if(res.status == 200){
+						uni.showToast({icon: 'none', title:'保存成功'})
+						this.quitOut()
+					}else{
+						uni.showToast({icon: 'none', title: res.message})
+					}
+					this.loading = false
+				})
+			},
+			quitOut(){
+				let _this = this
+				uni.showModal({
+					title: '提示',
+					content: '设置成功,需要重新登录!',
+					showCancel: false,
+					success: (ret) => {
+					  if(ret.confirm){
+						  _this.$store.dispatch('userLogout');
+						  uni.redirectTo({
+						  	 url: '/pages/login/login'
+						  });
+					  }
+					}
+				})
+			}
+		}
+	}
+</script>
+
+<style lang="less">
+	.container{
+		width:100%;
+		height: 100vh;
+		background: #ffffff;
+		.md-scroll{
+			flex-grow: 1;
+			overflow: auto;
+			.userInfo{
+				padding: 20upx 50upx;
+				text-align: center;
+				text{
+					color: coral;
+				}
+			}
+			.check-order-list{
+				padding: 10upx 20upx;
+				u-radio{
+					> view{
+						background: #ffffff;
+						border-radius: 20upx;
+						box-shadow: 1px 1px 3px #EEEEEE;
+						border:1px solid #eee;
+						margin: 10rpx 0;
+						padding: 20rpx;
+						>view:last-child{
+							flex-grow: 1;
+						}
+					}
+				}
+			}
+		}
+		.footer{
+			padding: 0.6rem;
+			background: #ffffff;
+		}
+	}
+</style>

+ 157 - 0
pages/storeManage/editIsManage.vue

@@ -0,0 +1,157 @@
+<template>
+	<view class="page-body flex flex_column">
+		<swiper class="scroll-list" :current="swiperCurrent">
+			<swiper-item class="swiper-item" style="height: 100%;width: 100%;overflow: hidden;">
+				<scroll-view scroll-y style="height: 100%;width: 100%;overflow: auto;" @scrolltolower="onreachBottom">
+					<view style="height: 20rpx;" ></view>
+					<view class="check-order-list">
+						 <u-radio-group wrap @change="radioGroupChange">
+						 	<u-radio 
+						 		v-model="item.checked" 
+						 		v-for="(item, index) in list" :key="item.userId" 
+						 		:name="item.userId"
+								v-if="item.isManager == 0"
+						 	>
+						 	<view class="u-name">
+						 		{{item.name}}/{{item.mobile}}
+						 	</view>
+						 	</u-radio>
+						 </u-radio-group>
+					 </view>
+					 <view style="padding:0 30upx 30upx;">
+						 <u-empty :src="`/static/nodata.png`" icon-size="180" :text="noDataText" img-width="120" v-if="list.length==0 && status!='loading'" mode="list"></u-empty>
+						 <u-loadmore v-if="(total>=list.length&&list.length)||status=='loading'" :status="status" />
+					 </view>
+				</scroll-view>
+			</swiper-item>
+		</swiper>
+		<view class="footer flex align_center justify_center">
+			<u-button @click="setNewAdmin()" :throttle-time="100" :custom-style="{ background: '#066cff', color: '#fff' }" shape="circle" type="info">
+				设为新负责人
+			</u-button>
+		</view>
+	</view>
+</template>
+
+<script>
+	import {searchEmployee} from '@/api/employee'
+	import moment from 'moment'
+	export default{
+		name:'personnel',
+		data(){
+			return{
+				status: 'loading',
+				noDataText: '暂无数据',
+				current: 0,
+				swiperCurrent: 0,
+				// 查询条件
+				pageNo: 1,
+				pageSize: 20,
+				list: [],
+				total: 0,
+				curPerson: null
+			}
+		},
+		onShow() {
+			this.getRow(1)
+		},
+		computed:{
+			userInfo(){
+				return this.$store.state.vuex_userInfo
+			},
+		},
+		methods:{
+			radioGroupChange(e){
+				console.log(e)
+				this.curPerson = e
+			},
+			// 查询列表
+			getRow (pageNo) {
+			  let _this = this
+			  if (pageNo) {
+			    this.pageNo = pageNo
+			  }
+			  
+			  let params = {
+			    pageNo:this.pageNo,
+			    pageSize:this.pageSize
+			  }
+			  this.status = "loading"
+			  searchEmployee(params).then(res => {
+				if (res.code == 200 || res.status == 204 || res.status == 200) {
+				  if(_this.pageNo>1){
+					  _this.list = _this.list.concat(res.data.list || [])
+				  }else{
+					  _this.list = res.data.list || []
+				  }
+				  _this.total = res.data.count || 0
+				} else {
+				  _this.list = []
+				  _this.total = 0
+				  _this.noDataText = res.message
+				}
+				 
+				_this.status = _this.total>=_this.list.length ? "nomore" : 'loadmore'
+			  })
+			},
+			// scroll-view到底部加载更多
+			onreachBottom() {
+				console.log(this.list.length, this.total)
+				if(this.list.length < this.total){
+					this.pageNo += 1
+					this.getRow()
+				}else{
+					this.status = "nomore"
+				}
+			},
+			// 设为负责人
+			setNewAdmin(){
+				console.log(this.curPerson)
+				if(!!this.curPerson){
+					const row = this.list.find(item => item.userId == this.curPerson )
+					this.$store.state.vuex_nowStaffData = row
+					uni.redirectTo({
+						url: "/pages/storeManage/editAdminAuth"
+					})
+				}else{
+					uni.showToast({
+						title: "请选择员工"
+					})
+				}
+			},
+		}
+	}
+</script>
+
+<style lang="less">
+	.page-body{
+		height: 100vh;
+		padding:0;
+		.scroll-list{
+			flex-grow: 1;
+			.check-order-list{
+				padding: 10upx 20upx;
+				u-radio{
+					> view{
+						background: #ffffff;
+						border-radius: 20upx;
+						box-shadow: 1px 1px 3px #EEEEEE;
+						margin: 10rpx 0;
+						padding: 20rpx;
+						>view:last-child{
+							flex-grow: 1;
+						}
+					}
+				}
+			}
+		}
+		.footer{
+			padding: 0.6rem;
+			background: #ffffff;
+			u-button{
+				width: 45%;
+				margin: 0 2%;
+			}
+		}
+	}
+</style>

+ 20 - 2
pages/storeManage/personnel.vue

@@ -33,8 +33,11 @@
 				</scroll-view>
 			</swiper-item>
 		</swiper>
-		<view class="footer">
-			<u-button @click="editPerson(null)" :throttle-time="100" :custom-style="{ background: '#066cff', color: '#fff',width:'400rpx' }" shape="circle" type="info">
+		<view class="footer flex align_center justify_center">
+			<u-button @click="editIsManage()" v-if="userInfo&&userInfo.superAdmin==1" :throttle-time="100" shape="circle" type="error" plain>
+				更换负责人
+			</u-button>
+			<u-button @click="editPerson(null)" :throttle-time="100" :custom-style="{ background: '#066cff', color: '#fff' }" shape="circle" type="info">
 				新增员工
 			</u-button>
 		</view>
@@ -62,6 +65,11 @@
 		onShow() {
 			this.getRow(1)
 		},
+		computed:{
+			userInfo(){
+				return this.$store.state.vuex_userInfo
+			},
+		},
 		methods:{
 			// 查询列表
 			getRow (pageNo) {
@@ -108,6 +116,12 @@
 				uni.navigateTo({
 					url: "/pages/storeManage/addPerson"
 				})
+			},
+			// 更换负责人
+			editIsManage(){
+				uni.navigateTo({
+					url: "/pages/storeManage/editIsManage"
+				})
 			}
 		}
 	}
@@ -140,6 +154,10 @@
 		.footer{
 			padding: 0.6rem;
 			background: #ffffff;
+			u-button{
+				width: 45%;
+				margin: 0 2%;
+			}
 		}
 	}
 </style>