index.vue 7.7 KB

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