exam-history-teacher.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. <template>
  2. <view class="p-30 pt-50">
  3. <view class="w-fit flex gap-x-80">
  4. <ie-picker ref="pickerRef" v-model="classId" :list="classList" placeholder="选择批次" title="选择批次" icon="arrow-down"
  5. key-label="name" key-value="classId" @change="handleClassChange"
  6. :placeholder-style="placeholderStyle"></ie-picker>
  7. <ie-picker ref="pickerRef" v-model="classId" :list="classList" placeholder="选择班级" title="选择班级" icon="arrow-down"
  8. key-label="name" key-value="classId" @change="handleClassChange"
  9. :placeholder-style="placeholderStyle"></ie-picker>
  10. </view>
  11. <view class="mt-32 py-38 bg-back border border-solid border-border rounded-10 flex">
  12. <view class="flex-1 text-center">
  13. <view class="text-40 text-primary font-bold leading-30">64</view>
  14. <view class="mt-24 text-28 text-fore-light leading-28">总人数</view>
  15. </view>
  16. <view class="flex-1 text-center">
  17. <view class="text-40 text-[#22C55E] font-bold leading-30">27</view>
  18. <view class="mt-24 text-28 text-fore-light leading-28">完成</view>
  19. </view>
  20. <view class="flex-1 text-center">
  21. <view class="text-40 text-[#F59E0B] font-bold leading-30">10</view>
  22. <view class="mt-24 text-28 text-fore-light leading-28">未完成</view>
  23. </view>
  24. <view class="flex-1 text-center">
  25. <view class="text-40 text-[#F59E0B] font-bold leading-30">9</view>
  26. <view class="mt-24 text-28 text-fore-light leading-28">未发送</view>
  27. </view>
  28. </view>
  29. <view class="mt-70">
  30. <ie-table :tableColumns="tableColumns" :data="tableData" :cellStyle="cellStyle" @rowClick="handleRowClick">
  31. <template #name="{ item }: { item: StudentExamRecord }">
  32. <text class="font-bold">{{ item.name }}</text>
  33. </template>
  34. <template #score="{ item }: { item: StudentExamRecord }">
  35. <text class="font-bold">{{ item.score }}</text>
  36. </template>
  37. <template #status="{ item }: { item: StudentExamRecord }">
  38. <text :class="getStatusClass(item.status)">{{ getStatusText(item.status) }}</text>
  39. </template>
  40. </ie-table>
  41. </view>
  42. </view>
  43. </template>
  44. <script lang="ts" setup>
  45. import { TableColumnConfig } from '@/types';
  46. import { StudentExamRecord, TeachClass } from '@/types/study';
  47. import { CSSProperties } from 'vue';
  48. const props = defineProps({
  49. examType: {
  50. type: String,
  51. default: 'test'
  52. }
  53. });
  54. const classId = ref<number>(0);
  55. const classList = ref<TeachClass[]>([]);
  56. const pickerRef = ref();
  57. const placeholderStyle = {
  58. color: '#1A1A1A'
  59. }
  60. const tableColumns: TableColumnConfig[] = [
  61. {
  62. prop: 'name',
  63. label: '姓名',
  64. flex: 1,
  65. slot: 'name',
  66. headerAlign: 'center',
  67. align: 'center'
  68. },
  69. {
  70. prop: 'score',
  71. label: '得分',
  72. flex: 1,
  73. slot: 'score'
  74. },
  75. {
  76. prop: 'status',
  77. label: '状态',
  78. flex: 1,
  79. slot: 'status'
  80. }
  81. ]
  82. const tableData = ref<StudentExamRecord[]>([
  83. {
  84. id: 1,
  85. name: '张三',
  86. score: 100,
  87. status: 1
  88. },
  89. {
  90. id: 2,
  91. name: '李四',
  92. score: 90,
  93. status: 2
  94. },
  95. {
  96. id: 3,
  97. name: '王五',
  98. score: 80,
  99. status: 1
  100. },
  101. {
  102. id: 4,
  103. name: '赵六',
  104. score: 70,
  105. status: 1
  106. },
  107. {
  108. id: 5,
  109. name: '孙七',
  110. score: 60,
  111. status: 2
  112. },
  113. {
  114. id: 6,
  115. name: '周八',
  116. score: 50,
  117. status: 2
  118. },
  119. {
  120. id: 7,
  121. name: '吴九',
  122. score: 40,
  123. status: 1
  124. }
  125. ])
  126. const cellStyle: CSSProperties = {
  127. padding: '30rpx 20rpx'
  128. }
  129. const handleClassChange = (value: number, selectedItem: TeachClass) => {
  130. classId.value = value;
  131. }
  132. // 处理表格行点击事件
  133. const handleRowClick = (row: StudentExamRecord) => {
  134. console.log('点击了行:', row);
  135. // 这里可以添加跳转到详情页或其他逻辑
  136. }
  137. // 获取状态文本
  138. const getStatusText = (status: number) => {
  139. const statusMap = {
  140. 1: '已完成',
  141. 2: '未完成',
  142. 3: '未发送'
  143. };
  144. return statusMap[status as keyof typeof statusMap] || '未知';
  145. }
  146. // 获取状态样式类
  147. const getStatusClass = (status: number) => {
  148. const classMap = {
  149. 1: 'text-[#22C55E] font-bold',
  150. 2: 'text-[#F59E0B] font-bold',
  151. 3: 'text-[#6B7280] font-bold'
  152. };
  153. return classMap[status as keyof typeof classMap] || 'text-gray-500';
  154. }
  155. const loadData = async () => {
  156. // const res = await getClassHistory();
  157. // console.log(res);
  158. uni.$ie.showLoading();
  159. setTimeout(() => {
  160. uni.$ie.hideLoading();
  161. }, 1000);
  162. }
  163. const loadClassList = async () => {
  164. // const res = await getClassList();
  165. // console.log(res);
  166. }
  167. watch(() => props.examType, (newVal) => {
  168. loadData();
  169. }, {
  170. immediate: true
  171. });
  172. </script>
  173. <style lang="scss" scoped></style>