editAdminAuth.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  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 { getPowerRoleList } 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. name: '',
  43. isEnable: ''
  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.formData = Object.assign({},this.formData,this.userInfo)
  59. },
  60. onShow() {
  61. this.pageNo = 1
  62. this.getRoleList()
  63. },
  64. // 下一页
  65. onReachBottom() {
  66. console.log('next page')
  67. if(this.roleList.length < this.total){
  68. this.pageNo += 1
  69. this.getRoleList()
  70. }else{
  71. this.status = "nomore"
  72. }
  73. },
  74. methods:{
  75. radioGroupChange(e){
  76. this.formData.roleIds = e;
  77. const roleNames = this.roleList.find(item => item.id == e);
  78. this.formData.roleNames = roleNames?roleNames.name:'';
  79. },
  80. // 获取列表数据
  81. getRoleList(){
  82. let _this = this
  83. this.status = "loading"
  84. getPowerRoleList(Object.assign({pageNo: this.pageNo, pageSize: this.pageSize}, this.queryParam)).then(res => {
  85. if (res.code == 200 || res.status == 204 || res.status == 200) {
  86. if(_this.pageNo>1){
  87. _this.roleList = _this.roleList.concat(res.data.list || [])
  88. }else{
  89. _this.roleList = res.data.list || []
  90. }
  91. _this.total = res.data.count || 0
  92. _this.roleList.map(item => {
  93. item.roleState = item.isEnable == 1
  94. })
  95. } else {
  96. _this.roleList = []
  97. _this.total = 0
  98. _this.noDataText = res.message
  99. }
  100. _this.status = "loadmore"
  101. })
  102. },
  103. // 保存
  104. save(name){
  105. if(!this.formData.roleIds){
  106. uni.showToast({icon: 'none', title: '请选择岗位'})
  107. }else{
  108. this.loading = true
  109. // 先更换负责人
  110. setManager({id: this.userInfo.id}).then(res => {
  111. console.log(res)
  112. if (res.status == 200){
  113. this.saveRole()
  114. }else{
  115. uni.showToast({
  116. title:res.message
  117. })
  118. this.loading = false
  119. }
  120. })
  121. }
  122. },
  123. // 设置岗位
  124. saveRole(){
  125. saveEmployee(this.formData).then(res=>{
  126. console.log(res)
  127. if(res.status == 200){
  128. uni.showToast({icon: 'none', title:'保存成功'})
  129. this.quitOut()
  130. }else{
  131. uni.showToast({icon: 'none', title: res.message})
  132. }
  133. this.loading = false
  134. })
  135. },
  136. quitOut(){
  137. let _this = this
  138. uni.showModal({
  139. title: '提示',
  140. content: '设置成功,需要重新登录!',
  141. showCancel: false,
  142. success: (ret) => {
  143. if(ret.confirm){
  144. _this.$store.dispatch('userLogout');
  145. uni.redirectTo({
  146. url: '/pages/login/login'
  147. });
  148. }
  149. }
  150. })
  151. }
  152. }
  153. }
  154. </script>
  155. <style lang="less">
  156. .container{
  157. width:100%;
  158. height: 100vh;
  159. background: #ffffff;
  160. .md-scroll{
  161. flex-grow: 1;
  162. overflow: auto;
  163. .userInfo{
  164. padding: 20upx 50upx;
  165. text-align: center;
  166. text{
  167. color: coral;
  168. }
  169. }
  170. .check-order-list{
  171. padding: 10upx 20upx;
  172. u-radio{
  173. > view{
  174. background: #ffffff;
  175. border-radius: 20upx;
  176. box-shadow: 1px 1px 3px #EEEEEE;
  177. border:1px solid #eee;
  178. margin: 10rpx 0;
  179. padding: 20rpx;
  180. >view:last-child{
  181. flex-grow: 1;
  182. }
  183. }
  184. }
  185. }
  186. }
  187. .footer{
  188. padding: 0.6rem;
  189. background: #ffffff;
  190. }
  191. }
  192. </style>