HetongList.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. <template>
  2. <view class="phone-list-page ht-list-page">
  3. <view class="icon-title-navBar-box border-navBar-box">
  4. <text class="nav-bar-title">历史合同</text>
  5. </view>
  6. <!-- 课程列表 -->
  7. <scroll-view scroll-y="true" refresher-enabled="true" :refresher-triggered="data.loading"
  8. :refresher-threshold="50" refresher-background="transparent" @refresherrefresh="onRefresh" @scrolltolower="onScrolltolower"
  9. class="admin-phone-tabbar-view">
  10. <uni-list class="admin-list-box">
  11. <uni-list-item v-for="item in data.list" class="admin-list-item-box">
  12. <template v-slot:body>
  13. <view class="ht-card-row" @click="checkKecheng(item)">
  14. <view class="ht-status">合同状态:<view :class="'status-' + item.status">{{formatStatus(item.status)}}</view></view>
  15. <view class="ht-time"><icon class="phone-time-icon" />合同开始时间:{{formatTime(item.startDate)}} </view>
  16. <view class="ht-time"><icon class="phone-time-icon" />合同结束时间:{{formatTime(item.endDate)}} </view>
  17. </view>
  18. </template>
  19. </uni-list-item>
  20. <uni-load-more :status="data.state" @click="getMore(0)" :contentText="data.contentText"></uni-load-more>
  21. </uni-list>
  22. </scroll-view>
  23. <!-- 页面底端 -->
  24. <customTabbarClientVue></customTabbarClientVue>
  25. </view>
  26. </template>
  27. <script setup>
  28. import {ref,reactive} from "vue";
  29. import {onLoad,onShow} from "@dcloudio/uni-app";
  30. import {getHetongList} from '@/api/hetong.js'
  31. import customTabbarClientVue from "@/components/custom-tabbar/custom-tabbar-admin.vue";
  32. const data = reactive({
  33. list: [], // 考试列表
  34. loading: false,
  35. page: 0,
  36. size: 10,
  37. state: 'more',
  38. contentText: {
  39. contentdown: '查看更多',
  40. contentrefresh: '加载中',
  41. contentnomore: '没有更多'
  42. },
  43. })
  44. onLoad((options) => {
  45. data.from = options.from;
  46. })
  47. onShow(() => {
  48. refreshData()
  49. })
  50. function onRefresh() {
  51. data.page = 0;
  52. data.list = [];
  53. data.loading = true;
  54. refreshData();
  55. }
  56. function refreshData() {
  57. const opt = {
  58. page: 1,
  59. size: 10, // 固定查询10条
  60. }
  61. data.list = [];
  62. // 数学
  63. data.state = 'loading';
  64. data.page++;
  65. opt.page = data.page;
  66. console.log('列表',opt)
  67. getHetongList(opt).then(res => {
  68. data.list = data.list.concat(res.data.data);
  69. data.loading = false;
  70. if (res.data.total > data.list.length) {
  71. data.state = 'more';
  72. data.loading = false;
  73. } else {
  74. data.state = 'no-more';
  75. data.loading = false;
  76. }
  77. }).catch(err => {
  78. data.state = 'more';
  79. data.loading = false;
  80. })
  81. }
  82. function getMore() {
  83. const opt = {
  84. page: 1,
  85. size: 10, // 固定查询10条
  86. }
  87. if (data.state == 'no-more') return;
  88. data.state = 'loading';
  89. data.page++;
  90. opt.page = data.page;
  91. getHetongList(opt).then(res => {
  92. console.log('列表2',res.data)
  93. data.list = data.list.concat(res.data.data);
  94. data.loading = false;
  95. if (res.data.total > data.list.length) {
  96. data.state = 'more';
  97. data.loading = false;
  98. } else {
  99. data.state = 'no-more';
  100. data.loading = false;
  101. }
  102. }).catch(err => {
  103. data.state = 'more';
  104. data.loading = false;
  105. })
  106. }
  107. function onScrolltolower() {
  108. getMore()
  109. }
  110. function handleSearch() {
  111. data.page = 0;
  112. refreshData();
  113. }
  114. // 在现有代码底部添加此方法
  115. function formatStatus(status) {
  116. const statusMap = {
  117. 0: '待签字',
  118. 1: '待审核',
  119. 2: '生效'
  120. };
  121. return statusMap[status] || '未知状态'; // 处理未知状态
  122. }
  123. function formatTime(data){
  124. return data.split(' ')[0];
  125. }
  126. function checkKecheng(item) {
  127. uni.navigateTo({
  128. url: `/pages/admin/Hetong/HetongInfo?id=${item.id}`
  129. })
  130. }
  131. </script>
  132. <style>
  133. </style>