lilei hace 3 años
padre
commit
a8b6bf0716

+ 2 - 2
App.vue

@@ -1,8 +1,8 @@
 <script>
 <script>
 	export default {
 	export default {
 		globalData: {
 		globalData: {
-			// baseUrl: 'http://192.168.0.103:9110/saas/clz/', // 本地
-			baseUrl: 'https://md.test.zyucgj.com/saas/clz/', // 预发布
+			baseUrl: 'http://192.168.0.103:9110/saas/clz/', // 本地
+			// baseUrl: 'https://md.test.zyucgj.com/saas/clz/', // 预发布
 			// baseUrl: 'https://car.zyucgj.com/saas/clz/' // 生产
 			// baseUrl: 'https://car.zyucgj.com/saas/clz/' // 生产
 		},
 		},
 		onLaunch: function() {
 		onLaunch: function() {

+ 3 - 2
api/powerRole-md.js

@@ -40,10 +40,11 @@ export const saveRolePower = params => {
 
 
 // 获取菜单树数据
 // 获取菜单树数据
 export const getMenuList = params => {
 export const getMenuList = params => {
-  const url = `mdrole/findAllMenu/${params.id}`
+  const url = `mdrole/findAllMenuByRootId/${params.id}`
   return request({
   return request({
     url: url,
     url: url,
-    method: 'get'
+	data: {rootIds: '10002'},
+    method: 'post'
   })
   })
 }
 }
 
 

+ 55 - 67
pages/storeManage/roleSetting/addRole.vue

@@ -1,59 +1,39 @@
 <template>
 <template>
 	<view class="container">
 	<view class="container">
 		<evan-form ref="formData" :rules="ruleValidate" :model="formData">
 		<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 prop="name">
+				<u-input class="form-input" :maxlength="30" style="width: 100%;" placeholder="请填写岗位名称(最多30个字符)" v-model="formData.name" />
 			</evan-form-item>
 			</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 class="role-box">
+				<view>岗位权限:</view>
+				<roleAuthSet ref="roleSet" @addPowerOk="addPowerOk"></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>
 			</view>
 		</evan-form>
 		</evan-form>
 	</view>
 	</view>
 </template>
 </template>
 
 
 <script>
 <script>
-	import {saveRolePower} from '@/api/powerRole-md.js'
+	import roleAuthSet from './roleAuthSet.vue'
+	import { clzConfirm } from '@/libs/tools.js'
+	import {saveRolePower, delectRolePower} from '@/api/powerRole-md.js'
 	export default{
 	export default{
 		name:"formData",
 		name:"formData",
+		components:{
+			roleAuthSet
+		},
 		data(){
 		data(){
 			return{
 			return{
 				loading: false,
 				loading: false,
 				formData:{
 				formData:{
 					name:'',
 					name:'',
-					isEnable:'',
+					isEnable:'1',
 					remarks:''
 					remarks:''
 				},
 				},
 				type: '', //  edit 编辑页  add  新增页
 				type: '', //  edit 编辑页  add  新增页
-				list: [
-					{
-						value: 1,
-						name: '启用',
-						disabled: false,
-					},
-					{
-						value: 0,
-						name: '禁用',
-						disabled: false
-						
-					}
-				],
 				ruleValidate: {
 				ruleValidate: {
 					name: [
 					name: [
 						{ required: true, message: '请输入角色名称', trigger: 'change' },
 						{ required: true, message: '请输入角色名称', trigger: 'change' },
@@ -68,11 +48,6 @@
 							}
 							}
 						}
 						}
 					],
 					],
-					isEnable: [
-						{
-						  required: true, type:'string',message: '请选择状态', trigger: 'blur'
-						}
-					],
 				},
 				},
 			}
 			}
 		},
 		},
@@ -82,6 +57,8 @@
 			uni.setNavigationBarTitle({
 			uni.setNavigationBarTitle({
 				title: this.type=="add" ? '添加角色' : '编辑角色'
 				title: this.type=="add" ? '添加角色' : '编辑角色'
 			})
 			})
+			// 初始化角色
+			this.$refs.roleSet.getMenuList(options.id)
 			this.init()
 			this.init()
 		},
 		},
 		methods:{
 		methods:{
@@ -89,39 +66,53 @@
 			init(){
 			init(){
 				if(this.type=='edit'){
 				if(this.type=='edit'){
 					let data = this.$store.state.vuex_nowRoleInfo
 					let data = this.$store.state.vuex_nowRoleInfo
-					console.log(data)	
 					this.formData.name = data.name
 					this.formData.name = data.name
-					this.formData.isEnable = data.isEnable
-					this.formData.remarks = data.remarks || ''
 					this.formData.id = data.id
 					this.formData.id = data.id
 				}else{
 				}else{
 					this.formData.name =''
 					this.formData.name =''
-					this.formData.isEnable = 0
-					this.formData.remarks =''
 					this.formData.id  =''
 					this.formData.id  =''
 				}
 				}
 			},
 			},
 			// 保存
 			// 保存
 			save(name){
 			save(name){
-				let data=this.formData
-				this.formData.isEnable = String(this.formData.isEnable)
-				console.log(data)
 				this.$refs[name].validate((valid) => {
 				this.$refs[name].validate((valid) => {
 				  if (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 = true
+					  this.$refs.roleSet.handleSubmit()
+				  }
+				})
+			},
+			// 保存角色
+			addPowerOk(){
+				saveRolePower(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
+				})
+			},
+			// 删除角色
+			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})
+							})
 						}
 						}
