role-switching.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. <template>
  2. <view class="role-page">
  3. <view class="row-box">
  4. <view class="role-list" v-for="(item,index) in permissionList" :key="index">
  5. <text class="role-name">{{item.label}}</text>
  6. <view class="radio-item" @click="toggleSelect(item,index)">
  7. <image class="icon" :src="`/static/${item.isChecked ? 'check-radio' : 'check-no'}.png`"></image>
  8. </view>
  9. <text class="nowrole" v-show="item.isNowRole" >当前角色</text>
  10. <text class="task-msg">{{item.todoNum}}</text>
  11. </view>
  12. </view>
  13. <view class="btn-confirm" @click="saveChange">
  14. <text class="btn-text">确定</text>
  15. </view>
  16. </view>
  17. </template>
  18. /**
  19. * 角色切换
  20. */
  21. <script>
  22. export default {
  23. data() {
  24. return {
  25. permissionList:[],//权限列表
  26. nowPermission:'',//当前权限
  27. selectedPermission:'',//当前选中的权限
  28. roleList:[
  29. {permission: 1, name: '管理员'},
  30. {permission: 2, name: '查核组长'},
  31. {permission: 3, name: '查核组员'},
  32. {permission: 4, name: '单位负责人'},
  33. {permission: 5, name: '改善者'}
  34. ]
  35. }
  36. },
  37. created() {
  38. let permissions=uni.getStorageSync('permissions');
  39. this.nowPermission=uni.getStorageSync('nowPermission');
  40. this.permissionList=permissions.map((item,index)=>{
  41. let match=this.roleList.find(i => i.permission == item.permission);
  42. return {
  43. value:match.permission,
  44. label:match.name,
  45. todoNum:item.todoNum>0?item.todoNum+'个任务待处理':'暂无待处理',
  46. isNowRole:this.nowPermission==match.permission?true:false,
  47. isChecked:this.nowPermission==match.permission?true:false,
  48. }
  49. });
  50. },
  51. methods: {
  52. toggleSelect(item,index) {
  53. this.permissionList.map((item,index)=>{
  54. item.isChecked=false;
  55. });
  56. this.permissionList[item.value-1].isChecked=true;
  57. this.selectedPermission=item.value;
  58. },
  59. saveChange(){
  60. this.$store.dispatch({
  61. type: 'roleSwitching/commActions',
  62. payload: {
  63. key: 'updatePermission',
  64. data: {
  65. permission: this.selectedPermission,
  66. }
  67. }
  68. }).then((data)=>{
  69. if(data){
  70. uni.navigateTo({
  71. url: '/pages/home/home'
  72. });
  73. }
  74. });
  75. }
  76. },
  77. }
  78. </script>
  79. <style lang="less">
  80. .role-page {
  81. height: 100%;
  82. .row-box {
  83. .role-list {
  84. height: 107.5rpx;
  85. width: 750rpx;
  86. background: #FFFFFF;
  87. border-bottom: 0.62rpx solid #DADEE6;
  88. position: relative;
  89. .role-name {
  90. font-size: 22.5rpx;
  91. font-family: SourceHanSansCN-Bold, SourceHanSansCN;
  92. font-weight: bold;
  93. color: #292C33;
  94. float: left;
  95. margin-left: 25rpx;
  96. margin-top: 25rpx;
  97. }
  98. .nowrole {
  99. float: right;
  100. font-size: 22.5rpx;
  101. font-family: SourceHanSansCN-Normal, SourceHanSansCN;
  102. font-weight: 400;
  103. color: #7A8599;
  104. margin-top: 42.5rpx;
  105. margin-right: 25rpx;
  106. }
  107. .radio-item {
  108. float: right;
  109. margin-right: 25rpx;
  110. margin-top: 41.25rpx;
  111. .icon {
  112. width: 25rpx;
  113. height: 25rpx;
  114. }
  115. }
  116. .task-msg {
  117. font-size: 20rpx;
  118. font-family: SourceHanSansCN-Normal, SourceHanSansCN;
  119. font-weight: 400;
  120. color: #7A8599;
  121. position: absolute;
  122. top: 62.5rpx;
  123. left: 25rpx;
  124. }
  125. }
  126. }
  127. .btn-confirm {
  128. width: 750rpx;
  129. height: 75rpx;
  130. background: #3377FF;
  131. position: absolute;
  132. bottom: 0rpx;
  133. .btn-text {
  134. font-size: 22.5rpx;
  135. font-family: SourceHanSansCN-Normal, SourceHanSansCN;
  136. font-weight: 400;
  137. color: #FFFFFF;
  138. line-height: 75rpx;
  139. margin-left: 352.5rpx;
  140. }
  141. }
  142. }
  143. </style>