index.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. <template>
  2. <div class="flex direction-column full">
  3. <!-- <mark-header
  4. :exclude-operations="['remark', 'problem', 'example', 'delete', 'bookmark']"
  5. :paper-path="current?.url"
  6. @click="onOperationClick"
  7. ></mark-header> -->
  8. <mark-header :exclude-operations="['delete', 'bookmark']" :paper-path="current?.url" @click="onOperationClick">
  9. <div v-show="current" class="data-item">
  10. <p class="main-ques-info truncate">{{ current?.mainNumber }}-{{ current?.mainTitle }}</p>
  11. </div>
  12. <div class="data-item">
  13. <current-time></current-time>
  14. </div>
  15. </mark-header>
  16. <div class="flex flex-1 overflow-hidden p-base mark-container">
  17. <div
  18. class="flex flex-1 direction-column radius-base fill-blank mark-content"
  19. :class="{ 'text-center': center }"
  20. :style="{ 'background-color': backgroundColor }"
  21. >
  22. <right-button class="next-button" @click="checkNext" />
  23. <div class="flex-1 p-base scroll-auto mark-content-paper img-wrap">
  24. <img :src="dataUrl" alt="" class="paper-img" :style="{ 'background-color': frontColor }" />
  25. </div>
  26. </div>
  27. <div class="p-base radius-base fill-blank scroll-auto m-l-base table-view">
  28. <base-table
  29. ref="tableRef"
  30. border
  31. stripe
  32. size="small"
  33. :data="tableData"
  34. :columns="columns"
  35. highlight-current-row
  36. :cell-style="{ padding: '6px 0' }"
  37. @current-change="onCurrentChange"
  38. ></base-table>
  39. </div>
  40. </div>
  41. </div>
  42. </template>
  43. <script setup lang="ts" name="MarkingViewSample">
  44. /** 查看样卷 */
  45. import { computed } from 'vue'
  46. import { useSetImgBg } from '@/hooks/useSetImgBg'
  47. import useFetch from '@/hooks/useFetch'
  48. import useMarkHeader from '@/hooks/useMarkHeader'
  49. import CurrentTime from '@/components/shared/CurrentTime.vue'
  50. import useTableCheck from '@/hooks/useTableCheck'
  51. import MarkHeader from '@/components/shared/MarkHeader.vue'
  52. import BaseTable from '@/components/element/BaseTable.vue'
  53. import MarkHistoryList from '@/components/shared/MarkHistoryList.vue'
  54. import RightButton from '@/components/shared/RightButton.vue'
  55. import type { SetImgBgOption } from '@/hooks/useSetImgBg'
  56. import type { ExtractApiResponse } from '@/api/api'
  57. import type { MarkHeaderInstance, EpTableColumn } from 'global-type'
  58. type RowType = ExtractArrayValue<ExtractApiResponse<'viewSamplePaper'>> & { index: number }
  59. const {
  60. rotate,
  61. scale,
  62. center,
  63. frontColor,
  64. backgroundColor,
  65. onBack,
  66. onScaleChange,
  67. onCenter,
  68. onRotate,
  69. setBackgroundColor,
  70. setFrontColor,
  71. onViewStandard,
  72. } = useMarkHeader()
  73. /** 刷新 */
  74. const onRefresh = () => {
  75. // viewSamplePaper()
  76. location.reload()
  77. }
  78. type OperationClick = MarkHeaderInstance['onClick']
  79. type OperationType = Parameters<Exclude<OperationClick, undefined>>[0]['type']
  80. const operationHandles: Partial<Record<OperationType, (...args: any) => void>> = {
  81. back: onBack,
  82. 'scale-change': onScaleChange,
  83. center: onCenter,
  84. rotate: onRotate,
  85. 'front-color': setFrontColor,
  86. 'background-color': setBackgroundColor,
  87. refresh: onRefresh,
  88. standard: onViewStandard,
  89. }
  90. const onOperationClick: OperationClick = ({ type, value }) => {
  91. operationHandles[type]?.(value)
  92. }
  93. /** 样卷 */
  94. const columns: EpTableColumn<RowType>[] = [
  95. { label: '密号', prop: 'secretNumber', width: 100, fixed: 'left' },
  96. { label: '题目', prop: 'mainTitle' },
  97. { label: '分数', prop: 'score', width: 50 },
  98. { label: '提交人', prop: 'markerName' },
  99. // { label: '提交时间', prop: 'markTime' },
  100. { label: '给分说明', prop: 'description' },
  101. { label: '提交时间', prop: 'markTime', width: 160 },
  102. ]
  103. const { fetch: viewSamplePaper, result: samplePaperList } = useFetch('viewSamplePaper')
  104. const { tableRef, tableData, current, next: checkNext, onCurrentChange } = useTableCheck(samplePaperList)
  105. viewSamplePaper()
  106. const imgOption = computed<SetImgBgOption>(() => {
  107. return {
  108. image: current?.value?.url,
  109. rotate: rotate.value,
  110. scale: scale.value,
  111. }
  112. })
  113. const { drawing, dataUrl } = useSetImgBg(imgOption, frontColor, setFrontColor)
  114. </script>
  115. <style scoped lang="scss">
  116. .mark-container {
  117. .mark-content {
  118. position: relative;
  119. .preview {
  120. position: absolute;
  121. cursor: pointer;
  122. top: 10px;
  123. right: 20px;
  124. font-size: 24px;
  125. }
  126. .next-button {
  127. position: absolute;
  128. right: -20px;
  129. top: 300px;
  130. }
  131. .mark-content-paper {
  132. img {
  133. max-width: 100%;
  134. }
  135. }
  136. }
  137. .table-view {
  138. // width: 580px;
  139. width: 35%;
  140. }
  141. }
  142. </style>