-						this.loading = false
-					}).catch(err=>{
-						this.loading = false
-					})
-				}
+					},
 				})
 				})
 			},
 			},
 			// 取消
 			// 取消
@@ -144,11 +135,8 @@
 		.form-input-placeholder{
 		.form-input-placeholder{
 			text-align: right;
 			text-align: right;
 		}
 		}
-		textarea {
-			text-align: right;
-			margin: 20upx;
-			height: 100upx;
-			width: 95%;
+		.role-box{
+			padding: 20rpx 0;
 		}
 		}
 	}
 	}
 </style>
 </style>

+ 15 - 42
pages/storeManage/roleSetting/roleAuthSet.vue

@@ -17,9 +17,6 @@
 				</view>
 				</view>
 			</view>
 			</view>
 		</view>
 		</view>
-		<view class="form-footer-btn">
-			<button type="primary" :style="{background:$config('buttonColors')}" :disabled="loading" :loading="loading" @click="handleSubmit()">保存</button>
-		</view>
 	</view>
 	</view>
 </template>
 </template>
 
 
@@ -35,26 +32,22 @@
 				loading: false
 				loading: false
 			}
 			}
 		},
 		},
-		onLoad(options) {
-			this.id = options.id
-			this.getMenuList()
-		},
 		methods: {
 		methods: {
 			// 获取菜单树列表
 			// 获取菜单树列表
-			getMenuList () {
+			getMenuList (id) {
 			  let _this = this
 			  let _this = this
+			  this.id = id || '1'
 			  getMenuList({id: this.id}).then(res => {
 			  getMenuList({id: this.id}).then(res => {
 			    if (res.status == 200) {
 			    if (res.status == 200) {
 			       _this.menuData = res.data
 			       _this.menuData = res.data
-			       if (_this.menuData.role.menuIds) {
+			       if (_this.menuData.role&&_this.menuData.role.menuIds) {
 			         const arr = _this.menuData.role.menuIds.split(',')
 			         const arr = _this.menuData.role.menuIds.split(',')
 			         // 勾选已选的
 			         // 勾选已选的
 			         _this.findLeaf(_this.menuData.allMenuList, arr)
 			         _this.findLeaf(_this.menuData.allMenuList, arr)
 					 _this.getIds(_this.menuData.allMenuList[0].children,0)
 					 _this.getIds(_this.menuData.allMenuList[0].children,0)
-					 _this.getIds(_this.menuData.allMenuList[1].children,1)
 			       }
 			       }
 				   // app 菜单
 				   // app 菜单
-				   _this.authList = _this.menuData.allMenuList[2].children
+				   _this.authList = _this.menuData.allMenuList[0].children
 			    }
 			    }
 				console.log(_this.menuData,'_this.menuData')
 				console.log(_this.menuData,'_this.menuData')
 			  })
 			  })
@@ -117,12 +110,12 @@
 			handleSubmit () {
 			handleSubmit () {
 			  const _this = this
 			  const _this = this
 			  // 获取已选的项
 			  // 获取已选的项
-			  this.checkedIds[2] = []
-			  this.getIds(this.authList,2)
-			  if (this.checkedIds[2].length == 0) {
+			  this.checkedIds[0] = []
+			  this.getIds(this.authList,0)
+			  if (this.checkedIds[0].length == 0) {
 				uni.showToast({
 				uni.showToast({
 					icon: 'none',
 					icon: 'none',
-					title:  '请先选择菜单'
+					title:  '请先选择权限'
 				})
 				})
 			    return false
 			    return false
 			  }
 			  }
@@ -131,37 +124,23 @@
 			  checkeNodes = checkeNodes.concat(this.checkedIds[1])
 			  checkeNodes = checkeNodes.concat(this.checkedIds[1])
 			  checkeNodes = checkeNodes.concat(this.checkedIds[2])
 			  checkeNodes = checkeNodes.concat(this.checkedIds[2])
 			  console.log(checkeNodes, 'checkeNodes')
 			  console.log(checkeNodes, 'checkeNodes')
-			  uni.showLoading({
-			  	title: "正在提交..."
-			  })
-			  this.loading = true
 			  addMenuPower({ id: this.id, menuIds: checkeNodes.join(',') }).then(res => {
 			  addMenuPower({ id: this.id, menuIds: checkeNodes.join(',') }).then(res => {
 			    console.log(res, 'res--save')
 			    console.log(res, 'res--save')
-				uni.showToast({
-					icon: 'none',
-					title:  res.message
-				})
 			    if (res.status + '' === '200') {
 			    if (res.status + '' === '200') {
-			      setTimeout(function () {
-			        _this.cancel()
-			      }, 300)
-			    }
-				uni.hideLoading()
-				this.loading = false
+			       this.$emit("addPowerOk")
+			    }else{
+					uni.showToast({
+						icon: 'none',
+						title: res.message
+					})
+				}
 			  })
 			  })
 			},
 			},
-			cancel(){
-				uni.navigateBack()
-			}
 		},
 		},
 	}
 	}
 </script>
 </script>
 
 
 <style lang="scss">
 <style lang="scss">
