index.vue 8.9 KB

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