editAdminAuth.vue 4.6 KB

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