index.vue 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759
  1. <template>
  2. <div class="flex direction-column full mark-page">
  3. <mark-header
  4. :exclude-operations="excludeOperations"
  5. :paper-path="currentTask?.url"
  6. :secret-number="currentTask?.secretNumber"
  7. @click="onOperationClick"
  8. >
  9. <div class="data-item">
  10. <!-- 已评: {{ markStatus?.personCount || 0 }} /
  11. {{ minus(markStatus?.totalCount || 0, markStatus?.markedCount || 0) }} -->
  12. <div>
  13. <p>
  14. 今日:{{ markStatus?.personDayCount }}
  15. {{ mainStore.myUserInfo?.markDayCount ? `/ ${mainStore.myUserInfo?.markDayCount}` : '' }}
  16. </p>
  17. <p class="m-t-mini">累计:{{ markStatus?.personCount }}</p>
  18. </div>
  19. </div>
  20. <!-- <span v-show="currentTask" class="data-item">密号: {{ currentTask?.secretNumber }}</span> -->
  21. <div v-show="currentTask" class="data-item">
  22. <div>
  23. <p class="main-ques-info truncate">{{ currentTask?.mainNumber }}-{{ currentTask?.mainTitle }}</p>
  24. <p>密号: {{ currentTask?.secretNumber }}</p>
  25. </div>
  26. </div>
  27. <div class="data-item">
  28. <current-time></current-time>
  29. </div>
  30. </mark-header>
  31. <div class="flex flex-1 overflow-hidden p-base mark-container">
  32. <div v-if="!enableRemark && !currentTask" class="waiting flex flex-1 justify-center items-center">
  33. 等待组长审核
  34. </div>
  35. <div
  36. v-else-if="!!currentTask"
  37. v-loading="imgLoading"
  38. class="flex flex-1 direction-column radius-base full fill-blank mark-content"
  39. :style="{ 'background-color': backgroundColor }"
  40. >
  41. <span class="mark-status">
  42. <img :src="statusIcon" alt="" />
  43. </span>
  44. <span class="preview" :style="{ left: previewLeft }" @click="onPreview">
  45. <svg-icon name="preview"></svg-icon>
  46. </span>
  47. <div v-if="markStore.curQuestionScore !== null" class="img-score" :style="imgScoreStyle">
  48. {{ markStore.curQuestionScore }}
  49. </div>
  50. <div ref="imgWrap" :class="{ 'text-center': center }" class="img-wrap scroll-auto">
  51. <img
  52. ref="paperImg"
  53. :src="dataUrl"
  54. alt=""
  55. class="paper-img"
  56. :style="{ 'background-color': frontColor, maxWidth: '100%' }"
  57. @load="imgLoaded"
  58. />
  59. </div>
  60. <scoring-panel-with-confirm
  61. v-if="currentTask && dataUrl && !imgLoading"
  62. :id="currentTask?.taskId"
  63. v-model:visible="scoringPanelVisible"
  64. v-model:score="modelScore"
  65. :main-number="currentTask?.mainNumber"
  66. :subject-code="mainStore.myUserInfo?.subjectCode"
  67. :large="true"
  68. :loading="mergeLoading"
  69. show-limit-time
  70. @submit="onSubmit"
  71. ></scoring-panel-with-confirm>
  72. </div>
  73. <remark-box
  74. v-if="remarkModalVisible"
  75. ref="remarkBoxRef"
  76. :img-option="imgOption"
  77. @task-change="historyTaskChange"
  78. @back="historyBack"
  79. @close="historyClose"
  80. ></remark-box>
  81. </div>
  82. </div>
  83. <base-dialog v-model="problemVisible" unless :width="280" center>
  84. <el-radio-group v-model="problemClass">
  85. <el-radio-button label="problem">问题卷</el-radio-button>
  86. <el-radio-button label="similar">雷同卷</el-radio-button>
  87. </el-radio-group>
  88. <div class="m-t-base problem-pane" style="height: 80px">
  89. <el-radio-group v-show="problemClass === 'problem'" v-model="problemType" class="full-w">
  90. <div class="full-w">
  91. <el-radio label="OVERSTEP">跨套</el-radio>
  92. </div>
  93. <div class="full-w">
  94. <el-radio label="DIM">扫描图片不清晰</el-radio>
  95. </div>
  96. </el-radio-group>
  97. <!-- <el-radio v-show="problemClass === 'similar'" model-value="similar" label="similar">提交雷同</el-radio> -->
  98. <el-radio v-show="problemClass === 'similar'" v-model="similarType" label="similar">提交雷同</el-radio>
  99. </div>
  100. <template #footer>
  101. <div class="flex items-center justify-between">
  102. <el-button class="confirm-button" type="primary" @click="onConfirmSubmitProblem">确定</el-button>
  103. <el-button class="confirm-button" plain @click="problemVisible = false">取消</el-button>
  104. </div>
  105. </template>
  106. </base-dialog>
  107. <!-- <remark-list-modal v-model="remarkModalVisible" @task-change="historyTaskChange"></remark-list-modal> -->
  108. <!-- <image-preview v-if="currentTask" v-model="previewModalVisible" :url="currentTask?.url"></image-preview> -->
  109. <image-preview v-if="currentTask" v-model="previewModalVisible" :url="currentTask?.url"></image-preview>
  110. <el-dialog
  111. v-model="showRejectReason"
  112. :title="`打回试卷(${rejectTask?.secretNumber})`"
  113. width="500px"
  114. :close-on-click-modal="false"
  115. :z-index="3001"
  116. >
  117. <div>
  118. <span style="font-size: 14px; font-weight: bold; color: #333">原因:</span
  119. ><span style="font-size: 14px">{{ rejectTask?.rejectReason }}</span>
  120. </div>
  121. <div class="m-t-base">
  122. <span style="font-size: 14px; font-weight: bold; color: #333">说明:</span
  123. ><span style="font-size: 14px">{{ rejectTask?.rejectDes }}</span>
  124. </div>
  125. <template #footer>
  126. <span class="dialog-footer">
  127. <el-button type="primary" @click="showRejectReason = false"> 确定 </el-button>
  128. </span>
  129. </template>
  130. </el-dialog>
  131. </template>
  132. <script setup lang="ts" name="MarkingMark">
  133. /** 阅卷-正式评卷 */
  134. import { computed, nextTick, ref, watch, onBeforeUnmount, unref, onUnmounted } from 'vue'
  135. import { useRouter } from 'vue-router'
  136. import { ElButton, ElRadioGroup, ElRadioButton, ElRadio, ElMessage, ElDialog } from 'element-plus'
  137. import { minus } from '@/utils/common'
  138. import { useSetImgBg } from '@/hooks/useSetImgBg'
  139. import useFetch from '@/hooks/useFetch'
  140. import useVW from '@/hooks/useVW'
  141. import useSpentTime from '@/hooks/useSpentTime'
  142. import useMarkHeader from '@/hooks/useMarkHeader'
  143. import BaseDialog from '@/components/element/BaseDialog.vue'
  144. import MarkHeader from '@/components/shared/MarkHeader.vue'
  145. import ScoringPanelWithConfirm from '@/components/shared/ScoringPanelWithConfirm.vue'
  146. import ImagePreview from '@/components/shared/ImagePreview.vue'
  147. import RemarkListModal from '@/components/shared/RemarkListModal.vue'
  148. import CurrentTime from '@/components/shared/CurrentTime.vue'
  149. import SvgIcon from '@/components/common/SvgIcon.vue'
  150. import bus from '@/utils/bus'
  151. import useMainLayoutStore from '@/store/layout'
  152. import useMainStore from '@/store/main'
  153. import MarkingStatus from '@/assets/images/status-marking.png'
  154. import ReMarkingStatus from '@/assets/images/status-remarking.png'
  155. import SampleAStatus from '@/assets/images/status-sample-a.png'
  156. import SampleBStatus from '@/assets/images/status-sample-b.png'
  157. import RemarkBox from './remark-box.vue'
  158. import { preloadImg } from '@/utils/common'
  159. import type { SetImgBgOption } from '@/hooks/useSetImgBg'
  160. import type { ExtractApiResponse } from '@/api/api'
  161. import type { MarkHeaderInstance } from 'global-type'
  162. import useMarkStore from '@/store/mark'
  163. const markStore = useMarkStore()
  164. const mainLayoutStore = useMainLayoutStore()
  165. const mainStore = useMainStore()
  166. const { push, replace } = useRouter()
  167. const imgWrap = ref()
  168. const { getSpentTime, resume } = useSpentTime()
  169. const remarkBoxKey = ref<any>(Date.now() + '')
  170. const CACHE_NUM = 2
  171. type TaskType = ExtractArrayValue<ExtractApiResponse<'getMarkingTask'>>['taskType'] | 'default' | 'remarking'
  172. const markStatusIcon: Partial<Record<TaskType, string>> = {
  173. FORMAL: MarkingStatus,
  174. remarking: ReMarkingStatus,
  175. SAMPLE_A: SampleAStatus,
  176. SAMPLE_B: SampleBStatus,
  177. default: MarkingStatus,
  178. }
  179. const paperImg = ref()
  180. const currentTaskType = ref<TaskType>('FORMAL')
  181. const statusIcon = computed(() => {
  182. return markStatusIcon[currentTaskType.value] || markStatusIcon.default
  183. })
  184. const enableRemark = ref(true)
  185. const {
  186. rotate,
  187. scale,
  188. center,
  189. frontColor,
  190. backgroundColor,
  191. onScaleChange,
  192. onCenter,
  193. onRotate,
  194. setBackgroundColor,
  195. setFrontColor,
  196. onViewSample,
  197. onViewStandard,
  198. } = useMarkHeader()
  199. type HistoryTaskType = ExtractArrayValue<ExtractApiResponse<'getMarkHistory'>>
  200. type FormalTaskType = ExtractArrayValue<ExtractApiResponse<'getMarkingTask'>>
  201. type TaskInfoType = FormalTaskType | HistoryTaskType
  202. // let currentTaskPool: ExtractApiResponse<'getMarkingTask'> = []
  203. let currentTaskPool: any = []
  204. const currentTask = ref<TaskInfoType & { dataUrl?: any }>()
  205. type excludeOperationTypes = InstanceType<typeof MarkHeader>['$props']['excludeOperations']
  206. const excludeOperations = computed<excludeOperationTypes>(() => {
  207. if (!currentTask.value?.taskType) {
  208. return ['delete', 'bookmark']
  209. }
  210. const isSampleType = ['SAMPLE_A', 'SAMPLE_B'].includes(currentTask.value.taskType)
  211. // return ['delete', 'bookmark'].concat(isSampleType ? ['problem'] : []) as excludeOperationTypes
  212. return ['delete', 'bookmark']
  213. })
  214. const { fetch: getMarkingTask, loading } = useFetch('getMarkingTask')
  215. const { fetch: submitMarkTask, loading: submitting } = useFetch('submitMarkTask')
  216. const { fetch: getMarkStatus, result: markStatus, loading: statusLoading } = useFetch('getMarkStatus')
  217. const historyTaskChange = (task: any) => {
  218. let saveTargetTask = unref(currentTask)
  219. console.log('saveTargetTask:', saveTargetTask)
  220. if (currentTaskType.value != 'remarking' && saveTargetTask) {
  221. currentTaskPool.unshift(saveTargetTask)
  222. handleTaskPool()
  223. }
  224. currentTask.value = task
  225. currentTaskType.value = 'remarking'
  226. nextTick(() => {
  227. modelScore.value = task.markerScores
  228. })
  229. }
  230. const historyBack = () => {
  231. setCurrentTask()
  232. remarkModalVisible.value = false
  233. }
  234. const historyClose = () => {
  235. remarkModalVisible.value = false
  236. }
  237. const setCurrentTask = () => {
  238. currentTask.value = currentTaskPool.shift()
  239. currentTaskType.value =
  240. currentTask.value && markStatusIcon[currentTask.value.taskType] ? currentTask.value.taskType : 'FORMAL'
  241. }
  242. let refreshTimer: number | null = null
  243. onBeforeUnmount(() => {
  244. if (refreshTimer) {
  245. clearTimeout(refreshTimer)
  246. refreshTimer = null
  247. }
  248. if (timer) {
  249. clearInterval(timer)
  250. timer = null
  251. }
  252. })
  253. const refreshTaskPool = (force = false, isRefresh = false, hasLimit = false) => {
  254. if (refreshTimer) {
  255. clearTimeout(refreshTimer)
  256. }
  257. refreshTimer = window.setTimeout(
  258. () => {
  259. if (currentTaskPool.length < (isRefresh ? Number.MAX_SAFE_INTEGER : CACHE_NUM)) {
  260. // if (currentTaskPool.length < Number.MAX_SAFE_INTEGER) {
  261. getMarkingTask().then((result: any) => {
  262. if (result?.length) {
  263. // currentTaskPool[isRefresh ? 'unshift' : 'push'](...result)
  264. // result[1] && (result[1].url = '/file/sample_b/1/1/1/SAMPA-14.jpg')
  265. // result[1] && (result[1].url = 'http://127.0.0.1:9991/break-test.jpg')
  266. if (hasLimit) {
  267. result = result.filter((item: any) => {
  268. return item.taskType === 'FORCE'
  269. })
  270. }
  271. if (isRefresh) {
  272. if ((result[0] as any).taskType === 'FORCE') {
  273. currentTaskPool = currentTaskPool.filter((item: any) => {
  274. return item.taskType === 'FORCE' || !!item.markerId
  275. })
  276. currentTaskPool.unshift(...result)
  277. } else {
  278. currentTaskPool.unshift(...result)
  279. }
  280. } else {
  281. currentTaskPool.push(...result)
  282. }
  283. handleTaskPool()
  284. }
  285. if (currentTaskPool?.length && !currentTask.value) {
  286. setCurrentTask()
  287. }
  288. refreshTaskPool(false, false, hasLimit)
  289. })
  290. }
  291. },
  292. force ? 0 : 5000
  293. )
  294. }
  295. /**
  296. * @param force 即时更新任务
  297. * @param isRefresh 是否有插队任务
  298. */
  299. const getNextTask = (force = false, isRefresh = false, hasLimit = false) => {
  300. // if (isRefresh) {
  301. // if (currentTaskPool.length && !!currentTaskPool[0].markerId) {
  302. // setCurrentTask()
  303. // }
  304. // } else {
  305. setCurrentTask()
  306. // }
  307. refreshTaskPool(force, isRefresh, !!hasLimit)
  308. }
  309. /** 给分板 */
  310. const scoringPanelVisible = ref<boolean>(true)
  311. /** 回评弹窗 */
  312. const remarkModalVisible = ref<boolean>(false)
  313. /** 图片预览 */
  314. const previewModalVisible = ref<boolean>(false)
  315. /** 问题卷弹窗 */
  316. const problemVisible = ref<boolean>(false)
  317. /** 问题卷 | 雷同卷 */
  318. const problemClass = ref<'problem' | 'similar'>('problem')
  319. /** 问题卷类型 */
  320. // const problemType = ref<ProblemType>('OVERSTEP')
  321. const problemType = ref<any>('')
  322. const similarType = ref<any>('')
  323. watch(problemVisible, () => {
  324. if (problemVisible.value) {
  325. problemClass.value = 'problem'
  326. problemType.value = ''
  327. similarType.value = ''
  328. }
  329. })
  330. /** 分数列表 */
  331. const modelScore = ref<number[]>([])
  332. const remarkBoxRef = ref()
  333. /** 提交评卷 */
  334. const onSubmit: InstanceType<typeof ScoringPanelWithConfirm>['onSubmit'] = async ({ question, scores, totalScore }) => {
  335. try {
  336. if (!currentTask.value?.taskId) {
  337. return
  338. }
  339. const spentTime = getSpentTime()
  340. const current = currentTask.value as FormalTaskType
  341. if (current.minMarkTime && current.minMarkTime * 1000 > spentTime) {
  342. scoringPanelVisible.value = true
  343. return ElMessage.warning('阅卷速度过快')
  344. }
  345. const submitResult = await submitMarkTask({
  346. spentTime,
  347. markScore: totalScore,
  348. markScores: scores,
  349. problem: false,
  350. taskId: currentTask.value.taskId,
  351. taskType: currentTask.value.taskType,
  352. })
  353. mainStore.setMarkerPausedLimit(submitResult?.markerPausedLimit || 0)
  354. let bool = await checkMarkStatus()
  355. // if (!bool) {
  356. // return false
  357. // }
  358. if (remarkModalVisible.value) {
  359. remarkBoxRef.value?.updateRow(totalScore)
  360. let nextHistoryTask = remarkBoxRef.value?.getNextRow()
  361. if (nextHistoryTask) {
  362. historyTaskChange(nextHistoryTask)
  363. } else {
  364. if (nextHistoryTask === false) {
  365. //说明回评列表是空的,当前依然处于正评,走正常的正评逻辑,且关闭回评列表
  366. remarkModalVisible.value = false
  367. await getNextTask(true, submitResult?.refresh, !bool)
  368. }
  369. }
  370. } else {
  371. await getNextTask(true, submitResult?.refresh, !bool)
  372. }
  373. } catch (error) {
  374. console.error(error)
  375. scoringPanelVisible.value = true
  376. }
  377. }
  378. const onSubmitSimilar = async () => {
  379. if (!currentTask.value) {
  380. return
  381. }
  382. const markHistory = await useFetch('getMarkHistory').fetch()
  383. if (!markHistory.markHistoryList.length) {
  384. return ElMessage.warning('暂无评卷记录')
  385. }
  386. return push({
  387. name: 'SubmitSimilar',
  388. params: { taskId: currentTask.value.taskId },
  389. query: {
  390. secretNumber: currentTask.value.secretNumber,
  391. },
  392. })
  393. }
  394. const onSubmitProblem = async () => {
  395. if (!currentTask.value) {
  396. return
  397. }
  398. const submitResult = await submitMarkTask({
  399. markScore: 0,
  400. markScores: [],
  401. spentTime: getSpentTime(),
  402. problem: true,
  403. problemType: problemType.value,
  404. taskId: currentTask.value.taskId,
  405. taskType: currentTask.value.taskType,
  406. })
  407. let bool = await checkMarkStatus()
  408. // if (!bool) {
  409. // return false
  410. // }
  411. // await getNextTask(true, submitResult?.refresh, !bool)
  412. if (remarkModalVisible.value) {
  413. let nextHistoryTask = remarkBoxRef.value?.getNextRow()
  414. if (nextHistoryTask) {
  415. historyTaskChange(nextHistoryTask)
  416. } else {
  417. if (nextHistoryTask === false) {
  418. //说明回评列表是空的,当前依然处于正评,走正常的正评逻辑,且关闭回评列表
  419. remarkModalVisible.value = false
  420. await getNextTask(true, submitResult?.refresh, !bool)
  421. }
  422. }
  423. } else {
  424. await getNextTask(true, submitResult?.refresh, !bool)
  425. }
  426. }
  427. /** 提交问题卷 & 雷同卷 */
  428. const onConfirmSubmitProblem = async () => {
  429. if (problemClass.value === 'problem' && !problemType.value) {
  430. ElMessage.error('请选择问题卷类型')
  431. return
  432. }
  433. if (problemClass.value === 'similar' && !similarType.value) {
  434. ElMessage.error('请选择雷同卷类型')
  435. return
  436. }
  437. try {
  438. if (!currentTask.value) {
  439. return
  440. }
  441. if (currentTask.value.taskType !== 'FORMAL') {
  442. ElMessage.error('该试卷类型不能提交问题卷')
  443. return
  444. }
  445. problemVisible.value = false
  446. if (problemClass.value === 'similar') {
  447. await onSubmitSimilar()
  448. } else {
  449. await onSubmitProblem()
  450. }
  451. } catch (error) {
  452. console.error(error)
  453. }
  454. }
  455. /** 返回 */
  456. const onBack = () => {
  457. /** 回评时返回到正评, 否则返回到评卷员主页 */
  458. // if (currentTaskType.value === 'remarking') {
  459. // getNextTask()
  460. // } else {
  461. replace({
  462. name: 'MarkingNav',
  463. })
  464. // }
  465. }
  466. const clearTaskView = () => {
  467. currentTaskPool = currentTaskPool.filter((item: any) => {
  468. return item.taskType === 'FORCE'
  469. })
  470. handleTaskPool()
  471. currentTask.value = undefined
  472. }
  473. const getUserInfoLoading = ref(false)
  474. const mergeLoading = computed(() => {
  475. return submitting.value || getUserInfoLoading.value || statusLoading.value
  476. })
  477. const checkMarkStatus = async (): Promise<boolean> => {
  478. if (currentTask.value?.taskType === 'FORCE') {
  479. return true
  480. }
  481. // let myUserInfo: any = await useFetch('getMyUserInfo').fetch()
  482. getUserInfoLoading.value = true
  483. let myUserInfo: any = (await mainStore.getMyUserInfo()) || {}
  484. getUserInfoLoading.value = false
  485. //markDayCount表示该用户当天的任务量限制,markTotalCount表示该用户总任务量限制
  486. const { markDayCount, markTotalCount } = myUserInfo
  487. let res: any = await getMarkStatus()
  488. if (!!markTotalCount && res.personCount >= markTotalCount) {
  489. ElMessage.success(`任务量${markTotalCount}已完成`)
  490. clearTaskView()
  491. return false
  492. } else if (!!markDayCount && res.personDayCount >= markDayCount) {
  493. ElMessage.success(`您当天的任务量${markDayCount}已完成`)
  494. clearTaskView()
  495. return false
  496. } else {
  497. return true
  498. }
  499. }
  500. const onRefreshNext = () => {
  501. // onRefresh(true) 暂时注释掉,这是之前做的,点击刷新按钮获取本地任务池里的下一条的效果
  502. location.reload()
  503. }
  504. /** 刷新 */
  505. const onRefresh = async (refreshToNext?: boolean) => {
  506. let bool = await checkMarkStatus()
  507. // if (!bool) {
  508. // return false
  509. // }
  510. if (!refreshToNext) {
  511. await useFetch('clearCachedTasks').fetch()
  512. }
  513. if (!bool) {
  514. getNextTask(true, false, true)
  515. } else {
  516. getNextTask(true)
  517. }
  518. }
  519. /** 回评 */
  520. const onRemark = () => {
  521. // remarkModalVisible.value = true
  522. useFetch('getMarkHistory')
  523. .fetch()
  524. .then((markHistoryRes: any) => {
  525. if (!markHistoryRes.enableRemark) {
  526. ElMessage.warning('审核中,暂时无法回评')
  527. } else {
  528. remarkBoxKey.value = new Date().getTime() + ''
  529. remarkModalVisible.value = true
  530. }
  531. })
  532. }
  533. /** 设置问题卷 */
  534. const onSetProblem = () => {
  535. problemVisible.value = true
  536. }
  537. /** 预览试卷 */
  538. const onPreview = () => {
  539. previewModalVisible.value = true
  540. }
  541. type OperationClick = MarkHeaderInstance['onClick']
  542. type OperationType = Parameters<Exclude<OperationClick, undefined>>[0]['type']
  543. const operationHandles: Partial<Record<OperationType, (...args: any) => void>> = {
  544. back: onBack,
  545. 'scale-change': onScaleChange,
  546. center: onCenter,
  547. rotate: onRotate,
  548. 'front-color': setFrontColor,
  549. 'background-color': setBackgroundColor,
  550. refresh: onRefreshNext,
  551. remark: onRemark,
  552. problem: onSetProblem,
  553. example: onViewSample,
  554. standard: onViewStandard,
  555. }
  556. const onOperationClick: OperationClick = ({ type, value }) => {
  557. operationHandles[type]?.(value)
  558. if (type === 'center') {
  559. nextTick(() => {
  560. updateImgScoreLeft()
  561. })
  562. }
  563. }
  564. const imgOption = computed<SetImgBgOption>(() => {
  565. return {
  566. image: currentTask?.value?.url,
  567. rotate: rotate.value,
  568. scale: scale.value,
  569. }
  570. })
  571. const { drawing, dataUrl, imgLoading } = useSetImgBg(imgOption, frontColor, setFrontColor)
  572. const getEnableRemark = () => {
  573. useFetch('getMarkHistory')
  574. .fetch()
  575. .then((markHistoryRes: any) => {
  576. enableRemark.value = markHistoryRes.enableRemark
  577. })
  578. }
  579. // const clearScrollTop = () => {
  580. // if (imgWrap.value) {
  581. // imgWrap.value.scrollTop = 0
  582. // }
  583. // }
  584. const showRejectReason = ref(false)
  585. const rejectTask = ref<any>(null)
  586. let timer: any = null
  587. watch(currentTask, (newVal, oldVal) => {
  588. if (!oldVal && !!newVal) {
  589. getMarkStatus()
  590. }
  591. resume()
  592. if (!currentTask.value) {
  593. getEnableRemark()
  594. } else {
  595. if (currentTask.value?.rejectReason) {
  596. showRejectReason.value = true
  597. rejectTask.value = currentTask.value
  598. setTimeout(() => {
  599. ;(document.querySelector('.score-input') as HTMLInputElement)?.blur()
  600. }, 500)
  601. }
  602. }
  603. // clearScrollTop()
  604. })
  605. onRefresh()
  606. getEnableRemark()
  607. // bus.on('showStandard', () => {
  608. // standardVisible.value = true
  609. // })
  610. watch(enableRemark, (val) => {
  611. if (!val) {
  612. timer = setInterval(() => {
  613. getEnableRemark()
  614. }, 7000)
  615. } else {
  616. clearInterval(timer)
  617. timer = null
  618. getMarkStatus()
  619. }
  620. mainLayoutStore.getRenderMenuList()
  621. })
  622. bus.on('mark-prev', async () => {
  623. if (currentTaskType.value == 'remarking') {
  624. const markHistory = await useFetch('getMarkHistory').fetch()
  625. if (!markHistory.markHistoryList.length) {
  626. return false
  627. } else {
  628. historyTaskChange(markHistory.markHistoryList[0])
  629. }
  630. }
  631. })
  632. const showPreviewBtn = ref(false)
  633. const previewLeft = computed(() => {
  634. return currentTaskType.value === 'SAMPLE_A' || currentTaskType.value === 'SAMPLE_B' ? '124px' : '96px'
  635. })
  636. // const previewLeft = ref('-1000px')
  637. const imgScoreLeft = ref(400)
  638. const imgScoreStyle = computed(() => {
  639. return {
  640. left: imgScoreLeft.value + 'px',
  641. }
  642. })
  643. function updateImgScoreLeft() {
  644. if (!paperImg.value) return
  645. imgScoreLeft.value = paperImg.value.offsetLeft + paperImg.value.offsetWidth - 80
  646. }
  647. const imgLoaded = (e: Event) => {
  648. // previewLeft.value = paperImg.value.width - 40 + 'px'
  649. showPreviewBtn.value = true
  650. updateImgScoreLeft()
  651. }
  652. const handleTaskPool = () => {
  653. currentTaskPool.forEach((task: any) => {
  654. preloadImg(task?.url)
  655. })
  656. }
  657. onUnmounted(() => {
  658. markStore.setCurQuestionScore(null)
  659. })
  660. </script>
  661. <style scoped lang="scss">
  662. .mark-page {
  663. :deep(> .el-overlay) {
  664. &.dialog-fade-leave-active {
  665. animation: none !important;
  666. }
  667. }
  668. }
  669. .mark-container {
  670. .waiting {
  671. background-color: #fff;
  672. font-size: 80px;
  673. color: #ccc;
  674. height: 100%;
  675. }
  676. .mark-content {
  677. position: relative;
  678. .img-wrap {
  679. // width: 100%;
  680. // height: 100%;
  681. // overflow: auto;
  682. }
  683. .img-score {
  684. position: absolute;
  685. top: 38px;
  686. left: 400px;
  687. font-size: 40px;
  688. color: red;
  689. font-weight: 600;
  690. z-index: 100;
  691. }
  692. .mark-status {
  693. display: inline-block;
  694. // width: 24px;
  695. height: 38px;
  696. position: absolute;
  697. cursor: pointer;
  698. top: 38px;
  699. left: 20px;
  700. z-index: 100;
  701. img {
  702. // max-width: 100%;
  703. max-height: 100%;
  704. }
  705. }
  706. .preview {
  707. position: absolute;
  708. cursor: pointer;
  709. z-index: 100;
  710. top: 36px;
  711. font-size: 38px;
  712. }
  713. }
  714. }
  715. </style>