index.vue 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  1. <template>
  2. <div class="flex direction-column full">
  3. <mark-header
  4. :exclude-operations="['remark', 'problem', 'example', 'delete', 'bookmark']"
  5. :paper-path="currentRfPaper?.filePath"
  6. @click="onOperationClick"
  7. >
  8. <el-button class="m-l-base m-r-auto" size="small" type="primary" @click="onEditScore">修改给分</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 img-wrap relative">
  21. <img :src="dataUrl" alt="" class="paper-img" :style="{ 'background-color': frontColor }" />
  22. <p v-if="currentRfPaper" class="absolute mark-score">{{ currentRfPaper.score }}</p>
  23. </div>
  24. <!-- <scoring-panel-with-confirm
  25. v-model:visible="editScoreVisible"
  26. v-model:score="modelScore"
  27. modal
  28. :toggle-modal="false"
  29. :auto-visible="false"
  30. :main-number="currentRfPaper?.mainNumber"
  31. @submit="onSubmit"
  32. ></scoring-panel-with-confirm> -->
  33. <scoring-panel-with-confirm
  34. v-model:visible="editScoreVisible"
  35. v-model:score="modelScore"
  36. modal
  37. :auto-visible="false"
  38. :main-number="currentRfPaper?.mainNumber"
  39. @submit="onSubmit"
  40. ></scoring-panel-with-confirm>
  41. </div>
  42. <div class="flex direction-column p-base radius-base fill-blank m-l-base table-view">
  43. <base-form size="small" :model="formModel" :items="formItems" :label-width="'52px'">
  44. <template #form-item-search>
  45. <el-button :loading="loading" type="primary" @click="onSearch">查询</el-button>
  46. </template>
  47. </base-form>
  48. <div>
  49. <el-button custom-1 size="small" class="detail-info-label">
  50. <span class="">RF卷: 共</span>
  51. <span class="m-l-extra-small detail-info-label-num">{{ tableData.length }}</span>
  52. </el-button>
  53. </div>
  54. <div class="flex-1 scroll-auto m-t-mini">
  55. <base-table
  56. ref="tableRef"
  57. border
  58. stripe
  59. size="small"
  60. height="100%"
  61. :data="tableData"
  62. :columns="columns"
  63. highlight-current-row
  64. :cell-style="{ padding: '6px 0' }"
  65. @current-change="onCurrentChange"
  66. @row-dblclick="onDbClick"
  67. ></base-table>
  68. </div>
  69. </div>
  70. </div>
  71. </div>
  72. <image-preview v-model="previewModalVisible" :url="currentRfPaper?.filePath"></image-preview>
  73. </template>
  74. <script setup lang="ts" name="ExpertSample">
  75. /** 专家卷浏览-RF卷 */
  76. import { reactive, ref, computed, watch, nextTick } from 'vue'
  77. import { ElButton, ElMessage } from 'element-plus'
  78. import { add } from '@/utils/common'
  79. import { useSetImgBg } from '@/hooks/useSetImgBg'
  80. import useFetch from '@/hooks/useFetch'
  81. import useVW from '@/hooks/useVW'
  82. import useForm from '@/hooks/useForm'
  83. import useOptions from '@/hooks/useOptions'
  84. import useMarkHeader from '@/hooks/useMarkHeader'
  85. import useTableCheck from '@/hooks/useTableCheck'
  86. import MarkHeader from '@/components/shared/MarkHeader.vue'
  87. import BaseForm from '@/components/element/BaseForm.vue'
  88. import BaseTable from '@/components/element/BaseTable.vue'
  89. import RightButton from '@/components/shared/RightButton.vue'
  90. import SvgIcon from '@/components/common/SvgIcon.vue'
  91. import ScoringPanelWithConfirm from '@/components/shared/ScoringPanelWithConfirm.vue'
  92. import ImagePreview from '@/components/shared/ImagePreview.vue'
  93. import type { SetImgBgOption } from '@/hooks/useSetImgBg'
  94. import type { ExtractMultipleApiResponse, ExtractApiParams, ExtractApiResponse } from '@/api/api'
  95. import type { MarkHeaderInstance, EpFormItem, EpTableColumn } from 'global-type'
  96. type RowType = ExtractMultipleApiResponse<'getRfSampleList'> & { index: number }
  97. /** 给分板 */
  98. const editScoreVisible = ref<boolean>(false)
  99. /** 图片预览 */
  100. const previewModalVisible = ref<boolean>(false)
  101. const modelScore = ref<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 onRefresh = () => {
  118. onSearch()
  119. }
  120. /** 预览试卷 */
  121. const onPreview = () => {
  122. previewModalVisible.value = true
  123. }
  124. const onEditScore = () => {
  125. editScoreVisible.value = true
  126. }
  127. type OperationClick = MarkHeaderInstance['onClick']
  128. type OperationType = Parameters<Exclude<OperationClick, undefined>>[0]['type']
  129. const operationHandles: Partial<Record<OperationType, (...args: any) => void>> = {
  130. back: onBack,
  131. 'scale-change': onScaleChange,
  132. center: onCenter,
  133. rotate: onRotate,
  134. 'front-color': setFrontColor,
  135. 'background-color': setBackgroundColor,
  136. refresh: onRefresh,
  137. standard: onViewStandard,
  138. }
  139. const onOperationClick: OperationClick = ({ type, value }) => {
  140. operationHandles[type]?.(value)
  141. }
  142. const { mainQuestionList, dataModel, changeModelValue, onOptionInit } = useOptions(['question'])
  143. const formModel = reactive<ExtractApiParams<'getRfSampleList'>>({
  144. mainNumber: dataModel.question,
  145. pageNumber: 1,
  146. pageSize: 9999999,
  147. })
  148. watch(dataModel, () => {
  149. formModel.mainNumber = dataModel.question
  150. })
  151. const { defineColumn, _ } = useForm()
  152. const span10 = defineColumn(_, '', { span: 10 })
  153. const formItems = computed<EpFormItem[]>(() => [
  154. span10({
  155. rowKey: 'row-1',
  156. label: '大题',
  157. prop: 'mainNumber',
  158. labelWidth: '46px',
  159. slotType: 'select',
  160. slot: { options: mainQuestionList.value, onChange: changeModelValue('question'), disabled: true },
  161. }),
  162. { rowKey: 'row-1', slotName: 'search', labelWidth: '10px', colProp: { span: 4 } },
  163. ])
  164. /** RF卷 */
  165. const columns: EpTableColumn<RowType>[] = [
  166. { label: '密号', prop: 'secretNumber', minWidth: 100, fixed: 'left' },
  167. { label: '分数', prop: 'score', minWidth: 60 },
  168. { label: '档次', prop: 'scoreLevel', minWidth: 90 },
  169. { label: '提交人', prop: 'createName', minWidth: 100 },
  170. { label: '提交时间', prop: 'createTime', minWidth: 130 },
  171. ]
  172. const { fetch: getRfSampleList, result: rfSampleList, loading } = useFetch('getRfSampleList')
  173. const {
  174. tableRef,
  175. tableData,
  176. current: currentRfPaper,
  177. next: checkNext,
  178. onDbClick,
  179. onCurrentChange,
  180. } = useTableCheck(rfSampleList)
  181. const onSearch = async () => {
  182. getRfSampleList(formModel)
  183. }
  184. /** 确定给分 */
  185. const { fetch: updateMarkScore } = useFetch('updateMarkScore')
  186. const onSubmit = async () => {
  187. try {
  188. if (currentRfPaper.value) {
  189. const scores = JSON.parse(JSON.stringify(modelScore.value))
  190. await updateMarkScore({ id: currentRfPaper.value.id, scores: modelScore.value })
  191. currentRfPaper.value.score = add(...scores)
  192. ElMessage.success('修改成功')
  193. // onSearch()
  194. }
  195. } catch (error) {
  196. console.error(error)
  197. }
  198. }
  199. onOptionInit(onSearch)
  200. const imgOption = computed<SetImgBgOption>(() => {
  201. return {
  202. image: currentRfPaper?.value?.filePath,
  203. rotate: rotate.value,
  204. scale: scale.value,
  205. }
  206. })
  207. const { drawing, dataUrl } = useSetImgBg(imgOption, frontColor, setFrontColor)
  208. </script>
  209. <style scoped lang="scss">
  210. .mark-container {
  211. .mark-content {
  212. position: relative;
  213. .preview {
  214. position: absolute;
  215. cursor: pointer;
  216. top: 10px;
  217. right: 20px;
  218. font-size: 24px;
  219. }
  220. .next-button {
  221. position: absolute;
  222. right: -20px;
  223. top: 300px;
  224. }
  225. .mark-content-paper {
  226. img {
  227. max-width: 100%;
  228. }
  229. }
  230. }
  231. .table-view {
  232. // width: 580px;
  233. width: 35%;
  234. .detail-info-label {
  235. .detail-info-label-num {
  236. min-width: 32px;
  237. height: 24px;
  238. line-height: 24px;
  239. background: #00987b;
  240. border-radius: 4px;
  241. }
  242. }
  243. }
  244. }
  245. </style>