刘洋 1 year ago
parent
commit
dd27f1c93c

+ 2 - 2
server.config.ts

@@ -3,11 +3,11 @@ import type { ServerOptions } from 'vite'
 const server: ServerOptions = {
   proxy: {
     '^/?(api|file)/': {
-      // target: 'http://192.168.10.41:8200',
+      target: 'http://192.168.10.41:8200',
       // target: 'http://192.168.10.178:8200',
       // target: 'http://192.168.10.108:8200',
       // target: 'http://cet-test.markingtool.cn',
-      target: 'http://192.168.10.136:80',
+      // target: 'http://192.168.10.136:80',
       // target: 'http://cet-dev.markingtool.cn:8200',
     },
   },

+ 2 - 1
src/components/shared/ScoringPanel.vue

@@ -16,6 +16,7 @@
           <p class="main-title">{{ question.mainTitle }}</p>
         </div>
         <scoring-panel-item
+          :id="props.id"
           v-model:score="scoreValues[index]"
           v-model:scoreValidFail="scoreValidFail[index]"
           :active="activeIndex === index"
@@ -63,7 +64,7 @@ const props = withDefaults(
     // mainNumber?: number | null
     mainNumber?: any
     subjectCode?: any
-    id?: number | null
+    id?: any
     autoVisible?: boolean | undefined
     large?: boolean
     cannotToggle?: boolean

+ 8 - 1
src/components/shared/ScoringPanelItem.vue

@@ -119,8 +119,9 @@ const props = withDefaults(
     allowSubmit: boolean
     showConfirmBtn?: boolean
     cannotToggle?: boolean
+    id?: any
   }>(),
-  { modal: false, toggleModal: true, score: void 0, scoreValidFail: false, large: true, cannotToggle: false }
+  { modal: false, toggleModal: true, score: void 0, scoreValidFail: false, large: true, cannotToggle: false, id: null }
 )
 
 const emit = defineEmits(['focused', 'blur', 'toggle-click', 'enter', 'update:score'])
@@ -175,6 +176,12 @@ watch(
   },
   { immediate: true }
 )
