jinhui.wang

version:0.5.5,wsso登录适配(暂),登陆方法改写,通用方法优化,页面优化

......@@ -80,7 +80,11 @@
color:#6379bb;
border-bottom:1px solid #ddd;
margin:8px 10px 25px 10px;
padding-bottom:5px
padding-bottom:5px;
.formItem {
width: 100%;
max-width: 310px;
}
}
/** 表格布局 **/
......
import router from './router'
import store from './store'
import { Message } from 'element-ui'
//import NProgress from 'nprogress'
//import 'nprogress/nprogress.css'
import { getToken } from '@/utils/auth'
import { getToken,setToken } from '@/utils/auth'
//NProgress.configure({ showSpinner: false })
const whiteList = ['/login', '/auth-redirect', '/bind', '/register']
router.beforeEach((to, from, next) => {
//NProgress.start()
if (getToken()) {
/* has token*/
if (to.path === '/login') {
next({ path: '/' })
//NProgress.done()
} else {
if (store.getters.roles.length === 0) {
// 判断当前用户是否已拉取完user_info信息
......@@ -26,9 +21,10 @@ router.beforeEach((to, from, next) => {
next({ ...to, replace: true }) // hack方法 确保addRoutes已完成
})
}).catch(err => {
Message.error(err)
store.dispatch('LogOut').then(() => {
Message.error(err)
next({ path: '/' })
// next({ path: '/' })
window.location.href = "https://testsso.ute.apac.fedex.com/logout";//wsso系统跳转
})
})
} else {
......@@ -37,16 +33,22 @@ router.beforeEach((to, from, next) => {
}
} else {
// 没有token
if (whiteList.indexOf(to.path) !== -1) {
// 在免登录白名单,直接进入
next()
} else {
next(`/login?redirect=${to.fullPath}`) // 否则全部重定向到登录页
//NProgress.done()
//wsso登录时对后端重定向带来的token进行记录
let token = location.search.split("token=")[1]
if(token != undefined && token != '' && token != null){
setToken(token)
next({ path: '/' })
}else{
if (whiteList.indexOf(to.path) !== -1) {
// 在免登录白名单,直接进入
next()
} else {
window.location.href = "https://testsso.ute.apac.fedex.com/logout";//wsso系统跳转
}
}
}
})
router.afterEach(() => {
//NProgress.done()
})
......
......@@ -106,5 +106,5 @@ export default new Router({
mode: 'history', // 去掉url中的#
scrollBehavior: () => ({ y: 0 }),
routes: constantRoutes,
base: '/iMac'
base: '/imacuat'
})
\ No newline at end of file
......
......@@ -42,5 +42,5 @@ module.exports = {
/**
* 版本号
*/
version:'version:0.5.4'
version:'version:0.5.5'
}
......
......@@ -10,18 +10,18 @@ const service = axios.create({
// axios中请求配置有baseURL选项,表示请求URL公共部分
//baseURL: process.env.VUE_APP_BASE_API,
// baseURL: `http://47.103.140.98:7001/IMAC2`,
baseURL: 'https://imacuat.zmd.apac.fedex.com/IMAC2',
// baseURL: 'http://192.168.1.134:18080',
baseURL: 'https://imacuat.zmd.apac.fedex.com/iMAC',
// baseURL: 'http://192.168.1.133:7001/IMAC2',
// 超时
timeout: 30000
timeout: 30000,
})
// request拦截器
service.interceptors.request.use(config => {
// 是否需要设置 token
const isToken = (config.headers || {}).isToken === false
if (getToken() && !isToken) {
config.headers['Authorization'] = getToken() // 让每个请求携带自定义token 请根据实际情况自行修改
config.headers['Authorization'] = decodeURIComponent(getToken()) // 让每个请求携带自定义token 请根据实际情况自行修改
}
// get请求映射params参数
if (config.method === 'get' && config.params) {
......@@ -58,14 +58,15 @@ service.interceptors.response.use(res => {
// 获取错误信息
const msg = errorCode[code] || res.data.msg || errorCode['default']
if (code === 301) {
MessageBox.confirm('登录状态已过期,您可以继续留在该页面,或者重新登录', '系统提示', {
confirmButtonText: '重新登录',
cancelButtonText: '取消',
MessageBox.confirm('登录状态已过期,需重新登录', '系统提示', {
confirmButtonText: '确定',
type: 'warning'
}
).then(() => {
store.dispatch('FedLogOut').then(() => {
location.href = '/index';
store.dispatch('LogOut').then(() => {
// location.href = '/index';
window.location.href = "https://testsso.ute.apac.fedex.com/logout";//wsso系统跳转
// testsso.ute.apac.fedex.com/iMAC
})
});
} else if (code === 403) {
......
......@@ -5,7 +5,7 @@ const mimeMap = {
xlsx: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
zip: 'application/zip'
}
const baseUrl = 'https://imacuat.zmd.apac.fedex.com/IMAC2' //uat服务器
const baseUrl = 'https://imacuat.zmd.apac.fedex.com/iMAC' //uat服务器
// const baseUrl = 'http://47.103.140.98:7001/IMAC2' //阿里云服务器
// const baseUrl = 'http://192.168.1.133:7001/IMAC2' //测试服务器
export function downLoadZip(str, filename) {
......@@ -14,36 +14,18 @@ export function downLoadZip(str, filename) {
method: 'get',
url: url,
responseType: 'blob',
headers: { 'Authorization': getToken() }
headers: { 'Authorization': decodeURIComponent(getToken()) }
}).then(res => {
resolveBlob(res, mimeMap.zip)
})
}
export function cargoXlsx(str, data) {
var url = baseUrl + str
return new Promise((resolve,rej)=>{
axios({
method: 'post',
url: url,
data: data,
responseType: 'blob',
headers: { 'Authorization': getToken() }
}).then(res => {
if (res.status === 200) {
cargoTableXlsx(res)
}
resolve()
}).catch((err)=>{
rej(err)
})
})
}
/**
* 解析blob响应内容并下载
* @param {*} res blob响应内容
* @param {String} mimeType MIME类型
*/
export function resolveBlob(res, mimeType) {
export function resolveBlob(res, mimeType) {
const aLink = document.createElement('a')
var blob = new Blob([res], { type: mimeType })
// //从response的headers中获取filename, 后端response.setHeader("Content-disposition", "attachment; filename=xxxx.docx") 设置的文件名;
......@@ -59,10 +41,31 @@ export function resolveBlob(res, mimeType) {
document.body.removeChild(aLink);
}
//货物查询表导出
export function cargoTableXlsx(val) {
// excel导出请求
export function downLoadXlsx(str, data,fileName) {
var url = baseUrl + str
return new Promise((resolve,rej)=>{
axios({
method: 'post',
url: url,
data: data,
responseType: 'blob',
headers: { 'Authorization': decodeURIComponent(getToken()) }
}).then(res => {
if (res.status === 200) {
cargoTableXlsx(res,fileName)
}
resolve()
}).catch((err)=>{
rej(err)
})
})
}
//excel导出下载
export function downLoadExcal(val,fileNames) {
const aLink = document.createElement('a')
const fileName = "货物查询表.xlsx"
const fileName = fileNames+".xlsx"
aLink.href = URL.createObjectURL(val.data)
aLink.setAttribute('download', fileName) // 设置下载文件名称
document.body.appendChild(aLink)
......
......@@ -288,7 +288,6 @@
},
/** 删除 启用 停用按钮操作 */
handleDeleteorPlayorpause(row, status, statusText) {
// debugger
//删除前需要停用
if (status === 0 && row.status != '3') {
this.$message({
......
......@@ -473,13 +473,11 @@
findFltConditionData() {
findFltConditionDataApi().then(response => {
if (response.code == 200) {
// debugger
//航班种类
this.flightKindlist = response.data.flightKind;
//航班类型
this.flightTypelist = response.data.flightType;
//航班状态
// debugger
this.flightStatuslist = response.data.flightStatus;
} else {
......@@ -657,7 +655,6 @@
submitForm: function() {
this.$refs["form"].validate(valid => {
if (valid) {
//debugger
let formdata = JSON.parse(JSON.stringify(this.form));
//高价百分比和低价百分比和不可以大于100
......
......@@ -2,6 +2,7 @@
<div class="cargoPage">
<el-form
ref="cargoForm"
class="form-header"
size="small"
:model="formData"
label-position="top"
......@@ -304,17 +305,17 @@
@click="select"
>查询</el-button
>
<el-button type="primary" size="small" @click="checks(tableData)"
<!-- <el-button type="primary" size="small" @click="checks(tableData)"
>全选/全否</el-button
> -->
<el-button :type="downLoadingTip.downloading?'warning':'primary'" size="small" @click="xlse(0)" :disabled="tableData.length==0" :loading="downLoadingTip.downloading"
>{{downLoadingTip.downloading?downLoadingTip.tip:"导出本页查询结果"}}</el-button
>
<el-button type="primary" size="small" @click="xlse(0)" v-dbClick :disabled="tableData.length==0" :loading="downloading"
>导出本页查询结果</el-button
>
<el-button type="primary" size="small" @click="xlse(1)" v-dbClick :disabled="tableData.length==0" :loading="downloading"
>导出全部查询结果</el-button
<el-button :type="downLoadingTip.downloading?'warning':'primary'" size="small" @click="xlse(1)" :disabled="tableData.length==0" :loading="downLoadingTip.downloading"
>{{downLoadingTip.downloading?downLoadingTip.tip:"导出全部查询结果"}}</el-button
>
<div class="tips">
<span style="paddingright: 50px">总重量:{{ allWeight }}</span>
<span style="paddingRight: 50px">总重量:{{ allWeight }}</span>
<span>总件数:{{ allQty }}</span>
</div>
</div>
......@@ -362,7 +363,7 @@
<script>
import { findConditionData, findCargoData } from "@/api/cargoSelect";
import { cargoXlsx } from "@/utils/zipdownload";
import { downLoadXlsx } from "@/utils/zipdownload";
export default {
name:"queryCargo",
......@@ -448,7 +449,10 @@ export default {
start: -1,
valueFormat: "yyyy-MM-dd",
tableLoading: false,
downloading:false,
downLoadingTip:{
tip:"",
downloading:false,
},
totalCount: 0,
selectTable: [],
flightTime: [],
......@@ -650,7 +654,7 @@ export default {
},
// 导出表格
xlse(page) {
this.downloading = true;
this.downLoadingTip.downloading = true;
let cargoXlse = {title:"货物导出表",cargoConditionDto:{}};
if(this.formData.customsReceiptStatusId != null && this.formData.customsReceiptStatusId.length < 1){
this.formData.customsReceiptStatusId = null;
......@@ -687,16 +691,35 @@ export default {
cargoXlse.cargoConditionDto.limitSize = this.limitSize;
if (page == 0) {
this.downLoadingTip.tip = "正在导出本页结果集"
cargoXlse.cargoConditionDto.limitStart = this.limitStart;
downLoadXlsx("/cargo/excel",cargoXlse,"货物查询表").then(()=>{
this.downLoadingTip.downloading = false;
this.downLoadingTip.tip = ""
}).catch(()=>{
this.downLoadingTip.downloading = false;
this.downLoadingTip.tip = ""
})
} else {
cargoXlse.cargoConditionDto.limitStart = 0;
cargoXlse.cargoConditionDto.limitSize = -1;
if(this.totalCount < 100000){
this.downLoadingTip.tip = "正在导出全部结果集"
cargoXlse.cargoConditionDto.limitStart = 0;
cargoXlse.cargoConditionDto.limitSize = -1;
downLoadXlsx("/cargo/excel",cargoXlse,"货物查询表").then(()=>{
this.downLoadingTip.downloading = false;
this.downLoadingTip.tip = ""
}).catch(()=>{
this.downLoadingTip.downloading = false;
this.downLoadingTip.tip = ""
})
}else{
this.downLoadingTip.downloading = false;
this.$message({
message: "数据量过大无法导出",
type: "warning",
});
}
}
cargoXlsx("/cargo/excel",cargoXlse).then(()=>{
this.downloading = false;
}).catch(()=>{
this.downloading = false;
})
},
//表格格式化
formatter(row,column,cellValue,index){
......@@ -754,8 +777,4 @@ export default {
font-size: 14px;
margin-right: 40px;
}
.formItem {
width:100%;
max-width: 300px;
}
</style>
\ No newline at end of file
......
<template>
<div class="login">
<el-form ref="loginForm" :model="loginForm" :rules="loginRules" class="login-form">
<div class="login" :style="display">
<el-form
ref="loginForm"
:model="loginForm"
:rules="loginRules"
class="login-form"
>
<h3 class="title">IMAC后台管理系统</h3>
<el-form-item prop="username">
<el-input v-model="loginForm.username" type="text" auto-complete="off" placeholder="账号">
<svg-icon slot="prefix" icon-class="user" class="el-input__icon input-icon" />
<el-input
v-model="loginForm.username"
type="text"
auto-complete="off"
placeholder="账号"
>
<svg-icon
slot="prefix"
icon-class="user"
class="el-input__icon input-icon"
/>
</el-input>
</el-form-item>
<el-form-item prop="password">
......@@ -15,17 +29,20 @@
placeholder="密码"
@keyup.enter.native="handleLogin"
>
<svg-icon slot="prefix" icon-class="password" class="el-input__icon input-icon" />
<svg-icon
slot="prefix"
icon-class="password"
class="el-input__icon input-icon"
/>
</el-input>
</el-form-item>
<!-- <el-checkbox v-model="loginForm.rememberMe" style="margin:0px 0px 25px 0px;">记住密码</el-checkbox> -->
<el-form-item style="width:100%;marginTop:44px">
<el-form-item style="width: 100%; marginTop: 44px">
<el-button
:loading="loading"
size="medium"
type="primary"
style="width:100%;"
style="width: 100%"
@click.native.prevent="handleLogin"
>
<span v-if="!loading">登 录</span>
......@@ -43,7 +60,7 @@
<script>
import { getCodeImg } from "@/api/login";
//import Cookies from "js-cookie";
import { encrypt, } from '@/utils/jsencrypt'
import { encrypt } from "@/utils/jsencrypt";
export default {
name: "Login",
......@@ -54,18 +71,19 @@ export default {
loginForm: {
username: "root",
password: "123",
rememberMe: false
rememberMe: false,
},
loginRules: {
username: [
{ required: true, trigger: "blur", message: "用户名不能为空" }
{ required: true, trigger: "blur", message: "用户名不能为空" },
],
password: [
{ required: true, trigger: "blur", message: "密码不能为空" }
]
{ required: true, trigger: "blur", message: "密码不能为空" },
],
},
loading: false,
redirect: undefined
redirect: undefined,
display: "display:none",
};
},
watch: {
......@@ -75,52 +93,59 @@ export default {
},
immediate: true
}
},
},
created() {
this.getCookie();
},
methods: {
getCookie() {
const username = localStorage.getItem("username");
const password = localStorage.getItem("password");
const rememberMe = localStorage.getItem('rememberMe')
const rememberMe = localStorage.getItem("rememberMe");
this.loginForm = {
username: username === undefined ? this.loginForm.username : username,
password: password === undefined ? this.loginForm.password : password,
rememberMe: rememberMe === undefined ? false : Boolean(rememberMe)
rememberMe: rememberMe === undefined ? false : Boolean(rememberMe),
};
},
handleLogin() {
this.$refs.loginForm.validate(valid => {
this.$refs.loginForm.validate((valid) => {
if (valid) {
this.loading = true;
if (this.loginForm.rememberMe) {
localStorage.setItem("username", this.loginForm.username, { expires: 30 });
localStorage.setItem("password", this.loginForm.password, { expires: 30 });
localStorage.setItem('rememberMe', this.loginForm.rememberMe, { expires: 30 });
localStorage.setItem("username", this.loginForm.username, {
expires: 30,
});
localStorage.setItem("password", this.loginForm.password, {
expires: 30,
});
localStorage.setItem("rememberMe", this.loginForm.rememberMe, {
expires: 30,
});
} else {
localStorage.removeItem("username");
localStorage.removeItem("password");
localStorage.removeItem('rememberMe');
localStorage.removeItem("rememberMe");
}
this.$store.dispatch("Login", this.loginForm).then(() => {
this.$router.push({ path: this.redirect || "/" }).catch(()=>{});
}).catch(() => {
this.loading = false;
//this.getCode();
});
this.$store
.dispatch("Login", this.loginForm)
.then(() => {
this.$router.push({ path: this.redirect || "/" }).catch(() => {});
})
.catch(() => {
this.loading = false;
//this.getCode();
});
}
});
}
}
},
},
};
</script>
<style rel="stylesheet/scss" lang="scss">
.login {
display: flex;
display: none;
justify-content: center;
align-items: center;
height: 100%;
......
//version:0.5.2
'use strict'
const path = require('path')
const defaultSettings = require('./src/settings.js')
......@@ -18,7 +17,7 @@ module.exports = {
// 部署生产环境和开发环境下的URL。
// 默认情况下,Vue CLI 会假设你的应用是被部署在一个域名的根路径上
// 例如 https://www.FedEx.vip/。如果应用被部署在一个子路径上,你就需要用这个选项指定这个子路径。例如,如果你的应用被部署在 https://www.FedEx.vip/admin/,则设置 baseUrl 为 /admin/。
publicPath: process.env.NODE_ENV === "production" ? "/iMac/" : "/",
publicPath: process.env.NODE_ENV === "production" ? "/imacuat/" : "/",
// 在npm run build 或 yarn build 时 ,生成文件的目录名称(要和baseUrl的生产环境路径一致)(默认dist)
outputDir: 'dist',
// 用于放置生成的静态资源 (js、css、img、fonts) 的;(项目打包之后,静态资源会放在这个文件夹下)
......@@ -35,7 +34,7 @@ module.exports = {
proxy: {
// detail: https://cli.vuejs.org/config/#devserver-proxy
[process.env.VUE_APP_BASE_API]: {
target: `https://imacuat.zmd.apac.fedex.com/IMAC2`,
target: `https://imacuat.zmd.apac.fedex.com/iMAC`,
// target: `http://47.103.140.98:7001/IMAC2`,
// target: `http://192.168.1.134:18080`,
changeOrigin: true,
......