Merge remote-tracking branch 'remotes/origin/test_thirdLogin' into test

This commit is contained in:
joylink_cuiweidong 2021-06-10 10:15:52 +08:00
commit 3a2670a367
11 changed files with 467 additions and 5 deletions

View File

@ -145,6 +145,34 @@ export function generateOfflineUser(data) {
data: data
});
}
// 创建第三方用户
export function createThirdCount(data) {
return request({
url: `/api/user`,
method: 'post',
data: data
});
}
// 第三方用户登陆通过url登陆
export function thirdCountLogin(data) {
return request({
url: `/api/login/third`,
method: 'post',
data: data
});
}
/** 查询在线的用户列表*/
export function getLoginUserList(params) {
return request({
url: `/api/loginUser/paging`,
method: 'get',
params: params
});
}
// 导入学生成绩
export function importStudentResults(projectCode, data) {
return request({

View File

@ -63,6 +63,7 @@ export default {
dataDictionary: 'Data dictionary',
dataDictionaryDetails: 'Data dictionary details',
userManage: 'user management',
loginUserManage:'login user Manage',
cacheManage: 'cache management',
userTrainingManage: 'User training management',
userExamManage: 'User examination management',

View File

@ -62,6 +62,7 @@ export default {
dataDictionary: '数据字典',
dataDictionaryDetails: '数据字典明细',
userManage: '用户管理',
loginUserManage:'在线用户管理',
cacheManage: '缓存管理',
userTrainingManage: '用户实训统计',
userExamManage: '用户考试统计',

View File

@ -69,7 +69,7 @@
</el-submenu>
</template>
</template>
<div class="rightGroup">
<div v-if="!thirdLogin" class="rightGroup">
<quick-entry ref="quickEntry" />
<user-logout ref="userLogout" />
</div>
@ -81,6 +81,7 @@ import { mapGetters } from 'vuex';
import UserLogout from './Logout';
import QuickEntry from './Entry';
import SystemTitle from './Title';
import {getSessionStorage } from '@/utils/auth';
export default {
components: {
@ -93,7 +94,8 @@ export default {
routes: [],
isShow: false,
activePath: '',
index: ''
index: '',
thirdLogin:''
};
},
computed: {
@ -101,6 +103,7 @@ export default {
'avatar',
'routers'
])
},
watch: {
$route(val) {
@ -112,6 +115,7 @@ export default {
}
},
mounted() {
this.thirdLogin = getSessionStorage('thirdLogin');
this.routes = this.$router.options.routes;
if (this.$route.fullPath.indexOf('design/usermap') >= 0) {
this.activePath = '/design/usermap/home';

View File

@ -7,7 +7,7 @@ import 'nprogress/nprogress.css';
import { setToken, getToken, removeToken, getSessionStorage } from '@/utils/auth';
import localStore from 'storejs';
const whiteList = ['/login', '/design/login', '/gzzbxy/relay', '/authorization', '/AUSline', '/AUStool', '/demo']; // 不重定向白名单
const whiteList = ['/login', '/design/login', '/gzzbxy/relay', '/authorization', '/AUSline', '/AUStool', '/demo', '/thirdLogin']; // 不重定向白名单
const loginList = ['/login', '/design/login']; // 登陆页面

View File

@ -59,6 +59,8 @@ const CommandDictionaryDetail = () => import('@/views/system/commandDictionary/e
const configLine = () => import('@/views/system/configLine/index');
const Notification = () => import('@/views/system/notification/index');
const LoginUserControl = () => import('@/views/system/userLoginControl/index');
const IscsSystem = () => import('@/views/iscs/iscsSystem/index');
const IscsDraw = () => import('@/views/iscs/iscsDraw/index');
const IscsDesign = () => import('@/views/iscs/iscsDesign/index');
@ -182,6 +184,8 @@ const UeditorDraftList = () => import('@/views/editor/listDraft');
const UploadPdfList = () => import('@/views/uploadPdf/list');
const ThirdLogin = () => import('@/views/thirdLogin');
// import { GenerateRouteProjectList } from '@/scripts/ProjectConfig';
// import { getSessionStorage } from '@/utils/auth';
@ -231,6 +235,11 @@ export const constantRoutes = [
component: Demo,
hidden: true
},
{
path: '/thirdLogin',
component: ThirdLogin,
hidden: true
},
{
path: '/demoTraining/:mode',
component: DemoTraining,
@ -1006,6 +1015,14 @@ export const asyncRouter = [
i18n: 'router.userManage'
}
},
{
// 用户管理
path: 'loginUserManage',
component: LoginUserControl,
meta: {
i18n: 'router.loginUserManage'
}
},
{
// 单位管理
path: 'companyManage',

View File

@ -211,6 +211,9 @@ const user = {
},
setBaseUrl ({commit}, baseUrl) {
commit('setBaseUrl', baseUrl);
},
setToken({commit}, token) {
commit('SET_TOKEN', token);
}
}
};

View File

@ -0,0 +1,104 @@
<template>
<el-dialog v-dialogDrag title="创建第三方账户" :visible.sync="dialogVisible" width="500px" :before-close="doClose" center :close-on-click-modal="false">
<el-form ref="form" :model="addModel" label-width="130px" :rules="rules">
<el-form-item label="账号" prop="account">
<el-input v-model="addModel.account" size="mini" style="width:220px" />
</el-form-item>
<el-form-item label="昵称" prop="nickname">
<el-input v-model="addModel.nickname" size="mini" style="width:220px" />
</el-form-item>
<el-form-item label="手机号">
<el-input v-model="addModel.mobile" size="mini" style="width:140px" />
<el-select v-model="addModel.nationcode" size="mini" style="width:80px">
<el-option
v-for="item in countryList"
:key="item.value"
:label="item.name"
:value="item.value"
/>
</el-select>
</el-form-item>
<el-form-item label="邮箱" prop="email">
<el-input v-model="addModel.email" size="mini" style="width:220px" />
</el-form-item>
<el-form-item label="密码" prop="password">
<el-input v-model="addModel.password" size="mini" style="width:220px" type="password" autocomplete="new-password" />
</el-form-item>
<el-form-item label="真实姓名" prop="name">
<el-input v-model="addModel.name" size="mini" style="width:220px" />
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button type="primary" @click="handleCommit">{{ $t('global.confirm') }}</el-button>
<el-button @click="doClose">{{ $t('global.cancel') }}</el-button>
</span>
</el-dialog>
</template>
<script>
import { createThirdCount } from '@/api/management/user';
export default {
name:'CreateSingleUser',
data() {
return {
dialogVisible:false,
addModel:{
account:'', //
mobile:'', //
nationcode:'86', //
email:'', //
password:'', //
name:'', //
nickname:'' //
},
countryList:[
{ name: this.$t('global.china'), value: '86' },
{ name: this.$t('global.australia'), value: '61' },
{ name: this.$t('global.england'), value: '44' },
{ name: this.$t('global.hongKong'), value: '852' },
{ name: this.$t('global.Japanese'), value: '81' },
{ name: this.$t('global.macao'), value: '853' },
{ name: this.$t('global.singapore'), value: '65' },
{ name: this.$t('global.taiwan'), value: '886' },
{ name: this.$t('global.america'), value: '1' }
],
rules:{
account: [
{ required: true, message: '请输入账号', trigger: 'blur' }
],
nickname: [
{ required: true, message: '请输入昵称', trigger: 'blur' }
]
}
};
},
methods:{
doShow() {
this.dialogVisible = true;
},
doClose() {
this.dialogVisible = false;
this.$refs.form.resetFields();
},
handleCommit() {
const self = this;
this.$refs.form.validate((valid) => {
if (valid) {
const model = Object.assign({}, this.addModel);
createThirdCount(model).then(resp=> {
self.$message.success('创建第三方账户成功!');
self.$emit('reloadTable');
self.doClose();
}).catch((error) => {
if (error.code == 10012) {
this.$message.error('此账户数据已存在!');
} else {
this.$message.error('创建第三方账户失败!');
}
});
}
});
}
}
};
</script>

View File

@ -1,8 +1,9 @@
<template>
<div>
<QueryListPage ref="queryListPage" :pager-config="pagerConfig" :query-form="queryForm" :query-list="queryList" />
<QueryListPage ref="queryListPage1" :pager-config="pagerConfig" :query-form="queryForm" :query-list="queryList" />
<dictionary-edit ref="edit" :company-list="companyList" @reloadTable="reloadTable" />
<create-user ref="createUser" />
<create-single-user ref="createSingleUser" @reloadTable="reloadTable" />
<bind-company ref="bindCompany" :company-list="companyList" @create="create" />
</div>
</template>
@ -12,6 +13,7 @@ import { getUserList } from '@/api/management/user';
import { getCompanyList } from '@/api/company';
import DictionaryEdit from './edit';
import CreateUser from './createUser';
import CreateSingleUser from './createSingleUser';
import BindCompany from './bindCompany';
export default {
@ -19,6 +21,7 @@ export default {
components: {
DictionaryEdit,
CreateUser,
CreateSingleUser,
BindCompany
},
data() {
@ -29,6 +32,11 @@ export default {
},
companyMap: {},
companyList: [],
countTypeList:[
{label:'个人账户', value:'1'},
{label:'企业账户', value:'2'},
{label:'企业账户下子账户', value:'3'}
],
queryForm: {
labelWidth: '80px',
reset: true,
@ -66,6 +74,13 @@ export default {
config: {
data: []
}
},
type:{
type: 'select',
label: '类型',
config: {
data: []
}
}
}
@ -88,6 +103,13 @@ export default {
title: this.$t('system.nickname'),
prop: 'nickname'
},
{
title: '类型',
prop: 'type',
type: 'tag',
columnValue: (row) => { return this.getCountType(row.type); },
tagType: (row) => { return 'success'; }
},
{
title: this.$t('global.mobile'),
prop: 'mobile'
@ -128,7 +150,8 @@ export default {
],
actions: [
{ text: '创建本地用户', btnCode: 'employee_auto', handler: this.createLocalUsers },
{ text: '组织管理', btnCode: 'company_manage', handler: this.companyManage }
{ text: '组织管理', btnCode: 'company_manage', handler: this.companyManage },
{ text: '创建第三方账户', btnCode: 'create_user', handler: this.createSingleUser }
]
},
currentModel: {}
@ -144,6 +167,7 @@ export default {
this.companyList.push({label: item.name, value: parseInt(item.id)});
});
this.queryForm.queryObject.companyId.config.data = this.companyList;
this.queryForm.queryObject.type.config.data = this.countTypeList;
}
}).catch((error) => {
console.error(error);
@ -157,12 +181,19 @@ export default {
getCompanyName(companyId) {
return this.companyMap[companyId];
},
getCountType(type) {
const countType = this.countTypeList.find(each=>{ return each.value == type; });
return countType ? countType.label : '';
},
reloadTable() {
this.queryList.reload();
},
createLocalUsers() {
this.$refs.createUser.doShow();
},
createSingleUser() {
this.$refs.createSingleUser.doShow();
},
companyManage() {
this.$router.push({ path: `/system/companyManage`});
},

View File

@ -0,0 +1,194 @@
<template>
<div>
<QueryListPage ref="queryListPage" :pager-config="pagerConfig" :query-form="queryForm" :query-list="queryList" />
</div>
</template>
<script>
import { getLoginUserList } from '@/api/management/user';
import { getCompanyList } from '@/api/company';
export default {
name: 'UserLoginControl',
data() {
return {
systemMap:{
'DEFAULT_Joylink':'城市轨道交通实训平台',
'DEFAULT_Design':'城市轨道交通设计平台',
'BJD_Joylink':'城市轨道交通列车运行智慧辅助系统(北交大)',
'WJLS_Joylink':'微机联锁仿真系统(大铁)',
'XTY_Joylink':'西铁院实训平台',
'XTY_Design':'西铁院设计平台',
'GZB_Joylink':'贵装备实训平台',
'GZB_Design':'贵装备设计平台',
'CGY_Joylink':'成都工业实训平台',
'CGY_Design':'成都工业设计平台',
'XADT_Joylink':'西安地铁实训平台',
'XADT_Design':'西安地铁设计平台',
'SDY_Joylink':'苏电院实训平台',
'SDY_Design':'苏电院设计平台',
'ZZWW_Joylink':'共赢列车仿真驾驶系统(郑州)',
'NTY_Joylink':'南铁院实训平台(云平台通用版)',
'NTY_Design':'南铁院设计平台(云平台通用版)',
'NTYC_Joylink':'南铁院实训平台(云平台专用版)',
'NTYC_Design':'南铁院设计平台(云平台专用版)',
'DRTS_Joylink':'调度大赛实训平台',
'DRTS_Design':'调度大赛设计平台'
},
pagerConfig: {
pageSize: 'pageSize',
pageIndex: 'pageNum'
},
companyMap: {},
companyList: [],
countTypeList:[
{label:'个人账户', value:'1'},
{label:'企业账户', value:'2'},
{label:'企业账户下子账户', value:'3'}
],
queryForm: {
labelWidth: '80px',
reset: true,
queryObject: {
name: {
type: 'text',
label: this.$t('system.name')
},
id: {
type: 'text',
label: 'id'
},
roles: {
type: 'select',
label: this.$t('system.roles'),
config: {
data: this.$ConstSelect.roleList
}
},
nickname: {
type: 'text',
label: '昵称'
},
mobile: {
type: 'text',
label: '手机号'
},
email: {
type: 'text',
label: '邮箱'
},
companyId: {
type: 'select',
label: '组织',
config: {
data: []
}
},
type:{
type: 'select',
label: '类型',
config: {
data: []
}
}
}
},
queryList: {
query: getLoginUserList,
selectCheckShow: false,
indexShow: true,
columns: [
{
title: 'id',
prop: 'accountVO.id',
width: 80,
type: 'basicText',
columnValue: (row) => { return row.accountVO.id; }
},
{
title: this.$t('system.name'),
prop: 'accountVO.name',
type: 'basicText',
columnValue: (row) => { return row.accountVO.name; }
},
{
title: this.$t('system.nickname'),
prop: 'accountVO.nickname',
type: 'basicText',
columnValue: (row) => { return row.accountVO.nickname; }
},
{
title: '类型',
prop: 'accountVO.type',
type: 'tag',
columnValue: (row) => { return this.getCountType(row.accountVO.type); },
tagType: (row) => { return 'success'; }
},
{
title: this.$t('global.mobile'),
prop: 'accountVO.mobile',
type: 'basicText',
width: 160,
columnValue: (row) => { return row.accountVO.mobile; }
},
{
title: this.$t('global.email'),
prop: 'accountVO.email',
type: 'basicText',
columnValue: (row) => { return row.accountVO.email; }
},
{
title: '组织',
prop: 'accountVO.companyId',
type: 'tag',
columnValue: (row) => { return this.getCompanyName(row.accountVO.companyId); },
tagType: (row) => { return 'success'; }
},
{
title: this.$t('system.roles'),
prop: 'accountVO.roles',
type: 'tagMore',
columnValue: (row) => { return this.$convertField(row.accountVO.roles, this.$ConstSelect.roleList, ['value', 'label'], true); },
tagType: (row) => { return 'success'; }
},
{
title: '登陆系统',
prop: 'project',
type: 'basicText',
width: 260,
columnValue: (row) => { return this.systemMap[row.project + '_' + row.client] || ''; }
// tagType: (row) => { return 'success'; }
}
],
actions: []
}
};
},
created() {
this.companyMap = {};
this.companyList = [];
getCompanyList().then(resp => {
if (resp && resp.data && resp.data.length) {
resp.data.forEach(item => {
this.companyMap[item.id] = item.name;
this.companyList.push({label: item.name, value: parseInt(item.id)});
});
this.queryForm.queryObject.companyId.config.data = this.companyList;
this.queryForm.queryObject.type.config.data = this.countTypeList;
}
}).catch((error) => {
console.error(error);
});
},
methods:{
getCompanyName(companyId) {
return this.companyMap[companyId];
},
getCountType(type) {
const countType = this.countTypeList.find(each=>{ return each.value == type; });
return countType ? countType.label : '';
},
reloadTable() {
this.queryList.reload();
}
}
};
</script>

View File

@ -0,0 +1,79 @@
<template>
<div class="thirdLoginContainer">
<div class="thirdLoginMessage">
{{ message }}
</div>
</div>
</template>
<script>
import { LoginParams } from '@/utils/login';
import { thirdCountLogin } from '@/api/management/user';
import md5 from 'js-md5';
import { setToken, getToken, setSessionStorage } from '@/utils/auth';
export default {
name:'ThirdLogin',
data() {
return {
message:''
};
},
computed: {
project() {
const project = this.$route.query.project;
return project || 'login';
}
},
mounted() {
setSessionStorage('project', this.project);
const userId = this.$route.query.userId;
const paccount = this.$route.query.paccount;
const secret = this.$route.query.secret;
// const project = this.$route.query.project || '';
const deviceCode = this.$route.query.deviceCode || '';
const computeSecret = md5(paccount + '::' + userId);
if (userId && paccount && secret == computeSecret) {
const model = Object.assign({
parentAccount:paccount,
account:userId,
deviceCode:deviceCode
}, LoginParams.LianKeTang);
this.message = '正在登陆中......';
const tokenKey = getToken();
if (tokenKey) {
const header = { group: '', 'X-Token': tokenKey };
this.$store.dispatch('setToken', tokenKey);
this.$store.dispatch('subscribe', {header, type:'class'});
this.$router.replace({path:'/trainingPlatform'});
} else {
thirdCountLogin(model).then(resp=> {
const token = resp.data;
const header = { group: '', 'X-Token': token };
setToken(token);
this.$store.dispatch('setToken', token);
this.$store.dispatch('subscribe', {header, type:'class'});
this.$router.replace({path:'/trainingPlatform'});
setSessionStorage('thirdLogin', true);
}).catch(() => {
this.message = '参数有误,请检查';
});
}
} else {
this.message = '参数有误,请检查';
}
},
methods:{
}
};
</script>
<style lang="scss" scoped>
.thirdLoginContainer{
}
.thirdLoginMessage{
padding: 20px;
font-size: 20px;
}
</style>