HetongList.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  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. getHetongList(opt).then(res => {
  67. data.list = data.list.concat(res.data.data);
  68. data.loading = false;
  69. if (res.data.total > data.list.length) {
  70. data.state = 'more';
  71. data.loading = false;
  72. } else {
  73. data.state = 'no-more';
  74. data.loading = false;
  75. }
  76. }).catch(err => {
  77. data.state = 'more';
  78. data.loading = false;
  79. })
  80. }
  81. function getMore() {
  82. const opt = {
  83. page: 1,
  84. size: 10, // 固定查询10条
  85. }
  86. if (data.state == 'no-more') return;
  87. data.state = 'loading';
  88. data.page++;
  89. opt.page = data.page;
  90. getHetongList(opt).then(res => {
  91. data.list = data.list.concat(res.data.data);
  92. data.loading = false;
  93. if (res.data.total > data.list.length) {
  94. data.state = 'more';
  95. data.loading = false;
  96. } else {
  97. data.state = 'no-more';
  98. data.loading = false;
  99. }
  100. }).catch(err => {
  101. data.state = 'more';
  102. data.loading = false;
  103. })
  104. }
  105. function onScrolltolower() {
  106. getMore()
  107. }
  108. function handleSearch() {
  109. data.page = 0;
  110. refreshData();
  111. }
  112. // 在现有代码底部添加此方法
  113. function formatStatus(status) {
  114. const statusMap = {
  115. 0: '待签字',
  116. 1: '待审核',
  117. 2: '生效'
  118. };
  119. return statusMap[status] || '未知状态'; // 处理未知状态
  120. }
  121. function formatTime(data){
  122. console.log(data.split(' ')[0],'data.split()[0]');
  123. return data.split(' ')[0];
  124. }
  125. function checkKecheng(item) {
  126. uni.navigateTo({
  127. url: `/pages/admin/Hetong/HetongInfo?id=${item.id}`
  128. })
  129. }
  130. </script>
  131. <style>
  132. </style>