index - 副本.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. <template>
  2. <u-popup :show="popShow" @close="close">
  3. <view class="mian-wrap">
  4. <view class="search-wrap">
  5. <uni-search-bar
  6. v-model="searchValue"
  7. placeholder="请输入/姓名/编码/部门"
  8. >
  9. </uni-search-bar>
  10. </view>
  11. <scroll-view scroll-y="true" class="scroll-Y">
  12. <checkbox-group @change="checkboxChange">
  13. <label class="uni-list-item" v-for="item in fList" :key="item.id">
  14. <checkbox :value="item.id" :checked="item.checked" />
  15. <view class="item s1">{{ item.trueName }}</view>
  16. <view class="item s3">部门:{{ item.dept }}</view>
  17. </label>
  18. </checkbox-group>
  19. </scroll-view>
  20. <view class="footer footer-right">
  21. <text class="footer-span-btn" @click="resetEqui">确定</text>
  22. </view>
  23. </view>
  24. </u-popup>
  25. </template>
  26. <script>
  27. import { get, postJ } from '@/utils/api.js'
  28. export default {
  29. data () {
  30. return {
  31. list: [],
  32. searchValue: '',
  33. popShow: false
  34. }
  35. },
  36. created () {
  37. this.getStaff()
  38. },
  39. computed: {
  40. fList () {
  41. let e = this.searchValue
  42. if (e) {
  43. let nlist = this.list.filter(n => {
  44. return (
  45. n.trueName.includes(e) || n.workNo.includes(e) || n.dept.includes(e)
  46. )
  47. })
  48. return nlist || []
  49. } else {
  50. return this.list
  51. }
  52. },
  53. checkedList () {
  54. return this.list.filter(n => {
  55. return n.checked
  56. })
  57. }
  58. },
  59. methods: {
  60. open () {
  61. this.popShow = true
  62. },
  63. checkboxChange (e) {
  64. var items = this.list,
  65. values = e.detail.value
  66. for (var i = 0, lenI = items.length; i < lenI; ++i) {
  67. const item = items[i]
  68. if (values.includes(item.id)) {
  69. item.checked = true
  70. } else {
  71. item.checked = false
  72. }
  73. }
  74. },
  75. // 获取员工数据
  76. getStaff () {
  77. let param = {}
  78. postJ(this.apiUrl + '/main/user/list', param).then(res => {
  79. if (res.success) {
  80. this.list = res.data.items.map(n => {
  81. return {
  82. id: String(n.userId),
  83. workNo: n.workNo,
  84. trueName: n.trueName,
  85. dept: n.deptName,
  86. checked: false
  87. }
  88. })
  89. }
  90. })
  91. },
  92. // 确定
  93. resetEqui () {
  94. this.$emit('submit', this.checkedList)
  95. },
  96. close () {
  97. this.popShow = false
  98. }
  99. }
  100. }
  101. </script>
  102. <style scoped lang="scss">
  103. .search-wrap {
  104. padding: 10px 0;
  105. }
  106. .mian-wrap {
  107. padding-bottom: 90rpx;
  108. }
  109. .uni-list-item {
  110. font-size: 32rpx;
  111. color: #333333;
  112. display: flex;
  113. padding: 0 10px;
  114. align-items: center;
  115. & + .uni-list-item {
  116. margin-top: 10px;
  117. }
  118. .item {
  119. &.s1 {
  120. width: 100upx;
  121. }
  122. &.s2 {
  123. width: 250upx;
  124. }
  125. & + .item {
  126. margin-left: 20px;
  127. }
  128. }
  129. }
  130. .scroll-Y {
  131. height: 500rpx;
  132. }
  133. .footer {
  134. position: absolute;
  135. display: flex;
  136. justify-content: space-between;
  137. align-items: center;
  138. bottom: 0;
  139. width: 100%;
  140. height: 90rpx;
  141. text-align: center;
  142. border-top: 0.5px solid #eeecec;
  143. background-color: #ffffff;
  144. }
  145. .footer-right {
  146. justify-content: flex-end;
  147. }
  148. .footer-span-btn {
  149. font-size: $uni-font-size-lg;
  150. color: #ffffff;
  151. margin-right: 20rpx;
  152. padding: 10rpx 20rpx;
  153. text-align: center;
  154. background-color: $j-primary-green;
  155. border-radius: 40rpx;
  156. }
  157. </style>