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