-	page{
-		height: 100%;
-		background: #FFFFFF;
-	}
 	.auth_page{
 	.auth_page{
 		display: flex;
 		display: flex;
 		flex-direction: column;
 		flex-direction: column;
@@ -190,12 +169,6 @@
 				}
 				}
 			}
 			}
 		}
 		}
-		.form-footer-btn{
-			margin: 20upx;
-			uni-button{
-				font-size: 30upx;
-			}
-		}
 	}
 	}
 	
 	
 </style>
 </style>

+ 27 - 55
pages/storeManage/roleSetting/roleSetting.vue

@@ -1,25 +1,29 @@
 <template>
 <template>
-	<view class="container">
+	<view class="container flex flex_column">
 		<view class="md-scroll">
 		<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 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 class="footer">
+			<u-button @click="addRole(null)" :throttle-time="100" :custom-style="{ background: '#066cff', color: '#fff',width:'400rpx' }" shape="circle" type="info">
+				新增岗位
+			</u-button>
 		</view>
 		</view>
 	</view>
 	</view>
 </template>
 </template>
 
 
 <script>
 <script>
-	import { getPowerRoleList,delectRolePower, updateEnableStatus } from '@/api/powerRole-md.js'
-	import { clzConfirm } from '@/libs/tools.js'
+	import { getPowerRoleList, updateEnableStatus } from '@/api/powerRole-md.js'
 	export default{
 	export default{
 		data(){
 		data(){
 			return{
 			return{
@@ -95,53 +99,16 @@
 				})
 				})
 			},
 			},
 			// 添加角色
 			// 添加角色
-			add(){
+			addRole(){
 				uni.navigateTo({
 				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})
-								}
-							})
-						}
-					},
+					url:'/pages/storeManage/roleSetting/addRole?type=add'
 				})
 				})
 			},
 			},
 			// 编辑修改
 			// 编辑修改
 			editItem(item){
 			editItem(item){
 				this.$store.state.vuex_nowRoleInfo=item
 				this.$store.state.vuex_nowRoleInfo=item
 				uni.navigateTo({
 				uni.navigateTo({
-					url:'/pages/storeManage/roleSetting/addRole?type=edit'
-				})
-			},
-			// 设置权限
-			setAuths(item){
-				uni.navigateTo({
-					url:'/pages/storeManage/roleSetting/roleAuthSet?id='+item.id
+					url:'/pages/storeManage/roleSetting/addRole?type=edit&id='+item.id
 				})
 				})
 			},
 			},
 			// 返回
 			// 返回
@@ -155,6 +122,7 @@
 <style lang="less" scoped>
 <style lang="less" scoped>
 	.container{
 	.container{
 		width:100%;
 		width:100%;
+		height: 100vh;
 		.md-scroll{
 		.md-scroll{
 			flex-grow: 1;
 			flex-grow: 1;
 			overflow: auto;
 			overflow: auto;
@@ -177,5 +145,9 @@
 				}
 				}
 			}
 			}
 		}
 		}
+		.footer{
+			padding: 0.6rem;
+			background: #ffffff;
+		}
 	}
 	}
 </style>
 </style>

+ 1 - 0
store/index.js

@@ -53,6 +53,7 @@ const store = new Vuex.Store({
 		vuex_permCodes: [], // 权限码
 		vuex_permCodes: [], // 权限码
 		vuex_openid: "",
 		vuex_openid: "",
 		vuex_nowStaffData: null, // 员工临时数据
 		vuex_nowStaffData: null, // 员工临时数据
+		vuex_nowRoleInfo: null, // 角色
 		vuex_vinScanNums:null, // 扫描次数
 		vuex_vinScanNums:null, // 扫描次数
 		vuex_scanMaxNums: 10, // 最大扫描次数
 		vuex_scanMaxNums: 10, // 最大扫描次数
 		vuex_storeAuthInfo: null // 门店认证状态信息
 		vuex_storeAuthInfo: null // 门店认证状态信息