selectUser.vue 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <template>
  2. <view class="main">
  3. <view class="list">
  4. <view class="item" v-for="(item, index) in list" :key="index" @click="check(item)">
  5. <view class="title omit">
  6. <text class="icon check" v-if="item.check" style="color: #4581fb">&#xe6ad;</text>
  7. <text class="icon check" v-else>&#xe8bb;</text>
  8. <text>{{ item.name }}</text>
  9. </view>
  10. </view>
  11. <u-empty v-if="list.length == 0" text="暂无患者"></u-empty>
  12. </view>
  13. <view class="mfooter">
  14. <button class="btn" @click="go()" v-if="selected.length > 0">选中{{ selected.length }}人</button>
  15. </view>
  16. </view>
  17. </template>
  18. <script>
  19. export default {
  20. data() {
  21. return {
  22. list: [],
  23. selected: []
  24. };
  25. },
  26. onLoad(e) {
  27. this.getData();
  28. this.selected = JSON.parse(e.selected) || [];
  29. },
  30. methods: {
  31. getData() {
  32. this.http.request({
  33. url: '/work/record/visit/list',
  34. data: this.param,
  35. success: (res) => {
  36. this.list = res.data.data;
  37. this.list.forEach((item) => {
  38. item.check = this.selected.some((i) => i.id === item.id);
  39. });
  40. this.$forceUpdate();
  41. }
  42. });
  43. },
  44. check(item) {
  45. item.check = !item.check;
  46. this.selected = this.list.filter((item) => item.check);
  47. this.$forceUpdate();
  48. },
  49. go() {
  50. uni.$emit('selectUser', this.selected);
  51. uni.navigateBack();
  52. }
  53. }
  54. };
  55. </script>
  56. <style lang="scss">
  57. .list {
  58. background-color: white;
  59. border-radius: 10px;
  60. margin-top: -10px;
  61. .item {
  62. padding: 16px 12px 16px 12px;
  63. border-bottom: 1px solid $line;
  64. overflow: hidden;
  65. .title {
  66. font-size: 15px;
  67. font-weight: bold;
  68. .check {
  69. color: #737373;
  70. font-size: 13px;
  71. font-weight: normal;
  72. padding-right: 5px;
  73. }
  74. }
  75. }
  76. }
  77. </style>