fix: 修复一些问题
This commit is contained in:
parent
43eaa23e7a
commit
360834b437
21
src/constants/doWork.ts
Normal file
21
src/constants/doWork.ts
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
/** 与 Web 端 subject/doWork/index.ts 保持一致 */
|
||||||
|
export const resource_type_free = '0';
|
||||||
|
export const resource_type_ai = '1';
|
||||||
|
export const resource_type_wrong_book = '2';
|
||||||
|
export const resource_type_analogy = '3';
|
||||||
|
export const resource_type_paper = '7';
|
||||||
|
export const resource_type_homework = '8';
|
||||||
|
export const resource_type_wrong_retry = '10';
|
||||||
|
export const resource_type_similar_recommend = '11';
|
||||||
|
|
||||||
|
/** 兼容历史错误传参 */
|
||||||
|
export const normalizeResourceType = (type?: string) => {
|
||||||
|
if (!type || type === 'homework') return resource_type_homework;
|
||||||
|
return type;
|
||||||
|
};
|
||||||
|
|
||||||
|
/** 需要走作业保存/提交接口的资源类型 */
|
||||||
|
export const isHomeworkExamResourceType = (type: string) =>
|
||||||
|
type === resource_type_homework ||
|
||||||
|
type === resource_type_wrong_retry ||
|
||||||
|
type === resource_type_similar_recommend;
|
||||||
@ -108,11 +108,14 @@ import {
|
|||||||
submitExam,
|
submitExam,
|
||||||
getPaperRecordDetail,
|
getPaperRecordDetail,
|
||||||
} from '@/api/homework';
|
} from '@/api/homework';
|
||||||
|
import {
|
||||||
|
resource_type_homework,
|
||||||
|
normalizeResourceType,
|
||||||
|
isHomeworkExamResourceType,
|
||||||
|
} from '@/constants/doWork';
|
||||||
import Loading from '@/components/Loading/index.vue';
|
import Loading from '@/components/Loading/index.vue';
|
||||||
import Question from './components/Question.vue';
|
import Question from './components/Question.vue';
|
||||||
|
|
||||||
const RESOURCE_TYPE_HOMEWORK = 'homework';
|
|
||||||
|
|
||||||
const pageLoading = ref(true);
|
const pageLoading = ref(true);
|
||||||
const submitLoading = ref(false);
|
const submitLoading = ref(false);
|
||||||
const menuButtonRightRpx = ref(0);
|
const menuButtonRightRpx = ref(0);
|
||||||
@ -127,7 +130,9 @@ const params = ref<any>({});
|
|||||||
let timer: any = null;
|
let timer: any = null;
|
||||||
const initialIdx = ref(0);
|
const initialIdx = ref(0);
|
||||||
|
|
||||||
const resourceType = computed(() => params.value.resourceType || RESOURCE_TYPE_HOMEWORK);
|
const resourceType = computed(() =>
|
||||||
|
normalizeResourceType(params.value.resourceType || paperInfo.value.resourceType),
|
||||||
|
);
|
||||||
|
|
||||||
const normalizePaperList = (list: any, markUnLook = false) => {
|
const normalizePaperList = (list: any, markUnLook = false) => {
|
||||||
if (!Array.isArray(list)) return [];
|
if (!Array.isArray(list)) return [];
|
||||||
@ -202,12 +207,24 @@ const timeFilter = computed(() => {
|
|||||||
|
|
||||||
onLoad((options: any) => {
|
onLoad((options: any) => {
|
||||||
initialIdx.value = Number(options.idx) || 0;
|
initialIdx.value = Number(options.idx) || 0;
|
||||||
|
// 与 Web route.params.id 一致:带 id 时为查看报告
|
||||||
if (options.id) {
|
if (options.id) {
|
||||||
reportFlag.value = 1;
|
reportFlag.value = 1;
|
||||||
params.value = { ...options, id: options.id };
|
params.value = {
|
||||||
|
...options,
|
||||||
|
id: options.id,
|
||||||
|
recordId: options.recordId || options.id,
|
||||||
|
resourceType: normalizeResourceType(options.resourceType),
|
||||||
|
};
|
||||||
} else {
|
} else {
|
||||||
reportFlag.value = Number(options.reportFlag || 0) as 0 | 1;
|
reportFlag.value = Number(options.reportFlag || 0) as 0 | 1;
|
||||||
params.value = { ...options };
|
params.value = {
|
||||||
|
...options,
|
||||||
|
resourceType: normalizeResourceType(options.resourceType),
|
||||||
|
};
|
||||||
|
if (reportFlag.value === 1 && params.value.recordId && !params.value.id) {
|
||||||
|
params.value.id = params.value.recordId;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
init();
|
init();
|
||||||
});
|
});
|
||||||
@ -232,19 +249,19 @@ const handleBack = () => {
|
|||||||
|
|
||||||
const switchQuestion = async (idx?: number) => {
|
const switchQuestion = async (idx?: number) => {
|
||||||
if (idx === activeIdx.value) {
|
if (idx === activeIdx.value) {
|
||||||
if (!reportFlag.value && resourceType.value === RESOURCE_TYPE_HOMEWORK) {
|
if (!reportFlag.value && isHomeworkExamResourceType(resourceType.value)) {
|
||||||
await saveAnswer();
|
await saveAnswer();
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (idx !== undefined) {
|
if (idx !== undefined) {
|
||||||
if (!reportFlag.value && resourceType.value === RESOURCE_TYPE_HOMEWORK) {
|
if (!reportFlag.value && isHomeworkExamResourceType(resourceType.value)) {
|
||||||
normalizeCurrentMultiAnswer();
|
normalizeCurrentMultiAnswer();
|
||||||
await saveAnswer();
|
await saveAnswer();
|
||||||
}
|
}
|
||||||
activeIdx.value = idx;
|
activeIdx.value = idx;
|
||||||
} else if (activeIdx.value < paperList.value.length - 1) {
|
} else if (activeIdx.value < paperList.value.length - 1) {
|
||||||
if (!reportFlag.value && resourceType.value === RESOURCE_TYPE_HOMEWORK) {
|
if (!reportFlag.value && isHomeworkExamResourceType(resourceType.value)) {
|
||||||
normalizeCurrentMultiAnswer();
|
normalizeCurrentMultiAnswer();
|
||||||
await saveAnswer();
|
await saveAnswer();
|
||||||
}
|
}
|
||||||
@ -364,6 +381,9 @@ const initReport = async () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const initNewTrain = async () => {
|
const initNewTrain = async () => {
|
||||||
|
if (resourceType.value !== resource_type_homework) {
|
||||||
|
throw new Error('暂不支持该练习类型');
|
||||||
|
}
|
||||||
const res: any = await startExam(params.value.recordId);
|
const res: any = await startExam(params.value.recordId);
|
||||||
paperInfo.value = res.data || res;
|
paperInfo.value = res.data || res;
|
||||||
if (paperInfo.value.costTime) {
|
if (paperInfo.value.costTime) {
|
||||||
|
|||||||
@ -149,10 +149,9 @@ import { onShow } from '@dcloudio/uni-app';
|
|||||||
import Empty from '@/components/Empty/index.vue';
|
import Empty from '@/components/Empty/index.vue';
|
||||||
import Loading from '@/components/Loading/index.vue';
|
import Loading from '@/components/Loading/index.vue';
|
||||||
import { getUnfinishedHomework, type PaperRecord } from '@/api/homework';
|
import { getUnfinishedHomework, type PaperRecord } from '@/api/homework';
|
||||||
|
import { resource_type_homework } from '@/constants/doWork';
|
||||||
import { formatTime } from '@/utils/format';
|
import { formatTime } from '@/utils/format';
|
||||||
|
|
||||||
const RESOURCE_TYPE = 'homework';
|
|
||||||
|
|
||||||
interface SubjectItem {
|
interface SubjectItem {
|
||||||
id: string;
|
id: string;
|
||||||
name: string;
|
name: string;
|
||||||
@ -222,7 +221,7 @@ const onSelectSubject = (item: SubjectItem) => {
|
|||||||
|
|
||||||
const onStartPaper = (paper: PaperRecord) => {
|
const onStartPaper = (paper: PaperRecord) => {
|
||||||
uni.navigateTo({
|
uni.navigateTo({
|
||||||
url: `/pages/doWork/index?resourceType=${RESOURCE_TYPE}&recordId=${paper.id}&reportFlag=0&subjectId=${activeSubjectId.value}`,
|
url: `/pages/doWork/index?resourceType=${resource_type_homework}&recordId=${paper.id}&reportFlag=0&subjectId=${activeSubjectId.value}`,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -225,6 +225,7 @@ import Empty from '@/components/Empty/index.vue';
|
|||||||
import Loading from '@/components/Loading/index.vue';
|
import Loading from '@/components/Loading/index.vue';
|
||||||
import ProgressBar from '@/components/ProgressBar/index.vue';
|
import ProgressBar from '@/components/ProgressBar/index.vue';
|
||||||
import { getJobAnalyse, getKnowledgeAnalyse, getPaperRecordDetail } from '@/api/homework';
|
import { getJobAnalyse, getKnowledgeAnalyse, getPaperRecordDetail } from '@/api/homework';
|
||||||
|
import { resource_type_homework } from '@/constants/doWork';
|
||||||
|
|
||||||
const recordId = ref('');
|
const recordId = ref('');
|
||||||
const paperName = ref('');
|
const paperName = ref('');
|
||||||
@ -374,7 +375,7 @@ const getKnowledgeColor = (item: any) => {
|
|||||||
|
|
||||||
const viewQuestion = (idx: number) => {
|
const viewQuestion = (idx: number) => {
|
||||||
uni.navigateTo({
|
uni.navigateTo({
|
||||||
url: `/pages/doWork/index?recordId=${recordId.value}&reportFlag=1&idx=${idx}`,
|
url: `/pages/doWork/index?id=${recordId.value}&recordId=${recordId.value}&reportFlag=1&resourceType=${resource_type_homework}&idx=${idx}`,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<ParentPage active="reports" :show-tab="false" :use-scroll-view="false">
|
<ParentPage active="reports" :show-tab="false">
|
||||||
<ParentFilterRow :items="filterItems" @change="onFilterChange" />
|
<ParentFilterRow :items="filterItems" @change="onFilterChange" />
|
||||||
|
|
||||||
<view class="module-section">
|
<view class="module-section">
|
||||||
@ -69,9 +69,9 @@
|
|||||||
canvasId="parentAbilityTrendCanvas2dLineChart"
|
canvasId="parentAbilityTrendCanvas2dLineChart"
|
||||||
background="rgba(255,255,255,0)"
|
background="rgba(255,255,255,0)"
|
||||||
:canvas2d="true"
|
:canvas2d="true"
|
||||||
:in-scroll-view="false"
|
:in-scroll-view="true"
|
||||||
:ontouch="false"
|
:ontouch="false"
|
||||||
:disable-scroll="false"
|
:disable-scroll="true"
|
||||||
:reshow="chartReshow"
|
:reshow="chartReshow"
|
||||||
:opts="abilityChartOpts"
|
:opts="abilityChartOpts"
|
||||||
:chartData="abilityChartData"
|
:chartData="abilityChartData"
|
||||||
@ -244,6 +244,9 @@ const abilityChartOpts = {
|
|||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
.module-section {
|
.module-section {
|
||||||
margin-top: 44rpx;
|
margin-top: 44rpx;
|
||||||
|
width: 100%;
|
||||||
|
max-width: 100%;
|
||||||
|
overflow-x: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
.filter-row + .module-section {
|
.filter-row + .module-section {
|
||||||
@ -254,6 +257,9 @@ const abilityChartOpts = {
|
|||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
gap: 28rpx;
|
gap: 28rpx;
|
||||||
|
width: 100%;
|
||||||
|
max-width: 100%;
|
||||||
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
.ratio-main {
|
.ratio-main {
|
||||||
@ -372,7 +378,7 @@ const abilityChartOpts = {
|
|||||||
|
|
||||||
.score-row {
|
.score-row {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: 1fr 112rpx 150rpx;
|
grid-template-columns: minmax(0, 1fr) 112rpx 150rpx;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
min-height: 76rpx;
|
min-height: 76rpx;
|
||||||
padding: 0 22rpx;
|
padding: 0 22rpx;
|
||||||
@ -384,6 +390,11 @@ const abilityChartOpts = {
|
|||||||
&:first-child {
|
&:first-child {
|
||||||
border-top: 0;
|
border-top: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
> text,
|
||||||
|
> .knowledge-name {
|
||||||
|
min-width: 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.table-head {
|
.table-head {
|
||||||
@ -409,13 +420,17 @@ const abilityChartOpts = {
|
|||||||
|
|
||||||
.ucharts-wrap {
|
.ucharts-wrap {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
max-width: 100%;
|
||||||
height: 360rpx;
|
height: 360rpx;
|
||||||
margin-top: 4rpx;
|
margin-top: 4rpx;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
|
position: relative;
|
||||||
}
|
}
|
||||||
|
|
||||||
.ability-chart {
|
.ability-chart {
|
||||||
width: 100%;
|
display: block;
|
||||||
|
width: 100% !important;
|
||||||
|
max-width: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -57,7 +57,9 @@ withDefaults(
|
|||||||
.native-scroll {
|
.native-scroll {
|
||||||
min-height: 100vh;
|
min-height: 100vh;
|
||||||
height: auto;
|
height: auto;
|
||||||
overflow: visible;
|
/* 原生纵向滚动时仍需裁剪横向溢出,避免 iOS 整页左右滑动 */
|
||||||
|
overflow-x: hidden;
|
||||||
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.decor {
|
.decor {
|
||||||
@ -87,15 +89,23 @@ withDefaults(
|
|||||||
position: relative;
|
position: relative;
|
||||||
z-index: 1;
|
z-index: 1;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
|
width: 100%;
|
||||||
|
overflow-x: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
.native-page-scroll {
|
.native-page-scroll {
|
||||||
min-height: 100vh;
|
min-height: 100vh;
|
||||||
height: auto;
|
height: auto;
|
||||||
|
width: 100%;
|
||||||
|
overflow-x: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
.page-content {
|
.page-content {
|
||||||
padding: 24rpx 28rpx 0;
|
padding: 24rpx 28rpx 0;
|
||||||
|
width: 100%;
|
||||||
|
max-width: 100%;
|
||||||
|
box-sizing: border-box;
|
||||||
|
overflow-x: hidden;
|
||||||
|
|
||||||
&.with-tab {
|
&.with-tab {
|
||||||
padding-bottom: calc(150rpx + env(safe-area-inset-bottom));
|
padding-bottom: calc(150rpx + env(safe-area-inset-bottom));
|
||||||
|
|||||||
@ -185,6 +185,7 @@
|
|||||||
import { computed, ref } from 'vue';
|
import { computed, ref } from 'vue';
|
||||||
import { onLoad } from '@dcloudio/uni-app';
|
import { onLoad } from '@dcloudio/uni-app';
|
||||||
import { getListCompleteRecord, getPaperRecordDetail } from '../../api/homework';
|
import { getListCompleteRecord, getPaperRecordDetail } from '../../api/homework';
|
||||||
|
import { resource_type_homework } from '@/constants/doWork';
|
||||||
|
|
||||||
type WrongStatus = 'new' | 'review' | 'mastered';
|
type WrongStatus = 'new' | 'review' | 'mastered';
|
||||||
type TabKey = 'all' | 'new' | 'mastered';
|
type TabKey = 'all' | 'new' | 'mastered';
|
||||||
@ -408,7 +409,7 @@ const markMastered = (item: WrongQuestion) => {
|
|||||||
|
|
||||||
const practiceAgain = (item: WrongQuestion) => {
|
const practiceAgain = (item: WrongQuestion) => {
|
||||||
uni.navigateTo({
|
uni.navigateTo({
|
||||||
url: `/pages/doWork/index?recordId=${item.recordId}&reportFlag=1&idx=${Math.max(item.number - 1, 0)}`,
|
url: `/pages/doWork/index?id=${item.recordId}&recordId=${item.recordId}&reportFlag=1&resourceType=${resource_type_homework}&idx=${Math.max(item.number - 1, 0)}`,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user