list.vue 4.5 KB

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