fix:修改个人中心学科方式; #208

Merged
yangws merged 1 commits from yws_dev into main 2025-01-07 17:20:08 +08:00
2 changed files with 91 additions and 51 deletions

View File

@ -1,50 +1,59 @@
<template>
<div style="display: flex;">
<div>
<div style="display: flex;align-items: center;" v-if="!showSelect">
<div style="margin-left: 15px">
<el-dropdown @command="handleUserEduStage">
<span class="el-dropdown-link">
<el-button class="custom-button" type="default" round >{{ userStore.edustage }}
<el-icon><ArrowDown /></el-icon>
<el-button class="custom-button" type="default" round>{{ userStore.edustage }}
</el-button>
</span>
<template #dropdown>
<el-dropdown-menu>
<el-dropdown-item command="幼儿园">幼儿园</el-dropdown-item>
<el-dropdown-item command="小学">小学</el-dropdown-item>
<el-dropdown-item command="初中">初中</el-dropdown-item>
<el-dropdown-item command="高中">高中</el-dropdown-item>
</el-dropdown-menu>
</template>
</el-dropdown>
</div>
<div style="margin-left: 15px">
<el-dropdown @command="handleUserEduSubject">
<span class="el-dropdown-link">
<el-button class="custom-button" type="default" round>{{ userStore.edusubject }}
<el-icon><ArrowDown /></el-icon>
</el-button>
</span>
<template #dropdown>
<el-dropdown-menu>
<template v-for="(item, index) in subjectList">
<el-dropdown-item v-if="item.edustage == userStore.edustage" :command="item.itemtitle">{{
item.itemtitle }}</el-dropdown-item>
</template>
</el-dropdown-menu>
</template>
</el-dropdown>
</div>
<el-text type="primary" style="margin-left: 10px;cursor:pointer" @click="handleUserEduSubject()">修改</el-text>
</div>
<div class="m-4" v-else>
<el-cascader v-model="cascaderValue" :options="options" @change="handleChange" />
</div>
</div>
</template>
<script setup>
import useUserStore from '@/store/modules/user'
import {ArrowDown} from '@element-plus/icons-vue'
import { onMounted,ref } from 'vue';
import { listEvaluation } from '@/api/subject/index'
import {sessionStore} from '@/utils/store'
const userStore = useUserStore().user
const subjectList = ref([])
//
const showSelect = ref(false)
const cascaderValue = ref([])
//
const options = ref([
{
value: '幼儿园',
label: '幼儿园',
children: [],
},
{
value: '小学',
label: '小学',
children: [],
},
{
value: '初中',
label: '初中',
children: [],
},
{
value: '高中',
label: '高中',
children: [],
},
])
//
const getSubject = () => {
//
@ -53,33 +62,64 @@ const getSubject = () => {
const arr = userStore.subject.split(',')
subjectList.value = res.rows.filter(item => arr.includes(String(item.id))).map(items => items)
console.log(subjectList,'subjectList');
if(subjectList.value.length === 0) return
// optionslabelsubjectListedustagechilren
options.value.forEach(item => {
subjectList.value.forEach(items => {
if(item.label === items.edustage){
item.children.push({
value: items.id,
label: items.edusubject
})
}
})
})
})
}
//
const handleUserEduStage = (item) => {
userStore.edustage = item
sessionStore.set('edustageSelf',item)
if(item === '幼儿园'){
//
userStore.edusubject = '语文'
sessionStore.set('edusubjectSelf','语文')
}
else if(item === '高中' && userStore.edusubject === "道德与法治"){
const handleUserEduStage = () => {
// userStore.edustage = item
// sessionStore.set('edustageSelf',item)
// if(item === ''){
// //
// userStore.edusubject = ''
// sessionStore.set('edusubjectSelf','')
// }
// else if(item === '' && userStore.edusubject === ""){
// //
// userStore.edusubject = ''
// sessionStore.set('edusubjectSelf','')
// }
// else if(item != '' && userStore.edusubject === ""){
// //
// userStore.edusubject = ''
// sessionStore.set('edusubjectSelf','')
// }
}
//
const handleUserEduSubject = () => {
showSelect.value = true
cascaderValue.value = []
}
const handleChange = (value) => {
const id = value[1];
userStore.edusubject = subjectList.value.find(item => item.id === id).edusubject
userStore.edustage = value[0]
sessionStore.set('edustageSelf',userStore.edustage)
if(userStore.edustage === '高中' && userStore.edusubject === "道德与法治"){
//
userStore.edusubject = '政治'
sessionStore.set('edusubjectSelf','政治')
}
else if(item != '高中' && userStore.edusubject === "政治"){
else if(userStore.edustage != '高中' && userStore.edusubject === "政治"){
//
userStore.edusubject = '道德与法治'
sessionStore.set('edusubjectSelf','道德与法治')
}else{
sessionStore.set('edusubjectSelf',userStore.edusubject)
}
}
//
const handleUserEduSubject = (item) => {
userStore.edusubject = item;
sessionStore.set('edusubjectSelf',item)
showSelect.value = false
}
onMounted(() => {
getSubject()

View File

@ -5,7 +5,7 @@
<div class="info">
<div class="info-name">{{ state.user.nickName }}</div>
<div class="infomation" v-if="isStadium() !== true" >
<selectClass v-if="!isSubject"/>
<SelectClass v-if="!isSubject"/>
</div>
</div>
</div>
@ -34,7 +34,7 @@ import resetPwd from './resetPwd.vue'
import { getUserProfile } from '@/api/system/user'
import pkc from "../../../../../package.json"
//
import selectClass from './components/selectClass.vue'
import SelectClass from './components/selectClass.vue'
import useUserStore from '@/store/modules/user'
const version = ref(pkc.version)