HetongList.vue 3.6 KB

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