[科学实验] - 更新作业学段学科回显

This commit is contained in:
“zouyf” 2024-12-25 17:04:29 +08:00
parent d9a0f2f8c3
commit d8c4876119
4 changed files with 60 additions and 18 deletions

View File

@ -7,7 +7,7 @@ const useClassTaskStore = defineStore('classTask',{
state: () => ({ state: () => ({
experimentObj:{ experimentObj:{
edustage: '小学', // 教育阶段 edustage: '小学', // 教育阶段
edusubject: '', // 学科 edusubject: '数学', // 学科
experimentList: [], // 实验科目列表 experimentList: [], // 实验科目列表
updateEduInfo: '小学-数学', //实际需上传的学段+学科信息(用于上传及回显实验内的学段学科) updateEduInfo: '小学-数学', //实际需上传的学段+学科信息(用于上传及回显实验内的学段学科)
}, },

View File

@ -42,7 +42,7 @@ const updateLabel = (val) => {
const onSelectOption = (option) => { const onSelectOption = (option) => {
classTaskStore.updateEduInfo = `${classTaskStore.edustage}-${classTaskStore.edusubject}`; classTaskStore.updateEduInfo = `${classTaskStore.edustage}-${classTaskStore.edusubject}`;
console.log('updateEduInfo->', classTaskStore.experimentList.updateEduInfo); console.log('updateEduInfo->', classTaskStore.updateEduInfo);
console.log(option,'选择的实验课-------') console.log(option,'选择的实验课-------')
emit('selectItem', classTaskStore.experimentList.filter(item => item.label === option)[0]) emit('selectItem', classTaskStore.experimentList.filter(item => item.label === option)[0])
} }

View File

@ -56,7 +56,7 @@ const subjectList = ref([])
const chooseGrade= ref({}) const chooseGrade= ref({})
const expList = ref([]) // const expList = ref([]) //
const checkList = ref([])// const checkList = ref([])//
const isLoaded = ref(false);
// //
const getSubject = () => { const getSubject = () => {
@ -80,8 +80,15 @@ const getSubject = () => {
}) })
}) })
console.log(subjectList,'subjectList'); console.log(subjectList,'subjectList');
// //
handleUserEduStage(useClassTaskStore().experimentObj.edustage) const edusubject = useClassTaskStore().experimentObj.edusubject;
handleUserEduStage(useClassTaskStore().experimentObj.edustage);
// , , .
useClassTaskStore().experimentObj.edusubject = edusubject;
// []
isLoaded.value = true;
//console.log('----');
} }
// //
const isExpList = (edusubject) => { const isExpList = (edusubject) => {
@ -108,7 +115,8 @@ const isExpList = (edusubject) => {
// //
const handleUserEduStage = (item) => { const handleUserEduStage = (item) => {
// userStore.edustage = item // userStore.edustage = item
useClassTaskStore().experimentObj.edustage = item useClassTaskStore().experimentObj.edustage = item;
// //
expList.value = [] expList.value = []
if(item === '小学'){ if(item === '小学'){
@ -121,6 +129,7 @@ const handleUserEduStage = (item) => {
useClassTaskStore().experimentObj.edusubject = name; useClassTaskStore().experimentObj.edusubject = name;
// //
handleUserEduSubject(name) handleUserEduSubject(name)
break;
} }
} }
}else if(item === '初中'){ }else if(item === '初中'){
@ -133,6 +142,7 @@ const handleUserEduStage = (item) => {
useClassTaskStore().experimentObj.edusubject = name; useClassTaskStore().experimentObj.edusubject = name;
// //
handleUserEduSubject(name) handleUserEduSubject(name)
break;
} }
} }
}else if(item === '高中'){ }else if(item === '高中'){
@ -145,6 +155,7 @@ const handleUserEduStage = (item) => {
useClassTaskStore().experimentObj.edusubject = name; useClassTaskStore().experimentObj.edusubject = name;
// //
handleUserEduSubject(name) handleUserEduSubject(name)
break;
} }
} }
} }
@ -177,7 +188,13 @@ const handleUserEduSubject = (item) => {
// emit('experlist',checkList.value) // emit('experlist',checkList.value)
} }
const updateCheckList = () => { const updateCheckList = async () => {
try {
await waitForSubjectData();
//console.log('-------', );
//console.log('experimentObj-> ', useClassTaskStore().experimentObj);
//
const edustage = useClassTaskStore().experimentObj.edustage; const edustage = useClassTaskStore().experimentObj.edustage;
if(edustage === '小学'){ if(edustage === '小学'){
chooseGrade.value = jsonData.data.primary chooseGrade.value = jsonData.data.primary
@ -189,7 +206,31 @@ const updateCheckList = () => {
expList.value = chooseGrade.value expList.value = chooseGrade.value
const edusubject = useClassTaskStore().experimentObj.edusubject; const edusubject = useClassTaskStore().experimentObj.edusubject;
handleUserEduSubject(edusubject); handleUserEduSubject(edusubject);
} catch (error) {
console.error(error);
} }
}
const waitForSubjectData = () => {
return new Promise((resolve, reject) => {
let timeoutId;
let intervalId;
const checkIsLoaded = () => {
if (isLoaded.value) {
clearInterval(intervalId);
clearTimeout(timeoutId);
resolve();
}
};
intervalId = setInterval(checkIsLoaded, 100);
timeoutId = setTimeout(() => {
clearInterval(intervalId);
reject(new Error('该作业-等待[科学实验]学科学段初始化超时'));
}, 5000);
});
};
onMounted(() => { onMounted(() => {

View File

@ -600,7 +600,8 @@ const handleClassWorkFormQuizRemove = (index) =>{
} }
else if(classWorkForm.worktype === "科学实验"){ else if(classWorkForm.worktype === "科学实验"){
if (classWorkForm.fileHomeworkList.length == 0) return ElMessage({ type: 'warning', message: '请选择科学实验的课程!'}); if (classWorkForm.fileHomeworkList.length == 0) return ElMessage({ type: 'warning', message: '请选择科学实验的课程!'});
cform.workcodes = JSON.stringify(classWorkForm.fileHomeworkList); cform.worktag = useClassTaskStores.experimentObj.updateEduInfo; // , [-]
cform.workcodes = JSON.stringify(classWorkForm.fileHomeworkList); //
cform.entpcourseworklist = JSON.stringify([{'id':-3, 'score': '10'}]); cform.entpcourseworklist = JSON.stringify([{'id':-3, 'score': '10'}]);
try { try {
console.log(cform,'科学实验') console.log(cform,'科学实验')