Commit a30f21ad authored by zengchao's avatar zengchao
Browse files

-

parent ab4da671
<!--
* @Author: 一日看尽长安花
* @since: 2019-09-09 12:16:28
* @LastEditTime: 2019-09-09 12:16:28
* @LastEditors: 一日看尽长安花
* @Description:
-->
<template>
<div :class="{'hidden':hidden}" class="pagination-container">
<div :class="{ hidden: hidden }" class="pagination-container">
<el-pagination
:background="background"
:current-page.sync="currentPage"
......@@ -15,7 +22,7 @@
</template>
<script>
import { scrollTo } from '@/utils/scroll-to'
import { scrollTo } from '@/utils/scroll-to';
export default {
name: 'Pagination',
......@@ -35,7 +42,7 @@ export default {
pageSizes: {
type: Array,
default() {
return [10, 20, 30, 50]
return [10, 20, 30, 50];
}
},
layout: {
......@@ -56,38 +63,38 @@ export default {
}
},
computed: {
currentPage: {
currentPagge: {
get() {
return this.page
return this.page;
},
set(val) {
this.$emit('update:page', val)
this.$emit('update:page', val);
}
},
pageSize: {
get() {
return this.limit
return this.limit;
},
set(val) {
this.$emit('update:limit', val)
this.$emit('update:limit', val);
}
}
},
methods: {
handleSizeChange(val) {
this.$emit('pagination', { page: this.currentPage, limit: val })
this.$emit('pagination', { page: this.currentPage, limit: val });
if (this.autoScroll) {
scrollTo(0, 800)
scrollTo(0, 800);
}
},
handleCurrentChange(val) {
this.$emit('pagination', { page: val, limit: this.pageSize })
this.$emit('pagination', { page: val, limit: this.pageSize });
if (this.autoScroll) {
scrollTo(0, 800)
scrollTo(0, 800);
}
}
}
}
};
</script>
<style scoped>
......
/*
* @Description: In User Settings Edit
* @Author: your name
* @Date: 2019-09-09 12:16:28
* @LastEditTime: 2019-09-09 12:16:28
* @LastEditors: your name
*/
import { constantRoutes } from '@/router';
import { getRoutes } from '@/api/role';
import { default as asyncRoutesMap } from '@/router/maps/index';
import {
deepClone,
objectMerge,
isNotNullAndNotUndefined,
} from '@/utils/index';
import { deepClone, objectMerge } from '@/utils/index';
import { isExists, isNotExists } from '@/utils/object-util';
/**
* Use meta.role to determine if the current user has permission
......@@ -39,10 +43,10 @@ export function filterAsyncRoutes(routesMap, routes, roles) {
// 从前端路由表中选出与当前后端路由信息相对应的那条路由信息
for (let rm of routesMap) {
if (
isNotNullAndNotUndefined(rm.name) &&
isNotNullAndNotUndefined(route.name) &&
isNotNullAndNotUndefined(rm.path) &&
isNotNullAndNotUndefined(route.path) &&
isExists(rm.name) &&
isExists(route.name) &&
isExists(rm.path) &&
isExists(route.path) &&
(rm.path === route.path || rm.name === route.name)
) {
// 优先path判断,是因为导航菜单的展开和收起是根据path判断的。
......@@ -57,7 +61,7 @@ export function filterAsyncRoutes(routesMap, routes, roles) {
tempRoute.children = filterAsyncRoutes(
tempRouteMap.children,
tempRoute.children,
roles,
roles
);
}
// 以后台路由表优先,相同属性覆盖前台路由映射.除去路由路径交由前台控制
......@@ -74,14 +78,14 @@ export function filterAsyncRoutes(routesMap, routes, roles) {
const state = {
routes: [],
addRoutes: [],
addRoutes: []
};
const mutations = {
SET_ROUTES: (state, routes) => {
state.addRoutes = routes;
state.routes = constantRoutes.concat(routes);
},
}
};
const actions = {
......@@ -95,7 +99,7 @@ const actions = {
accessedRoutes = filterAsyncRoutes(
deepClone(asyncRoutesMap),
asyncRoutes,
roles,
roles
);
accessedRoutes.push({ path: '*', redirect: '/404', hidden: true });
......@@ -106,12 +110,12 @@ const actions = {
reject(error);
});
});
},
}
};
export default {
namespaced: true,
state,
mutations,
actions,
actions
};
/*
* @Description: In User Settings Edit
* @Author: your name
* @Date: 2019-10-11 17:40:57
* @LastEditTime: 2019-10-12 09:24:07
* @LastEditors: Please set LastEditors
*/
/**
* @description: obj不存在。由于js存在undefined 和 null两种特殊的数据类型,认为从空间和引用指向上,只要有一个不存在则判断为不存在。
* @param {Object}
* @return {Boolean}
*/
export function isExists(obj) {
return void 0 === obj || null === obj;
}
/**
* @description: obj存在
* @param {Object}
* @return {Boolean}
*/
export function isNotExists(obj) {
return !isExists(obj);
}
import axios from 'axios'
import { MessageBox, Message } from 'element-ui'
import store from '@/store'
import { getToken } from '@/utils/auth'
/*
* @Description: In User Settings Edit
* @Author: your name
* @Date: 2019-09-09 12:16:28
* @LastEditTime: 2019-09-09 12:16:28
* @LastEditors: your name
*/
import axios from 'axios';
import { MessageBox, Message } from 'element-ui';
import store from '@/store';
import { getToken } from '@/utils/auth';
// create an axios instance
const service = axios.create({
baseURL: process.env.VUE_APP_BASE_API, // url = base url + request url
// withCredentials: true, // send cookies when cross-domain requests
timeout: 5000 // request timeout
})
});
// request interceptor
service.interceptors.request.use(
......@@ -19,16 +26,16 @@ service.interceptors.request.use(
// let each request carry token
// ['Authorization'] see to MDN explain about "HTTP Authorization"
// please modify it according to the actual situation
config.headers['Authorization'] = getToken()
config.headers['Authorization'] = getToken();
}
return config
return config;
},
error => {
// do something with request error
console.log('request err => ' + error) // for debug
return Promise.reject(error)
console.log('request err => ' + error); // for debug
return Promise.reject(error);
}
)
);
// response interceptor
service.interceptors.response.use(
......@@ -43,7 +50,7 @@ service.interceptors.response.use(
* You can also judge the status by HTTP Status Code
*/
response => {
const res = response.data
const res = response.data;
// if the custom code is not 20000, it is judged as an error.
if (res.code !== 200) {
......@@ -51,7 +58,7 @@ service.interceptors.response.use(
message: res.message || 'Error',
type: 'error',
duration: 5 * 1000
})
});
// 50008: Illegal token; 50012: Other clients logged in; 50014: Token expired;
if (res.code === 50008 || res.code === 50012 || res.code === 50014) {
......@@ -66,24 +73,24 @@ service.interceptors.response.use(
}
).then(() => {
store.dispatch('user/resetToken').then(() => {
location.reload()
})
})
location.reload();
});
});
}
return Promise.reject(new Error(res.message || 'Error'))
return Promise.reject(new Error(res.message || 'Error'));
} else {
return res
return res;
}
},
error => {
console.log('response err ==> ' + error) // for debug
console.log('response err ==> ' + error); // for debug
Message({
message: error.message,
type: 'error',
duration: 5 * 1000
})
return Promise.reject(error)
});
return Promise.reject(error);
}
)
);
export default service
export default service;
/*
* @Description: 字符串工具类
* @Author: 一日看尽长安花
* @Date: 2019-10-11 17:40:47
* @LastEditTime: 2019-10-12 09:36:33
* @LastEditors: Please set LastEditors
*/
import { isExists, isNotExists } from '@/utils/object-util';
import { isString, trim } from 'lodash';
/**
* @description: 字符串为空串
* @param {Object}
* @return {Boolean}
*/
export function isBlank(str) {
if (isNotExists(str)) {
if (isString(str)) {
if (trim(str).length === 0) {
return true;
} else {
return false;
}
} else {
throw 'str is not string type';
}
} else {
throw 'str is null';
}
}
/**
* @description: 字符串不为空串
* @param {Object}
* @return {Boolean}
*/
export function isNotBlank(str) {
if (isNotExists(str)) {
if (isString(str)) {
if (trim(str).length > 0) {
return true;
} else {
return false;
}
} else {
throw 'str is not string type';
}
} else {
throw 'str is null';
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment