list.vue 4.5 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. <view class="ks-totalTm">
  33. <icon class="phone-cishu-icon" />次数:{{item.maxTimes}}次
  34. </view>
  35. <!-- 分数 -->
  36. <view class="ks-score-content">
  37. <view class="ks-score">
  38. <icon class="phone-zongfen-icon" />总分:<text>{{item.ksScore}}</text>
  39. </view>
  40. <view class="ks-okScore">
  41. <icon class="phone-jigefen-icon" />及格分:<text>{{item.okScore}}</text>
  42. </view>
  43. </view>
  44. <button type="primary" size="mini" @click="checkKsXz(item)"
  45. class="item-view-btn">查看内容</button>
  46. </view>
  47. </template>
  48. </uni-list-item>
  49. <uni-load-more :status="data.state" @click="getMore(0)"
  50. :contentText="data.contentText"></uni-load-more>
  51. </uni-list>
  52. </scroll-view>
  53. <!-- 页面底端 -->
  54. <customTabbarAdminVue></customTabbarAdminVue>
  55. <!-- 考试须知 -->
  56. <kaoshixuzhiVue ref="ksxzRef" @confirm="handleConfirmKs"></kaoshixuzhiVue>
  57. </view>
  58. </template>
  59. <script setup>
  60. import customTabbarAdminVue from "@/components/custom-tabbar/custom-tabbar-admin.vue";
  61. import kaoshixuzhiVue from "@/components/kaoshixuzhi/kaoshixuzhi.vue";
  62. import {
  63. ref,
  64. reactive
  65. } from "vue";
  66. import {
  67. onLoad
  68. } from "@dcloudio/uni-app";
  69. import {
  70. getKaoshiList
  71. } from "@/api/kaoshi.js";
  72. const ksxzRef = ref(null);
  73. const data = reactive({
  74. zyName: '', // 职业名称
  75. list: [], // 考试列表
  76. loading: false,
  77. page: 0,
  78. size: 8,
  79. state: 'more',
  80. contentText: {
  81. contentdown: '查看更多',
  82. contentrefresh: '加载中',
  83. contentnomore: '没有更多'
  84. }
  85. })
  86. function goUpPage() {
  87. uni.redirectTo({
  88. url: '/pages/admin/ShouYe/shouye'
  89. })
  90. }
  91. function handleConfirmKs(data) {
  92. checkKaoshi(data)
  93. }
  94. function checkKsXz(data) {
  95. ksxzRef.value.showDialog(data)
  96. }
  97. function handleSearch() {
  98. data.page = 0;
  99. refreshData();
  100. }
  101. function checkKaoshi(item) {
  102. uni.navigateTo({
  103. url: `/pages/admin/Kaoshi/exam?ksId=${item.ksId}`
  104. })
  105. }
  106. function onRefresh() {
  107. data.page = 0;
  108. data.list = [];
  109. data.loading = true;
  110. refreshData();
  111. }
  112. function refreshData() {
  113. const opt = {
  114. page: 1,
  115. size: data.size, // 固定查询10条
  116. zyName: data.zyName
  117. }
  118. data.list = [];
  119. // 数学
  120. data.state = 'loading';
  121. data.page++;
  122. opt.page = data.page;
  123. getKaoshiList(opt).then(res => {
  124. data.list = data.list.concat(res.data.data);
  125. data.loading = false;
  126. if (res.data.total > data.list.length) {
  127. data.state = 'more';
  128. data.loading = false;
  129. } else {
  130. data.state = 'no-more';
  131. data.loading = false;
  132. }
  133. }).catch(err => {
  134. data.state = 'more';
  135. data.loading = false;
  136. })
  137. }
  138. function getMore() {
  139. const opt = {
  140. page: 1,
  141. size: data.size, // 固定查询10条
  142. zyName: data.zyName
  143. }
  144. if (data.state == 'no-more') return;
  145. data.state = 'loading';
  146. data.page++;
  147. opt.page = data.page;
  148. getKaoshiList(opt).then(res => {
  149. data.list = data.list.concat(res.data.data);
  150. data.loading = false;
  151. if (res.data.total > data.list.length) {
  152. data.state = 'more';
  153. data.loading = false;
  154. } else {
  155. data.state = 'no-more';
  156. data.loading = false;
  157. }
  158. }).catch(err => {
  159. data.state = 'more';
  160. data.loading = false;
  161. })
  162. }
  163. onLoad(() => {
  164. getMore()
  165. })
  166. </script>