index.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  1. <template>
  2. <div class="flex direction-column full">
  3. <mark-header :exclude-operations="['remark', 'problem', 'example', 'delete', 'bookmark']" @click="onOperationClick">
  4. <el-button class="m-l-base m-r-auto" size="small" type="primary" @click="onConfirmReMark">确认</el-button>
  5. </mark-header>
  6. <div class="flex flex-1 overflow-hidden p-base mark-container">
  7. <div
  8. class="flex flex-1 direction-column radius-base fill-blank mark-content"
  9. :class="{ 'text-center': center }"
  10. :style="{ 'background-color': backgroundColor }"
  11. >
  12. <span class="preview" @click="onPreview">
  13. <svg-icon name="preview"></svg-icon>
  14. </span>
  15. <right-button class="next-button" @click="checkNext" />
  16. <div class="flex-1 p-base scroll-auto mark-content-paper">
  17. <img :src="dataUrl" alt="" class="paper-img" :style="{ 'background-color': frontColor }" />
  18. </div>
  19. <scoring-panel-with-confirm
  20. v-model:visible="scoringPanelVisible"
  21. v-model:score="modelScore"
  22. :main-number="mockTask.mainNumber"
  23. @submit="onSubmit"
  24. ></scoring-panel-with-confirm>
  25. </div>
  26. <div class="p-base radius-base fill-blank scroll-auto m-l-base problem-list">
  27. <base-form size="small" :model="formModel" :items="formItems" :label-width="useVW(62)">
  28. <template #form-item-search>
  29. <el-button type="primary" @click="onSearch">查询</el-button>
  30. </template>
  31. </base-form>
  32. <div class="flex items-center p-l-base">
  33. <span>重评卷</span>
  34. <span>: 共{{ tableData.length }}</span>
  35. </div>
  36. <base-table
  37. ref="tableRef"
  38. size="small"
  39. :data="tableData"
  40. :columns="columns"
  41. @current-change="onCurrentChange"
  42. @row-dblclick="onDbClick"
  43. ></base-table>
  44. </div>
  45. </div>
  46. </div>
  47. <image-preview v-model="previewModalVisible" :url="MockImg"></image-preview>
  48. <mark-history-list :id="currentViewHistory?.taskId" v-model="visibleHistory"></mark-history-list>
  49. </template>
  50. <script setup lang="ts" name="MarkingRepeat">
  51. /** 重评卷查看 */
  52. import { reactive, ref, computed, watch, nextTick } from 'vue'
  53. import { ElButton } from 'element-plus'
  54. import { add } from '@/utils/common'
  55. import { useSetImgBg } from '@/hooks/useSetImgBg'
  56. import useVW from '@/hooks/useVW'
  57. import useFetch from '@/hooks/useFetch'
  58. import useForm from '@/hooks/useForm'
  59. import useOptions from '@/hooks/useOptions'
  60. import useMarkHeader from '@/hooks/useMarkHeader'
  61. import useMainStore from '@/store/main'
  62. import useTableCheck from '@/hooks/useTableCheck'
  63. import MarkHeader from '@/components/shared/MarkHeader.vue'
  64. import ScoringPanelWithConfirm from '@/components/shared/ScoringPanelWithConfirm.vue'
  65. import SvgIcon from '@/components/common/SvgIcon.vue'
  66. import BaseForm from '@/components/element/BaseForm.vue'
  67. import BaseTable from '@/components/element/BaseTable.vue'
  68. import MarkHistoryList from '@/components/shared/MarkHistoryList.vue'
  69. import RightButton from '@/components/shared/RightButton.vue'
  70. import ImagePreview from '@/components/shared/ImagePreview.vue'
  71. import MockImg from '@/assets/mock/SAMPA-1.jpg'
  72. import type { SetImgBgOption } from '@/hooks/useSetImgBg'
  73. import type { ExtractApiParams, ExtractApiResponse, ExtractMultipleApiResponse } from 'api-type'
  74. import type { MarkHeaderInstance, EpFormItem, EpTableColumn } from 'global-type'
  75. type RowType = ExtractMultipleApiResponse<'getReMarkPaperList'> & { index: number }
  76. const {
  77. rotate,
  78. scale,
  79. center,
  80. frontColor,
  81. backgroundColor,
  82. onBack,
  83. onScaleChange,
  84. onCenter,
  85. onRotate,
  86. setBackgroundColor,
  87. setFrontColor,
  88. onViewStandard,
  89. } = useMarkHeader()
  90. /** 给分板 */
  91. const scoringPanelVisible = ref<boolean>(true)
  92. /** 图片预览 */
  93. const previewModalVisible = ref<boolean>(false)
  94. const modelScore = ref<number[]>([])
  95. const imgOption = computed<SetImgBgOption>(() => {
  96. return {
  97. image: MockImg,
  98. immediate: true,
  99. rotate: rotate.value,
  100. scale: scale.value,
  101. }
  102. })
  103. const { drawing, dataUrl } = useSetImgBg(imgOption)
  104. const mockTask = ref<{ mainNumber: number }>({
  105. mainNumber: 1,
  106. })
  107. /** 刷新 */
  108. const onRefresh = () => {
  109. onSearch()
  110. }
  111. /** 预览试卷 */
  112. const onPreview = () => {
  113. previewModalVisible.value = true
  114. }
  115. const { fetch: confirmReMarkPaper } = useFetch('confirmReMarkPaper')
  116. /** 确认重评 */
  117. const onConfirmReMark = () => {
  118. if (currentReMarkPaper.value?.id) {
  119. confirmReMarkPaper({ id: currentReMarkPaper.value.id }).then(checkNext)
  120. }
  121. }
  122. type OperationClick = MarkHeaderInstance['onClick']
  123. type OperationType = Parameters<Exclude<OperationClick, undefined>>[0]['type']
  124. const operationHandles: Partial<Record<OperationType, (...args: any) => void>> = {
  125. back: onBack,
  126. 'scale-change': onScaleChange,
  127. center: onCenter,
  128. rotate: onRotate,
  129. 'front-color': setFrontColor,
  130. 'background-color': setBackgroundColor,
  131. refresh: onRefresh,
  132. standard: onViewStandard,
  133. }
  134. const onOperationClick: OperationClick = ({ type, value }) => {
  135. operationHandles[type]?.(value)
  136. }
  137. const formModel = reactive<ExtractApiParams<'getReMarkPaperList'>>({
  138. mainNumber: void 0,
  139. status: false,
  140. pageNumber: 1,
  141. pageSize: 9999999,
  142. })
  143. const mainStore = useMainStore()
  144. const { mainQuestionList, dataModel, changeModelValue, onOptionInit } = useOptions(['question'], {
  145. subject: mainStore.myUserInfo?.subjectCode,
  146. })
  147. watch(dataModel, () => {
  148. formModel.mainNumber = dataModel.question
  149. })
  150. const { defineColumn, _ } = useForm()
  151. const span10 = defineColumn(_, '', { span: 10 })
  152. const formItems = computed<EpFormItem[]>(() => [
  153. span10({
  154. rowKey: 'row-1',
  155. label: '大题',
  156. prop: 'mainNumber',
  157. slotType: 'select',
  158. slot: { options: mainQuestionList.value, onChange: changeModelValue('question') },
  159. }),
  160. span10({
  161. rowKey: 'row-1',
  162. label: '状态',
  163. labelWidth: useVW(40),
  164. prop: 'status',
  165. slotType: 'select',
  166. slot: {
  167. options: [
  168. { label: '已确认', value: true },
  169. { label: '未确认', value: false },
  170. ],
  171. },
  172. }),
  173. { rowKey: 'row-1', slotName: 'search', labelWidth: '10px', colProp: { span: 4 } },
  174. ])
  175. /** 查询重评卷列表 */
  176. const columns: EpTableColumn[] = [
  177. { label: '密号', prop: 'secretNumber', width: 70 },
  178. { label: '评卷员', prop: 'markerName', width: 70 },
  179. { label: '给分', prop: 'markerScore', width: 54 },
  180. { label: '重评时间', prop: 'reMarkTime', width: 88 },
  181. { label: '确认状态', prop: 'confirm', width: 72 },
  182. { label: '确认给分', prop: 'confirmScore', width: 72 },
  183. ]
  184. const { fetch: getReMarkPaperList, result: reMarkPaperList } = useFetch('getReMarkPaperList')
  185. const {
  186. tableRef,
  187. tableData,
  188. current: currentReMarkPaper,
  189. currentView: currentViewHistory,
  190. next: checkNext,
  191. visibleHistory,
  192. onDbClick,
  193. onCurrentChange,
  194. } = useTableCheck(reMarkPaperList)
  195. const onSearch = async () => {
  196. getReMarkPaperList(formModel)
  197. }
  198. /** 重评卷打分 */
  199. const { fetch: markReMarkPaper } = useFetch('markReMarkPaper')
  200. const onSubmit = () => {
  201. if (currentReMarkPaper.value) {
  202. markReMarkPaper({ id: currentReMarkPaper.value.id, scores: modelScore.value })
  203. }
  204. }
  205. onOptionInit(onSearch)
  206. </script>
  207. <style scoped lang="scss">
  208. .mark-container {
  209. .mark-content {
  210. position: relative;
  211. .preview {
  212. position: absolute;
  213. cursor: pointer;
  214. top: 10px;
  215. right: 20px;
  216. font-size: 24px;
  217. }
  218. .next-button {
  219. position: absolute;
  220. right: -20px;
  221. top: 300px;
  222. }
  223. .mark-content-paper {
  224. img {
  225. max-width: 100%;
  226. }
  227. }
  228. }
  229. .problem-list {
  230. width: 480px;
  231. }
  232. }
  233. </style>