exam-history-paperwork.vue 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  1. <template>
  2. <view>
  3. <view class="w-full flex mb-30 justify-between">
  4. <view class="max-w-180">
  5. <ie-picker ref="pickerRef" v-model="queryForm.buildType" :list="buildTypeList" placeholder="类型" title="类型"
  6. icon="arrow-down" key-label="name" key-value="value" :fontSize="28"
  7. :placeholder-style="placeholderStyle"></ie-picker>
  8. </view>
  9. <view class="max-w-180">
  10. <ie-picker ref="pickerRef" v-model="queryForm.batchId" :list="batchList" placeholder="批次" title="批次"
  11. icon="arrow-down" key-label="name" key-value="batchId" :fontSize="28"
  12. :placeholder-style="placeholderStyle"></ie-picker>
  13. </view>
  14. <view class="max-w-180">
  15. <ie-picker ref="pickerRef" v-model="queryForm.classId" :list="classList" placeholder="班级" title="班级"
  16. icon="arrow-down" key-label="name" key-value="classId" :fontSize="28"
  17. :placeholder-style="placeholderStyle"></ie-picker>
  18. </view>
  19. <view class="max-w-180">
  20. <ie-picker ref="pickerRef" v-model="queryForm.subjectId" :list="subjectList" placeholder="科目" title="科目"
  21. icon="arrow-down" key-label="subjectName" key-value="subjectId" :fontSize="28"
  22. :placeholder-style="placeholderStyle"></ie-picker>
  23. </view>
  24. </view>
  25. <ie-table :tableColumns="tableColumns" :data="tableData" :cellStyle="cellStyle">
  26. <template #name="{ item }">
  27. <text class="font-bold">{{ getStatusText(item.buildStatus) }}</text>
  28. </template>
  29. <template #total="{ item }">
  30. <text class="font-bold">{{ item.count || 0 }}</text>
  31. </template>
  32. <template #status="{ item }">
  33. <text class="text-30 text-primary font-bold" @click="handleRowClick(item)">查看</text>
  34. </template>
  35. </ie-table>
  36. </view>
  37. <ie-popup :title="popupTitle" ref="popupRef" mode="bottom" :showToolbar="false">
  38. <view class="p-30 relative">
  39. <view class="text-center text-30 font-bold">{{ popupTitle }}</view>
  40. <uv-icon name="close" size="18" color="#333" class="absolute top-34 right-20" @click="popupRef.close()" />
  41. </view>
  42. <view class="h-[400px]">
  43. <scroll-view scroll-y class="h-full">
  44. <view class="px-20 py-4">
  45. <ie-table :tableColumns="tableColumns2" :data="tableData2" :cellStyle="cellStyle" @rowClick="handleRowClick">
  46. <template #status="{ item }">
  47. <text class="text-30 text-primary font-bold" @click="handleRowClick(item)">查看</text>
  48. </template>
  49. </ie-table>
  50. </view>
  51. </scroll-view>
  52. </view>
  53. </ie-popup>
  54. </template>
  55. <script lang="ts" setup>
  56. import { Study, TableColumnConfig } from '@/types';
  57. import { CSSProperties } from 'vue';
  58. import { getBatchList, getTeachClassList, getTeacherSubjectList, getTeacherTestRecord, getTeacherTestRecordDetail, getTeacherTestRecordCondition } from '@/api/modules/study';
  59. import { EnumPaperBuildType, EnumPaperWorkState } from '@/common/enum';
  60. const cellStyle: CSSProperties = {
  61. padding: '30rpx 20rpx'
  62. }
  63. const queryForm = ref<Partial<Study.PaperWorkRecordQuery>>({});
  64. const buildTypeList = ref([
  65. {
  66. name: '定向智能',
  67. value: EnumPaperBuildType.EXACT_INTELLIGENT
  68. },
  69. {
  70. name: '全量智能',
  71. value: EnumPaperBuildType.FULL_INTELLIGENT
  72. },
  73. {
  74. name: '定向手动',
  75. value: EnumPaperBuildType.EXACT_HAND
  76. },
  77. {
  78. name: '全量手动',
  79. value: EnumPaperBuildType.FULL_HAND
  80. }
  81. ]);
  82. const buildStatusList = ref([
  83. {
  84. name: '未定向未组卷',
  85. value: 10
  86. },
  87. {
  88. name: '未组卷',
  89. value: 20
  90. },
  91. {
  92. name: '组卷未完成',
  93. value: 30
  94. },
  95. {
  96. name: '组卷已完成',
  97. value: 40
  98. }
  99. ]);
  100. const popupTitle = ref('');
  101. const classList = ref<Study.TeachClass[]>([]);
  102. const batchList = ref<Study.Batch[]>([]);
  103. const subjectList = ref<Study.Subject[]>([]);
  104. const pickerRef = ref();
  105. const placeholderStyle = {
  106. color: '#1A1A1A'
  107. }
  108. const tableData = ref<Study.PaperWorkRecord[]>([]);
  109. const tableColumns: TableColumnConfig[] = [
  110. {
  111. prop: 'name',
  112. label: '状态',
  113. flex: 1,
  114. slot: 'name',
  115. headerAlign: 'center',
  116. align: 'center'
  117. },
  118. {
  119. prop: 'total',
  120. label: '人数',
  121. flex: 1,
  122. slot: 'total'
  123. },
  124. {
  125. prop: 'status',
  126. label: '操作',
  127. flex: 1,
  128. slot: 'status'
  129. }
  130. ];
  131. const tableColumns2: TableColumnConfig[] = [
  132. {
  133. prop: 'className',
  134. label: '班级',
  135. flex: 1,
  136. headerAlign: 'center',
  137. align: 'center'
  138. },
  139. {
  140. prop: 'nickName',
  141. label: '姓名',
  142. flex: 1
  143. },
  144. {
  145. prop: 'state',
  146. label: '状态',
  147. flex: 1,
  148. headerAlign: 'right',
  149. align: 'right',
  150. }
  151. ];
  152. const tableData2 = ref<Study.PaperWorkRecordDetail[]>([]);
  153. const getStatusText = (status: number | null) => {
  154. if (!status) {
  155. return '总人数';
  156. }
  157. const statusMap = {
  158. 10: '未定向未组卷',
  159. 20: '未组卷',
  160. 30: '组卷未完成',
  161. 40: '组卷已完成'
  162. }
  163. return statusMap[status as keyof typeof statusMap];
  164. }
  165. const popupRef = ref();
  166. const handleRowClick = async (row: Study.PaperWorkRecord) => {
  167. if (!row.count) {
  168. uni.$ie.showToast('暂无数据');
  169. return;
  170. }
  171. uni.$ie.showLoading();
  172. try {
  173. const params = {
  174. ...queryForm.value
  175. } as Study.PaperWorkRecordQuery;
  176. if (row.buildStatus !== null) {
  177. params.buildStatus = row.buildStatus;
  178. } else {
  179. delete (params as any).buildStatus;
  180. }
  181. await getTeacherTestRecordDetail(params).then(res => {
  182. tableData2.value = res.data;
  183. });
  184. } finally {
  185. uni.$ie.hideLoading();
  186. }
  187. popupTitle.value = getStatusText(row.buildStatus);
  188. popupRef.value.open();
  189. }
  190. const loadData = async () => {
  191. const queryBatch = getBatchList({}).then(res => {
  192. batchList.value = res.data;
  193. });
  194. const queryClass = getTeachClassList({}).then(res => {
  195. classList.value = res.data;
  196. });
  197. const querySubject = getTeacherSubjectList({}).then(res => {
  198. subjectList.value = res.data;
  199. });
  200. await Promise.all([queryBatch, queryClass, querySubject]);
  201. const queryCondition = getTeacherTestRecordCondition({}).then(res => {
  202. const { buildType, buildStatus, batchId, classId, subjectId } = res.data;
  203. queryForm.value = {
  204. buildType: buildType || buildTypeList.value[0].value,
  205. buildStatus: buildStatus || buildStatusList.value[0].value,
  206. batchId: batchId || batchList.value[0].batchId,
  207. classId: classId || classList.value[0].classId,
  208. subjectId: subjectId || subjectList.value[0].subjectId,
  209. };
  210. });
  211. await Promise.all([queryCondition]);
  212. }
  213. const loadTestRecord = () => {
  214. const params = {} as Study.PaperWorkRecordQuery;
  215. const { buildType, buildStatus, batchId, classId, subjectId } = queryForm.value;
  216. if (buildType !== undefined && buildType !== null) {
  217. params.buildType = buildType;
  218. }
  219. if (batchId !== undefined && batchId !== null) {
  220. params.batchId = batchId;
  221. }
  222. if (classId !== undefined && classId !== null) {
  223. params.classId = classId;
  224. }
  225. if (subjectId !== undefined && subjectId !== null) {
  226. params.subjectId = subjectId;
  227. }
  228. uni.$ie.showLoading();
  229. getTeacherTestRecord(params).then(res => {
  230. tableData.value = res.data;
  231. }).finally(() => {
  232. uni.$ie.hideLoading();
  233. });
  234. }
  235. watch(() => queryForm.value, () => {
  236. loadTestRecord();
  237. }, {
  238. deep: true,
  239. immediate: false
  240. });
  241. onMounted(() => {
  242. loadData();
  243. });
  244. </script>
  245. <style lang="scss" scoped></style>