From 28294d0a25ccec554cfda41b4d4021e10421840d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Czouyf=E2=80=9D?= <80906036@qq.com> Date: Mon, 20 Jan 2025 16:10:51 +0800 Subject: [PATCH] =?UTF-8?q?[=E7=A7=91=E5=AD=A6=E5=AE=9E=E9=AA=8C]=20-=20?= =?UTF-8?q?=E6=9B=B4=E6=94=B9=E5=AD=A6=E6=AE=B5=E5=AD=A6=E7=A7=91=E9=80=89?= =?UTF-8?q?=E6=8B=A9=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/selectClass.vue | 160 +++++++++++++++--- 1 file changed, 134 insertions(+), 26 deletions(-) diff --git a/src/renderer/src/views/classTask/newClassTaskAssign/experimentQuestion/components/selectClass.vue b/src/renderer/src/views/classTask/newClassTaskAssign/experimentQuestion/components/selectClass.vue index a504518..b076850 100644 --- a/src/renderer/src/views/classTask/newClassTaskAssign/experimentQuestion/components/selectClass.vue +++ b/src/renderer/src/views/classTask/newClassTaskAssign/experimentQuestion/components/selectClass.vue @@ -1,6 +1,9 @@ - + --> @@ -52,12 +54,114 @@ const userStore = useUserStore().user // edustage: useClassTaskStore().experimentObj.edustage, // edusubject: useClassTaskStore().experimentObj.edusubject, // }) -const subjectList = ref([]) + +//const subjectList = ref([]) const chooseGrade= ref({}) const expList = ref([]) // 当前年级的所有课程 const checkList = ref([])// 当前年级对应学科的课程, const isLoaded = ref(false); + +const bindSubject = ref([useClassTaskStore().experimentObj.edustage, useClassTaskStore().experimentObj.edusubject]); // 默认为小学数学 +const subjectList = [ + { + value: '小学', + label: '小学', + children: [ + { + value: '数学', + label: '数学', + + }, + { + value: '物理', + label: '物理', + + }, + { + value: '化学', + label: '化学', + + }, + { + value: '生物', + label: '生物', + + }, + { + value: '科学', + label: '科学', + + }] + }, + { + value: '初中', + label: '初中', + children: [ + { + value: '数学', + label: '数学', + + }, + { + value: '物理', + label: '物理', + + }, + { + value: '化学', + label: '化学', + + }, + { + value: '生物', + label: '生物', + + }, + { + value: '科学', + label: '科学', + + }] + }, + { + value: '高中', + label: '高中', + children: [ + { + value: '数学', + label: '数学', + + }, + { + value: '物理', + label: '物理', + + }, + { + value: '化学', + label: '化学', + + }, + { + value: '生物', + label: '生物', + + }, + { + value: '科学', + label: '科学', + + }] + } +] +const handleChange = (val) => { + useClassTaskStore().experimentObj.edustage = val[0]; + useClassTaskStore().experimentObj.edusubject = val[1]; + handleUserEduStage(useClassTaskStore().experimentObj.edustage); +} + + // 获取基础的学科 const getSubject = () => { //没有学科则不进行下面的步骤 @@ -67,19 +171,20 @@ const getSubject = () => { // subjectList.value = res.rows.filter(item => arr.includes(String(item.id))).map(items => items) // console.log(subjectList,'subjectList'); // }) + //这里获取死数据 学科list - const edustageList = ['小学','初中','高中']; - const subList = ['数学','物理','化学','生物','科学']; - edustageList.forEach((item) => { - subList.forEach((subItems) => { - subjectList.value.push({ - edustage: item, - edusubject: subItems, - itemtitle: subItems - }) - }) - }) - console.log(subjectList,'subjectList'); + // const edustageList = ['小学','初中','高中']; + // const subList = ['数学','物理','化学','生物','科学']; + // edustageList.forEach((item) => { + // subList.forEach((subItems) => { + // subjectList.value.push({ + // edustage: item, + // edusubject: subItems, + // itemtitle: subItems + // }) + // }) + // }) + // console.log(subjectList,'subjectList'); // 默认读取一个学科 const edusubject = useClassTaskStore().experimentObj.edusubject; @@ -90,6 +195,8 @@ const getSubject = () => { isLoaded.value = true; //console.log('初始化执行完毕----'); } + + // 展示有 实验科目的学科 const isExpList = (edusubject) => { let list = []; @@ -101,7 +208,7 @@ const isExpList = (edusubject) => { list = expList.value.filter(item => item.subject === 'physics') break; case '化学': - checkList.value = expList.value.filter(item => item.subject === 'chemistry') + list = expList.value.filter(item => item.subject === 'chemistry') break; case '生物': list = expList.value.filter(item => item.subject === 'biology') @@ -112,19 +219,19 @@ const isExpList = (edusubject) => { } return list.length > 0 } + // 选择学段 const handleUserEduStage = (item) => { // userStore.edustage = item useClassTaskStore().experimentObj.edustage = item; - //清空操作 expList.value = [] if(item === '小学'){ chooseGrade.value = jsonData.data.primary expList.value = chooseGrade.value - const newSubjectList = subjectList.value.filter(item => item.edustage === '小学'); - for(let i in newSubjectList){ - const name = newSubjectList[i].itemtitle + const newSubjectList = subjectList.filter(item => item.value === '小学'); + for(let i of newSubjectList[0].children){ + const name = i.value if(isExpList(name) && useClassTaskStore().experimentObj.edusubject===name){ //useClassTaskStore().experimentObj.edusubject = name; // 更改学科默认与学科下的实验科目 @@ -135,9 +242,9 @@ const handleUserEduStage = (item) => { }else if(item === '初中'){ chooseGrade.value = jsonData.data.junior expList.value = chooseGrade.value - const newSubjectList = subjectList.value.filter(item => item.edustage === '初中'); - for(let i in newSubjectList){ - const name = newSubjectList[i].itemtitle + const newSubjectList = subjectList.filter(item => item.value === '初中'); + for(let i of newSubjectList[0].children){ + const name = i.value if(isExpList(name) && useClassTaskStore().experimentObj.edusubject===name){ //useClassTaskStore().experimentObj.edusubject = name; // 更改学科默认与学科下的实验科目 @@ -148,9 +255,9 @@ const handleUserEduStage = (item) => { }else if(item === '高中'){ chooseGrade.value = jsonData.data.senior expList.value = chooseGrade.value - const newSubjectList = subjectList.value.filter(item => item.edustage === '高中'); - for(let i in newSubjectList){ - const name = newSubjectList[i].itemtitle + const newSubjectList = subjectList.filter(item => item.value === '高中'); + for(let i of newSubjectList[0].children){ + const name = i.value if(isExpList(name) && useClassTaskStore().experimentObj.edusubject===name){ //useClassTaskStore().experimentObj.edusubject = name; // 更改学科默认与学科下的实验科目 @@ -205,6 +312,7 @@ const updateCheckList = async () => { } expList.value = chooseGrade.value const edusubject = useClassTaskStore().experimentObj.edusubject; + bindSubject.value = [edustage, edusubject]; handleUserEduSubject(edusubject); } catch (error) { console.error(error);