index.vue 9.7 KB

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