|
@@ -1,9 +1,61 @@
|
|
|
<script setup lang="ts" generic="T extends any, O extends any">
|
|
|
-import { stepsMap } from '~/composables/steps'
|
|
|
+import request from '~/utils/request'
|
|
|
+// import { stepsMap } from '~/composables/steps'
|
|
|
+
|
|
|
+const ykl_id = 607
|
|
|
+
|
|
|
+const server = (await request({
|
|
|
+ url: '/yzy/kmksyjlc/detail',
|
|
|
+ data: {
|
|
|
+ ykl_id,
|
|
|
+ },
|
|
|
+})).data.one_info
|
|
|
+
|
|
|
+const ykl_lc = Object.assign(JSON.parse(Object.assign(server.ykl_lc)), { ykl_id })
|
|
|
+sessionStorage.setItem('ykl_lc', JSON.stringify(ykl_lc))
|
|
|
+
|
|
|
+// request({
|
|
|
+// url: '/yzy/kmksyjlc/save',
|
|
|
+// data: {
|
|
|
+// ykl_id,
|
|
|
+// yk: {
|
|
|
+// ykl_lc: JSON.stringify({
|
|
|
+// ...ykl_lc,
|
|
|
+// processList: [
|
|
|
+// [
|
|
|
+// [0, 0, 1],
|
|
|
+// [0, 0],
|
|
|
+// [0],
|
|
|
+// ],
|
|
|
+// [
|
|
|
+// [0],
|
|
|
+// [0],
|
|
|
+// [0],
|
|
|
+// ],
|
|
|
+// [
|
|
|
+// [0],
|
|
|
+// [0],
|
|
|
+// ],
|
|
|
+// [
|
|
|
+// [0],
|
|
|
+// [0],
|
|
|
+// ],
|
|
|
+// [
|
|
|
+// [0],
|
|
|
+// [0],
|
|
|
+// [0],
|
|
|
+// ],
|
|
|
+// ],
|
|
|
+// }),
|
|
|
+// },
|
|
|
+// },
|
|
|
+// })
|
|
|
+
|
|
|
+const stepsReactiveMap = reactive<unknown[][][]>(ykl_lc.processList)
|
|
|
|
|
|
// 先上传后划块
|
|
|
const steps = reactive(
|
|
|
- true
|
|
|
+ ykl_lc.ykj_yjlc === '1'
|
|
|
? [
|
|
|
{
|
|
|
title: '组卷考试',
|
|
@@ -204,13 +256,15 @@ let gid = $ref<number>(0)
|
|
|
let pids = $ref<number[]>([])
|
|
|
// const cid = $ref(-1)
|
|
|
function getGid() {
|
|
|
- return stepsMap.findLastIndex(item => item.some(subItem => subItem.some(subSubItem => subSubItem)))
|
|
|
+ return stepsReactiveMap.findLastIndex(item => item.some(subItem => subItem.some(subSubItem => judgeStepCompleted(subSubItem))))
|
|
|
}
|
|
|
|
|
|
function getPids() {
|
|
|
- return stepsMap.map((item, idx) => (idx < gid ? 1 : 0) + item.findLastIndex(subItem => subItem.some(subSubItem => subSubItem)))
|
|
|
+ return stepsReactiveMap.map((item, idx) => (idx < gid ? 1 : 0) + item.findLastIndex(subItem => subItem.some(subSubItem => judgeStepCompleted(subSubItem))))
|
|
|
}
|
|
|
-watch(() => stepsMap, (val) => {
|
|
|
+watch(() => stepsReactiveMap, (val) => {
|
|
|
+ sessionStorage.setItem('stepsMap', JSON.stringify(val))
|
|
|
+
|
|
|
gid = getGid()
|
|
|
pids = getPids()
|
|
|
}, {
|
|
@@ -237,7 +291,7 @@ const lineList: any[][][] = []
|
|
|
// size: 6,
|
|
|
// startSocket: 'right',
|
|
|
// endSocket: 'left',
|
|
|
-// color: stepsMap[currentStep][idx][idy] ? '#003eee' : '#a3a3a3',
|
|
|
+// color: stepsReactiveMap[currentStep][idx][idy] ? '#003eee' : '#a3a3a3',
|
|
|
// },
|
|
|
// )
|
|
|
// lineList.push(line)
|
|
@@ -249,60 +303,71 @@ function handleSwitchGid(id: number) {
|
|
|
currentStep = id
|
|
|
}
|
|
|
|
|
|
-watch(() => currentStep, (val, old) => {
|
|
|
- if (old !== undefined)
|
|
|
- lineList[old].forEach(lines => lines.forEach(line => line?.hide('none')))
|
|
|
- if (lineList[val]?.length) {
|
|
|
- lineList[val].forEach(lines => lines.forEach(line => line?.show('none')))
|
|
|
- }
|
|
|
- else {
|
|
|
- nextTick(() => {
|
|
|
- CardsRef.forEach((cards, idx) => {
|
|
|
- if (idx === CardsRef.length - 1)
|
|
|
- return
|
|
|
- cards.forEach((card, idy) => {
|
|
|
- if (card === null || CardsRef[idx + 1][0] === null)
|
|
|
+onMounted(() => {
|
|
|
+ watch(() => currentStep, (val, old) => {
|
|
|
+ if (old !== undefined)
|
|
|
+ lineList[old].forEach(lines => lines.forEach(line => line?.hide('none')))
|
|
|
+ if (lineList[val]?.length) {
|
|
|
+ lineList[val].forEach(lines => lines.forEach(line => line?.show('none')))
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ nextTick(() => {
|
|
|
+ CardsRef.forEach((cards, idx) => {
|
|
|
+ if (idx === CardsRef.length - 1)
|
|
|
return
|
|
|
- const line = new LeaderLine(
|
|
|
- card.getDom(),
|
|
|
- CardsRef[idx + 1][0].getDom(),
|
|
|
- {
|
|
|
- path: 'grid',
|
|
|
- endPlug: 'behind',
|
|
|
- size: 6,
|
|
|
- startSocket: 'right',
|
|
|
- endSocket: 'left',
|
|
|
- color: stepsMap[currentStep][idx][idy] ? '#003eee' : '#a3a3a3',
|
|
|
- },
|
|
|
- )
|
|
|
- line?.position()
|
|
|
- if (stepsMap[currentStep][idx][idy])
|
|
|
- document.querySelectorAll('.leader-line')[line._id as number - 1]?.classList.add('z10')
|
|
|
+ cards.forEach((card, idy) => {
|
|
|
+ if (card === null || CardsRef[idx + 1][0] === null)
|
|
|
+ return
|
|
|
+ const line = new LeaderLine(
|
|
|
+ card.getDom(),
|
|
|
+ CardsRef[idx + 1][0].getDom(),
|
|
|
+ {
|
|
|
+ path: 'grid',
|
|
|
+ endPlug: 'behind',
|
|
|
+ size: 6,
|
|
|
+ startSocket: 'right',
|
|
|
+ endSocket: 'left',
|
|
|
+ color: stepsReactiveMap[currentStep][idx][idy] ? '#003eee' : '#a3a3a3',
|
|
|
+ },
|
|
|
+ )
|
|
|
+ line?.position()
|
|
|
+ if (stepsReactiveMap[currentStep][idx][idy])
|
|
|
+ document.querySelectorAll('.leader-line')[line._id as number - 1]?.classList.add('z10')
|
|
|
|
|
|
- lineList[val] = lineList[val] || []
|
|
|
- lineList[val][idx] = lineList[val][idx] || []
|
|
|
- lineList[val][idx][idy] = line
|
|
|
+ lineList[val] = lineList[val] || []
|
|
|
+ lineList[val][idx] = lineList[val][idx] || []
|
|
|
+ lineList[val][idx][idy] = line
|
|
|
+ })
|
|
|
})
|
|
|
})
|
|
|
- })
|
|
|
- }
|
|
|
-}, {
|
|
|
- immediate: true,
|
|
|
+ }
|
|
|
+ }, {
|
|
|
+ immediate: true,
|
|
|
+ })
|
|
|
})
|
|
|
+
|
|
|
const router = useRouter()
|
|
|
-function handleClickTask(currentStep: number, idx: number, idy: number) {
|
|
|
+
|
|
|
+function routerPush(path: string) {
|
|
|
+ router.push(path)
|
|
|
+}
|
|
|
+function windowPushState(path: string) {
|
|
|
+ window.open(`${location.origin}/${path}`, '_self')
|
|
|
+}
|
|
|
+
|
|
|
+function handleValidTask(currentStep: number, idx: number, idy: number) {
|
|
|
let lastIdx = idx
|
|
|
let lastStep = currentStep
|
|
|
- const lastTasks = idx > 0 ? stepsMap[currentStep][lastIdx = idx - 1] : currentStep > 0 ? stepsMap[lastStep = currentStep - 1][lastIdx = stepsMap[currentStep - 1].length - 1] : []
|
|
|
+ const lastTasks = idx > 0 ? stepsReactiveMap[currentStep][lastIdx = idx - 1] : currentStep > 0 ? stepsReactiveMap[lastStep = currentStep - 1][lastIdx = stepsReactiveMap[currentStep - 1].length - 1] : []
|
|
|
|
|
|
if (lastTasks.every((item, idz) => {
|
|
|
if (steps[lastStep].children[lastIdx].children[idz].optional)
|
|
|
return true
|
|
|
else
|
|
|
- return item
|
|
|
+ return !!item
|
|
|
})) {
|
|
|
sessionStorage.setItem('StepId', JSON.stringify({ gid: currentStep, pid: idx, cid: idy }))
|
|
|
- router.push('/detail')
|
|
|
+ return true
|
|
|
}
|
|
|
else {
|
|
|
ElMessage({
|
|
@@ -310,11 +375,12 @@ function handleClickTask(currentStep: number, idx: number, idy: number) {
|
|
|
type: 'warning',
|
|
|
grouping: true,
|
|
|
})
|
|
|
+ return false
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-function beforeClickTask() {
|
|
|
- const continueDoTask = Math.random() > 0.8// false
|
|
|
+function beforeClickTask(gid: number, pid: number, idy: number) {
|
|
|
+ const continueDoTask = true
|
|
|
if (!continueDoTask) {
|
|
|
ElMessage({
|
|
|
message: '无权操作',
|
|
@@ -322,19 +388,56 @@ function beforeClickTask() {
|
|
|
grouping: true,
|
|
|
})
|
|
|
}
|
|
|
+ else {
|
|
|
+ return handleValidTask(gid, pid, idy)
|
|
|
+ }
|
|
|
return continueDoTask
|
|
|
}
|
|
|
|
|
|
-function handleCompleteTask(gid: number, pid: number, idy: number) {
|
|
|
- if (stepsMap[gid][pid][idy] === 1) {
|
|
|
+function judgeStepCompleted(val: unknown) {
|
|
|
+ return (!!val) || (typeof val === 'object' && !!(val?.value))
|
|
|
+}
|
|
|
+
|
|
|
+function handleCompleteTask(gid: number, pid: number, cid: number, val?: unknown) {
|
|
|
+ const _ykl_lc_ = JSON.parse(sessionStorage.getItem('ykl_lc')!)
|
|
|
+ _ykl_lc_.processList[gid][pid][cid] = val || 1
|
|
|
+ request({
|
|
|
+ url: '/yzy/kmksyjlc/save',
|
|
|
+ data: {
|
|
|
+ ykl_id,
|
|
|
+ yk: {
|
|
|
+ ykl_lc: JSON.stringify(_ykl_lc_),
|
|
|
+ },
|
|
|
+ },
|
|
|
+ }).then((res) => {
|
|
|
+ if (res.code === '1') {
|
|
|
+ ElMessage({
|
|
|
+ message: '操作成功',
|
|
|
+ type: 'success',
|
|
|
+ grouping: true,
|
|
|
+ })
|
|
|
+ stepsReactiveMap[gid][pid][cid] = val || 1
|
|
|
+ }
|
|
|
+ }).catch(() => {
|
|
|
+ ElMessage({
|
|
|
+ message: '操作失败',
|
|
|
+ type: 'error',
|
|
|
+ grouping: true,
|
|
|
+ })
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+function handleJumpTask(gid: number, pid: number, idy: number) {
|
|
|
+ if (judgeStepCompleted(stepsReactiveMap[gid][pid][idy])) {
|
|
|
return ElMessage({
|
|
|
message: '该任务已完成',
|
|
|
type: 'warning',
|
|
|
grouping: true,
|
|
|
})
|
|
|
}
|
|
|
- window.handleCompleteTask(gid, pid, idy)
|
|
|
- if (pid === stepsMap[gid].length - 1)
|
|
|
+ // stepsReactiveMap[gid][pid][idy] = 1
|
|
|
+ handleCompleteTask(gid, pid, idy)
|
|
|
+ if (pid === stepsReactiveMap[gid].length - 1)
|
|
|
return
|
|
|
const line = lineList[gid][pid][idy]
|
|
|
line.setOptions({ color: '#003eee' })
|
|
@@ -381,19 +484,19 @@ onBeforeRouteLeave(() => {
|
|
|
<the-card
|
|
|
v-for="(task, idy) in step.children " :key="idy"
|
|
|
:ref="el => { CardsRef[idx] = CardsRef[idx] || []; CardsRef[idx][idy] = el as any }" :title="task.title"
|
|
|
- :description="task.description" :completed="!!stepsMap[currentStep][idx][idy]"
|
|
|
+ :description="task.description" :completed="judgeStepCompleted(stepsReactiveMap[currentStep][idx][idy])"
|
|
|
>
|
|
|
<template #operate>
|
|
|
<template v-if="task.title === '预划考号区域'">
|
|
|
<div
|
|
|
class="min-w-60px cursor-pointer rounded bg-light-50 py-3px text-center text-xs"
|
|
|
- @click="beforeClickTask() && handleClickTask(currentStep, idx, idy)"
|
|
|
+ @click="beforeClickTask(currentStep, idx, idy) && windowPushState('/dist/index.html')"
|
|
|
>
|
|
|
- {{ !!stepsMap[currentStep][idx][idy] ? '已经完成' : '立即开始' }}
|
|
|
+ {{ judgeStepCompleted(stepsReactiveMap[currentStep][idx][idy]) ? '已经完成' : '立即开始' }}
|
|
|
</div>
|
|
|
<div
|
|
|
class="min-w-60px cursor-pointer rounded bg-light-50 py-3px text-center text-xs"
|
|
|
- @click="beforeClickTask() && handleCompleteTask(currentStep, idx, idy)"
|
|
|
+ @click="beforeClickTask(currentStep, idx, idy) && handleJumpTask(currentStep, idx, idy)"
|
|
|
>
|
|
|
{{ '跳过' }}
|
|
|
</div>
|
|
@@ -401,9 +504,9 @@ onBeforeRouteLeave(() => {
|
|
|
<template v-else>
|
|
|
<div
|
|
|
class="min-w-60px cursor-pointer rounded bg-light-50 py-3px text-center text-xs"
|
|
|
- @click="beforeClickTask() && handleClickTask(currentStep, idx, idy)"
|
|
|
+ @click="beforeClickTask(currentStep, idx, idy) && routerPush('detail')"
|
|
|
>
|
|
|
- {{ !!stepsMap[currentStep][idx][idy] ? '已经完成' : '立即开始' }}
|
|
|
+ {{ judgeStepCompleted(stepsReactiveMap[currentStep][idx][idy]) ? '已经完成' : '立即开始' }}
|
|
|
</div>
|
|
|
</template>
|
|
|
</template>
|
|
@@ -414,7 +517,7 @@ onBeforeRouteLeave(() => {
|
|
|
<el-link type="primary">
|
|
|
修改试题答案
|
|
|
</el-link>
|
|
|
- <qxsz :disabled="!!stepsMap[currentStep][idx][idy]" />
|
|
|
+ <qxsz :disabled="judgeStepCompleted(stepsReactiveMap[currentStep][idx][idy])" />
|
|
|
<el-link type="primary">
|
|
|
标记缺考
|
|
|
</el-link>
|