StaffEdit.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. <template>
  2. <div class="seek">
  3. <div class="com-mobile-header mobile-center-header">
  4. <a @click="goLastPage"><i class="iconfont icon-fanhui"></i></a>
  5. <p>编辑角色</p>
  6. <p class="en-name"><img :src="`/images/mobile/center/${user.data.enterprise.uu ? 'en' : 'self'}.png`" alt="">{{currentEnName}}</p>
  7. </div>
  8. <div class="mobile-fix-content mobile-centerfix-content" id="mobile-staff-center" v-if="roles">
  9. <div v-for="role in roles">
  10. <div class="staff-role">
  11. <div class="staff-header"><span :class="'active_0' + role.color"><b></b>{{role.desc}}</span></div>
  12. <div class="staff-content">
  13. <label class="radio-label clearfix" @click="checkRole(role)">
  14. <input type="checkbox" :id="role.id" v-bind:class="{'checked': role.checked}"/>
  15. <label :for="role.id" v-bind:class="{'margin0': role.color === '4'}"></label>
  16. <p class="staff-des">{{role.duty}}</p>
  17. </label>
  18. </div>
  19. </div>
  20. </div>
  21. <div class="staff-footer">
  22. <div class="cancel handle" @click="cancelBind">取消</div>
  23. <div class="agree handle" @click="sureEdit">确定</div>
  24. </div>
  25. </div>
  26. </div>
  27. </template>
  28. <script>
  29. export default {
  30. data () {
  31. return {
  32. checked: false,
  33. roles: []
  34. }
  35. },
  36. computed: {
  37. currentData () {
  38. return this.$store.state.staff.infoList.edit.data
  39. }
  40. },
  41. mounted () {
  42. // 获取角色
  43. this.$nextTick(() => {
  44. this.getRoles()
  45. })
  46. },
  47. methods: {
  48. // 获取角色
  49. getRoles () {
  50. this.$http.get('/account/role')
  51. .then(response => {
  52. if (response.data) {
  53. this.roles = response.data
  54. for (let i = 0; i < this.currentData.roles.length; i++) {
  55. for (let j = 0; j < this.roles.length; j++) {
  56. //判断已绑定角色
  57. if (this.currentData.roles[i].id === this.roles[j].id) {
  58. this.roles[j].checked = true
  59. // console.log(this.roles[j].checked)
  60. }
  61. }
  62. }
  63. }
  64. })
  65. },
  66. // 选择角色
  67. checkRole (role) {
  68. console.log(role)
  69. role.checked = !role.checked
  70. console.log(this.currentData.roles, 'roles')
  71. // this.currentData.roles.push(role)
  72. },
  73. // 取消编辑
  74. cancelBind () {
  75. this.$router.push('/mobile/user/staff')
  76. },
  77. // 确定编辑
  78. sureEdit () {
  79. this.$http.put(`/basic/user/updaterole/${this.currentData}`)
  80. .then(() => {})
  81. }
  82. }
  83. }
  84. </script>
  85. <style lang="scss">
  86. $base-color: #3f84f6;
  87. #mobile-staff-center {
  88. margin: 0 auto;
  89. .staff-role{
  90. margin: .2rem auto 0;
  91. padding: 0 .24rem;
  92. width: 7.1rem;
  93. height: 1.72rem;
  94. background-color: #fff;
  95. border-radius: .05rem;
  96. .staff-header {
  97. height: .5rem;
  98. line-height: .5rem;
  99. text-align: left;
  100. border-bottom: 1px solid #d9d9d9;
  101. span {
  102. font-size: .28rem;
  103. color: #333;
  104. b{
  105. display: inline-block;
  106. margin-right: .05rem;
  107. width: .05rem;
  108. height: .18rem;
  109. background-color: #3f84f6;
  110. }
  111. }
  112. span.active_02 b{
  113. background-color: #8aaefc;
  114. }
  115. span.active_03 b{
  116. background-color: #09d7cd;
  117. }
  118. span.active_04 b{
  119. background-color: #ff676a;
  120. }
  121. span.active_05 b{
  122. background-color: #fc9b68;
  123. }
  124. }
  125. .staff-content {
  126. padding-top: .25rem;
  127. .radio-label {
  128. background-size: contain;
  129. vertical-align: middle;
  130. input{
  131. float: left;
  132. display: none;
  133. margin: .18rem .1rem 0 0;
  134. width: .36rem;
  135. height: .36rem;
  136. border: solid 2px #999999;
  137. }
  138. label {
  139. float: left;
  140. margin: .18rem .1rem 0 0;
  141. width: .36rem;
  142. height: .36rem;
  143. border-radius: 50%;
  144. background: url(/images/mobile/center/user/car-noChecked.png) no-repeat;
  145. background-size: contain;
  146. vertical-align: middle;
  147. }
  148. label.margin0 {
  149. margin: 0.05rem .1rem 0 0;
  150. }
  151. input:checked + label {
  152. background-image: url(/images/mobile/center/user/car-checked.png);
  153. }
  154. input.checked + label {
  155. background-image: url(/images/mobile/center/user/car-checked.png);
  156. }
  157. }
  158. .staff-des{
  159. float: left;
  160. width: 6rem;
  161. line-height: .42rem;
  162. font-weight: normal;
  163. font-size: .28rem;
  164. color: #666666;
  165. }
  166. }
  167. }
  168. .staff-footer{
  169. overflow: hidden;
  170. margin-top: .6rem;
  171. div.handle{
  172. float: left;
  173. width: 3.24rem;
  174. height: .77rem;
  175. line-height: .77rem;
  176. font-size: .32rem;
  177. color: #fff;
  178. text-align: center;
  179. border-radius: .08rem;
  180. &:first-child{
  181. margin: 0 .28rem 0 .35rem;
  182. background-color: #acaaab;
  183. }
  184. &:last-child{
  185. background-color: #3f84f6;
  186. }
  187. }
  188. }
  189. }
  190. </style>