editAdminAuth.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. <template>
  2. <view class="container flex flex_column">
  3. <view class="md-scroll">
  4. <view class="userInfo">
  5. 设置<text>{{userInfo.name}}</text>为新的负责人后,您将不再是门店负责人,
  6. 请为自己选择一个新的岗位
  7. </view>
  8. <view class="check-order-list">
  9. <u-radio-group wrap @change="radioGroupChange">
  10. <u-radio
  11. v-model="item.checked"
  12. v-for="(item, index) in roleList" :key="item.id"
  13. :name="item.id"
  14. >
  15. <view class="u-name">
  16. {{item.name}}
  17. </view>
  18. </u-radio>
  19. </u-radio-group>
  20. </view>
  21. <view style="padding:0 30upx 30upx;">
  22. <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>
  23. </view>
  24. </view>
  25. <view class="footer">
  26. <u-button @click="save" :loading="loading" :throttle-time="100" :custom-style="{ background: '#066cff', color: '#fff',width:'400rpx' }" shape="circle" type="info">
  27. 确定
  28. </u-button>
  29. </view>
  30. </view>
  31. </template>
  32. <script>
  33. import { getRoleList } from '@/api/powerRole-md.js'
  34. import {saveEmployee,setManager} from '@/api/employee'
  35. export default{
  36. data(){
  37. return{
  38. status: 'loadmore',
  39. noDataText: '暂无数据',
  40. // 查询参数
  41. queryParam: {
  42. isEnable: '1'
  43. },
  44. formData:{},
  45. pageSize: 100,
  46. pageNo: 1,
  47. roleList:[],
  48. checked:true,
  49. nowId: '', // 当前员工 id
  50. loading:false,
  51. total:'' ,// 获取数据总数
  52. userInfo: null,
  53. adminId: null
  54. }
  55. },
  56. onLoad(opts) {
  57. this.userInfo = this.$store.state.vuex_nowStaffData
  58. this.adminId = opts.adminId
  59. this.getRoleList()
  60. },
  61. methods:{
  62. radioGroupChange(e){
  63. this.formData.roleIds = e;
  64. const roleNames = this.roleList.find(item => item.id == e);
  65. this.formData.roleNames = roleNames?roleNames.name:'';
  66. },
  67. // 获取列表数据
  68. getRoleList(){
  69. let _this = this
  70. this.status = "loading"
  71. getRoleList({isEnable: '1'}).then(res => {
  72. uni.hideLoading()
  73. _this.roleList = res.data || []
  74. _this.noDataText = res.message
  75. _this.status = "loadmore"
  76. })
  77. },
  78. // 保存
  79. save(name){
  80. if(!this.formData.roleIds){
  81. uni.showToast({icon: 'none', title: '请选择岗位'})
  82. }else{
  83. this.loading = true
  84. // 先更换负责人
  85. setManager({id: this.userInfo.id}).then(res => {
  86. console.log(res)
  87. if (res.status == 200){
  88. this.saveRole()
  89. }else{
  90. uni.showToast({
  91. title:res.message
  92. })
  93. this.loading = false
  94. }
  95. })
  96. }
  97. },
  98. // 设置岗位
  99. saveRole(){
  100. this.formData.id = this.adminId
  101. saveEmployee(this.formData).then(res=>{
  102. console.log(res)
  103. if(res.status == 200){
  104. uni.showToast({icon: 'none', title:'保存成功'})
  105. this.quitOut()
  106. }else{
  107. uni.showToast({icon: 'none', title: res.message})
  108. }
  109. this.loading = false
  110. })
  111. },
  112. quitOut(){
  113. this.$store.dispatch('userLogout');
  114. uni.redirectTo({
  115. url: '/pages/login/login?showModal=1'
  116. });
  117. }
  118. }
  119. }
  120. </script>
  121. <style lang="less">
  122. .container{
  123. width:100%;
  124. height: 100vh;
  125. background: #ffffff;
  126. .md-scroll{
  127. flex-grow: 1;
  128. overflow: auto;
  129. .userInfo{
  130. padding: 20upx 50upx;
  131. text-align: center;
  132. text{
  133. color: coral;
  134. }
  135. }
  136. .check-order-list{
  137. padding: 10upx 20upx;
  138. u-radio{
  139. > view{
  140. background: #ffffff;
  141. border-radius: 20upx;
  142. box-shadow: 1px 1px 3px #EEEEEE;
  143. border:1px solid #eee;
  144. margin: 10rpx 0;
  145. padding: 20rpx;
  146. >view:last-child{
  147. flex-grow: 1;
  148. }
  149. }
  150. }
  151. }
  152. }
  153. .footer{
  154. padding: 0.6rem;
  155. background: #ffffff;
  156. }
  157. }
  158. </style>