index.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. <template>
  2. <view>
  3. <view class="search">
  4. <u-search placeholder="搜索患者" v-model="param.patientName" bgColor="white" :showAction="false" @search="refresh()" @clear="(param.patientName = ''), refresh()"></u-search>
  5. </view>
  6. <view class="listv">
  7. <view class="item" v-for="(item, index) in list" :key="index" @click="detail(item)">
  8. <view class="title omit">
  9. <text class="icon" v-if="item.top === 1">&#xe61f;</text>
  10. <text>{{ item.templateName }}</text>
  11. </view>
  12. <view class="desc">
  13. <text>{{ item.patientName }}</text>
  14. <text>{{ item.createTime }}</text>
  15. <text class="del" @click.stop="del(item, index)">删除</text>
  16. <text class="edit" @click.stop="go('/pages/follow/doctor/add?id=' + item.id + ' &patientName=' + item.patientName)">编辑</text>
  17. <text class="icon state" :style="{ color: item.state == 0 ? '#b5b5b5' : '#4CAF50' }" v-if="param.type == 1">&#xe830;{{ item.state == 0 ? '待回访' : '已回访' }}</text>
  18. </view>
  19. </view>
  20. <view class="loading" v-if="loadMore"><u-loadmore :status="loadMore ? 'loading' : 'nomore'" /></view>
  21. <u-empty v-if="!loadMore && list.length == 0"></u-empty>
  22. </view>
  23. <view class="mfooter">
  24. <button class="btn" @click="go('/pages/follow/doctor/add?type=' + param.type)">
  25. <text class="icon">&#xe8d5;</text>
  26. <text>新增</text>
  27. </button>
  28. </view>
  29. </view>
  30. </template>
  31. <script>
  32. export default {
  33. data() {
  34. return {
  35. list: [],
  36. param: { pageNum: 1, pageSize: 10, orderByColumn: 'k.id', isAsc: 'desc' },
  37. loadMore: true
  38. };
  39. },
  40. onLoad(e) {
  41. this.param.type = e.type || 0;
  42. this.getData();
  43. uni.$on('record', (res) => {
  44. this.refresh();
  45. });
  46. setTimeout(() => {
  47. uni.setNavigationBarTitle({ title: this.param.type == 0 ? '复诊提醒' : '随访记录' });
  48. }, 300);
  49. },
  50. methods: {
  51. getData() {
  52. this.http.request({
  53. url: '/work/record/list',
  54. data: this.param,
  55. loading: 'false',
  56. success: (res) => {
  57. this.loadMore = res.data.pages > this.param.pageNum ? true : false;
  58. res.data.rows.forEach((item) => {
  59. item.createTime = uni.$u.timeFrom(Date.parse(item.createTime));
  60. this.list.push(item);
  61. });
  62. }
  63. });
  64. },
  65. del(item, index) {
  66. uni.showModal({
  67. title: '提示',
  68. content: '确定删除该内容?',
  69. success: (res) => {
  70. if (res.confirm) {
  71. this.http.request({
  72. url: '/work/record/remove/' + item.id,
  73. success: (res) => {
  74. uni.showToast({ title: '删除成功' });
  75. this.list.splice(index, 1);
  76. }
  77. });
  78. }
  79. }
  80. });
  81. },
  82. detail(item) {
  83. if (this.param.type == 1) {
  84. uni.navigateTo({ url: '/pages/follow/detail?id=' + item.id });
  85. }
  86. },
  87. go(url) {
  88. uni.navigateTo({ url: url });
  89. },
  90. //刷新数据
  91. refresh() {
  92. this.loadMore = true;
  93. this.param.pageNum = 1;
  94. this.list = [];
  95. this.getData();
  96. }
  97. },
  98. //下拉刷新
  99. onPullDownRefresh() {
  100. setTimeout(() => {
  101. this.refresh();
  102. uni.stopPullDownRefresh();
  103. }, 1000);
  104. },
  105. //上拉加载
  106. onReachBottom() {
  107. if (this.loadMore) {
  108. this.param.pageNum++;
  109. this.getData();
  110. }
  111. }
  112. };
  113. </script>
  114. <style lang="scss"></style>