HetongList.vue 3.8 KB

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