index.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. <template>
  2. <view class="container">
  3. <uni-section :title="task !== null ? task.name : '当前无检测任务'" type="line">
  4. <uni-list :border="true" v-if="list.length > 0">
  5. <view :id="item && item.residentId" class="delBox" v-for="(item, index) in list" :key="index" >
  6. <uni-list-chat :class="{ left: isId == item.residentId }" class="item" :avatar="item.avatar || '/static/user1.png'" :title="item.name" :note="item.phone" badge-positon="left">
  7. <view class="chat-custom-right">
  8. <text class="chat-custom-text">{{ item && item.status == 0 ? '未检' : '已检' }}</text>
  9. <button type="primary" size="mini" :disabled="item && item.status == 1" @click="filing(item)">已检</button>
  10. </view>
  11. </uni-list-chat>
  12. </view>
  13. </uni-list>
  14. <text v-if="list.length <= 0 && task !== null" class="chat-custom-text msgText">请完善成员信息 / 家庭成员审核中</text>
  15. </uni-section>
  16. </view>
  17. </template>
  18. <script>
  19. import requestFamily from '../../api/family.js';
  20. export default {
  21. data() {
  22. return {
  23. isId: '',
  24. startX: 0,
  25. extraIcon: {
  26. color: '#ff8319',
  27. size: '20',
  28. type: 'plusempty'
  29. },
  30. list: [],
  31. natTaskId: '',
  32. task: null
  33. }
  34. },
  35. async mounted() {
  36. const task = await requestFamily.runningTask();
  37. if (task.code == 200 && task.data.length > 0) {
  38. this.task = task.data[0];
  39. this.natTaskId = task.data[0].natTaskId;
  40. this.query();
  41. }
  42. },
  43. onShow() {
  44. this.isId = '';
  45. },
  46. methods: {
  47. async query() {
  48. const residentIds = [];
  49. const familyInfo = await requestFamily.getUserAll();
  50. familyInfo.data.forEach(e => residentIds.push(e.residentId))
  51. if (familyInfo.code == 200) {
  52. const membersStatus = await requestFamily.membersStatus({ residentIds, natTaskId: this.natTaskId });
  53. familyInfo.data = familyInfo.data.map(e => {
  54. const resident = membersStatus.data.find(j => j.residentId == e.residentId);
  55. return { ...e, status: resident?.status || 0 };
  56. })
  57. this.list = familyInfo.data;
  58. }
  59. },
  60. // 报备
  61. async filing(e) {
  62. const res = await requestFamily.filing({ residentId: e.residentId, natTaskId: this.natTaskId });
  63. if (res.code == 200) {
  64. this.query();
  65. uni.showToast({
  66. title: '报备成功',
  67. duration: 2000,
  68. });
  69. }
  70. }
  71. }
  72. }
  73. </script>
  74. <style>
  75. .container {
  76. width: 100%;
  77. }
  78. .addUser {
  79. display: block;
  80. /* width: 90%; */
  81. margin: 5px auto;
  82. }
  83. .chat-custom-text {
  84. font-size: 12px;
  85. color: #999;
  86. width: 100%;
  87. text-align: center;
  88. display: block;
  89. }
  90. .addUser .uni-list-item__container {
  91. flex: none;
  92. margin: 0 auto;
  93. }
  94. .addUser .uni-list-item__content-title {
  95. color: #ff8319;
  96. }
  97. .delBox {
  98. display: flex;
  99. width: 100%;
  100. overflow: hidden;
  101. }
  102. .item {
  103. width: 100%;
  104. }
  105. .del {
  106. display: block;
  107. width: 50px;
  108. background: red;
  109. }
  110. .right {
  111. margin-right: -100px;
  112. }
  113. .uni-icons {
  114. display: block;
  115. width: 100%;
  116. text-align: center;
  117. line-height: 2.3em;
  118. }
  119. .left {
  120. margin-left: -100px;
  121. }
  122. .compose {
  123. background: #1aad19;
  124. }
  125. .msgText {
  126. padding-bottom: 20px;
  127. }
  128. </style>