list.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. <template>
  2. <view class="phone-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. <view class="phone-search-box">
  9. <input class="search-input" placeholder="请输入职业名称" v-model="data.zyName" />
  10. <view class="search-icon" @click="handleSearch">
  11. <uni-icons type="search" size="24" color="#fff"></uni-icons>
  12. </view>
  13. </view>
  14. <!-- 考试列表 -->
  15. <scroll-view scroll-y="true" refresher-enabled="true" :refresher-triggered="data.loading"
  16. :refresher-threshold="50" refresher-background="transparent" @refresherrefresh="onRefresh"
  17. class="phone-scroll-view">
  18. <uni-list class="admin-list-box">
  19. <uni-list-item v-for="item in data.list" class="admin-list-item-box">
  20. <template v-slot:body>
  21. <!-- 考试项 -->
  22. <view class="item-card-row">
  23. <!-- 考试名 + 等级 -->
  24. <view class="ks-item-top">
  25. <view class="ks-name">{{item.zyName}}</view>
  26. <view class="ks-zyLevelName">{{item.zyLevelName}}</view>
  27. </view>
  28. <!-- 时间 -->
  29. <view class="ks-totalTm">
  30. <icon class="phone-time-icon" />时间:{{item.totalTm}}分钟
  31. </view>
  32. <!-- 分数 -->
  33. <view class="ks-score-content">
  34. <view class="ks-score">
  35. <icon class="phone-zongfen-icon" />总分:<text>{{item.ksScore}}</text>
  36. </view>
  37. <view class="ks-okScore">
  38. <icon class="phone-jigefen-icon" />及格分:<text>{{item.okScore}}</text>
  39. </view>
  40. </view>
  41. <button type="primary" size="mini" @click="checkKsXz(item)"
  42. class="item-view-btn">查看内容</button>
  43. </view>
  44. </template>
  45. </uni-list-item>
  46. <uni-load-more :status="data.state" @click="getMore(0)"
  47. :contentText="data.contentText"></uni-load-more>
  48. </uni-list>
  49. </scroll-view>
  50. <!-- 页面底端 -->
  51. <customTabbarAdminVue></customTabbarAdminVue>
  52. <!-- 考试须知 -->
  53. <lianxixuzhi ref="lxxzRef" @confirm="handleConfirmKs"></lianxixuzhi>
  54. </view>
  55. </template>
  56. <script setup>
  57. import * as lianxiApi from "@/api/lianxi.js";
  58. import customTabbarAdminVue from "@/components/custom-tabbar/custom-tabbar-admin.vue";
  59. import lianxixuzhi from "@/components/kaoshixuzhi/lianxixuzhi.vue";
  60. import {
  61. ref,
  62. reactive
  63. } from "vue";
  64. import {
  65. onLoad
  66. } from "@dcloudio/uni-app";
  67. const lxxzRef = ref(null);
  68. const data = reactive({
  69. zyName: '', // 职业名称
  70. list: [], // 考试列表
  71. loading: false,
  72. page: 0,
  73. size: 8,
  74. state: 'more',
  75. contentText: {
  76. contentdown: '查看更多',
  77. contentrefresh: '加载中',
  78. contentnomore: '没有更多'
  79. }
  80. })
  81. function checkKsXz(data) {
  82. lxxzRef.value.showDialog(data)
  83. }
  84. function handleConfirmKs(data) {
  85. checkKaoshi(data)
  86. }
  87. function goUpPage() {
  88. uni.redirectTo({
  89. url: '/pages/admin/ShouYe/shouye'
  90. })
  91. }
  92. function handleSearch() {
  93. data.page = 0;
  94. refreshData();
  95. }
  96. function checkKaoshi(item) {
  97. uni.redirectTo({
  98. url: `/pages/admin/Lianxi/lianxi?lxId=${item.lxId}`
  99. })
  100. }
  101. function onRefresh() {
  102. data.page = 0;
  103. data.list = [];
  104. data.loading = true;
  105. refreshData();
  106. }
  107. function refreshData() {
  108. const opt = {
  109. page: 1,
  110. size: data.size, // 固定查询10条
  111. zyName: data.zyName
  112. }
  113. data.list = [];
  114. // 数学
  115. data.state = 'loading';
  116. data.page++;
  117. opt.page = data.page;
  118. lianxiApi.getLianxiList(opt).then(res => {
  119. data.list = data.list.concat(res.data.data);
  120. data.loading = false;
  121. if (res.data.total > data.list.length) {
  122. data.state = 'more';
  123. data.loading = false;
  124. } else {
  125. data.state = 'no-more';
  126. data.loading = false;
  127. }
  128. }).catch(err => {
  129. data.state = 'more';
  130. data.loading = false;
  131. })
  132. }
  133. function getMore() {
  134. const opt = {
  135. page: 1,
  136. size: data.size, // 固定查询10条
  137. zyName: data.zyName
  138. }
  139. if (data.state == 'no-more') return;
  140. data.state = 'loading';
  141. data.page++;
  142. opt.page = data.page;
  143. lianxiApi.getLianxiList(opt).then(res => {
  144. data.list = data.list.concat(res.data.data);
  145. data.loading = false;
  146. if (res.data.total > data.list.length) {
  147. data.state = 'more';
  148. data.loading = false;
  149. } else {
  150. data.state = 'no-more';
  151. data.loading = false;
  152. }
  153. }).catch(err => {
  154. data.state = 'more';
  155. data.loading = false;
  156. })
  157. }
  158. onLoad(() => {
  159. getMore()
  160. })
  161. </script>
  162. <style>
  163. </style>