提交 f5e59b9a authored 作者: Yroc's avatar Yroc

'学生登录'

上级 fbe83b92
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* @Author: AnthonyD * @Author: AnthonyD
* @Date: 2023-02-22 11:31:31 * @Date: 2023-02-22 11:31:31
* @Last Modified by: AnthonyD * @Last Modified by: AnthonyD
* @Last Modified time: 2023-03-13 10:11:24 * @Last Modified time: 2023-03-17 18:38:05
*/ */
import request from '@/utils/request' import request from '@/utils/request'
...@@ -24,9 +24,9 @@ export function login(data) { ...@@ -24,9 +24,9 @@ export function login(data) {
} }
//获取邮件 //获取邮件
export function getCode(data){ export function getCode(data) {
return request({ return request({
url: 'student/mail/code', url: '/student/mail/code',
method: 'post', method: 'post',
data data
}) })
...@@ -58,7 +58,7 @@ export function getResults(params) { ...@@ -58,7 +58,7 @@ export function getResults(params) {
} }
//开始考试详情 //开始考试详情
export function getResultsData(id,params) { export function getResultsData(id, params) {
return request({ return request({
url: `/student/test_results/${id}`, url: `/student/test_results/${id}`,
method: 'get', method: 'get',
...@@ -67,15 +67,16 @@ export function getResultsData(id,params) { ...@@ -67,15 +67,16 @@ export function getResultsData(id,params) {
} }
//学员拍照上传考试结果 //学员拍照上传考试结果
export function getPhotoResults(id) { export function getPhotoResults(id, data) {
return request({ return request({
url: `/student/test_results/imageUpload/${id}`, url: `/student/test_results/imageUpload/${id}`,
method: 'post', method: 'post',
data
}) })
} }
//提交答题结果 //提交答题结果
export function uploadTestResults(id,data) { export function uploadTestResults(id, data) {
return request({ return request({
url: `/student/test_results/${id}`, url: `/student/test_results/${id}`,
method: 'put', method: 'put',
...@@ -91,6 +92,35 @@ export function viewExamResults(id) { ...@@ -91,6 +92,35 @@ export function viewExamResults(id) {
}) })
} }
//注册
export function userLogon(data) {
return request({
url: '/student/auth/sign_up',
method: 'post',
data
})
}
//账号密码登录
export function accountLogin(data) {
return request({
url: '/student/auth/login',
method: 'post',
data
})
}
//获取省市信息
export function getCityIntfo(data) {
return request({
url: '/api/treeprovince',
method: 'post',
data
})
}
export function logout() { export function logout() {
return request({ return request({
url: '/vue-element-admin/user/logout', url: '/vue-element-admin/user/logout',
......
...@@ -55,9 +55,5 @@ export default { ...@@ -55,9 +55,5 @@ export default {
height: 100%; height: 100%;
} }
} }
.btn {
// background-color: $defaultColor;
}
} }
</style> </style>
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* @Author: AnthonyD * @Author: AnthonyD
* @Date: 2023-02-22 11:31:31 * @Date: 2023-02-22 11:31:31
* @Last Modified by: AnthonyD * @Last Modified by: AnthonyD
* @Last Modified time: 2023-03-07 16:07:17 * @Last Modified time: 2023-03-20 15:52:07
*/ */
import Vue from 'vue' import Vue from 'vue'
...@@ -28,9 +28,10 @@ import * as filters from './filters' // global filters ...@@ -28,9 +28,10 @@ import * as filters from './filters' // global filters
//引入加密函数,并将其封装 //引入加密函数,并将其封装
import {handleParams,Aesdecrypt} from '@/utils/cryptoJS'; import { handleParams, Aesdecrypt, removeProperty } from '@/utils/cryptoJS';
Vue.prototype.$handleParams = handleParams;//封装机密格式的参数 Vue.prototype.$handleParams = handleParams;//封装机密格式的参数
Vue.prototype.$Aesdecrypt = Aesdecrypt;//封装机密格式的参数 Vue.prototype.$Aesdecrypt = Aesdecrypt;//封装机密格式的参数
Vue.prototype.$removeProperty = removeProperty;//去除空值
/** /**
* If you don't want to use mock-server * If you don't want to use mock-server
...@@ -45,6 +46,7 @@ if (process.env.NODE_ENV === 'production') { ...@@ -45,6 +46,7 @@ if (process.env.NODE_ENV === 'production') {
mockXHR() mockXHR()
} }
Vue.use(Element, { Vue.use(Element, {
size: Cookies.get('size') || 'medium', // set element-ui default size size: Cookies.get('size') || 'medium', // set element-ui default size
locale: enLang // 如果使用中文,无需设置,请删除 locale: enLang // 如果使用中文,无需设置,请删除
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* @Author: AnthonyD * @Author: AnthonyD
* @Date: 2023-02-22 11:31:31 * @Date: 2023-02-22 11:31:31
* @Last Modified by: AnthonyD * @Last Modified by: AnthonyD
* @Last Modified time: 2023-03-01 14:40:23 * @Last Modified time: 2023-03-17 16:45:37
*/ */
import router from './router' import router from './router'
import store from './store' import store from './store'
...@@ -14,9 +14,9 @@ import getPageTitle from '@/utils/get-page-title' ...@@ -14,9 +14,9 @@ import getPageTitle from '@/utils/get-page-title'
NProgress.configure({ showSpinner: false }) // NProgress Configuration NProgress.configure({ showSpinner: false }) // NProgress Configuration
const whiteList = ['/login', '/auth-redirect'] // no redirect whitelist const whiteList = ['/login', '/auth-redirect', '/login_info'] // no redirect whitelist
router.beforeEach(async(to, from, next) => { router.beforeEach(async (to, from, next) => {
// start progress bar // start progress bar
NProgress.start() NProgress.start()
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* @Author: AnthonyD * @Author: AnthonyD
* @Date: 2023-02-22 11:31:31 * @Date: 2023-02-22 11:31:31
* @Last Modified by: AnthonyD * @Last Modified by: AnthonyD
* @Last Modified time: 2023-03-14 18:19:16 * @Last Modified time: 2023-03-17 16:45:18
*/ */
import Vue from 'vue' import Vue from 'vue'
import Router from 'vue-router' import Router from 'vue-router'
...@@ -61,6 +61,11 @@ export const constantRoutes = [ ...@@ -61,6 +61,11 @@ export const constantRoutes = [
component: () => import('@/views/login/index'), component: () => import('@/views/login/index'),
hidden: true hidden: true
}, },
{
path: '/login_info',
component: () => import('@/views/login-info/index.vue'),
},
{ {
path: '/auth-redirect', path: '/auth-redirect',
component: () => import('@/views/login/auth-redirect'), component: () => import('@/views/login/auth-redirect'),
...@@ -77,6 +82,7 @@ export const constantRoutes = [ ...@@ -77,6 +82,7 @@ export const constantRoutes = [
hidden: true hidden: true
}, },
// { // {
// path: '/documentation', // path: '/documentation',
// component: Layout, // component: Layout,
...@@ -127,32 +133,33 @@ export const asyncRoutes = [ ...@@ -127,32 +133,33 @@ export const asyncRoutes = [
path: '/', path: '/',
component: Layout, component: Layout,
redirect: '/personal', redirect: '/personal',
children:[ children: [
{ {
path:'personal', path: 'personal',
name:'personal', name: 'personal',
component: () => import('@/views/personal/index.vue'), component: () => import('@/views/personal/index.vue'),
}, },
{ {
path:'affirm', path: 'affirm',
name:'affirm', name: 'affirm',
component: () => import('@/views/affirm/index.vue'), component: () => import('@/views/affirm/index.vue'),
}, },
{ {
path:'test-result', path: 'test-result',
name:'test-result', name: 'test-result',
component: () => import('@/views/test-result/index.vue'), component: () => import('@/views/test-result/index.vue'),
}, },
{ {
path:'upload-result', path: 'upload-result',
name:'upload-result', name: 'upload-result',
component: () => import('@/views/upload-result/index.vue'), component: () => import('@/views/upload-result/index.vue'),
}, },
{ {
path:'analysis', path: 'analysis',
name:'analysis', name: 'analysis',
component: () => import('@/views/analysis/index.vue'), component: () => import('@/views/analysis/index.vue'),
}, },
] ]
}, },
......
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
* @Author: AnthonyD * @Author: AnthonyD
* @Date: 2023-02-22 11:31:31 * @Date: 2023-02-22 11:31:31
* @Last Modified by: AnthonyD * @Last Modified by: AnthonyD
* @Last Modified time: 2023-03-07 15:00:39 * @Last Modified time: 2023-03-20 15:37:37
*/ */
import { login, logout, getInfo } from '@/api/user' import { login, logout, getInfo, accountLogin } from '@/api/user'
import { getToken, setToken, removeToken } from '@/utils/auth' import { getToken, setToken, removeToken } from '@/utils/auth'
import router, { resetRouter } from '@/router' import router, { resetRouter } from '@/router'
...@@ -16,12 +16,12 @@ const state = { ...@@ -16,12 +16,12 @@ const state = {
roles: [], roles: [],
hasUser: false, hasUser: false,
//创建一个对象 //创建一个对象
user:{}, user: {},
} }
const mutations = { const mutations = {
//存vuex里 //存vuex里
SET_USER:(state,user)=>{ SET_USER: (state, user) => {
state.user = user state.user = user
}, },
SET_TOKEN: (state, token) => { SET_TOKEN: (state, token) => {
...@@ -66,6 +66,24 @@ const actions = { ...@@ -66,6 +66,24 @@ const actions = {
}) })
}, },
// user login
AccountLogin({ commit }, userInfo) {
const { username, password } = userInfo
return new Promise((resolve, reject) => {
accountLogin(userInfo).then(response => {
// const { data } = response
//存储在vuex中
commit('SET_TOKEN', response.access_token)
//存储在Cookies中
setToken(response.access_token)
//返回继续执行then
resolve(response)
}).catch(error => {
reject(error)
})
})
},
// get user info // get user info
getInfo({ commit, state }) { getInfo({ commit, state }) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* @Author: AnthonyD * @Author: AnthonyD
* @Date: 2023-02-22 11:31:31 * @Date: 2023-02-22 11:31:31
* @Last Modified by: AnthonyD * @Last Modified by: AnthonyD
* @Last Modified time: 2023-03-14 11:12:01 * @Last Modified time: 2023-03-17 14:58:10
*/ */
/** /**
* Created by PanJiaChen on 16/11/18. * Created by PanJiaChen on 16/11/18.
...@@ -71,6 +71,7 @@ export function validEmail(email) { ...@@ -71,6 +71,7 @@ export function validEmail(email) {
return reg.test(email) return reg.test(email)
} }
/** /**
* @param {string} str * @param {string} str
* @returns {Boolean} * @returns {Boolean}
......
差异被折叠。
<script>
/**
* @Author: AnthonyD
* @Date: 2023-03-17 13:37:43
* @Last Modified by: AnthonyD
* @Last Modified time: 2023-03-20 17:27:35
*/
</script><template>
<div>
<el-form
:model="loginForm"
:rules="loginRules"
ref="ruleForm"
class="demo-ruleForm"
>
<el-form-item prop="name">
<div>
<p style="font-weight: bold; line-height: 25px" class="pointer">
账号
</p>
<div>
<el-input
ref="account_input"
v-model="loginForm.name"
placeholder="手机号/邮箱/身份证号"
type="text"
tabindex="1"
>
</el-input>
</div>
</div>
</el-form-item>
<el-form-item prop="password">
<div>
<p style="font-weight: bold; line-height: 25px" class="pointer">
密码
</p>
<div>
<el-input
ref="password"
:key="passwordType"
:type="passwordType"
placeholder="输入密码"
v-model="loginForm.password"
name="password"
@keyup.native="checkCapslock"
@blur="capsTooltip = false"
@keyup.enter.native="handleLogin"
tabindex="2"
>
</el-input>
</div>
</div>
</el-form-item>
</el-form>
</div>
</template>
<script>
export default {
name: '',
data() {
const validateAccount = (rule, value, callback) => {
if (!value || /[\u4E00-\u9FA5]/g.test(value) || '') {
console.log(value);
callback(new Error('请重新账号输入'));
} else {
callback();
}
};
const validatePassword = (rule, value, callback) => {
if (!value || !(value.length >= 8)) {
callback(new Error('密码错误,请重新输入'));
} else {
callback();
}
};
return {
loginForm: {
name: null,
password: null,
},
passwordType: 'password',
loginRules: {
name: [{ required: true, trigger: 'blur', validator: validateAccount }],
password: [
{ required: true, trigger: 'blur', validator: validatePassword },
],
},
};
},
mounted() {
// if (!this.loginForm.name) {
// this.$refs.account_input.focus();
// } else if (!this.loginForm.password) {
// this.$refs.password.focus();
// }
},
methods: {
checkCapslock(e) {
const { key } = e;
this.capsTooltip = key && key.length === 1 && key >= 'A' && key <= 'Z';
},
//
handleLogin() {
this.$emit('Login', null);
},
},
};
</script>
<style lang="" scoped>
</style>
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* @Author: AnthonyD * @Author: AnthonyD
* @Date: 2023-02-22 11:31:31 * @Date: 2023-02-22 11:31:31
* @Last Modified by: AnthonyD * @Last Modified by: AnthonyD
* @Last Modified time: 2023-03-15 11:00:55 * @Last Modified time: 2023-03-20 18:33:10
*/ */
</script> </script>
<template> <template>
...@@ -20,14 +20,94 @@ ...@@ -20,14 +20,94 @@
<div> <div>
<h3 class="title">国家烟草识别培训系统</h3> <h3 class="title">国家烟草识别培训系统</h3>
</div> </div>
<el-form <!-- 账号登陆 -->
<el-tabs v-model="activeName">
<el-tab-pane label="账号登陆" name="account">
<account-login
ref="user_login"
@Login="handleLogin"
></account-login>
</el-tab-pane>
<!-- 邮箱登陆 -->
<el-tab-pane label="邮箱登陆" name="email"
><el-form
:model="loginForm" :model="loginForm"
:rules="loginRules" :rules="loginRules"
ref="ruleForm" ref="ruleForm"
class="demo-ruleForm" class="demo-ruleForm"
> >
<el-form-item prop="email"> <el-form-item prop="email">
<!-- 手机号 --> <div>
<p
style="font-weight: bold; line-height: 25px"
class="pointer"
>
邮箱
</p>
<div>
<el-input
ref="username"
v-model="loginForm.email"
placeholder="输入邮箱"
name="username"
type="text"
tabindex="1"
>
</el-input>
</div>
</div>
</el-form-item>
<el-form-item prop="verification_code">
<div>
<p
style="font-weight: bold; line-height: 25px"
class="pointer"
>
验证码
</p>
<div>
<el-row>
<el-col :span="15" style="padding-right: 25px">
<el-input
ref="password"
v-model="loginForm.verification_code"
placeholder="输入验证码"
:maxlength="4"
name="password"
autocomplete="off"
@keyup.native="checkCapslock"
@blur="capsTooltip = false"
@keyup.enter.native="handleLogin"
tabindex="2"
>
</el-input>
</el-col>
<el-col :span="9">
<el-button
@click="sendMessage"
type="warning"
style="background-color: #e6a23c; float: right"
:disabled="time > 0"
>
{{ timer ? '重新发送' + time + 's' : '获取验证码' }}
<i class="el-icon-loading" v-if="is_loading"></i>
</el-button>
</el-col>
</el-row>
</div>
</div>
</el-form-item>
</el-form>
</el-tab-pane>
</el-tabs>
<!-- <el-form
:model="loginForm"
:rules="loginRules"
ref="ruleForm"
class="demo-ruleForm"
v-if="false"
>
<el-form-item prop="email">
<div> <div>
<p style="font-weight: bold" class="pointer">邮箱</p> <p style="font-weight: bold" class="pointer">邮箱</p>
<div> <div>
...@@ -64,9 +144,6 @@ ...@@ -64,9 +144,6 @@
</el-input> </el-input>
</el-col> </el-col>
<el-col :span="8"> <el-col :span="8">
<!-- <button class="send_message" @click="sendMessage">
发送短信
</button> -->
<el-button <el-button
@click="sendMessage" @click="sendMessage"
type="warning" type="warning"
...@@ -81,10 +158,12 @@ ...@@ -81,10 +158,12 @@
</div> </div>
</div> </div>
</el-form-item> </el-form-item>
</el-form> </el-form> -->
<div class="login_enter_box_">
<a @click="goLogin()">没有账号?点击注册</a>
</div>
<!-- 登录按钮 --> <!-- 登录按钮 -->
<div style="margin-top: 25px"> <div style="margin-top: 9px">
<el-button <el-button
:loading="loading" :loading="loading"
type="primary" type="primary"
...@@ -101,10 +180,11 @@ ...@@ -101,10 +180,11 @@
<script> <script>
import { validUsername, validEmail } from '@/utils/validate'; import { validUsername, validEmail } from '@/utils/validate';
import SocialSign from './components/SocialSignin'; import SocialSign from './components/SocialSignin';
import { getCode } from '@/api/user.js'; import { getCode, accountLogin } from '@/api/user.js';
import AccountLogin from './components/account';
export default { export default {
name: 'Login', name: 'Login',
components: { SocialSign }, components: { SocialSign, AccountLogin },
data() { data() {
const validateUsername = (rule, value, callback) => { const validateUsername = (rule, value, callback) => {
console.log(value); console.log(value);
...@@ -116,14 +196,13 @@ export default { ...@@ -116,14 +196,13 @@ export default {
}; };
const validatePassword = (rule, value, callback) => { const validatePassword = (rule, value, callback) => {
console.log(value); console.log(value);
if (!(value.length == 4)) { if (!value || !(value.length == 4)) {
callback(new Error('验证码错误,请重新输入')); callback(new Error('验证码错误,请重新输入'));
} else { } else {
callback(); callback();
} }
}; };
return { return {
is_loading: false,
loginForm: { loginForm: {
email: null, email: null,
phone: null, phone: null,
...@@ -140,7 +219,6 @@ export default { ...@@ -140,7 +219,6 @@ export default {
{ required: true, trigger: 'blur', validator: validatePassword }, { required: true, trigger: 'blur', validator: validatePassword },
], ],
}, },
passwordType: 'password',
capsTooltip: false, capsTooltip: false,
loading: false, loading: false,
showDialog: false, showDialog: false,
...@@ -148,6 +226,8 @@ export default { ...@@ -148,6 +226,8 @@ export default {
otherQuery: {}, otherQuery: {},
timer: null, timer: null,
time: null, time: null,
is_loading: false,
activeName: 'account',
}; };
}, },
watch: { watch: {
...@@ -165,13 +245,7 @@ export default { ...@@ -165,13 +245,7 @@ export default {
created() { created() {
// window.addEventListener('storage', this.afterQRScan) // window.addEventListener('storage', this.afterQRScan)
}, },
mounted() { mounted() {},
if (this.loginForm.username === '') {
this.$refs.username.focus();
} else if (this.loginForm.password === '') {
this.$refs.password.focus();
}
},
destroyed() { destroyed() {
// window.removeEventListener('storage', this.afterQRScan) // window.removeEventListener('storage', this.afterQRScan)
}, },
...@@ -215,8 +289,15 @@ export default { ...@@ -215,8 +289,15 @@ export default {
// .catch(() => { // .catch(() => {
// this.loading = false; // this.loading = false;
// }); // });
console.log('11111111'); if (this.activeName == 'account') {
this.$store
.dispatch('user/AccountLogin', this.$refs.user_login.loginForm)
.then((response) => {
console.log('登录返回值' + response);
this.loading = false;
this.$router.push('/');
});
} else if (this.activeName == 'email') {
let data = { let data = {
verification_key: this.loginForm.eamil_key, verification_key: this.loginForm.eamil_key,
verification_code: this.loginForm.verification_code, verification_code: this.loginForm.verification_code,
...@@ -229,34 +310,14 @@ export default { ...@@ -229,34 +310,14 @@ export default {
// path: this.redirect || '/', // path: this.redirect || '/',
// query: this.otherQuery, // query: this.otherQuery,
// }); // });
console.log(response); console.log('登录返回值' + response);
this.loading = false; this.loading = false;
this.$router.push('/'); this.$router.push('/');
}) })
.catch(() => { .catch(() => {
this.loading = false; this.loading = false;
}); });
}
// this.$refs.loginForm.validate((valid) => {
// if (valid) {
// this.loading = true;
// this.$store
// .dispatch('user/login', this.loginForm)
// .then(() => {
// this.$router.push({
// path: this.redirect || '/',
// query: this.otherQuery,
// });
// this.loading = false;
// })
// .catch(() => {
// this.loading = false;
// });
// } else {
// console.log('error submit!!');
// return false;
// }
// });
}, },
getOtherQuery(query) { getOtherQuery(query) {
return Object.keys(query).reduce((acc, cur) => { return Object.keys(query).reduce((acc, cur) => {
...@@ -286,7 +347,6 @@ export default { ...@@ -286,7 +347,6 @@ export default {
// } // }
sendMessage() { sendMessage() {
this.is_loading = true; this.is_loading = true;
// this.$refs.retrieveForm.validateField('email', (errMsg) => {});
getCode({ email: this.loginForm.email }) getCode({ email: this.loginForm.email })
.then((res) => { .then((res) => {
this.loginForm.eamil_key = res.key || null; this.loginForm.eamil_key = res.key || null;
...@@ -301,6 +361,11 @@ export default { ...@@ -301,6 +361,11 @@ export default {
console.log('效验通过'); console.log('效验通过');
} }
}); });
// this.$refs.ruleForm.validateField('email', (errMsg) => {
// });
},
goLogin() {
this.$router.push('/login_info');
}, },
}, },
}; };
...@@ -330,16 +395,6 @@ $light_gray: #eee; ...@@ -330,16 +395,6 @@ $light_gray: #eee;
box-sizing: border-box; box-sizing: border-box;
padding: 62px 69px; padding: 62px 69px;
.login-form {
background-color: #fff;
width: 400px;
height: 384px;
padding: 40px;
margin-top: 7px;
border-radius: 10px;
float: right;
}
.title-container { .title-container {
position: relative; position: relative;
...@@ -384,6 +439,27 @@ $light_gray: #eee; ...@@ -384,6 +439,27 @@ $light_gray: #eee;
box-shadow: 4px 4px 15px #c2c4c9; box-shadow: 4px 4px 15px #c2c4c9;
border-radius: 15px; border-radius: 15px;
position: relative; position: relative;
.login-form {
background-color: #fff;
width: 400px;
height: 430px;
padding: 40px;
border-radius: 10px;
position: absolute;
right: 10%;
top: 18%;
.login_enter_box_ {
text-align: right;
position: absolute;
bottom: 22%;
right: 10%;
a {
font-size: 12px;
text-decoration: underline;
font-weight: bold;
}
}
}
} }
.sign_container { .sign_container {
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* @Author: AnthonyD * @Author: AnthonyD
* @Date: 2023-03-01 16:25:21 * @Date: 2023-03-01 16:25:21
* @Last Modified by: AnthonyD * @Last Modified by: AnthonyD
* @Last Modified time: 2023-03-14 16:18:01 * @Last Modified time: 2023-03-17 11:25:26
*/ */
</script> </script>
...@@ -111,6 +111,8 @@ ...@@ -111,6 +111,8 @@
<h3 class="photo_header_title">上传纸质考试照片</h3> <h3 class="photo_header_title">上传纸质考试照片</h3>
</el-col> </el-col>
<el-col :span="12" style="text-align: right"> <el-col :span="12" style="text-align: right">
<!-- :on-success="handleAvatarSuccess" -->
<!-- :http-request="uploadSubmit" -->
<el-upload <el-upload
name="image" name="image"
v-if="test_results && test_results.test_results_image" v-if="test_results && test_results.test_results_image"
...@@ -118,6 +120,7 @@ ...@@ -118,6 +120,7 @@
:action=" :action="
IP + '/student/test_results/imageUpload/' + result_id IP + '/student/test_results/imageUpload/' + result_id
" "
:on-progress="uploadSubmit"
:on-success="handleAvatarSuccess" :on-success="handleAvatarSuccess"
:headers="headers" :headers="headers"
:show-file-list="false" :show-file-list="false"
...@@ -138,7 +141,7 @@ ...@@ -138,7 +141,7 @@
</el-upload> --> </el-upload> -->
</el-col> </el-col>
</el-row> </el-row>
<div class="grid-content_upload"> <div class="grid-content_upload" v-loading="is_loading">
<div class="upload_btn"> <div class="upload_btn">
<div <div
class="img_box" class="img_box"
...@@ -153,6 +156,7 @@ ...@@ -153,6 +156,7 @@
:action=" :action="
IP + '/student/test_results/imageUpload/' + result_id IP + '/student/test_results/imageUpload/' + result_id
" "
:on-progress="uploadSubmit"
:on-success="handleAvatarSuccess" :on-success="handleAvatarSuccess"
:headers="headers" :headers="headers"
drag drag
...@@ -198,6 +202,7 @@ export default { ...@@ -198,6 +202,7 @@ export default {
imgrul: null, imgrul: null,
test_card_info: {}, test_card_info: {},
is_force: false, is_force: false,
is_loading: false,
}; };
}, },
created() { created() {
...@@ -293,8 +298,19 @@ export default { ...@@ -293,8 +298,19 @@ export default {
// }); // });
// }, // },
handleAvatarSuccess(res, file) { handleAvatarSuccess(res, file) {
// this.imageUrl = URL.createObjectURL(file.raw); if (res.code == 200 && res.message) {
this.getTestData(); this.is_loading = false;
this.test_results.test_results_image = res.status;
for (let i in this.test_result_sub_data) {
if (res.message[this.test_result_sub_data[i].id]) {
this.test_result_sub_data[i].value =
res.message[this.test_result_sub_data[i].id];
}
}
}
},
uploadSubmit(event, file, fileList) {
this.is_loading = true;
}, },
}, },
}; };
...@@ -397,18 +413,18 @@ export default { ...@@ -397,18 +413,18 @@ export default {
.grid-content_upload { .grid-content_upload {
text-align: center; text-align: center;
background: #fafafa; background: #fafafa;
height: 648px; height: 779px;
border: 2px solid #dcdfe6; border: 2px solid #dcdfe6;
border-radius: 5px; border-radius: 5px;
position: relative; position: relative;
.img_box { .img_box {
width: 100%; width: 100%;
height: 640px; // height: 100%;
// position: absolute; // position: absolute;
text-align: center; text-align: center;
img { img {
width: 100%; width: 100%;
height: 100%; height: 775px;
} }
} }
} }
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论