list.vue 4.4 KB

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