Merge pull request 'zdg' (#184) from zdg into main

Reviewed-on: #184
This commit is contained in:
zhangxuelin 2024-09-10 16:16:44 +08:00
commit ee9e5d1326
7 changed files with 558 additions and 3 deletions

View File

@ -36,6 +36,7 @@
"electron-log": "^5.1.7", "electron-log": "^5.1.7",
"electron-store": "8.0.0", "electron-store": "8.0.0",
"electron-updater": "^6.1.7", "electron-updater": "^6.1.7",
"element-china-area-data": "^6.1.0",
"element-plus": "^2.7.6", "element-plus": "^2.7.6",
"fabric": "^5.3.0", "fabric": "^5.3.0",
"im_electron_sdk": "^8.0.5904", "im_electron_sdk": "^8.0.5904",

View File

@ -56,4 +56,68 @@ export function getCodeImg() {
method: 'get', method: 'get',
timeout: 20000 timeout: 20000
}) })
}
// 注册模块-生成人机验证
export function captchaImg(data) {
return request({
url: '/captchaImg',
headers: {
isToken: false
},
method: 'get',
params: data
})
}
//注册模块-发送验证码
export function sendCode(data) {
return request({
url: '/smarttalk/register/authSendCode',
method: 'post',
data:data
})
}
//注册模块-申请注册
export function signIn(data) {
return request({
url: '/smarttalk/register/authSignIn',
method: 'post',
data:data
})
}
//注册模块-获取学校
export function deptTree(data) {
return request({
url: '/smarttalk/register/authDeptTree',
method: 'get',
params:data
})
}
// 查询部门详细
export function getDept(query) {
return request({
url: '/system/dept/detail',
method: 'get',
params: query
})
}
// 查询classmain列表
export function listClassmain(query) {
return request({
url: '/education/classmain/list',
method: 'get',
params: query
})
}
// 查询evaluation列表
export function listEvaluation(query) {
return request({
url: '/smarttalk/register/authEvaluationList',
method: 'get',
params: query
})
} }

View File