+watch(
+  () => props.id,
+  (val: any) => {
+    !!val && inputFocus()
+  }
+)
 
 const getClass = (val: string, callback?: string) => {
   return dialogMode.value ? val : callback || ''

+ 2 - 0
src/components/shared/ScoringPanelWithConfirm.vue

@@ -1,6 +1,7 @@
 <template>
   <scoring-panel
     v-bind="attrs"
+    :id="props.id"
     v-model:score="modelScore"
     v-model:visible="modalVisible"
     :main-number="props.mainNumber"
@@ -60,6 +61,7 @@ const props = defineProps<{
   subjectCode?: any
   large?: boolean
   cannotToggle?: boolean
+  id?: any
 }>()
 
 const attrs = useAttrs()

+ 25 - 5
src/modules/marking/mark/index.vue

@@ -75,6 +75,7 @@
         ></scoring-panel-with-confirm>
       </div>
       <remark-box
+        ref="remarkBoxRef"
         v-model="remarkModalVisible"
         @task-change="historyTaskChange"
         @back="historyBack"
@@ -116,8 +117,14 @@
     width="500px"
     :close-on-click-modal="false"
   >
-    <span style="font-size: 14px; font-weight: bold; color: #333">原因:</span
-    ><span style="font-size: 14px">{{ rejectTask?.rejectReason }}</span>
+    <div>
+      <span style="font-size: 14px; font-weight: bold; color: #333">原因:</span
+      ><span style="font-size: 14px">{{ rejectTask?.rejectReason }}</span>
+    </div>
+    <div class="m-t-base">
+      <span style="font-size: 14px; font-weight: bold; color: #333">说明:</span
+      ><span style="font-size: 14px">{{ rejectTask?.rejectDes }}</span>
+    </div>
     <template #footer>
       <span class="dialog-footer">
         <el-button type="primary" @click="showRejectReason = false"> 确定 </el-button>
@@ -332,10 +339,9 @@ const problemType = ref<any>('')
 const similarType = ref<any>('')
 /** 分数列表 */
 const modelScore = ref<number[]>([])
-
+const remarkBoxRef = ref()
 /** 提交评卷 */
 const onSubmit: InstanceType<typeof ScoringPanelWithConfirm>['onSubmit'] = async ({ question, scores, totalScore }) => {
-  remarkModalVisible.value = false
   try {
     if (!currentTask.value?.taskId) {
       return
@@ -360,7 +366,21 @@ const onSubmit: InstanceType<typeof ScoringPanelWithConfirm>['onSubmit'] = async
     // if (!bool) {
     //   return false
     // }
-    await getNextTask(true, submitResult?.refresh, !bool)
+    if (remarkModalVisible.value) {
+      remarkBoxRef.value?.updateRow(totalScore)
+      let nextHistoryTask = remarkBoxRef.value?.getNextRow()
+      if (nextHistoryTask) {
+        historyTaskChange(nextHistoryTask)
+      } else {
+        if (nextHistoryTask === false) {
+          //说明回评列表是空的,当前依然处于正评,走正常的正评逻辑,且关闭回评列表
+          remarkModalVisible.value = false
+          await getNextTask(true, submitResult?.refresh, !bool)
+        }
+      }
+    } else {
+      await getNextTask(true, submitResult?.refresh, !bool)
+    }
   } catch (error) {
     console.error(error)
     scoringPanelVisible.value = true

+ 101 - 2
src/modules/marking/mark/remark-box.vue

@@ -16,6 +16,7 @@
             :columns="tableColumns"
             :data="markHistoryList"
             highlight-current-row
+            :cell-style="{ padding: '6px 0' }"
             @current-change="onCurrentChange"
           ></base-table>
           <div v-else class="flex flex-wrap preview-list">
@@ -42,17 +43,25 @@
   </div>
 </template>
 <script name="RemarkBox" setup lang="ts">
-import { reactive, ref, watch, nextTick } from 'vue'
-import { ElRadioGroup, ElRadio, ElButton } from 'element-plus'
+import { reactive, ref, watch, nextTick, onMounted, onBeforeUnmount } from 'vue'
+import { ElRadioGroup, ElRadio, ElButton, ElMessage } from 'element-plus'
 import ConfirmButton from '../../../components/common/ConfirmButton.vue'
 import useFetch from '@/hooks/useFetch'
 import useVModel from '@/hooks/useVModel'
 import BaseTable from '@/components/element/BaseTable.vue'
+import { throttle } from 'lodash-es'
 const markHistoryList = ref<any>([])
 const historyTable = ref()
 const getMarkHistory = async () => {
   let res = await useFetch('getMarkHistory').fetch()
   markHistoryList.value = res.markHistoryList
+  nextTick(() => {
+    if (!markHistoryList.value.length) {
+      ElMessage.info('暂无回评数据')
+    } else {
+      historyTable.value?.tableRef?.setCurrentRow(markHistoryList.value[0])
+    }
+  })
 }
 const props = defineProps<{ modelValue: boolean }>()
 const emits = defineEmits<{
@@ -100,6 +109,96 @@ const back = () => {
 const close = () => {
   emits('close')
 }
+const getCurIndex = () => {
+  return (markHistoryList.value || []).findIndex((item: any) => item.taskId == task.value?.taskId)
+}
+const nextRow = throttle(() => {
+  if (!markHistoryList.value.length) {
+    return
+  }
+  let curIndex = getCurIndex()
+  if (curIndex == markHistoryList.value.length - 1) {
+    ElMessage.warning('当前已是最后一条回评数据')
+    return
+  }
+  const index = curIndex + 1
+  const elTableRef = historyTable.value?.tableRef
+  elTableRef?.setCurrentRow(markHistoryList.value[index])
+  const tBodyDomWrap: any = elTableRef?.$refs.bodyWrapper
+  if (tBodyDomWrap) {
+    if (index == 0) {
+      elTableRef?.scrollTo({ left: 0, top: 0, behavior: 'smooth' })
+    } else {
+      const wrap = tBodyDomWrap.getElementsByClassName('el-scrollbar__wrap')[0]
+      const oHeight = wrap.offsetHeight
+      const sTop = wrap.scrollTop
+      const sHeight = wrap.scrollHeight
+      const targetRowAsHeight = 36 * (curIndex + 1)
+      if (sHeight > oHeight && targetRowAsHeight - sTop > oHeight) {
+        const t = sHeight - targetRowAsHeight
+        elTableRef?.scrollTo({ left: 0, top: sTop + 36, behavior: 'smooth' })
+      }
+    }
+  }
+}, 300)
+const prevRow = throttle(() => {
+  if (!markHistoryList.value.length) {
+    return
+  }
+  let curIndex = getCurIndex()
+  const elTableRef = historyTable.value?.tableRef
+  if (curIndex > 0) {
+    elTableRef?.setCurrentRow(markHistoryList.value[curIndex - 1])
+    const tBodyDomWrap: any = elTableRef?.$refs.bodyWrapper
+    if (tBodyDomWrap) {
+      const wrap = tBodyDomWrap.getElementsByClassName('el-scrollbar__wrap')[0]
+      const oHeight = wrap.offsetHeight
+      const sTop = wrap.scrollTop
+      const sHeight = wrap.scrollHeight
+      const targetRowAsHeight = 36 * (curIndex || 0)
+      if (targetRowAsHeight - 36 < sTop) {
+        elTableRef?.scrollTo({ left: 0, top: targetRowAsHeight - 36, behavior: 'smooth' })
+      }
+    }
+  }
+}, 300)
+const arrowDownToNextRow = (e: any) => {
+  if ((e.target.className || '').includes('contenteditable-ele')) {
+    return false
+  }
+  if (e.key === 'ArrowDown') {
+    e.preventDefault()
+    nextRow()
+  } else if (e.key === 'ArrowUp') {
+    e.preventDefault()
+    prevRow()
+  }
+}
+onMounted(() => {
+  document.addEventListener('keydown', arrowDownToNextRow)
+})
+onBeforeUnmount(() => {
+  document.removeEventListener('keydown', arrowDownToNextRow)
+})
+
+const updateRow = (score: any) => {
+  !!task.value && (task.value.markScore = score)
+}
+const getNextRow = () => {
+  if (!markHistoryList.value || !markHistoryList.value.length) {
+    return false
+  }
+  let curIndex = (markHistoryList.value || []).findIndex((item: any) => item.taskId == task.value?.taskId)
+  if (curIndex < markHistoryList.value?.length - 1) {
+    let nextTask = markHistoryList.value[curIndex + 1]
+    historyTable.value?.tableRef?.setCurrentRow(nextTask)
+    return nextTask
+  } else {
+    ElMessage.warning('当前已是最后一条回评数据')
+    return null
+  }
+}
+defineExpose({ updateRow, getNextRow })
 </script>
 <style lang="scss" scoped>
 .remark-container {