roleid.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. <template>
  2. <view>
  3. <view class="head">
  4. 请选择角色
  5. </view>
  6. <My_listbox ref="List" @getlist="getList" bottomHeight="70">
  7. <view class="item" hover-class="navigator-hover" v-for="item in list" :key="item.roleid"
  8. @click="selectItem(item)">
  9. <view class="checkbox-box">
  10. <checkbox :checked="selectList.some(v => v == item.roleid)" color="#3874F6"
  11. style="transform:scale(0.7)" />
  12. </view>
  13. <view class="name u-line-1">
  14. {{ item.rolename || '--' }}
  15. </view>
  16. </view>
  17. </My_listbox>
  18. <view class="footer">
  19. <view class="total">
  20. 已选:{{ selectList.length }}
  21. </view>
  22. <view class="confirm" :class="selectList.length ? '' : 'forbidden'" @click="selectList.length ? submit() : ''">
  23. 确定
  24. </view>
  25. </view>
  26. </view>
  27. </template>
  28. <script>
  29. export default {
  30. data() {
  31. return {
  32. list: [],
  33. "content": {
  34. "where": {
  35. "sys_enterprise_hrid": 0
  36. }
  37. },
  38. selectList: [],
  39. results: [],
  40. }
  41. },
  42. onLoad(options) {
  43. console.log("options", options)
  44. uni.setNavigationBarTitle({
  45. title: options.title || '选择角色'
  46. });
  47. if (options.sys_enterprise_hrid) this.content.where.sys_enterprise_hrid = options.sys_enterprise_hrid;
  48. if (options.alreadySelecteds) {
  49. const alreadySelecteds = JSON.parse(options.alreadySelecteds);
  50. this.selectList = alreadySelecteds.value;
  51. this.results = alreadySelecteds.value.map((v, i) => {
  52. return {
  53. roleid: v,
  54. rolename: alreadySelecteds.showValue[i]
  55. }
  56. });
  57. }
  58. this.getList()
  59. },
  60. methods: {
  61. getList(init = false) {
  62. if (this.paging(this.content, init)) return;
  63. this.$Http.basic({
  64. "id": 20240411110602,
  65. content: this.content
  66. }).then(res => {
  67. this.$refs.List.RefreshToComplete()
  68. console.log("获取角色列表", res)
  69. if (this.cutoff(res.msg)) return;
  70. this.list = res.pageNumber == 1 ? res.data : this.list.concat(res.data);
  71. this.content = this.$refs.List.paging(this.content, res)
  72. })
  73. },
  74. selectItem(item) {
  75. let index = this.selectList.findIndex(v => v == item.roleid);
  76. if (index == -1) {
  77. this.selectList.push(item.roleid)
  78. this.results.push(item)
  79. } else {
  80. this.selectList.splice(index, 1);
  81. this.results.splice(index, 1);
  82. }
  83. },
  84. submit() {
  85. this.$Http.routeSelected({
  86. value: this.selectList,
  87. showValue: this.results.map(v => v.rolename)
  88. })
  89. }
  90. },
  91. }
  92. </script>
  93. <style lang="scss" scoped>
  94. .head {
  95. line-height: 17px;
  96. font-family: Source Han Sans SC, Source Han Sans SC;
  97. font-size: 12px;
  98. color: #666666;
  99. padding: 10px;
  100. }
  101. .item {
  102. display: flex;
  103. align-items: center;
  104. height: 50px;
  105. background: #fff;
  106. .checkbox-box {
  107. display: flex;
  108. justify-content: center;
  109. width: 44px;
  110. flex-shrink: 0;
  111. }
  112. .name {
  113. height: 50px;
  114. line-height: 50px;
  115. width: 100%;
  116. box-sizing: border-box;
  117. border-bottom: 0.5px solid #ddd;
  118. font-family: PingFang SC, PingFang SC;
  119. font-size: 14px;
  120. color: #333333;
  121. padding-right: 10px;
  122. }
  123. }
  124. .footer {
  125. position: fixed;
  126. bottom: 0;
  127. width: 100vw;
  128. height: 65px;
  129. background: #FFFFFF;
  130. box-shadow: 0px -2px 6px 1px rgba(0, 0, 0, 0.16);
  131. box-sizing: border-box;
  132. padding: 5px 10px;
  133. display: flex;
  134. justify-content: space-between;
  135. .total {
  136. line-height: 45px;
  137. font-family: PingFang SC, PingFang SC;
  138. font-size: 14px;
  139. color: #333333;
  140. }
  141. .confirm {
  142. display: flex;
  143. align-items: center;
  144. justify-content: center;
  145. width: 112px;
  146. height: 45px;
  147. background: #C30D23;
  148. border-radius: 5px;
  149. font-family: PingFang SC, PingFang SC;
  150. font-size: 14px;
  151. color: #FFFFFF;
  152. }
  153. .forbidden {
  154. opacity: .6;
  155. }
  156. }
  157. </style>