Browse Source

升级前端登录框架

master
qqkj 5 years ago
parent
commit
1bbb3e412e
  1. 4
      src/api/itemOption.js
  2. 59
      src/api/login.js
  3. 93
      src/api/mdp/meta/itemOption.js
  4. 15
      src/api/sms/sms.js
  5. 3
      src/common/config.js
  6. 17
      src/permission.js
  7. 2
      src/store/getters.js
  8. 15
      src/store/modules/tagsView.js
  9. 226
      src/store/modules/user.js
  10. 10
      src/utils/request.js
  11. 2
      src/views/layout/Layout.vue
  12. 2
      src/views/layout/components/AppMain.vue
  13. 585
      src/views/layout/components/Navbar.vue
  14. 2
      src/views/layout/components/TagsView.vue
  15. 95
      src/views/login/index.vue

4
src/api/itemOption.js

@ -38,7 +38,7 @@ export const listOption = params => {
});
return new Promise((resolve,reject) => {
if(noExistsParams.length>0){
axios.post(`${base}/mdp/common/itemOption/list/byItemCode`, noExistsParams ).then(res=>{
axios.post(`${base}/mdp/meta/itemOption/list/byItemCode`, noExistsParams ).then(res=>{
var tips = res.data.tips;
if(tips.isOk){
var data=res.data.data;
@ -84,7 +84,7 @@ export const listOptionByItemIds = params => {
});
return new Promise((resolve,reject) => {
if(noExistsParams.length>0){
axios.post(`${base}/mdp/common/itemOption/listItemOptionByItemIds`, noExistsParams ).then(res=>{
axios.post(`${base}/mdp/meta/itemOption/listItemOptionByItemIds`, noExistsParams ).then(res=>{
var tips = res.data.tips;
if(tips.isOk){
var data=res.data.data;

59
src/api/login.js

@ -2,29 +2,32 @@ import axios from '@/utils/request'
import config from '@/common/config'
let base=config.getSysBasePath();
let base=config.getOauth2LoginBasePath();
export function loginByUsername(username, password) {
//let base='';
export function loginByUsername(username, password,deptid) {
const data = {
displayUserid: username,
password: password,
loginType:'password'
userloginid: username,
password: password,
authType:'password_display_userid',
deptid:deptid
}
return axios({
url: base+'/common/login',
url: base+'/login/token?grantType=password',
method: 'post',
data
})
}
export function loginByPhoneno(phoneno, smsCode,isAdmin) {
export function loginByPhoneno(phoneno, smsCode,isAdmin,deptid) {
const data = {
phoneno: phoneno,
smsCode: smsCode,
loginType:'sms',
isAdmin:true
userloginid: phoneno,
password: smsCode,
authType:'sms',
isAdmin:true,
deptid:deptid
}
return axios({
url: base+'/common/login',
url: base+'/login/token?grantType=password',
method: 'post',
data
})
@ -39,17 +42,33 @@ export function logout() {
}
export function getUserInfo(params) {
if( !params || !params.scopes ){
params={
scopes:['userInfo','roles','posts','menus','qxs','depts','branchs']
}
}
const data=params;
return axios({
url: base+'/sys/pub/login/user/info/all',
method: 'get',
params: params
url: base+'/user/info',
method: 'post',
data
})
}
export function createShortToken(params) {
return axios.post( base+'/sys/pub/login/createShortToken', params )
export function getUserDepts(userid) {
if( !userid ){
params={
userid:userid
}
}else{
return
}
const data= { params: params };
return axios({
url: base+'/user/depts',
method: 'get',
data
})
}
export function switchDept(params) {
return axios.post( base+'/sys/pub/login/user/switch', params )
return axios.post( base+'/login/switch', params )
}

93
src/api/mdp/meta/itemOption.js

@ -14,96 +14,7 @@ let base=config.getSysBasePath();
export const listItemOption = params => { return axios.get(`${base}/mdp/meta/itemOption/list`, { params: params }); };
//普通查询 条件之间and关系 params=[{categoryId:'0001',itemCode:'sex'}] 返回结果 {'sex':[{optionValue:'1',optionName:'男',seqOrder:'1',fp:'',isDefault:'0'},{optionValue:'2',optionName:'女',seqOrder:'2',fp:'',isDefault:'0'}]}
export const listOption = params => {
var date=new Date();
var dateStr=date.getFullYear()+"-"+date.getMonth()+"-"+date.getDay()
var result={
data:{
tips:{
isOk:true,
},
data:{
}
}
}
var noExistsParams=params.filter(i=>{
var key=i.categoryId+"-"+i.itemCode+"-"+dateStr;
var options = localStorage.getItem(key);
if(options){
result.data.data[i.itemCode]=JSON.parse(options)
return false
}return true;
});
return new Promise((resolve,reject) => {
if(noExistsParams.length>0){
axios.post(`${base}/mdp/common/itemOption/list/byItemCode`, noExistsParams ).then(res=>{
var tips = res.data.tips;
if(tips.isOk){
var data=res.data.data;
noExistsParams.forEach(k=>{
var key=k.categoryId+"-"+k.itemCode+"-"+dateStr;
localStorage.setItem(key, JSON.stringify(data[k.itemCode]));
result.data.data[k.itemCode]= data[k.itemCode]
})
}else{
result.data.tips=tips;
}
resolve(result);
}).catch(e=>reject(e));
}else{
resolve(result);
}
});
};
export const listOptionByItemIds = params => {
var date=new Date();
var dateStr=date.getFullYear()+"-"+date.getMonth()+"-"+date.getDay()
var result={
data:{
tips:{
isOk:true,
},
data:{
}
}
}
var noExistsParams=params.filter(i=>{
var key=i+"-"+dateStr;
var options = localStorage.getItem(key);
if(options){
var optionsJson=JSON.parse(options);
result.data.data[i]=optionsJson
return false
}return true;
});
return new Promise((resolve,reject) => {
if(noExistsParams.length>0){
axios.post(`${base}/mdp/common/itemOption/listItemOptionByItemIds`, noExistsParams ).then(res=>{
var tips = res.data.tips;
if(tips.isOk){
var data=res.data.data;
noExistsParams.forEach(k=>{
var key= k+"-"+dateStr;
localStorage.setItem(key, JSON.stringify(data[k]));
result.data.data[k]= data[k]
})
}else{
result.data.tips=tips;
}
resolve(result);
}).catch(e=>reject(e));
}else{
resolve(result);
}
});
};
export const listOption = params => { return axios.post(`${base}/mdp/meta/itemOption/list/byItemCode`, params ); };
//params={id:''} 返回 {optionValue:'1',optionName:'男',seqOrder:'1',fp:'',isDefault:'0'}
export const getSysParam = params => { return axios.post(`${base}/mdp/meta/itemOption/sysParam`, params ); };
@ -124,4 +35,4 @@ export const addItemOption = params => { return axios.post(`${base}/mdp/meta/ite
//刷新缓存
export const refresh = params => { return axios.post(`${base}/mdp/common/itemOption/refresh`, params); };
export const refresh = params => { return axios.post(`${base}/mdp/meta/itemOption/refresh`, params); };

15
src/api/sms/sms.js

@ -0,0 +1,15 @@
import axios from '@/utils/request'
import config from '@/common/config'
let base=config.getSmsBasePath();
/**
* 发送短信验证码验证短信验证码接口
**/
//发送短信验证码
export const sendSmsCode = params => { return axios.post(`${base}/sms/sendSmsCode`, params); };
//验证短信验证码
export const validateSmsCode = params => { return axios.post(`${base}/sms/validateSmsCode`, params); };

3
src/common/config.js

@ -8,6 +8,9 @@
var sysName = 'oa协同办公系统'// 系统名称,用于展示
export default {
getOauth2LoginBasePath:function(){
return "/oauth2client"
},
getBaseDomainUrl:function(){
return "https://www.qingqinkj.com"

17
src/permission.js

@ -46,7 +46,6 @@ router.beforeEach((to, from, next) => {
}
if(outUrl.indexOf("${curlDomain}")>=0){
var curlDomain=window.location.protocol+"//"+window.location.host; // 返回https://mp.csdn.net
//var curlDomain="https://www.qingqinkj.com"
outUrl=outUrl.replace("${curlDomain}",curlDomain);
}
var indexOfHttp=outUrl.indexOf("://");
@ -60,15 +59,15 @@ router.beforeEach((to, from, next) => {
return;
}
if(to!=null && to.fullPath!=null){
var userToken=getQueryVariable("userToken",to.fullPath);
if(userToken!=null){
setToken(userToken);
var accessToken=getQueryVariable("accessToken",to.fullPath);
if(accessToken!=null){
setToken(accessToken);
}
}
if (getToken()) { // determine if there has token
/* has token*/
if (to.path === '/login') {
next({ path: '/' })
next()//
NProgress.done() // if current page is dashboard will not trigger afterEach hook, so manually handle it
} else {
if(store.getters.isLoadOk==false ){
@ -144,10 +143,10 @@ function getQueryVariable(variable,url){
}
return null;
}
var userToken=getQueryVariable('userToken');
if(userToken!=null){
//alert(userToken);
setToken(userToken);
var accessToken=getQueryVariable('accessToken');
if(accessToken!=null){
//alert(access_token);
setToken(accessToken);
}
router.afterEach(() => {
NProgress.done() // finish progress bar

2
src/store/getters.js

@ -5,9 +5,9 @@ const getters = {
cachedViews: state => state.tagsView.cachedViews,
token: state => state.user.token,
userInfo: state => state.user.userInfo,
workShop:state=>state.user.workShop,
introduction: state => state.user.introduction,
status: state => state.user.status,
workShop:state=>state.user.workShop,
roles: state => state.user.roles,
myDepts: state => state.user.myDepts,
myShops: state => state.user.myShops,

15
src/store/modules/tagsView.js

@ -6,19 +6,12 @@ const tagsView = {
mutations: {
ADD_VISITED_VIEWS: (state, view) => {
if (state.visitedViews.some(v => v.path === view.path)) return
var page ={
state.visitedViews.push({
name: view.name,
path: view.path,
title: view.meta.title || 'no-name',
}
if(view.query){
page.query=view.query;
}
if(view.params){
page.params=view.params;
}
state.visitedViews.push(page)
title: view.meta.title || 'no-name',
query:view.query
})
if (!view.meta.noCache) {
state.cachedViews.push(view.name)
}

226
src/store/modules/user.js

@ -4,7 +4,7 @@ import { getToken, setToken, removeToken } from '@/utils/auth'
const user = {
state: {
userInfo: {
userid:'a',
userid:'',
jsessionid:'',
displayUserid:'',
username:'',
@ -21,10 +21,7 @@ const user = {
isPlatformAdmin:false,
isBranchAdmin:false,
isShopAdmin:false,
isLocationAdmin:false,
isProjectAdmin:false,
isProductAdmin:false,
isTestAdmin:false,
isLocationAdmin:false
},
workShop:{},
status: '',
@ -104,7 +101,7 @@ const user = {
LoginByUsername({ commit }, userInfo) {
const username = userInfo.username.trim()
return new Promise((resolve, reject) => {
loginByUsername(username, userInfo.password).then(res => {
loginByUsername(username, userInfo.password,userInfo.deptid).then(res => {
if(res.data.tips.isOk==true){
let data = res.data
let userInfo=data.userInfo;
@ -126,37 +123,13 @@ const user = {
if(role.roleid=='locationAdmin'){
userInfo.isLocationAdmin=true
}
if(role.roleid=='projectAdmin'){
userInfo.isProjectAdmin=true
}
if(role.roleid=='teamAdmin'){
userInfo.isTeamAdmin=true
}
if(role.roleid=='productAdmin'){
userInfo.isProductAdmin=true
}
if(role.roleid=='productTeamAdmin'){
userInfo.isProductTeamAdmin=true
}
if(role.roleid=='testAdmin'){
userInfo.isTestAdmin=true
}
if(role.roleid=='testTeamAdmin'){
userInfo.isTestTeamAdmin=true
}
if(role.roleid=='tester'){
userInfo.isTester=true
}
if(role.roleid=='iterationAdmin'){
userInfo.isIterationAdmin=true
}
});
}
commit('SET_USER_INFO', userInfo)
commit('SET_ROLES', roles)
commit('SET_QXS', data.qxs)
commit('SET_TOKEN', data.userToken)
setToken( data.userToken)
commit('SET_TOKEN', data.data.accessToken.tokenValue)
setToken( data.data.accessToken.tokenValue)
}
resolve(res)
}).catch(error => {
@ -167,59 +140,35 @@ const user = {
// 用户名登录
LoginByPhoneno({ commit }, userInfo) {
return new Promise((resolve, reject) => {
loginByPhoneno(userInfo.phoneno, userInfo.smsCode, userInfo.isAdmin).then(res => {
loginByPhoneno(userInfo.phoneno, userInfo.smsCode, userInfo.isAdmin,userInfo.deptid).then(res => {
if(res.data.tips.isOk==true){
let data = res.data
let userInfo=data.userInfo;
let roles=data.roles;
if(roles!=null && roles.length>0){
roles.forEach(role=>{
if(role.roleid=='superAdmin'){
userInfo.isSuperAdmin=true
}
if(role.roleid=='platformAdmin'){
userInfo.isPlatformAdmin=true
}
if(role.roleid=='branchAdmin'){
userInfo.isBranchAdmin=true
}
if(role.roleid=='shopAdmin'){
userInfo.isShopAdmin=true
}
if(role.roleid=='locationAdmin'){
userInfo.isLocationAdmin=true
}
if(role.roleid=='projectAdmin'){
userInfo.isProjectAdmin=true
}
if(role.roleid=='teamAdmin'){
userInfo.isTeamAdmin=true
}
if(role.roleid=='productAdmin'){
userInfo.isProductAdmin=true
}
if(role.roleid=='productTeamAdmin'){
userInfo.isProductTeamAdmin=true
}
if(role.roleid=='testAdmin'){
userInfo.isTestAdmin=true
}
if(role.roleid=='testTeamAdmin'){
userInfo.isTestTeamAdmin=true
}
if(role.roleid=='tester'){
userInfo.isTester=true
}
if(role.roleid=='iterationAdmin'){
userInfo.isIterationAdmin=true
}
if(role.roleid=='superAdmin'){
userInfo.isSuperAdmin=true
}
if(role.roleid=='platformAdmin'){
userInfo.isPlatformAdmin=true
}
if(role.roleid=='branchAdmin'){
userInfo.isBranchAdmin=true
}
if(role.roleid=='shopAdmin'){
userInfo.isShopAdmin=true
}
if(role.roleid=='locationAdmin'){
userInfo.isLocationAdmin=true
}
});
}
commit('SET_USER_INFO', userInfo)
commit('SET_ROLES', roles)
commit('SET_QXS', data.qxs)
commit('SET_TOKEN', data.userToken)
setToken( data.userToken)
commit('SET_TOKEN', data.data.accessToken.tokenValue)
setToken( data.data.accessToken.tokenValue)
}
resolve(res)
}).catch(error => {
@ -238,45 +187,21 @@ const user = {
if(roles!=null && roles.length>0){
roles.forEach(role=>{
if(role.roleid=='superAdmin'){
userInfo.isSuperAdmin=true
}
if(role.roleid=='platformAdmin'){
userInfo.isPlatformAdmin=true
}
if(role.roleid=='branchAdmin'){
userInfo.isBranchAdmin=true
}
if(role.roleid=='shopAdmin'){
userInfo.isShopAdmin=true
}
if(role.roleid=='locationAdmin'){
userInfo.isLocationAdmin=true
}
if(role.roleid=='projectAdmin'){
userInfo.isProjectAdmin=true
}
if(role.roleid=='teamAdmin'){
userInfo.isTeamAdmin=true
}
if(role.roleid=='productAdmin'){
userInfo.isProductAdmin=true
}
if(role.roleid=='productTeamAdmin'){
userInfo.isProductTeamAdmin=true
}
if(role.roleid=='testAdmin'){
userInfo.isTestAdmin=true
}
if(role.roleid=='testTeamAdmin'){
userInfo.isTestTeamAdmin=true
}
if(role.roleid=='tester'){
userInfo.isTester=true
}
if(role.roleid=='iterationAdmin'){
userInfo.isIterationAdmin=true
}
if(role.roleid=='superAdmin'){
userInfo.isSuperAdmin=true
}
if(role.roleid=='platformAdmin'){
userInfo.isPlatformAdmin=true
}
if(role.roleid=='branchAdmin'){
userInfo.isBranchAdmin=true
}
if(role.roleid=='shopAdmin'){
userInfo.isShopAdmin=true
}
if(role.roleid=='locationAdmin'){
userInfo.isLocationAdmin=true
}
});
}
@ -308,7 +233,12 @@ const user = {
}
})
})
depts.forEach(d=>{
var branch=branchs.find(b=>b.branchId==d.branchId)
if(branch){
d.branchName=branch.branchName
}
})
commit('SET_MYBRANCHS',branchs);
commit('SET_MYDEPTS',depts);
commit('SET_MYLOCATIONS',locations);
@ -317,8 +247,8 @@ const user = {
commit('SET_USER_INFO',userInfo);
commit('SET_ROLES', roles)
commit('SET_QXS', qxs)
commit('SET_TOKEN', res.data.userToken);
commit('SET_WORK_SHOP',JSON.parse(JSON.stringify(userInfo)));
//commit('SET_TOKEN', res.data.access_token);
commit('SET_WORK_SHOP',userInfo);
commit('SET_IS_LOAD_OK', true)
}
resolve(res);
@ -326,7 +256,7 @@ const user = {
reject(error)
});
/**
getUserInfo(state.userToken).then(response => {
getUserInfo(state.access_token).then(response => {
if (!response.data) { // 由于mockjs 不支持自定义状态码只能这样hack
reject('error')
}
@ -355,45 +285,21 @@ const user = {
if(roles!=null && roles.length>0){
roles.forEach(role=>{
if(role.roleid=='superAdmin'){
userInfo.isSuperAdmin=true
}
if(role.roleid=='platformAdmin'){
userInfo.isPlatformAdmin=true
}
if(role.roleid=='branchAdmin'){
userInfo.isBranchAdmin=true
}
if(role.roleid=='shopAdmin'){
userInfo.isShopAdmin=true
}
if(role.roleid=='locationAdmin'){
userInfo.isLocationAdmin=true
}
if(role.roleid=='projectAdmin'){
userInfo.isProjectAdmin=true
}
if(role.roleid=='teamAdmin'){
userInfo.isTeamAdmin=true
}
if(role.roleid=='productAdmin'){
userInfo.isProductAdmin=true
}
if(role.roleid=='productTeamAdmin'){
userInfo.isProductTeamAdmin=true
}
if(role.roleid=='testAdmin'){
userInfo.isTestAdmin=true
}
if(role.roleid=='testTeamAdmin'){
userInfo.isTestTeamAdmin=true
}
if(role.roleid=='tester'){
userInfo.isTester=true
}
if(role.roleid=='iterationAdmin'){
userInfo.isIterationAdmin=true
}
if(role.roleid=='superAdmin'){
userInfo.isSuperAdmin=true
}
if(role.roleid=='platformAdmin'){
userInfo.isPlatformAdmin=true
}
if(role.roleid=='branchAdmin'){
userInfo.isBranchAdmin=true
}
if(role.roleid=='shopAdmin'){
userInfo.isShopAdmin=true
}
if(role.roleid=='locationAdmin'){
userInfo.isLocationAdmin=true
}
});
}
@ -434,7 +340,7 @@ const user = {
commit('SET_USER_INFO',userInfo);
commit('SET_ROLES', roles)
commit('SET_QXS', qxs)
commit('SET_TOKEN', res.data.userToken)
commit('SET_TOKEN', res.data.access_token)
commit('SET_WORK_SHOP',JSON.parse(JSON.stringify(userInfo)));
commit('SET_IS_LOAD_OK', true)
}
@ -450,8 +356,8 @@ const user = {
// return new Promise((resolve, reject) => {
// commit('SET_CODE', code)
// loginByThirdparty(state.status, state.email, state.code).then(response => {
// commit('SET_TOKEN', response.data.userToken)
// setToken(response.data.userToken)
// commit('SET_TOKEN', response.data.access_token)
// setToken(response.data.access_token)
// resolve()
// }).catch(error => {
// reject(error)
@ -493,7 +399,7 @@ const user = {
const data = response.data
commit('SET_USER_INFO', data.userInfo)
commit('SET_ROLES', data.roles)
commit('SET_TOKEN', data.userToken)
commit('SET_TOKEN', data.access_token)
setToken(data.userInfo.jsessionid)
resolve()
})

10
src/utils/request.js

@ -30,7 +30,13 @@ const service = axios.create({
// request interceptor
service.interceptors.request.use(config => {
// Do something before request is sent
config.headers['Authorization'] = 'userToken '+getToken() // 让每个请求携带token-- ['X-Token']为自定义key 请根据实际情况自行修改
var token=getToken();
if(token==null ||token=='' ||token=="" || token ==undefined ){
return config;
}else{
config.headers['Authorization'] = 'Bearer '+token // 让每个请求携带token-- ['X-Token']为自定义key 请根据实际情况自行修改
}
return config
}, error => {
// Do something with request error
@ -51,7 +57,7 @@ service.interceptors.response.use(
return response
},
error => {
console.log('err' + error)// for debug
console.log(error)// for debug
if(error.response){
switch (error.response.status) {
case 401:

2
src/views/layout/Layout.vue

@ -3,7 +3,7 @@
<sidebar class="sidebar-container"></sidebar>
<div class="main-container">
<navbar></navbar>
<tags-view class="hidden-sm-and-down"></tags-view>
<tags-view></tags-view>
<app-main></app-main>
</div>
</div>

2
src/views/layout/components/AppMain.vue

@ -12,7 +12,7 @@
export default {
name: 'AppMain',
computed: {
cachedViews:function() {
cachedViews() {
return this.$store.state.tagsView.cachedViews
}
// key() {

585
src/views/layout/components/Navbar.vue

@ -1,413 +1,291 @@
<template>
<el-menu class="navbar" mode="horizontal">
<hamburger class="hamburger-container" :toggleClick="toggleSideBar" :isActive="sidebar.opened=='1'"></hamburger>
<hamburger class="hamburger-container" :toggleClick="toggleSideBar" :isActive="sidebar.opened"></hamburger>
<breadcrumb class="breadcrumb-container hidden-sm-and-down"></breadcrumb>
<div class="right-menu">
<div class="hidden-sm-and-down" style="float:left;display:flex;align-items: center;height:100%;">
<!-- <el-tooltip class="itemt" effect="dark" content="跳转到组织" placement="bottom-start">
<div target="_blank" @click="jumpToOtherSystem('sys')">
<div v-if="screenWidth<500">
<i class="iconfont icon-zuzhi" style="margin-right:10px;" data-title="组织"></i>
</div>
<div v-if="screenWidth>500" class="big">
<i class="iconfont icon-zuzhi" style="font-size:25px;" data-title="组织"></i>
<span style="position:absolute;bottom:-18px;">组织</span>
</div>
</div>
</el-tooltip>
<el-tooltip class="itemt" effect="dark" content="跳转到内容" placement="bottom-start">
<div target="_blank" @click="jumpToOtherSystem('arc')">
<div v-if="screenWidth<500">
<i class="iconfont icon-neirong-copy" style="margin-right:10px;" data-title="内容"></i>
</div>
<div v-if="screenWidth>500" class="big">
<i class="iconfont icon-neirong-copy" style="font-size:25px" data-title="内容"></i>
<span style="position:absolute;bottom:-18px;">内容</span>
</div>
</div>
</el-tooltip>
<el-tooltip class="itemt" effect="dark" content="跳转到流程" placement="bottom-start">
<div target="_blank" @click="jumpToOtherSystem('oa')">
<div v-if="screenWidth<500">
<i class="iconfont icon-icon-liucheng" style="margin-right:10px;" data-title="流程"></i>
</div>
<div v-if="screenWidth>500" class="big">
<i class="iconfont icon-icon-liucheng" style="font-size:25px" data-title="流程"></i>
<span style="position:absolute;bottom:-18px;">流程</span>
</div>
</div>
</el-tooltip>
<el-tooltip class="itemt" effect="dark" content="跳转到商城" placement="bottom-start">
<div target="_blank" @click="jumpToOtherSystem('mallm')">
<div v-if="screenWidth<500">
<i class="iconfont icon-shangcheng" style="margin-right:10px;" data-title="商城"></i>
</div>
<div v-if="screenWidth>500" class="big">
<i class="iconfont icon-shangcheng" style="font-size:25px" data-title="商城"></i>
<span style="position:absolute;bottom:-18px;">商城</span>
</div>
</div>
</el-tooltip>
<el-tooltip class="itemt" effect="dark" content="跳转到营销" placement="bottom-start">
<div target="_blank" @click="jumpToOtherSystem('mk')">
<div v-if="screenWidth<500">
<i class="iconfont icon-yingxiao" style="margin-right:10px;" data-title="营销"></i>
</div>
<div v-if="screenWidth>500" class="big">
<i class="iconfont icon-yingxiao" style="font-size:25px" data-title="营销"></i>
<span style="position:absolute;bottom:-18px;">营销</span>
</div>
</div>
</el-tooltip>
<el-tooltip class="itemt" effect="dark" content="跳转到财务" placement="bottom-start">
<div target="_blank" @click="jumpToOtherSystem('ac')">
<div v-if="screenWidth<500">
<i class="iconfont icon-caiwuguanli" style="margin-right:10px;" data-title="财务"></i>
</div>
<div v-if="screenWidth>500" class="big">
<i class="iconfont icon-caiwuguanli" style="font-size:25px" data-title="财务"></i>
<span style="position:absolute;bottom:-18px;">财务</span>
</div>
</div>
</el-tooltip>
<el-tooltip class="itemt" effect="dark" content="跳转到短信" placement="bottom-start">
<div target="_blank" @click="jumpToOtherSystem('sms')">
<div v-if="screenWidth<500">
<i class="iconfont icon-sms" style="margin-right:10px;" data-title="短信"></i>
</div>
<div v-if="screenWidth>500" class="big">
<i class="iconfont icon-sms" style="font-size:25px" data-title="短信"></i>
<span style="position:absolute;bottom:-18px;">短信</span>
</div>
</div>
</el-tooltip>
<el-tooltip class="itemt" effect="dark" content="跳转到聊天" placement="bottom-start">
<div target="_blank" @click="jumpToOtherSystem('im')">
<div v-if="screenWidth<500">
<i class="iconfont icon-liaotian1" style="margin-right:10px;" data-title="聊天oa"></i>
</div>
<div v-if="screenWidth>500" class="big">
<i class="iconfont icon-liaotian1" style="font-size:25px" data-title="聊天"></i>
<span style="position:absolute;bottom:-18px;">聊天</span>
</div>
</div>
</el-tooltip> -->
<el-tooltip class="itemt hidden-sm-and-down" effect="dark" :content="workShop.branchId+'-'+workShop.shopId+'-'+workShop.locationId"
placement="top-start">
<el-tag>{{workShop.branchName}}-{{workShop.locationName}}</el-tag>
</el-tooltip>
<el-button @click="showSelectShopMethod" type="primary" v-if="workShop.isSuperAdmin||workShop.isPlatFormAdmin">切换商户</el-button>
</div>
<error-log class="errLog-container right-menu-item hidden-sm-and-down"></error-log>
<div class="hidden-sm-and-down" style="float:left;display:flex;align-items: center;height:100%;">
<el-tooltip class="item" effect="dark" :content="workShop.branchId+'-'+workShop.shopId+'-'+workShop.locationId" placement="top-start">
<el-tag>{{workShop.branchName}}-{{workShop.locationName}}</el-tag>
</el-tooltip>
<el-button @click="showSelectShopMethod" type="primary" v-if="workShop.isSuperAdmin||workShop.isPlatFormAdmin">切换商户</el-button>
</div>
<error-log class="errLog-container right-menu-item hidden-sm-and-down"></error-log>
<el-tooltip class="hidden-sm-and-down" effect="dark" :content="$t('navbar.screenfull')" placement="bottom">
<screenfull class="screenfull right-menu-item"></screenfull>
</el-tooltip>
<lang-select class="international right-menu-item hidden-sm-and-down"></lang-select>
<el-tooltip class="hidden-sm-and-down" effect="dark" :content="$t('navbar.theme')" placement="bottom">
<el-tooltip class="hidden-sm-and-down" effect="dark" :content="$t('navbar.theme')" placement="bottom">
<theme-picker class="theme-switch right-menu-item"></theme-picker>
</el-tooltip>
<el-dropdown class="avatar-container right-menu-item" trigger="click">
<div class="avatar-wrapper">
<img v-if="userInfo && userInfo.headimgurl && userInfo.headimgurl!=null && userInfo.headimgurl!=='' " class="user-avatar"
:src="userInfo.headimgurl">
<img v-if="userInfo && userInfo.headimgurl && userInfo.headimgurl!=null && userInfo.headimgurl!=='' " class="user-avatar" :src="userInfo.headimgurl">
<img v-else class="user-avatar" src="../../../assets/image/user_img.gif">
<i class="el-icon-caret-bottom"></i>
</div>
<el-dropdown-menu slot="dropdown">
</div>
<el-dropdown-menu slot="dropdown">
<router-link to="/">
<el-dropdown-item>
{{$t('navbar.dashboard')}}
</el-dropdown-item>
</router-link>
<el-dropdown-item divided>
用户名{{userInfo.username}}
</el-dropdown-item>
</router-link>
<el-dropdown-item divided>
公司{{userInfo.branchName}}
用户名{{userInfo.username}}
</el-dropdown-item>
<el-dropdown-item divided>
<div style=" overflow-x:auto; height:150px;">
部门及岗位 <el-form>
<el-form-item v-for="item in deptPostsTree" :label="item.deptName">
<el-row v-if="item.children!=null && item.children.length>0" v-for="post in item.children">
<el-tag>{{post.postName}}</el-tag>
</el-row>
</el-form-item>
</el-form>
</div>
公司{{userInfo.branchName}}
</el-dropdown-item>
<el-dropdown-item divided>
<div style=" overflow-x:auto; height:150px;">
部门及岗位 <el-form>
<el-form-item v-for="(item ,index) in deptPostsTree" :label="item.deptName" :key="index">
<div v-if="item.children!=null && item.children.length>0">
<el-row v-for="(post,idx) in item.children" :key="idx">
<el-tag>{{post.postName}}</el-tag>
</el-row>
</div>
</el-form-item>
</el-form>
</div>
</el-dropdown-item>
<el-dropdown-item divided>
<div style=" overflow-x:auto; height:150px;">
商户及门店 <el-form>
<el-form-item label-width="300" v-for="item in shopLocationsTree" :label="item.shopName">
<el-row v-for="location in item.locations">
<el-col :span="24">
<el-tag>{{location.locationName}}</el-tag><i v-if="location.locationId==userInfo.locationId"
class="el-icon-check"></i>
</el-col>
</el-row>
<el-row v-if="item.locations==null || item.locations.length<=0">
<el-col :span="24">
<el-tag> 无门店或者我不是该商户的门店管理员</el-tag>
</el-col>
</el-row>
</el-form-item>
</el-form>
</div>
<el-dropdown-item divided>
<div style=" overflow-x:auto; height:150px;">
商户及门店 <el-form>
<el-form-item label-width="300" v-for="item in shopLocationsTree" :label="item.shopName" :key="item.shopId">
<el-row v-for="location in item.locations" :key="location.locationId">
<el-col :span="24"><el-tag>{{location.locationName}}</el-tag><i v-if="location.locationId==userInfo.locationId" class="el-icon-check"></i>
</el-col>
</el-row>
<el-row v-if="item.locations==null || item.locations.length<=0">
<el-col :span="24"><el-tag> 无门店或者我不是该商户的门店管理员</el-tag> </el-col>
</el-row>
</el-form-item>
</el-form>
</div>
</el-dropdown-item>
<el-dropdown-item divided>
<div style=" overflow-x:auto; height:150px;">
我拥有的角色 <el-form>
<el-form-item label="">
<el-row v-for="role in roles">
<el-tag>{{role.rolename}}</el-tag>
</el-row>
</el-form-item>
</el-form>
</div>
<el-dropdown-item divided>
<div style=" overflow-x:auto; height:150px;">
我拥有的角色 <el-form>
<el-form-item label="">
<el-row v-for="role in roles" :key="role.roleid">
<el-tag v-if="role.roleid.indexOf('SCOPE')<0">{{role.rolename}}</el-tag>
</el-row>
</el-form-item>
</el-form>
</div>
</el-dropdown-item>
<el-dropdown-item divided>
<span @click="logout" style="display:block;">{{$t('navbar.logOut')}}</span>
</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown-menu>
</el-dropdown>
</div>
<el-dialog title="选择商户" :visible.sync="selectShopVisible" width="70%" append-to-body>
<select-shop-location-by-sys-dept @sure="sureMethod"></select-shop-location-by-sys-dept>
</el-dialog>
</el-menu>
</template>
<script>
import {
mapGetters
} from 'vuex'
import Breadcrumb from '@/components/Breadcrumb'
import Hamburger from '@/components/Hamburger'
import ErrorLog from '@/components/ErrorLog'
import Screenfull from '@/components/Screenfull'
import LangSelect from '@/components/LangSelect'
import ThemePicker from '@/components/ThemePicker'
import selectShopLocationBySysDept from '@/components/selectShopLocation/selectShopLocationBySysDept';
export default {
components: {
'select-shop-location-by-sys-dept': selectShopLocationBySysDept,
Breadcrumb,
Hamburger,
ErrorLog,
Screenfull,
LangSelect,
ThemePicker
},
data: function() {
return {
selectShopVisible: false,
postChecked: '',
envVersion: ''
}
},
computed: {
import { mapGetters } from 'vuex'
import Breadcrumb from '@/components/Breadcrumb'
import Hamburger from '@/components/Hamburger'
import ErrorLog from '@/components/ErrorLog'
import Screenfull from '@/components/Screenfull'
import LangSelect from '@/components/LangSelect'
import ThemePicker from '@/components/ThemePicker';
//import selectShopLocationBySysDept from '@/views/mdp/app/selectShopLocationBySysDept/selectShopLocationBySysDept';
export default {
components: {
Breadcrumb,
Hamburger,
ErrorLog,
Screenfull,
LangSelect,
ThemePicker
},
data:function(){
return {
selectShopVisible: false,
postChecked:''
}
},
computed: {
screenWidth: function() {
return screen.width;
},
...mapGetters([
'sidebar',
'userInfo',
'roles',
'myPosts',
'myLocations',
'myShops',
'workShop'
]),
'deptPostsTree': function() {
var deptPostsTree = []
if (this.myPosts == null || this.myPosts.length <= 0) {
return deptPostsTree
}
var checkedPostId = this.myPosts.length > 0 ? this.myPosts[0].postId : ''
this.postChecked = checkedPostId
this.myPosts.forEach(post => {
if (post.postId == checkedPostId) {
post.checked = '1'
}
var deptPostArray = deptPostsTree.filter(dp => dp.deptid == post.deptid)
if (deptPostArray != null && deptPostArray.length > 0) {
if (deptPostArray[0].children && deptPostArray[0].children.length > 0) {
if (!deptPostArray[0].children.some(i => i.postId == post.postId)) {
deptPostArray[0].children.push(post)
}
} else {
deptPostArray[0].children = []
deptPostArray[0].children.push(post)
}
} else {
let deptPostsNode = {
deptid: post.deptid,
deptName: post.deptName
}
deptPostsNode.children = [post]
deptPostsTree.push(deptPostsNode)
}
})
return deptPostsTree
},
'shopLocationsTree': function() {
let myShops = this.myShops;
if (myShops == null || myShops.length <= 0) {
return []
}
let myLocations = this.myLocations;
myShops.forEach(shop => {
shop.locations = [];
if (shop.shopId == this.userInfo.shopId) {
shop.checked = true
}
if (myLocations != null && myLocations.length > 0) {
myLocations.forEach(l => {
if (l.shopId == shop.shopId) {
if (l.locationId == this.userInfo.locationId) {
l.checked = true
}
shop.locations.push(l)
}
})
}
})
return myShops
}
...mapGetters([
'sidebar',
'userInfo',
'roles',
'myPosts',
'myLocations',
'myShops',
'workShop'
]),
'deptPostsTree':function(){
var deptPostsTree=[]
if(this.myPosts==null ||this.myPosts.length<=0){
return deptPostsTree
}
var checkedPostId=this.myPosts.length>0?this.myPosts[0].postId:''
this.postChecked=checkedPostId
this.myPosts.forEach(post=>{
if(post.postId==checkedPostId){
post.checked='1'
}
var deptPostArray=deptPostsTree.filter(dp=>dp.deptid==post.deptid)
if(deptPostArray!=null && deptPostArray.length>0){
if(deptPostArray[0].children && deptPostArray[0].children.length>0){
if(!deptPostArray[0].children.some(i=>i.postId==post.postId)){
deptPostArray[0].children.push(post)
}
}else{
deptPostArray[0].children=[]
deptPostArray[0].children.push(post)
}
}else{
let deptPostsNode={deptid:post.deptid,deptName:post.deptName}
deptPostsNode.children=[post]
deptPostsTree.push(deptPostsNode)
}
})
return deptPostsTree
},
methods: {
toggleSideBar(toOpen) {
this.$store.dispatch('toggleSideBar', toOpen)
},
logout() {
this.$store.dispatch('LogOut').then(() => {
location.reload() // In order to re-instantiate the vue-router object to avoid bugs
})
},
showSelectShopMethod() {
this.selectShopVisible = true;
},
sureMethod(row) {
this.selectShopVisible = false;
this.workShop.shopId = row.shopId;
this.workShop.branchId = row.branchId;
this.workShop.branchName = row.sysBranchName;
this.workShop.locationId = row.id;
this.workShop.deptid = row.deptid;
this.workShop.locationName = row.businessName;
this.$store.commit('SET_WORK_SHOP', this.workShop);
},
jumpToOtherSystem(name) {
let href = window.location.protocol + "//" + window.location.host + "/" + name + "/" + process.env.VERSION;
if(name=='im'){
href=window.location.protocol + "//" + window.location.host + "/" + name + "/" + process.env.VERSION+"/#/mdp/im/messages/messageChat";
}
console.log(href);
window.open(href, '_blank');
NProgress.done() // if current page is login will not trigger afterEach hook, so manually handle it
}
'shopLocationsTree':function(){
let myShops=this.myShops;
if(myShops==null||myShops.length<=0){
return []
}
let myLocations=this.myLocations;
myShops.forEach(shop=>{
shop.locations=[];
if(shop.shopId==this.userInfo.shopId){
shop.checked=true
}
if(myLocations!=null && myLocations.length>0){
myLocations.forEach(l=>{
if(l.shopId==shop.shopId){
if(l.locationId==this.userInfo.locationId){
l.checked=true
}
shop.locations.push(l)
}
})
}
})
return myShops
}
},
methods: {
toggleSideBar(toOpen) {
this.$store.dispatch('toggleSideBar', toOpen)
},
mounted() {
if (screen.width <= 500) {
this.toggleSideBar(false);
} else {
this.toggleSideBar(true);
logout() {
this.$store.dispatch('LogOut').then(() => {
location.reload()// In order to re-instantiate the vue-router object to avoid bugs
})
},
showSelectShopMethod() {
this.selectShopVisible = true;
},
sureMethod(row) {
this.selectShopVisible = false;
this.workShop.shopId=row.shopId;
this.workShop.branchId=row.branchId;
this.workShop.branchName=row.sysBranchName;
this.workShop.locationId=row.id;
this.workShop.deptid=row.deptid;
this.workShop.locationName=row.businessName;
this.$store.commit('SET_WORK_SHOP',this.workShop);
},
jumpToOtherSystem(name) {
let href = window.location.protocol + "//" + window.location.host + "/" + name + "/" + process.env.VERSION;
if(name=='im'){
href=window.location.protocol + "//" + window.location.host + "/" + name + "/" + process.env.VERSION+"/#/mdp/im/messages/messageChat";
}
console.log(href);
window.open(href, '_blank');
NProgress.done() // if current page is login will not trigger afterEach hook, so manually handle it
}
},
mounted() {
if (screen.width <= 500) {
this.toggleSideBar(false);
} else {
this.toggleSideBar(true);
}
}
}
</script>
<style rel="stylesheet/scss" lang="scss" scoped>
@import './iconfont.css';
.navbar {
<style rel="stylesheet/scss" lang="scss" scoped>
@import './iconfont.css';
.navbar {
height: 50px;
line-height: 50px;
border-radius: 0px !important;
.hamburger-container {
line-height: 58px;
height: 50px;
line-height: 50px;
border-radius: 0px !important;
.hamburger-container {
line-height: 58px;
height: 50px;
float: left;
padding: 0 10px;
}
.breadcrumb-container {
float: left;
float: left;
padding: 0 10px;
}
.breadcrumb-container{
float: left;
}
.errLog-container {
display: inline-block;
vertical-align: top;
}
.right-menu {
float: right;
height: 100%;
&:focus{
outline: none;
}
.errLog-container {
.right-menu-item {
display: inline-block;
margin: 0 8px;
}
.screenfull {
height: 20px;
}
.international{
vertical-align: top;
}
.right-menu {
float: right;
height: 100%;
&:focus {
outline: none;
}
.right-menu-item {
display: inline-block;
margin: 0 8px;
}
.screenfull {
height: 20px;
}
.international {
vertical-align: top;
}
.theme-switch {
vertical-align: 15px;
}
.avatar-container {
height: 50px;
margin-right: 30px;
.avatar-wrapper {
cursor: pointer;
margin-top: 5px;
position: relative;
.user-avatar {
height: 40px;
border-radius: 10px;
}
.el-icon-caret-bottom {
position: absolute;
right: -20px;
top: 25px;
font-size: 12px;
}
.theme-switch {
vertical-align: 15px;
}
.avatar-container {
height: 50px;
margin-right: 30px;
.avatar-wrapper {
cursor: pointer;
margin-top: 5px;
position: relative;
.user-avatar {
height: 40px;
border-radius: 10px;
}
.el-icon-caret-bottom {
position: absolute;
right: -20px;
top: 25px;
font-size: 12px;
}
}
}
}
}
.iconfont {
position: relative
@ -425,4 +303,5 @@
align-items:center;
margin-right: 20px;
}
</style>

2
src/views/layout/components/TagsView.vue

@ -1,7 +1,7 @@
<template>
<div class="tags-view-container">
<scroll-pane class='tags-view-wrapper' ref='scrollPane'>
<router-link ref='tag' class="tags-view-item" :class="isActive(tag)?'active':''" v-for="(tag) in Array.from(visitedViews)"
<router-link ref='tag' class="tags-view-item" :class="isActive(tag)?'active':''" v-for="tag in Array.from(visitedViews)"
:to="tag" :key="tag.path" @contextmenu.prevent.native="openMenu(tag,$event)">
{{generateTitle(tag.title)}}
<span class='el-icon-close' @click.prevent.stop='closeSelectedTag(tag)'></span>

95
src/views/login/index.vue

@ -5,14 +5,21 @@
<h3 class="title">{{$t('login.title')}}</h3>
<lang-select class="set-language"></lang-select>
</div>
<el-form-item prop="username">
<el-form-item prop="authType">
<span class="svg-container svg-container_login">
<svg-icon icon-class="user" />
</span>
<el-input name="username" type="text" v-model="loginForm.username" autoComplete="on" placeholder="用户编号" />
<el-radio v-model="loginForm.authType" label="password">账户密码登录</el-radio>
<el-radio v-model="loginForm.authType" label="sms">短信验证码快速登录</el-radio>
</el-form-item>
<el-form-item prop="username" v-if="loginForm.authType=='password'">
<span class="svg-container svg-container_login">
<svg-icon icon-class="user" />
</span>
<el-input name="username" type="text" v-model="loginForm.username" autoComplete="on" placeholder="用户编号" />
</el-form-item>
<el-form-item prop="password">
<el-form-item prop="password" v-if="loginForm.authType=='password'">
<span class="svg-container">
<svg-icon icon-class="password" />
</span>
@ -21,6 +28,18 @@
<svg-icon icon-class="eye" />
</span>
</el-form-item>
<el-form-item prop="phoneno" v-if="loginForm.authType=='sms'">
<span class="svg-container svg-container_login">
<svg-icon icon-class="user" />
</span>
<el-input name="phoneno" type="text" v-model="loginForm.phoneno" autoComplete="on" placeholder="手机号码" />
</el-form-item>
<el-form-item prop="smsCode" v-if="loginForm.authType=='sms'">
<span class="svg-container svg-container_login">
<svg-icon icon-class="user" />
</span>
<el-input name="smsCode" type="text" v-model="loginForm.smsCode" autoComplete="on" placeholder="短信验证码" /><el-button @click.prevent="sendPhonenoSmsCode">发送验证码</el-button>
</el-form-item>
<el-button type="primary" style="width:100%;margin-bottom:30px;" :loading="loading" @click.native.prevent="handleLogin">{{$t('login.logIn')}}</el-button>
<div class="tips">
@ -37,9 +56,9 @@
<el-dialog
title="请选择一个部门进行登陆"
:visible.sync="deptSelectVisible"
:width="screenWidth<500?'90%':'500px'" append-to-body>
width="screenWidth<500?'90%':'500px" append-to-body>
<el-row class="app-container">
<el-col :span=20 v-for="d in myDepts">
<el-col :span=20 v-for="(d,index) in myDepts" :key="index">
<el-col :span=20><el-radio v-model="userDeptid" :label="d.deptid">{{d.deptName}}({{d.branchName}}) </el-radio> </el-col>
</el-col>
</el-row >
@ -69,6 +88,8 @@
<script>
import { isvalidUsername } from '@/utils/validate';
import { sendSmsCode,validateSmsCode } from '@/api/sms/sms';
import { getUserDepts } from '@/api/login';
import LangSelect from '@/components/LangSelect';
import SocialSign from './socialsignin';
import BranchAdd from './BranchAdd';
@ -96,13 +117,17 @@ export default {
return {
loginForm: {
username: '',
password: ''
password: '',
authType:'password',//password/sms
phoneno:'',//
smsCode:'',//
},
loginRules: {
username: [{ required: true, trigger: 'blur', validator: validateUsername }],
password: [{ required: true, trigger: 'blur', validator: validatePassword }]
},
passwordType: 'password',
loading: false,
showTpLoginDialog: false, //
deptSelectVisible:false,//
@ -118,33 +143,64 @@ export default {
this.passwordType = 'password'
}
},
sendPhonenoSmsCode(){
var params={
phoneno:this.loginForm.phoneno,
scene:"login"
}
sendSmsCode(params).then(res=>{
if(res.data.tips.isOk){
this.$message.info(res.data.tips.msg);
}else{
this.$message.error(res.data.tips.msg);
}
})
},
handleLogin() {
this.$refs.loginForm.validate(valid => {
if (valid) {
this.loading = true
let params={
username:this.loginForm.username,
password:md5(this.loginForm.password)
password:md5(this.loginForm.password),
deptid:this.userDeptid,
authType:this.loginForm.authType,
phoneno:this.loginForm.phoneno,
smsCode:this.loginForm.smsCode
}
var dispatchName="LoginByUsername"
if(this.loginForm.authType=='sms'){
dispatchName="LoginByPhoneno"
}
this.$store.dispatch('LoginByUsername',params).then(res => {
this.$store.dispatch(dispatchName,params).then(res => {
this.loading = false
if(res.data.tips.isOk==true){
console.log(this.$store);
this.loading = true;
this.$store.dispatch('GetUserInfo').then((res2)=>{
this.userDeptid=res2.data.userInfo.deptid
//this.userDeptid=res2.data.userInfo.deptid
this.loading = false
if(res2.data.tips.isOk==true){
if(this.$store.state.user.myBranchs==null ||this.$store.state.user.myBranchs.length==0||this.$store.state.user.myDepts==null || this.$store.state.user.myDepts.length<=0){
//this.$message.error("\n ");
this.addBranchFormVisible=true;
}else if(this.$store.state.user.myDepts.length>1){
//this.$message.info("");
this.deptSelectVisible=true;
}else if(this.$store.state.user.myDepts.length>1 ){
//this.$message.info("");
if( !this.userDeptid ){
this.userDeptid=res2.data.userInfo.deptid
this.deptSelectVisible=true;
}else{
this.rolesChecked();
}
//this.$router.push({ path: 'mdp/sys/branch/BranchAdd' })
}else{
}else if(this.$store.state.user.myDepts.length==1){
//
this.userDeptid=res2.data.userInfo.deptid
this.rolesChecked();
}else{
this.rolesChecked();
}
}else{
this.$message.error(res2.data.tips.msg);
@ -168,18 +224,15 @@ export default {
})
},
deptChecked() {
if(this.userDeptid==''){
this.$message.error("亲,请选择登陆的部门")
if( !this.userDeptid){
this.$message.error("请选择登陆的部门")
return
}
let depts=this.myDepts.filter(d=>d.deptid==this.userDeptid)
if(this.$store.state.user.userInfo.deptid!=this.userDeptid){
this.$store.dispatch('SwitchDept', depts[0]).then(() => {
this.deptSelectVisible = false
//
this.rolesChecked();
})
this.handleLogin();
return;
}else{
this.rolesChecked();
}
@ -263,7 +316,7 @@ $light_gray:#eee;
border-radius: 0px;
padding: 12px 5px 12px 15px;
color: $light_gray;
height: 47px;
height: 47px;
}
}
.el-form-item {

Loading…
Cancel
Save