index.vue 8.0 KB

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