editAdminAuth.vue 4.7 KB

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