editAdminAuth.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  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. import { getCurrUserInfo } from '@/api/data.js';
  36. export default{
  37. data(){
  38. return{
  39. status: 'loadmore',
  40. noDataText: '暂无数据',
  41. // 查询参数
  42. queryParam: {
  43. isEnable: '1'
  44. },
  45. formData:{},
  46. pageSize: 100,
  47. pageNo: 1,
  48. roleList:[],
  49. checked:true,
  50. nowId: '', // 当前员工 id
  51. loading:false,
  52. total:'' ,// 获取数据总数
  53. userInfo: null,
  54. }
  55. },
  56. onLoad(opts) {
  57. this.userInfo = this.$store.state.vuex_nowStaffData
  58. this.getCurrUserInfo()
  59. },
  60. methods:{
  61. radioGroupChange(e){
  62. this.formData.roleIds = e;
  63. const roleNames = this.roleList.find(item => item.id == e);
  64. this.formData.roleNames = roleNames?roleNames.name:'';
  65. },
  66. // 获取列表数据
  67. getRoleList(){
  68. let _this = this
  69. this.status = "loading"
  70. getRoleList({isEnable: '1'}).then(res => {
  71. uni.hideLoading()
  72. _this.roleList = res.data || []
  73. _this.noDataText = res.message
  74. _this.status = "loadmore"
  75. })
  76. },
  77. getCurrUserInfo(){
  78. uni.showLoading({
  79. mask:true,
  80. title: '正在加载...'
  81. })
  82. getCurrUserInfo().then(res => {
  83. if(res.data){
  84. this.formData = Object.assign({},this.formData,{id:res.data.id})
  85. this.pageNo = 1
  86. this.getRoleList()
  87. }else{
  88. uni.hideLoading()
  89. }
  90. })
  91. },
  92. // 保存
  93. save(name){
  94. if(!this.formData.roleIds){
  95. uni.showToast({icon: 'none', title: '请选择岗位'})
  96. }else{
  97. this.loading = true
  98. // 先更换负责人
  99. setManager({id: this.userInfo.id}).then(res => {
  100. console.log(res)
  101. if (res.status == 200){
  102. this.saveRole()
  103. }else{
  104. uni.showToast({
  105. title:res.message
  106. })
  107. this.loading = false
  108. }
  109. })
  110. }
  111. },
  112. // 设置岗位
  113. saveRole(){
  114. saveEmployee(this.formData).then(res=>{
  115. console.log(res)
  116. if(res.status == 200){
  117. uni.showToast({icon: 'none', title:'保存成功'})
  118. this.quitOut()
  119. }else{
  120. uni.showToast({icon: 'none', title: res.message})
  121. }
  122. this.loading = false
  123. })
  124. },
  125. quitOut(){
  126. this.$store.dispatch('userLogout');
  127. uni.redirectTo({
  128. url: '/pages/login/login?showModal=1'
  129. });
  130. }
  131. }
  132. }
  133. </script>
  134. <style lang="less">
  135. .container{
  136. width:100%;
  137. height: 100vh;
  138. background: #ffffff;
  139. .md-scroll{
  140. flex-grow: 1;
  141. overflow: auto;
  142. .userInfo{
  143. padding: 20upx 50upx;
  144. text-align: center;
  145. text{
  146. color: coral;
  147. }
  148. }
  149. .check-order-list{
  150. padding: 10upx 20upx;
  151. u-radio{
  152. > view{
  153. background: #ffffff;
  154. border-radius: 20upx;
  155. box-shadow: 1px 1px 3px #EEEEEE;
  156. border:1px solid #eee;
  157. margin: 10rpx 0;
  158. padding: 20rpx;
  159. >view:last-child{
  160. flex-grow: 1;
  161. }
  162. }
  163. }
  164. }
  165. }
  166. .footer{
  167. padding: 0.6rem;
  168. background: #ffffff;
  169. }
  170. }
  171. </style>