cys #35
|
@ -29,7 +29,7 @@
|
||||||
"jsencrypt": "^3.3.2",
|
"jsencrypt": "^3.3.2",
|
||||||
"pinia": "^2.1.7",
|
"pinia": "^2.1.7",
|
||||||
"pinia-plugin-persistedstate": "^3.2.1",
|
"pinia-plugin-persistedstate": "^3.2.1",
|
||||||
"vue-cropper": "^1.1.3",
|
"vue-cropper": "^1.0.3",
|
||||||
"vue-router": "^4.4.0"
|
"vue-router": "^4.4.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
http-equiv="Content-Security-Policy"
|
http-equiv="Content-Security-Policy"
|
||||||
content="default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data:"
|
content="default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data:"
|
||||||
/> -->
|
/> -->
|
||||||
<meta http-equiv="Content-Security-Policy" content="connect-src *; default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data:" />
|
<meta http-equiv="Content-Security-Policy" content="connect-src *; default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data: blob:" />
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
|
|
|
@ -31,10 +31,10 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref, reactive } from 'vue'
|
import { ref, reactive, getCurrentInstance } from 'vue'
|
||||||
import { updateUserPwd } from '@/api/system/user'
|
import { updateUserPwd } from '@/api/system/user'
|
||||||
|
|
||||||
// const { proxy } = getCurrentInstance();
|
const { proxy } = getCurrentInstance()
|
||||||
|
|
||||||
const user = reactive({
|
const user = reactive({
|
||||||
oldPassword: undefined,
|
oldPassword: undefined,
|
||||||
|
|
|
@ -1,7 +1,14 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="user-info-head" @click="editCropper()">
|
<div class="user-info-head" @click="editCropper()">
|
||||||
<img :src="options.img" title="点击上传头像" class="img-circle" />
|
<img :src="options.img" title="点击上传头像" class="img-circle img-lg" />
|
||||||
<el-dialog :title="title" v-model="open" width="800px" append-to-body @opened="modalOpened" @close="closeDialog">
|
<el-dialog
|
||||||
|
:title="title"
|
||||||
|
v-model="open"
|
||||||
|
width="800px"
|
||||||
|
append-to-body
|
||||||
|
@opened="modalOpened"
|
||||||
|
@close="closeDialog"
|
||||||
|
>
|
||||||
<el-row>
|
<el-row>
|
||||||
<el-col :xs="24" :md="12" :style="{ height: '350px' }">
|
<el-col :xs="24" :md="12" :style="{ height: '350px' }">
|
||||||
<vue-cropper
|
<vue-cropper
|
||||||
|
@ -60,18 +67,18 @@
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { Upload, Plus, Minus, RefreshLeft, RefreshRight } from '@element-plus/icons-vue'
|
import { Upload, Plus, Minus, RefreshLeft, RefreshRight } from '@element-plus/icons-vue'
|
||||||
import { ref, reactive } from 'vue'
|
import { ref, reactive, getCurrentInstance } from 'vue'
|
||||||
import "vue-cropper/dist/index.css";
|
import 'vue-cropper/dist/index.css'
|
||||||
import { VueCropper } from "vue-cropper";
|
import { VueCropper } from 'vue-cropper'
|
||||||
import { uploadAvatar } from "@/api/system/user";
|
import { uploadAvatar } from '@/api/system/user'
|
||||||
import useUserStore from "@/store/modules/user";
|
import useUserStore from '@/store/modules/user'
|
||||||
|
|
||||||
const userStore = useUserStore();
|
const userStore = useUserStore()
|
||||||
// const { proxy } = getCurrentInstance();
|
const { proxy } = getCurrentInstance()
|
||||||
|
|
||||||
const open = ref(false);
|
const open = ref(false)
|
||||||
const visible = ref(false);
|
const visible = ref(false)
|
||||||
const title = ref("修改头像");
|
const title = ref('修改头像')
|
||||||
|
|
||||||
//图片裁剪数据
|
//图片裁剪数据
|
||||||
const options = reactive({
|
const options = reactive({
|
||||||
|
@ -80,67 +87,67 @@
|
||||||
autoCropWidth: 200, // 默认生成截图框宽度
|
autoCropWidth: 200, // 默认生成截图框宽度
|
||||||
autoCropHeight: 200, // 默认生成截图框高度
|
autoCropHeight: 200, // 默认生成截图框高度
|
||||||
fixedBox: true, // 固定截图框大小 不允许改变
|
fixedBox: true, // 固定截图框大小 不允许改变
|
||||||
outputType: "png", // 默认生成截图为PNG格式
|
outputType: 'png', // 默认生成截图为PNG格式
|
||||||
previews: {} //预览数据
|
previews: {} //预览数据
|
||||||
});
|
})
|
||||||
|
|
||||||
/** 编辑头像 */
|
/** 编辑头像 */
|
||||||
function editCropper() {
|
function editCropper() {
|
||||||
open.value = true;
|
open.value = true
|
||||||
}
|
}
|
||||||
/** 打开弹出层结束时的回调 */
|
/** 打开弹出层结束时的回调 */
|
||||||
function modalOpened() {
|
function modalOpened() {
|
||||||
visible.value = true;
|
visible.value = true
|
||||||
}
|
}
|
||||||
/** 覆盖默认上传行为 */
|
/** 覆盖默认上传行为 */
|
||||||
function requestUpload() {}
|
function requestUpload() {}
|
||||||
/** 向左旋转 */
|
/** 向左旋转 */
|
||||||
function rotateLeft() {
|
function rotateLeft() {
|
||||||
proxy.$refs.cropper.rotateLeft();
|
proxy.$refs.cropper.rotateLeft()
|
||||||
}
|
}
|
||||||
/** 向右旋转 */
|
/** 向右旋转 */
|
||||||
function rotateRight() {
|
function rotateRight() {
|
||||||
proxy.$refs.cropper.rotateRight();
|
proxy.$refs.cropper.rotateRight()
|
||||||
}
|
}
|
||||||
/** 图片缩放 */
|
/** 图片缩放 */
|
||||||
function changeScale(num) {
|
function changeScale(num) {
|
||||||
num = num || 1;
|
num = num || 1
|
||||||
proxy.$refs.cropper.changeScale(num);
|
proxy.$refs.cropper.changeScale(num)
|
||||||
}
|
}
|
||||||
/** 上传预处理 */
|
/** 上传预处理 */
|
||||||
function beforeUpload(file) {
|
function beforeUpload(file) {
|
||||||
if (file.type.indexOf("image/") == -1) {
|
if (file.type.indexOf('image/') == -1) {
|
||||||
proxy.$modal.msgError("文件格式错误,请上传图片类型,如:JPG,PNG后缀的文件。");
|
proxy.$modal.msgError('文件格式错误,请上传图片类型,如:JPG,PNG后缀的文件。')
|
||||||
} else {
|
} else {
|
||||||
const reader = new FileReader();
|
const reader = new FileReader()
|
||||||
reader.readAsDataURL(file);
|
reader.readAsDataURL(file)
|
||||||
reader.onload = () => {
|
reader.onload = () => {
|
||||||
options.img = reader.result;
|
options.img = reader.result
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/** 上传图片 */
|
/** 上传图片 */
|
||||||
function uploadImg() {
|
function uploadImg() {
|
||||||
proxy.$refs.cropper.getCropBlob(data => {
|
proxy.$refs.cropper.getCropBlob((data) => {
|
||||||
let formData = new FormData();
|
let formData = new FormData()
|
||||||
formData.append("avatarfile", data);
|
formData.append('avatarfile', data)
|
||||||
uploadAvatar(formData).then(response => {
|
uploadAvatar(formData).then((response) => {
|
||||||
open.value = false;
|
open.value = false
|
||||||
options.img = import.meta.env.VITE_APP_BASE_API + response.imgUrl;
|
options.img = import.meta.env.VITE_APP_BASE_API + response.imgUrl
|
||||||
userStore.avatar = options.img;
|
userStore.avatar = options.img
|
||||||
proxy.$modal.msgSuccess("修改成功");
|
proxy.$modal.msgSuccess('修改成功')
|
||||||
visible.value = false;
|
visible.value = false
|
||||||
});
|
})
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
/** 实时预览 */
|
/** 实时预览 */
|
||||||
function realTime(data) {
|
function realTime(data) {
|
||||||
options.previews = data;
|
options.previews = data
|
||||||
}
|
}
|
||||||
/** 关闭窗口 */
|
/** 关闭窗口 */
|
||||||
function closeDialog() {
|
function closeDialog() {
|
||||||
options.img = userStore.avatar;
|
options.img = userStore.avatar
|
||||||
options.visible = false;
|
options.visible = false
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
@ -152,7 +159,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
.user-info-head:hover:after {
|
.user-info-head:hover:after {
|
||||||
content: "+";
|
content: '+';
|
||||||
position: absolute;
|
position: absolute;
|
||||||
left: 0;
|
left: 0;
|
||||||
right: 0;
|
right: 0;
|
||||||
|
@ -170,6 +177,6 @@
|
||||||
}
|
}
|
||||||
.img-circle {
|
.img-circle {
|
||||||
height: 120px;
|
height: 120px;
|
||||||
width: auto
|
width: auto;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
|
@ -10,7 +10,7 @@
|
||||||
<el-input v-model="user.email" maxlength="50" />
|
<el-input v-model="user.email" maxlength="50" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="性别">
|
<el-form-item label="性别">
|
||||||
<el-radio-group >
|
<el-radio-group v-model="user.sex">
|
||||||
<el-radio label="0">男</el-radio>
|
<el-radio label="0">男</el-radio>
|
||||||
<el-radio label="1">女</el-radio>
|
<el-radio label="1">女</el-radio>
|
||||||
</el-radio-group>
|
</el-radio-group>
|
||||||
|
@ -18,72 +18,87 @@
|
||||||
<el-form-item label="任教学科">
|
<el-form-item label="任教学科">
|
||||||
<el-radio-group v-model="user.edusubject">
|
<el-radio-group v-model="user.edusubject">
|
||||||
<template v-for="item in subjectList">
|
<template v-for="item in subjectList">
|
||||||
<el-radio v-if="item.edustage==user.edustage" :label="item.itemtitle">{{ item.itemtitle }}</el-radio>
|
<el-radio v-if="item.edustage == user.edustage" :label="item.itemtitle">{{
|
||||||
|
item.itemtitle
|
||||||
|
}}</el-radio>
|
||||||
</template>
|
</template>
|
||||||
</el-radio-group>
|
</el-radio-group>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item>
|
<el-form-item>
|
||||||
<el-button type="primary" @click="submit">保存</el-button>
|
<el-button type="primary" @click="submit">保存</el-button>
|
||||||
<el-button type="primary" @click="handleclick1">测验</el-button>
|
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-form>
|
</el-form>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref } from 'vue'
|
import { ref, getCurrentInstance } from 'vue'
|
||||||
import { updateUserProfile } from "@/api/system/user";
|
import { updateUserProfile } from '@/api/system/user'
|
||||||
import { listEvaluation } from "@/api/subject/index";
|
import { listEvaluation } from '@/api/subject/index'
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
user: {
|
user: {
|
||||||
type: Object
|
type: Object
|
||||||
}
|
}
|
||||||
});
|
})
|
||||||
|
|
||||||
// const { proxy } = getCurrentInstance();
|
const { proxy } = getCurrentInstance()
|
||||||
|
|
||||||
const rules = ref({
|
const rules = ref({
|
||||||
nickName: [{ required: true, message: "用户昵称不能为空", trigger: "blur" }],
|
nickName: [{ required: true, message: '用户昵称不能为空', trigger: 'blur' }],
|
||||||
email: [{ required: true, message: "邮箱地址不能为空", trigger: "blur" }, { type: "email", message: "请输入正确的邮箱地址", trigger: ["blur", "change"] }],
|
email: [
|
||||||
phonenumber: [{ required: true, message: "手机号码不能为空", trigger: "blur" }, { pattern: /^1[3|4|5|6|7|8|9][0-9]\d{8}$/, message: "请输入正确的手机号码", trigger: "blur" }],
|
{ required: true, message: '邮箱地址不能为空', trigger: 'blur' },
|
||||||
});
|
{ type: 'email', message: '请输入正确的邮箱地址', trigger: ['blur', 'change'] }
|
||||||
|
],
|
||||||
|
phonenumber: [
|
||||||
|
{ required: true, message: '手机号码不能为空', trigger: 'blur' },
|
||||||
|
{ pattern: /^1[3|4|5|6|7|8|9][0-9]\d{8}$/, message: '请输入正确的手机号码', trigger: 'blur' }
|
||||||
|
]
|
||||||
|
})
|
||||||
|
|
||||||
const subjectList = ref([]);
|
const subjectList = ref([])
|
||||||
|
|
||||||
function handleclick1() {
|
|
||||||
console.log(props.user.edudegree)
|
|
||||||
}
|
|
||||||
|
|
||||||
// 获取基础的学科
|
// 获取基础的学科
|
||||||
listEvaluation({ itemkey: "subject", pageSize: 500 }).then((res) => {
|
listEvaluation({ itemkey: 'subject', pageSize: 500 }).then((res) => {
|
||||||
subjectList.value = res.rows;
|
subjectList.value = res.rows
|
||||||
});
|
})
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
|
|
||||||
if (props.user.edudegree != '') {
|
if (props.user.edudegree != '') {
|
||||||
var upcaseName = ['一年级', '二年级', '三年级', '四年级', '五年级', '六年级', '初一', '初二', '初三', '高一', '高二', '高三'];
|
var upcaseName = [
|
||||||
var d = parseInt(props.user.edudegree.replace('年级', ''));
|
'一年级',
|
||||||
|
'二年级',
|
||||||
|
'三年级',
|
||||||
|
'四年级',
|
||||||
|
'五年级',
|
||||||
|
'六年级',
|
||||||
|
'初一',
|
||||||
|
'初二',
|
||||||
|
'初三',
|
||||||
|
'高一',
|
||||||
|
'高二',
|
||||||
|
'高三'
|
||||||
|
]
|
||||||
|
var d = parseInt(props.user.edudegree.replace('年级', ''))
|
||||||
if (d <= 6) {
|
if (d <= 6) {
|
||||||
props.user.edustage = '小学';
|
props.user.edustage = '小学'
|
||||||
} else if (d >= 7 && d <= 9) {
|
} else if (d >= 7 && d <= 9) {
|
||||||
props.user.edustage = '初中';
|
props.user.edustage = '初中'
|
||||||
} else if (d >= 9 && d <= 12) {
|
} else if (d >= 9 && d <= 12) {
|
||||||
props.user.edustage = '高中';
|
props.user.edustage = '高中'
|
||||||
}
|
}
|
||||||
props.user.stagelabel = upcaseName[d-1];
|
props.user.stagelabel = upcaseName[d - 1]
|
||||||
}
|
}
|
||||||
}, 1000);
|
}, 1000)
|
||||||
|
|
||||||
/** 提交按钮 */
|
/** 提交按钮 */
|
||||||
function submit() {
|
function submit() {
|
||||||
proxy.$refs.userRef.validate(valid => {
|
proxy.$refs.userRef.validate((valid) => {
|
||||||
if (valid) {
|
if (valid) {
|
||||||
console.log(props.user);
|
console.log(props.user)
|
||||||
updateUserProfile(props.user).then(response => {
|
updateUserProfile(props.user).then((response) => {
|
||||||
proxy.$modal.msgSuccess("修改成功");
|
proxy.$modal.msgSuccess('修改成功')
|
||||||
});
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
});
|
|
||||||
};
|
|
||||||
</script>
|
</script>
|
Loading…
Reference in New Issue