index.vue 8.5 KB

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