Merge pull request 'fix:修改个人中心学科方式;' (#208) from yws_dev into main

Reviewed-on: #208
This commit is contained in:
yangws 2025-01-07 17:20:06 +08:00
commit c2a3ffb0a0
2 changed files with 91 additions and 51 deletions

View File

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

View File

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