[科学实验] - 更新作业学段学科回显
This commit is contained in:
parent
d9a0f2f8c3
commit
d8c4876119
|
@ -7,7 +7,7 @@ const useClassTaskStore = defineStore('classTask',{
|
||||||
state: () => ({
|
state: () => ({
|
||||||
experimentObj:{
|
experimentObj:{
|
||||||
edustage: '小学', // 教育阶段
|
edustage: '小学', // 教育阶段
|
||||||
edusubject: '', // 学科
|
edusubject: '数学', // 学科
|
||||||
experimentList: [], // 实验科目列表
|
experimentList: [], // 实验科目列表
|
||||||
updateEduInfo: '小学-数学', //实际需上传的学段+学科信息(用于上传及回显实验内的学段学科)
|
updateEduInfo: '小学-数学', //实际需上传的学段+学科信息(用于上传及回显实验内的学段学科)
|
||||||
},
|
},
|
||||||
|
|
|
@ -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])
|
||||||
}
|
}
|
||||||
|
|
|
@ -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()
|
||||||
|
|
|
@ -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,'科学实验')
|
||||||
|
|
Loading…
Reference in New Issue