[科学实验] - 更新作业学段学科回显
This commit is contained in:
parent
d9a0f2f8c3
commit
d8c4876119
|
@ -7,7 +7,7 @@ const useClassTaskStore = defineStore('classTask',{
|
|||
state: () => ({
|
||||
experimentObj:{
|
||||
edustage: '小学', // 教育阶段
|
||||
edusubject: '', // 学科
|
||||
edusubject: '数学', // 学科
|
||||
experimentList: [], // 实验科目列表
|
||||
updateEduInfo: '小学-数学', //实际需上传的学段+学科信息(用于上传及回显实验内的学段学科)
|
||||
},
|
||||
|
|
|
@ -42,7 +42,7 @@ const updateLabel = (val) => {
|
|||
|
||||
const onSelectOption = (option) => {
|
||||
classTaskStore.updateEduInfo = `${classTaskStore.edustage}-${classTaskStore.edusubject}`;
|
||||
console.log('updateEduInfo->', classTaskStore.experimentList.updateEduInfo);
|
||||
console.log('updateEduInfo->', classTaskStore.updateEduInfo);
|
||||
console.log(option,'选择的实验课-------')
|
||||
emit('selectItem', classTaskStore.experimentList.filter(item => item.label === option)[0])
|
||||
}
|
||||
|
|
|
@ -56,7 +56,7 @@ const subjectList = ref([])
|
|||
const chooseGrade= ref({})
|
||||
const expList = ref([]) // 当前年级的所有课程
|
||||
const checkList = ref([])// 当前年级对应学科的课程,
|
||||
|
||||
const isLoaded = ref(false);
|
||||
|
||||
// 获取基础的学科
|
||||
const getSubject = () => {
|
||||
|
@ -80,8 +80,15 @@ const getSubject = () => {
|
|||
})
|
||||
})
|
||||
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) => {
|
||||
|
@ -108,7 +115,8 @@ const isExpList = (edusubject) => {
|
|||
// 选择学段
|
||||
const handleUserEduStage = (item) => {
|
||||
// userStore.edustage = item
|
||||
useClassTaskStore().experimentObj.edustage = item
|
||||
useClassTaskStore().experimentObj.edustage = item;
|
||||
|
||||
//清空操作
|
||||
expList.value = []
|
||||
if(item === '小学'){
|
||||
|
@ -121,6 +129,7 @@ const handleUserEduStage = (item) => {
|
|||
useClassTaskStore().experimentObj.edusubject = name;
|
||||
// 更改学科默认与学科下的实验科目
|
||||
handleUserEduSubject(name)
|
||||
break;
|
||||
}
|
||||
}
|
||||
}else if(item === '初中'){
|
||||
|
@ -133,6 +142,7 @@ const handleUserEduStage = (item) => {
|
|||
useClassTaskStore().experimentObj.edusubject = name;
|
||||
// 更改学科默认与学科下的实验科目
|
||||
handleUserEduSubject(name)
|
||||
break;
|
||||
}
|
||||
}
|
||||
}else if(item === '高中'){
|
||||
|
@ -145,6 +155,7 @@ const handleUserEduStage = (item) => {
|
|||
useClassTaskStore().experimentObj.edusubject = name;
|
||||
// 更改学科默认与学科下的实验科目
|
||||
handleUserEduSubject(name)
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -177,7 +188,13 @@ const handleUserEduSubject = (item) => {
|
|||
// emit('experlist',checkList.value)
|
||||
}
|
||||
|
||||
const updateCheckList = () => {
|
||||
const updateCheckList = async () => {
|
||||
try {
|
||||
await waitForSubjectData();
|
||||
|
||||
//console.log('父组件执行开始-------', );
|
||||
//console.log('experimentObj-> ', useClassTaskStore().experimentObj);
|
||||
// 再执行更新逻辑
|
||||
const edustage = useClassTaskStore().experimentObj.edustage;
|
||||
if(edustage === '小学'){
|
||||
chooseGrade.value = jsonData.data.primary
|
||||
|
@ -189,8 +206,32 @@ const updateCheckList = () => {
|
|||
expList.value = chooseGrade.value
|
||||
const edusubject = useClassTaskStore().experimentObj.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(() => {
|
||||
getSubject()
|
||||
|
|
|
@ -600,7 +600,8 @@ const handleClassWorkFormQuizRemove = (index) =>{
|
|||
}
|
||||
else if(classWorkForm.worktype === "科学实验"){
|
||||
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'}]);
|
||||
try {
|
||||
console.log(cform,'科学实验')
|
||||
|
|
Loading…
Reference in New Issue