@ -104,6 +104,9 @@ const switchPageMode = () => {
} }
} }
onMounted(async () => { onMounted(async () => {
window.addEventListener('focus', () => {
console.log(11111111111111)
})
const isDev = process.env.NODE_ENV == 'development' const isDev = process.env.NODE_ENV == 'development'
// toolState.showBoardAll = false // // toolState.showBoardAll = false //
toolState.isPdfWin=true //pdf toolState.isPdfWin=true //pdf

View File

@ -0,0 +1,462 @@
<template>
<el-dialog
v-model="dialogVisible"
title="注册账号"
:fullscreen="true"
center
:before-close="handleClose"
>
<el-steps style="max-width: 100%;-webkit-app-region: no-drag;height:35px" :active="activeIndex" finish-status="success" simple>
<el-step title="1.基本信息" @click="activeIndex=1" />
<el-step title="2.在校信息" />
</el-steps>
<el-form
style="width: 80%;margin: 0 auto;margin-top: 10px;-webkit-app-region: no-drag;"
:model="ruleForm"
:rules="rules"
label-width="auto"
status-icon
ref="ruleFormRef"
>
<el-form-item label="姓名" prop="name" v-if="activeIndex==1">
<el-input v-model="ruleForm.name" />
</el-form-item>
<el-form-item label="身份证号" prop="idNumber" v-if="activeIndex==1">
<el-input v-model="ruleForm.idNumber" />
</el-form-item>
<el-form-item label="手机号" prop="phoneNumber" v-if="activeIndex==1">
<el-input v-model="ruleForm.phoneNumber" />
</el-form-item>
<el-form-item label="验证码" prop="Code" v-if="activeIndex==1">
<el-input style="width:60%" v-model="ruleForm.Code" :disabled="true" />
<el-button type="primary" style="margin-left:10px" @click="sendcaptchaImg">发送验证码</el-button>
</el-form-item>
<el-form-item label="设置密码" prop="password" v-if="activeIndex==1">
<el-input v-model="ruleForm.password" type="password" />
</el-form-item>
<el-form-item label="确认密码" prop="confirmPassword" v-if="activeIndex==1">
<el-input v-model="ruleForm.confirmPassword" type="password" />
</el-form-item>
<el-form-item label="所属地区" prop="address" v-if="activeIndex==2">
<el-cascader
style="width:100%"
v-model="ruleForm.address"
:options="regionData"
@change="handleChange"
/>
</el-form-item>
<el-form-item label="学校" prop="school" v-if="activeIndex==2">
<el-cascader :options="optionsSchool" style="width:100%" v-model="ruleForm.school" @change="handleSchoolChange" />
</el-form-item>
<el-form-item label="班级" prop="class" v-if="activeIndex==2">
<el-tree-select
v-model="ruleForm.class"
:data="gradeTree"
multiple
:render-after-expand="false"
style="width: 100%"
/>
</el-form-item>
<el-form-item label="学科" prop="discipline" v-if="activeIndex==2">
<div v-for="item in schoolSubject" style="display: flex;">
<span style="width:50px">{{ item.name }}</span>
<el-checkbox-group style="width:100%" v-model="ruleForm.discipline" >
<el-checkbox style="margin-right:10px" v-for="el in item.children" :key="el.id" :label="el.itemtitle" :value="el" />
</el-checkbox-group>
</div>
</el-form-item>
<el-form-item v-if="activeIndex==1">
<div class="centerDiv">
<el-button type="primary" @click="nextStep(ruleFormRef)">下一步</el-button>
</div>
</el-form-item>
<el-form-item v-if="activeIndex==2">
<div class="centerDiv">
<el-button type="primary" @click="submitForm(ruleFormRef)">立即注册</el-button>
</div>
</el-form-item>
</el-form>
<!-- <template #footer>
<div class="dialog-footer" >
<el-button @click="dialogVisible = false">下一步</el-button>
</div>
</template> -->
<el-dialog
v-model="isImg"
title="人机验证"
width="500"
>
<span>根据图片回答相关问题</span>
<div style="display: flex;align-items: center;;margin-top:30px">
<img :src="isPeopleImg" style="width:200px;height:60px;cursor: pointer;" alt="" srcset="" @click="refreshImg">
<el-input v-model="ruleForm.imgCode" style="width: 250px;height:40px;margin-left:20px" placeholder="请根据图片填入答案" />
</div>
<div style="display: flex;justify-content: center;margin-top:30px">
<el-button type="primary" @click="sbmitImg">确定</el-button>
</div>
<!-- <template #footer>
<div class="dialog-footer">
<el-button @click="dialogVisible = false">Cancel</el-button>
<el-button type="primary" @click="dialogVisible = false">
Confirm
</el-button>
</div>
</template> -->
</el-dialog>
</el-dialog>
</template>
<script setup>
import { ref, defineExpose, reactive ,onMounted} from 'vue'
import {captchaImg,sendCode,deptTree,getDept,listClassmain,listEvaluation,signIn} from '@/api/login'
import { ElMessage } from 'element-plus'
import {setToken, removeToken } from '@/utils/auth'
import { regionData, codeToText } from 'element-china-area-data'
const ruleFormRef = ref(null)
const activeIndex=ref(1)
const ruleForm = reactive({
name: '',
idNumber:'',
phoneNumber: '',
Code:'',
password:'',
confirmPassword:'',
class:[],
discipline:[],
school:[],
})
const isImg=ref(false)
const btnName=ref('发送验证码')
const resImg = reactive({ imgData: {} });
const optionsSchool=ref([])
const gradeTree=ref([])
const schoolSubject=ref([])
const allSubjectList = ref([])
const gradeDataList = [
[
{ label: '一年级', agekey: 1, checked: false, current: 1 },
{ label: '二年级', agekey: 2, checked: false, current: 1 },
{ label: '三年级', agekey: 3, checked: false, current: 1 },
{ label: '四年级', agekey: 4, checked: false, current: 1 },
{ label: '五年级', agekey: 5, checked: false, current: 1 },
{ label: '六年级', agekey: 6, checked: false, current: 1 },
],
[
{ label: '初一', agekey: 7, checked: false, current: 2 },
{ label: '初二', agekey: 8, checked: false, current: 2 },
{ label: '初三', agekey: 9, checked: false, current: 2 },
],
[
{ label: '高一', agekey: 10, checked: false, current: 3 },
{ label: '高二', agekey: 11, checked: false, current: 3 },
{ label: '高三', agekey: 12, checked: false, current: 3 },
],
]
//
const isPeopleImg=ref(null)
const rules = reactive({
name: [
{ required: true, message: '请输入姓名', trigger: 'blur' },
],
Code: [
{ required: true, message: '请输入验证码', trigger: 'blur' },
],
phoneNumber: [
{ required: true, message: '手机号码是必填项', trigger: 'blur' },
{ pattern: /^1[3-9]\d{9}$/, message: '手机号码格式不正确', trigger: 'blur' },
],
idNumber: [
{ required: true, message: '身份证号码是必填项', trigger: 'blur' },
{
validator: (rule, value, callback) => {
if (!value) {
callback();
return;
}
// 1518
const pattern = /^(?:\d{15}|\d{17}[\dX])$/;
const valid = pattern.test(value);
if (!valid) {
callback(new Error('身份证号码格式不正确'));
} else {
callback();
}
},
trigger: 'blur'
}
],
password: [
{ required: true, message: '请输入密码', trigger: 'blur' },
{ min: 6, message: '密码长度必须大于6位数', trigger: 'blur' },
],
confirmPassword: [
{ required: true, message: '请再次输入密码', trigger: 'blur' },
{ min: 6, message: '密码长度必须大于6位数', trigger: 'blur' },
{ validator: (rule, value, callback) => {
if (value !== ruleForm.password) {
callback(new Error('两次输入的密码不一致!'));
} else {
callback();
}
}, trigger: 'change' }
],
address:[ {
required: true,
message: '请选择地址',
trigger: 'change',
},],
school:[{
required: true,
message: '请选择地址',
trigger: 'change',
},],
class:[ {
type:'array',
required: true,
message: '请选择班级',
trigger: 'change',
},],
discipline:[ {
type: 'array',
required: true,
message: '请选择学科',
trigger: 'change',
},]
})
const dialogVisible = ref(false)
//
const OpenModel = () =>{
dialogVisible.value=true
}
//
const handleClose = () => {
if (ruleFormRef.value) ruleFormRef.value.resetFields()
removeToken();
activeIndex.value=1
dialogVisible.value=false
}
const nextStep = (formEl) => {
if (!formEl) return
formEl.validate((valid) => {
if (valid) {
activeIndex.value=2
//
deptTree({phone:ruleForm.phoneNumber}).then(res=>{
optionsSchool.value=res.data
optionsSchool.value.forEach(item=>{
item.value=item.id
if(!item.children){
item.disabled=true
}
if(item.children){
item.children.forEach(child=>{
child.value=child.id
if(!child.children){
child.disabled=true
}
if(child.children){
child.children.forEach(grandson=>{
grandson.value=grandson.id
})
}
})
}
})
getSubject()
console.log(res)
})
console.log('submit!')
} else {
console.log('error submit!')
}
})
}
//
const getSubject = async ()=>{
const rows= await listEvaluation({ itemkey: "subject", pageSize: 500 })
console.log(rows,'所有学科')
allSubjectList.value = rows.data
}
const submitForm = async (formEl) => {
if (!formEl) return
await formEl.validate((valid, fields) => {
if (valid) {
var araname = codeToText[ruleForm.address[0]] + '-' + codeToText[ruleForm.address[1]] + '-' + codeToText[ruleForm.address[2]];
var form={
mobile:ruleForm.phoneNumber,
code:ruleForm.Code,
name:ruleForm.name,
idCard:ruleForm.idNumber,
password:ruleForm.password,
confirmPassword:ruleForm.confirmPassword,
schoolId:ruleForm.school[2],
classIds:ruleForm.class.join(','),
subjectIds:ruleForm.discipline.map(o=>o.id).join(','),
subject:ruleForm.discipline.map(o=>o.itemtitle).join(','),
areaIds:ruleForm.address.join(','),
area:araname
}
signIn(form).then(res=>{
if(res.code==200){
ElMessage.success('您已注册成功,等待学校管理员审核')
if (ruleFormRef.value) ruleFormRef.value.resetFields()
var restValue={
name: '',
idNumber:'',
phoneNumber: '',
Code:'',
password:'',
confirmPassword:'',
class:[],
discipline:[],
school:[],
}
Object.assign(ruleForm, restValue);
activeIndex.value=1
dialogVisible.value=false
}else{
ElMessage.error(res.msg)
}
})
console.log('submit!')
} else {
console.log('error submit!', fields)
}
})
}
//
const sendcaptchaImg=()=>{
if(ruleForm.phoneNumber){
const pattern = /^1[3-9]\d{9}$/;
if( pattern.test(ruleForm.phoneNumber) ){
captchaImg({mobile:ruleForm.phoneNumber}).then(res=>{
ruleForm.imgCode=null
isImg.value=true
isPeopleImg.value='data:image/jpg;base64,'+res.img
if(res.token){
setToken(res.token)
}
resImg.imgData=res
})
}else{
ElMessage.error('请输入正确的手机号码')
}
// captchaImg({mobile:ruleForm.phoneNumber}).then(res=>{
// console.log('res->', res)
// })
}else{
ElMessage.error('请输入手机号码')
}
}
//
const refreshImg=()=>{
captchaImg({mobile:ruleForm.phoneNumber}).then(res=>{
isPeopleImg.value='data:image/jpg;base64,'+res.img
if(res.token){
setToken(res.token)
}
resImg.imgData=res
})
}
//
const sbmitImg=()=>{
if(ruleForm.imgCode){
sendCode({mobile:ruleForm.phoneNumber,code:ruleForm.imgCode,uuid:resImg.imgData.uuid}).then(res=>{
if(res.code==200){
ruleForm.Code=res.data
isImg.value=false
}
})
}else{
ElMessage.error('请根据图片输入验证码')
}
//
}
const handleChange = (value) => {
console.log('选中的地址值:', value);
};
const handleSchoolChange= async ()=>{
ruleForm.discipline=[];
ruleForm.class=[];
getDept({deptId:ruleForm.school[2]}).then(res =>{
if(res.data.studying && res.data.studying.length){
let studying = res.data.studying.split(',')
let ary = []
studying.forEach(item =>{
let obj = {
name: item,
children: []
}
allSubjectList.value.forEach(el =>{
if(item == el.edustage){
obj.children.push(el)
}
})
ary.push(obj)
})
schoolSubject.value = ary
}
else{
schoolSubject.value = []
}
})
listClassmain( {entpid: ruleForm.school[2], pageSize: 500, status: 'open'}).then(res=>{
gradeTree.value = groupByCondition(res.rows, item => item.agekey);
console.log(gradeTree.value,'班级')
})
}
//
const groupByCondition = (arr, condition)=>{
//
const groups = arr.reduce((groups, item) => {
const groupKey = condition(item);
item.label = item.caption
item.value = item.id
groups[groupKey] = groups[groupKey] || [];
groups[groupKey].push(item);
return groups;
}, {});
//
const formattedGroups = Object.keys(groups).map(key => ({
label: gradeName(key),
value: key,
children: groups[key]
}));
return formattedGroups;
}
//key
const gradeName = (key) =>{
//
const flatGradeDataList = gradeDataList.flat();
const currentIndex = flatGradeDataList.findIndex(item => item.agekey === Number(key));
if(currentIndex !== -1){
return flatGradeDataList[currentIndex].label;
}else{
//
const defaultLabel = '社团';
flatGradeDataList[currentIndex] = { ...flatGradeDataList[currentIndex], label: defaultLabel };
return defaultLabel;
}
}
onMounted(()=>{
})
defineExpose({
OpenModel,
})
</script>
<style scoped lang="scss">
.centerDiv{
-webkit-app-region: no-drag;
padding-bottom: 20px;
width: 100%;
display: flex;
justify-content: center;
}
</style>

View File

@ -21,12 +21,21 @@
placeholder="请输入密码" placeholder="请输入密码"
/> />
</el-form-item> </el-form-item>
<el-checkbox v-model="loginForm.rememberMe" class="flex mb-5">记住密码</el-checkbox> <div class="flex mb-5">
<el-checkbox v-model="loginForm.rememberMe" >记住密码</el-checkbox>
<!-- <el-checkbox >阅读并同意xxx</el-checkbox> -->
</div>
<el-form-item> <el-form-item>
<el-button :loading="btnLoading" class="btn" type="primary" @click="submitForm(formRef)" <el-button :loading="btnLoading" class="btn" type="primary" @click="submitForm(formRef)"
>登录</el-button >登录</el-button
> >
</el-form-item> </el-form-item>
<div class="flex mb-4" style="display: flex;justify-content: center;color: #ccc;cursor: pointer;">
<a style="margin-right: 10px;" @click="RegisterModel">注册账号</a>
<!-- | -->
<!-- <a style="margin-left: 10px;">忘记密码</a> -->
</div>
</el-form> </el-form>
</div> </div>
</div> </div>
@ -48,6 +57,8 @@
</el-dialog> </el-dialog>
<!--选择学科--> <!--选择学科-->
<SelectSubject v-model="isSubject" :login-data="loginForm" /> <SelectSubject v-model="isSubject" :login-data="loginForm" />
<!--注册弹框-->
<Register ref="RegModel"></Register>
</template> </template>
<script setup> <script setup>
import { onMounted, reactive, ref } from 'vue' import { onMounted, reactive, ref } from 'vue'
@ -57,6 +68,7 @@ import useUserStore from '@/store/modules/user'
import leftBg2 from '@/assets/images/login/left-bg2.png' import leftBg2 from '@/assets/images/login/left-bg2.png'
import WindowTools from '@/components/window-tools/index.vue' import WindowTools from '@/components/window-tools/index.vue'
import SelectSubject from '@/components/select-subject/index.vue' import SelectSubject from '@/components/select-subject/index.vue'
import Register from './components/Register.vue'
const { session } = require('@electron/remote') const { session } = require('@electron/remote')
const downloadProp = ref(0) const downloadProp = ref(0)
@ -66,6 +78,7 @@ const formRef = ref()
const userStore = useUserStore() const userStore = useUserStore()
const btnLoading = ref(false) const btnLoading = ref(false)
const isSubject = ref(false) const isSubject = ref(false)
const RegModel = ref(false)
// //
const loginForm = reactive({ const loginForm = reactive({
username: '', username: '',
@ -84,7 +97,10 @@ ipcRenderer.on('update-app-progress', (e, prop) => {
downloadProp.value = prop downloadProp.value = prop
showDownLoading.value = prop !== 100 showDownLoading.value = prop !== 100
}) })
//
const RegisterModel = () =>{
RegModel.value.OpenModel()
}
// //
const submitForm = async (formEl) => { const submitForm = async (formEl) => {
if (!formEl) return if (!formEl) return
@ -162,7 +178,6 @@ onMounted(() => {
align-items: center; align-items: center;
justify-content: center; justify-content: center;
-webkit-app-region: drag; -webkit-app-region: drag;
.box-item { .box-item {
width: 444px; width: 444px;
height: 520px; height: 520px;

View File

@ -232,6 +232,16 @@ export default {
openFileWin(items) { openFileWin(items) {
if (items.fileFlag === 'apt') { if (items.fileFlag === 'apt') {
console.log(items); console.log(items);
const path="/teaching/aptindex?id="+items.fileId
let configObj = outLink().getBaseData()
let fullPath = configObj.fullPath + path
fullPath = fullPath.replaceAll('//', '/')
//
ipcRenderer.send('openWindow', {
key: path,
fullPath: fullPath,
cookieData: { ...configObj.data }
})
return return
} }
if (!items||!items.fileSuffix) return; if (!items||!items.fileSuffix) return;