role-switching.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. <template>
  2. <view class="role-page">
  3. <view class="row-box">
  4. <view class="role-list" v-for="(item,index) in permissionList">
  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. uni.navigateTo({
  70. url: '/pages/home/home'
  71. });
  72. });
  73. }
  74. },
  75. }
  76. </script>
  77. <style lang="less">
  78. .role-page {
  79. height: 100%;
  80. .row-box {
  81. .role-list {
  82. height: 107.5rpx;
  83. width: 750rpx;
  84. background: #FFFFFF;
  85. border-bottom: 0.62rpx solid #DADEE6;
  86. position: relative;
  87. .role-name {
  88. font-size: 22.5rpx;
  89. font-family: SourceHanSansCN-Bold, SourceHanSansCN;
  90. font-weight: bold;
  91. color: #292C33;
  92. float: left;
  93. margin-left: 25rpx;
  94. margin-top: 25rpx;
  95. }
  96. .nowrole {
  97. float: right;
  98. font-size: 22.5rpx;
  99. font-family: SourceHanSansCN-Normal, SourceHanSansCN;
  100. font-weight: 400;
  101. color: #7A8599;
  102. margin-top: 42.5rpx;
  103. margin-right: 25rpx;
  104. }
  105. .radio-item {
  106. float: right;
  107. margin-right: 25rpx;
  108. margin-top: 41.25rpx;
  109. .icon {
  110. width: 25rpx;
  111. height: 25rpx;
  112. }
  113. }
  114. .task-msg {
  115. font-size: 20rpx;
  116. font-family: SourceHanSansCN-Normal, SourceHanSansCN;
  117. font-weight: 400;
  118. color: #7A8599;
  119. position: absolute;
  120. top: 62.5rpx;
  121. left: 25rpx;
  122. }
  123. }
  124. }
  125. .btn-confirm {
  126. width: 750rpx;
  127. height: 75rpx;
  128. background: #3377FF;
  129. position: absolute;
  130. bottom: 0rpx;
  131. .btn-text {
  132. font-size: 22.5rpx;
  133. font-family: SourceHanSansCN-Normal, SourceHanSansCN;
  134. font-weight: 400;
  135. color: #FFFFFF;
  136. line-height: 75rpx;
  137. margin-left: 352.5rpx;
  138. }
  139. }
  140. }
  141. </style>