|
@@ -16,6 +16,7 @@
|
|
:columns="tableColumns"
|
|
:columns="tableColumns"
|
|
:data="markHistoryList"
|
|
:data="markHistoryList"
|
|
highlight-current-row
|
|
highlight-current-row
|
|
|
|
+ :cell-style="{ padding: '6px 0' }"
|
|
@current-change="onCurrentChange"
|
|
@current-change="onCurrentChange"
|
|
></base-table>
|
|
></base-table>
|
|
<div v-else class="flex flex-wrap preview-list">
|
|
<div v-else class="flex flex-wrap preview-list">
|
|
@@ -42,17 +43,25 @@
|
|
</div>
|
|
</div>
|
|
</template>
|
|
</template>
|
|
<script name="RemarkBox" setup lang="ts">
|
|
<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 ConfirmButton from '../../../components/common/ConfirmButton.vue'
|
|
import useFetch from '@/hooks/useFetch'
|
|
import useFetch from '@/hooks/useFetch'
|
|
import useVModel from '@/hooks/useVModel'
|
|
import useVModel from '@/hooks/useVModel'
|
|
import BaseTable from '@/components/element/BaseTable.vue'
|
|
import BaseTable from '@/components/element/BaseTable.vue'
|
|
|
|
+import { throttle } from 'lodash-es'
|
|
const markHistoryList = ref<any>([])
|
|
const markHistoryList = ref<any>([])
|
|
const historyTable = ref()
|
|
const historyTable = ref()
|
|
const getMarkHistory = async () => {
|
|
const getMarkHistory = async () => {
|
|
let res = await useFetch('getMarkHistory').fetch()
|
|
let res = await useFetch('getMarkHistory').fetch()
|
|
markHistoryList.value = res.markHistoryList
|
|
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 props = defineProps<{ modelValue: boolean }>()
|
|
const emits = defineEmits<{
|
|
const emits = defineEmits<{
|
|
@@ -100,6 +109,96 @@ const back = () => {
|
|
const close = () => {
|
|
const close = () => {
|
|
emits('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>
|
|
</script>
|
|
<style lang="scss" scoped>
|
|
<style lang="scss" scoped>
|
|
.remark-container {
|
|
.remark-container {
|