Merge pull request 'lyc-dev' (#31) from lyc-dev into main

This commit is contained in:
lyc 2024-07-17 18:34:12 +08:00
commit b078f55d77
6 changed files with 195 additions and 18 deletions

View File

@ -38,3 +38,12 @@ export function getUserProfile() {
data: data
})
}
// 修改用户,这个不涉及到用户的权限、角色更新
export function updateUserInfo(data) {
return request({
url: '/system/user/updateUserInfo',
method: 'put',
data: data
})
}

View File

@ -305,6 +305,7 @@ onMounted(() => {
border-bottom: solid #f4f5f7 1px;
font-size: 15px;
font-weight: 600;
border-radius: 10px 10px 0 0;
}
.book-list {

View File

@ -0,0 +1,149 @@
<template>
<el-dialog v-model="dialogVisible" append-to-body :show-close="false" width="500"
top="25vh"
:close-on-click-modal="false"
:close-on-press-escape="false"
style="border-radius: 5px;padding-top: 0;">
<div class="dialog-title flex">
<span>选择你的年级学科</span>
</div>
<div class="dialog-content">
<el-form :inline="true">
<el-form-item label="年级">
<el-select v-model="gradeVal" style="width: 120px;" @change="changeGrade">
<el-option v-for="item in gradeList" :label="item.label" :value="item.value" />
</el-select>
</el-form-item>
<el-form-item label="学科">
<el-select v-model="subjectVal" style="width: 130px;">
<el-option v-for="item in subjectList" :key="item.id" :label="item.itemtitle" :value="item.itemtitle" />
</el-select>
</el-form-item>
</el-form>
</div>
<template #footer>
<div class="dialog-footer">
<el-button type="primary" @click="editUserInfo">
确定
</el-button>
</div>
</template>
</el-dialog>
</template>
<script setup>
import { ref, onMounted, watch, defineProps, defineEmits } from 'vue'
import { listEvaluation } from '@/api/subject'
import { updateUserInfo } from '@/api/system/user'
import useUserStore from '@/store/modules/user'
const userStore = useUserStore()
const { userId, userName } = userStore.user
const props = defineProps({
modelValue: {
type: Boolean,
default: false
},
})
// emit
const emit = defineEmits(['update:modelValue', 'onSuccess'])
const gradeList = ref([
{
label: '高中',
value: '高中'
},
{
label: '初中',
value: '初中'
},
{
label: '小学',
value: '小学'
},
{
label: '幼儿园',
value: '幼儿园'
},
]
)
const subjectVal = ref('')
const gradeVal = ref('')
//
gradeVal.value = gradeList.value[0].value
//
const subjectList = ref([])
const allSubject = ref([])
const dialogVisible = ref(false)
watch(() => props.modelValue, (newVal) => {
dialogVisible.value = newVal
})
//
const changeGrade = ()=>{
//
subjectList.value = allSubject.value.filter( item => item.edustage == gradeVal.value)
if(!subjectList.value.length){
subjectVal.value = ''
return
}
//
subjectVal.value = subjectList.value[0].itemtitle
}
//
const getSubject = async ()=>{
const { rows } = await listEvaluation({ itemkey: "subject", pageSize: 500 })
//
allSubject.value = rows;
// (gradeVal)
subjectList.value = rows.filter( item => item.edustage == gradeVal.value)
if(!subjectList.value.length) return
//
subjectVal.value = subjectList.value[0].itemtitle
}
//
const editUserInfo = async () =>{
const data = {
userId,
userName,
edustage: subjectVal.value,
edusubject: gradeVal.value
}
await updateUserInfo(data)
await userStore.getInfo()
emit('onSuccess')
}
onMounted(getSubject)
</script>
<style lang="scss" scoped>
.dialog-title {
justify-content: space-between;
font-size: 16px;
font-weight: 600;
color: #000;
.icon-close {
cursor: pointer;
}
}
.dialog-content {
padding: 30px 20px 10px 30px;
}
.dialog-footer{
text-align: center;
padding-bottom: 10px;
}
</style>

View File

@ -33,6 +33,8 @@
</el-form>
</div>
</div>
<!--选择学科-->
<SelectSubject v-model="isSubject" v-if="isSubject" class="select-subject" @onSuccess="successEditSubject" />
</template>
<script setup>
import { onMounted, reactive, ref } from 'vue'
@ -42,6 +44,7 @@ import Cookies from 'js-cookie'
import { encrypt, decrypt } from '@/utils/jsencrypt'
import useUserStore from '@/store/modules/user'
import leftBg2 from '@/assets/images/login/left-bg2.png'
import SelectSubject from '@/components/select-subject/index.vue'
const { ipcRenderer } = window.electron || {}
const formRef = ref()
@ -49,6 +52,7 @@ const userStore = useUserStore()
const router = useRouter()
const isMaxSize = ref(false)
const btnLoading = ref(false)
const isSubject = ref(false)
//
const loginForm = reactive({
username: '',
@ -83,8 +87,14 @@ const submitForm = async (formEl) => {
try{
await userStore.login(loginForm)
await userStore.getInfo()
if(userStore.user.edustage || userStore.user.edusubject){
ElMessage.success('登录成功')
router.push('/resource')
}
else{
isSubject.value = true
}
}finally{
btnLoading.value = false
@ -93,6 +103,12 @@ const submitForm = async (formEl) => {
})
}
const successEditSubject = ()=>{
isSubject.value = false
ElMessage.success('登录成功')
router.push('/resource')
}
const getCookie = () => {
const username = Cookies.get('username')
const password = Cookies.get('password')
@ -207,4 +223,7 @@ const closeWindow = () => {
.el-form-item {
margin-bottom: 40px;
}
.select-subject{
-webkit-app-region: drag;
}
</style>

View File

@ -69,14 +69,22 @@ import useResoureStore from '../store'
const { ipcRenderer } = window.electron || {}
const sourceStore = useResoureStore()
const handleSizeChange = () => { }
const handleCurrentChange = () => { }
// change
const handleSizeChange = (limit) => {
sourceStore.query.pageSize = limit
sourceStore.handleQuery()
}
const handleCurrentChange = (page) => {
sourceStore.query.pageNum = page
sourceStore.handleQuery()
}
//
const downloadFile = (item) => {
ipcRenderer.send('save-as', item.fileFullPath, item.fileShowName)
}
//
const editRow = (item) => {
console.log(item.fileShowName.substring(0, item.fileShowName.lastIndexOf('.')))
ElMessageBox.prompt('请输入新的名称', '重命名', {
@ -134,14 +142,6 @@ const addLesson = ({ id }) => {
finally {
sourceStore.loading = false
}
// ElMessageBox.confirm('', '', {
// confirmButtonText: '',
// cancelButtonText: '',
// type: 'warning'
// }).then(() => {
// ElMessage.success('')
// }).catch(() => { })
}

View File

@ -27,11 +27,10 @@ import ResoureList from './container/resoure-list.vue'
import uploadDialog from '@/components/upload-dialog/index.vue'
import uploaderState from '@/store/modules/uploader'
const sourceStore = useResoureStore()
const isDialogOpen = ref(false)
const openDialog = () => {
isDialogOpen.value = true
}
@ -46,7 +45,7 @@ const changeBook = (data) => {
}
//
const nodeClick = (data) => {
// getData(data)
getData(data)
}
//