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

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,20 +188,50 @@ const handleUserEduSubject = (item) => {
// emit('experlist',checkList.value) // emit('experlist',checkList.value)
} }
const updateCheckList = () => { const updateCheckList = async () => {
const edustage = useClassTaskStore().experimentObj.edustage; try {
if(edustage === '小学'){ await waitForSubjectData();
chooseGrade.value = jsonData.data.primary
}else if(edustage === '初中'){ //console.log('-------', );
chooseGrade.value = jsonData.data.junior //console.log('experimentObj-> ', useClassTaskStore().experimentObj);
}else if(edustage === '高中'){ //
chooseGrade.value = jsonData.data.senior const edustage = useClassTaskStore().experimentObj.edustage;
if(edustage === '小学'){
chooseGrade.value = jsonData.data.primary
}else if(edustage === '初中'){
chooseGrade.value = jsonData.data.junior
}else if(edustage === '高中'){
chooseGrade.value = jsonData.data.senior
}
expList.value = chooseGrade.value
const edusubject = useClassTaskStore().experimentObj.edusubject;
handleUserEduSubject(edusubject);
} catch (error) {
console.error(error);
} }
expList.value = chooseGrade.value
const edusubject = useClassTaskStore().experimentObj.edusubject;
handleUserEduSubject(edusubject);
} }
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(() => {
getSubject() getSubject()

View File

@ -537,7 +537,7 @@ const handleClassWorkFormQuizRemove = (index) =>{
if(isShow.value === false){ if(isShow.value === false){
if(classWorkForm.id != '' ) {// id if(classWorkForm.id != '' ) {// id
editWork(cform); // editWork(cform); //
return; return;
} }
} }
@ -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,'科学实验')