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,
|
||||
getPaperRecordDetail,
|
||||
} from '@/api/homework';
|
||||
import {
|
||||
resource_type_homework,
|
||||
normalizeResourceType,
|
||||
isHomeworkExamResourceType,
|
||||
} from '@/constants/doWork';
|
||||
import Loading from '@/components/Loading/index.vue';
|
||||
import Question from './components/Question.vue';
|
||||
|
||||
const RESOURCE_TYPE_HOMEWORK = 'homework';
|
||||
|
||||
const pageLoading = ref(true);
|
||||
const submitLoading = ref(false);
|
||||
const menuButtonRightRpx = ref(0);
|
||||
@ -127,7 +130,9 @@ const params = ref<any>({});
|
||||
let timer: any = null;
|
||||
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) => {
|
||||
if (!Array.isArray(list)) return [];
|
||||
@ -202,12 +207,24 @@ const timeFilter = computed(() => {
|
||||
|
||||
onLoad((options: any) => {
|
||||
initialIdx.value = Number(options.idx) || 0;
|
||||
// 与 Web route.params.id 一致:带 id 时为查看报告
|
||||
if (options.id) {
|
||||
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 {
|
||||
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();
|
||||
});
|
||||
@ -232,19 +249,19 @@ const handleBack = () => {
|
||||
|
||||
const switchQuestion = async (idx?: number) => {
|
||||
if (idx === activeIdx.value) {
|
||||
if (!reportFlag.value && resourceType.value === RESOURCE_TYPE_HOMEWORK) {
|
||||
if (!reportFlag.value && isHomeworkExamResourceType(resourceType.value)) {
|
||||
await saveAnswer();
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (idx !== undefined) {
|
||||
if (!reportFlag.value && resourceType.value === RESOURCE_TYPE_HOMEWORK) {
|
||||
if (!reportFlag.value && isHomeworkExamResourceType(resourceType.value)) {
|
||||
normalizeCurrentMultiAnswer();
|
||||
await saveAnswer();
|
||||
}
|
||||
activeIdx.value = idx;
|
||||
} else if (activeIdx.value < paperList.value.length - 1) {
|
||||
if (!reportFlag.value && resourceType.value === RESOURCE_TYPE_HOMEWORK) {
|
||||
if (!reportFlag.value && isHomeworkExamResourceType(resourceType.value)) {
|
||||
normalizeCurrentMultiAnswer();
|
||||
await saveAnswer();
|
||||
}
|
||||
@ -364,6 +381,9 @@ const initReport = async () => {
|
||||
};
|
||||
|
||||
const initNewTrain = async () => {
|
||||
if (resourceType.value !== resource_type_homework) {
|
||||
throw new Error('暂不支持该练习类型');
|
||||
}
|
||||
const res: any = await startExam(params.value.recordId);
|
||||
paperInfo.value = res.data || res;
|
||||
if (paperInfo.value.costTime) {
|
||||
|
||||
@ -149,10 +149,9 @@ import { onShow } from '@dcloudio/uni-app';
|
||||
import Empty from '@/components/Empty/index.vue';
|
||||
import Loading from '@/components/Loading/index.vue';
|
||||
import { getUnfinishedHomework, type PaperRecord } from '@/api/homework';
|
||||
import { resource_type_homework } from '@/constants/doWork';
|
||||
import { formatTime } from '@/utils/format';
|
||||
|
||||
const RESOURCE_TYPE = 'homework';
|
||||
|
||||
interface SubjectItem {
|
||||
id: string;
|
||||
name: string;
|
||||
@ -222,7 +221,7 @@ const onSelectSubject = (item: SubjectItem) => {
|
||||
|
||||
const onStartPaper = (paper: PaperRecord) => {
|
||||
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 ProgressBar from '@/components/ProgressBar/index.vue';
|
||||
import { getJobAnalyse, getKnowledgeAnalyse, getPaperRecordDetail } from '@/api/homework';
|
||||
import { resource_type_homework } from '@/constants/doWork';
|
||||
|
||||
const recordId = ref('');
|
||||
const paperName = ref('');
|
||||
@ -374,7 +375,7 @@ const getKnowledgeColor = (item: any) => {
|
||||
|
||||
const viewQuestion = (idx: number) => {
|
||||
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>
|
||||
<ParentPage active="reports" :show-tab="false" :use-scroll-view="false">
|
||||
<ParentPage active="reports" :show-tab="false">
|
||||
<ParentFilterRow :items="filterItems" @change="onFilterChange" />
|
||||
|
||||
<view class="module-section">
|
||||
@ -69,9 +69,9 @@
|
||||
canvasId="parentAbilityTrendCanvas2dLineChart"
|
||||
background="rgba(255,255,255,0)"
|
||||
:canvas2d="true"
|
||||
:in-scroll-view="false"
|
||||
:in-scroll-view="true"
|
||||
:ontouch="false"
|
||||
:disable-scroll="false"
|
||||
:disable-scroll="true"
|
||||
:reshow="chartReshow"
|
||||
:opts="abilityChartOpts"
|
||||
:chartData="abilityChartData"
|
||||
@ -244,6 +244,9 @@ const abilityChartOpts = {
|
||||
<style lang="scss" scoped>
|
||||
.module-section {
|
||||
margin-top: 44rpx;
|
||||
width: 100%;
|
||||
max-width: 100%;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
.filter-row + .module-section {
|
||||
@ -254,6 +257,9 @@ const abilityChartOpts = {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 28rpx;
|
||||
width: 100%;
|
||||
max-width: 100%;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.ratio-main {
|
||||
@ -372,7 +378,7 @@ const abilityChartOpts = {
|
||||
|
||||
.score-row {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 112rpx 150rpx;
|
||||
grid-template-columns: minmax(0, 1fr) 112rpx 150rpx;
|
||||
align-items: center;
|
||||
min-height: 76rpx;
|
||||
padding: 0 22rpx;
|
||||
@ -384,6 +390,11 @@ const abilityChartOpts = {
|
||||
&:first-child {
|
||||
border-top: 0;
|
||||
}
|
||||
|
||||
> text,
|
||||
> .knowledge-name {
|
||||
min-width: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.table-head {
|
||||
@ -409,13 +420,17 @@ const abilityChartOpts = {
|
||||
|
||||
.ucharts-wrap {
|
||||
width: 100%;
|
||||
max-width: 100%;
|
||||
height: 360rpx;
|
||||
margin-top: 4rpx;
|
||||
overflow: hidden;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.ability-chart {
|
||||
width: 100%;
|
||||
display: block;
|
||||
width: 100% !important;
|
||||
max-width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
|
||||
@ -57,7 +57,9 @@ withDefaults(
|
||||
.native-scroll {
|
||||
min-height: 100vh;
|
||||
height: auto;
|
||||
overflow: visible;
|
||||
/* 原生纵向滚动时仍需裁剪横向溢出,避免 iOS 整页左右滑动 */
|
||||
overflow-x: hidden;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.decor {
|
||||
@ -87,15 +89,23 @@ withDefaults(
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
.native-page-scroll {
|
||||
min-height: 100vh;
|
||||
height: auto;
|
||||
width: 100%;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
.page-content {
|
||||
padding: 24rpx 28rpx 0;
|
||||
width: 100%;
|
||||
max-width: 100%;
|
||||
box-sizing: border-box;
|
||||
overflow-x: hidden;
|
||||
|
||||
&.with-tab {
|
||||
padding-bottom: calc(150rpx + env(safe-area-inset-bottom));
|
||||
|
||||
@ -185,6 +185,7 @@
|
||||
import { computed, ref } from 'vue';
|
||||
import { onLoad } from '@dcloudio/uni-app';
|
||||
import { getListCompleteRecord, getPaperRecordDetail } from '../../api/homework';
|
||||
import { resource_type_homework } from '@/constants/doWork';
|
||||
|
||||
type WrongStatus = 'new' | 'review' | 'mastered';
|
||||
type TabKey = 'all' | 'new' | 'mastered';
|
||||
@ -408,7 +409,7 @@ const markMastered = (item: WrongQuestion) => {
|
||||
|
||||
const practiceAgain = (item: WrongQuestion) => {
|
||||
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