统计报表,登录缓存,录缓存,

This commit is contained in:
jiangrui 2021-05-17 11:13:41 +08:00
parent 026cf8edfb
commit 35de06310b
6 changed files with 83 additions and 70 deletions

View File

@ -3,13 +3,16 @@ import Cookies from 'js-cookie'
const TokenKey = 'Admin-Token' const TokenKey = 'Admin-Token'
export function getToken() { export function getToken() {
return Cookies.get(TokenKey) // return Cookies.get(TokenKey)
return localStorage.getItem(TokenKey)
} }
export function setToken(token) { export function setToken(token) {
return Cookies.set(TokenKey, token) // return Cookies.set(TokenKey, token)
return localStorage.setItem(TokenKey,token)
} }
export function removeToken() { export function removeToken() {
return Cookies.remove(TokenKey) // return Cookies.remove(TokenKey)
return localStorage.removeItem(TokenKey)
} }

View File

@ -367,7 +367,7 @@ export function errorCodeMap(code) {
200102: '账号验证不通过', 200102: '账号验证不通过',
200103: '账号已被禁用', 200103: '账号已被禁用',
200010: '权限资源不存在', 200010: '权限资源不存在',
401: '未经授权', 401: '未在APP进行实名认证,暂无访问权限',
403: '无访问权限', 403: '无访问权限',
404: '接口不存在', 404: '接口不存在',
400001: '请求参数错误', 400001: '请求参数错误',

View File

@ -1,15 +1,15 @@
import axios from 'axios' import axios from "axios";
import { MessageBox, Message } from 'element-ui' import { MessageBox, Message } from "element-ui";
import store from '@/store' import store from "@/store";
import { getToken } from '@/utils/auth' import { getToken } from "@/utils/auth";
import { errorCodeMap } from '@/utils/index' import { errorCodeMap } from "@/utils/index";
// create an axios instance // create an axios instance
const service = axios.create({ const service = axios.create({
baseURL: process.env.VUE_APP_BASE_API, // url = base url + request url baseURL: process.env.VUE_APP_BASE_API, // url = base url + request url
// withCredentials: true, // send cookies when cross-domain requests // withCredentials: true, // send cookies when cross-domain requests
timeout: 5000 // request timeout timeout: 5000 // request timeout
}) });
// request interceptor // request interceptor
service.interceptors.request.use( service.interceptors.request.use(
@ -20,23 +20,23 @@ service.interceptors.request.use(
// let each request carry token // let each request carry token
// ['X-Token'] is a custom headers key // ['X-Token'] is a custom headers key
// please modify it according to the actual situation // please modify it according to the actual situation
config.headers['Authorization'] = `bearer ${getToken()}` config.headers["Authorization"] = `bearer ${getToken()}`;
} }
return config return config;
}, },
error => { error => {
// do something with request error // do something with request error
console.log(error) // for debug console.log(error); // for debug
return Promise.reject(error) return Promise.reject(error);
} }
) );
// response interceptor // response interceptor
service.interceptors.response.use( service.interceptors.response.use(
/** /**
* If you want to get http information such as headers or status * If you want to get http information such as headers or status
* Please return response => response * Please return response => response
*/ */
/** /**
* Determine the request status by custom code * Determine the request status by custom code
@ -44,22 +44,17 @@ service.interceptors.response.use(
* You can also judge the status by HTTP Status Code * You can also judge the status by HTTP Status Code
*/ */
response => { response => {
const res = response.data const res = response.data;
// if the custom code is not 20000, it is judged as an error. // if the custom code is not 20000, it is judged as an error.
if (res.c !== 200) { if (res.c !== 200) {
if (res.c === 500) { if (res.c === 500) {
// console.log(123);
Message({ Message({
message: errorCodeMap(res.c), message: errorCodeMap(res.c),
type: 'error', type: "error",
duration: 5 * 1000 duration: 5 * 1000
}) });
} else {
Message({
message: res.m || 'Error',
type: 'error',
duration: 5 * 1000
})
} }
// 50008: Illegal token; 50012: Other clients logged in; 50014: Token expired; // 50008: Illegal token; 50012: Other clients logged in; 50014: Token expired;
@ -74,21 +69,22 @@ service.interceptors.response.use(
location.reload() location.reload()
}) })
}) })
} }
return Promise.reject(new Error(res.data.m || 'Error')) // return Promise.reject(new Error(res.data.m || "Error"));
return Promise.reject(new Error(errorCodeMap(res.c)||"Error"))
} else { } else {
return res return res;
} }
}, },
error => { error => {
console.log('err' + error) // for debug console.log("err" + error); // for debug
Message({ Message({
message: '服务器连接失败,请稍后重试', message: "服务器连接失败,请稍后重试",
type: 'error', type: "error",
duration: 5 * 1000 duration: 5 * 1000
}) });
return Promise.reject(error) return Promise.reject(error);
} }
) );
export default service export default service;

View File

@ -33,6 +33,13 @@
<el-row :gutter="20"> <el-row :gutter="20">
<el-col :xs="24" :lg="24" :sm="24" style="color:#787878;margin-bottom:20px" <el-col :xs="24" :lg="24" :sm="24" style="color:#787878;margin-bottom:20px"
><span>数据统计</span ><span>数据统计</span
><el-button
v-has="'WORKORDER_ADMIN'"
type="primary"
target="blank"
@click="toTj"
style="border-radius:21px;margin-left:10px"
>统计图表</el-button
><span style="float:right" ><span style="float:right"
>更新时间{{ new Date() | parseTime("{y}-{m}-{d} {h}:00:00") }}</span >更新时间{{ new Date() | parseTime("{y}-{m}-{d} {h}:00:00") }}</span
></el-col ></el-col
@ -93,30 +100,30 @@ export default {
// } // }
getStatisticalData() { getStatisticalData() {
statisticalData(this.listQuery).then(res => { statisticalData(this.listQuery).then(res => {
this.statisticalData = { // this.statisticalData = {
all: 318, // all: 318,
平均办结时间: 61722, // : 61722,
平均受理时间: 22349, // : 22349,
未受理量: 0, // : 0,
未受理率: 0, // : 0,
按时受理量: 318, // : 318,
按时受理率: 1.0, // : 1.0,
超时受理量: 0, // : 0,
超时受理率: 0.0, // : 0.0,
按时办结量: 307, // : 307,
按时办结率: 1.0, // : 1.0,
超时办结量: 0, // : 0,
超时办结率: 0.0, // : 0.0,
未办结量: 11, // : 11,
未办结率: 0.0346, // : 0.0346,
非常满意量: 274, // : 274,
非常满意率: 0.8925, // : 0.8925,
满意量: 33, // : 33,
满意率: 0.1075, // : 0.1075,
不满意量: 0, // : 0,
不满意率: 0.0 // : 0.0
}; // };
// this.statisticalData = res.d; this.statisticalData = res.d;
}); });
}, },
formatUnit(key, value) { formatUnit(key, value) {
@ -147,6 +154,10 @@ export default {
: Math.floor(((timeStamp % 86400) % 3600) % 60) : Math.floor(((timeStamp % 86400) % 3600) % 60)
}`; }`;
return timeStr; return timeStr;
},
toTj(){
window.open('http://new.rtmedia.myntv.cn/static/largeScreen/leaderForTv.html')
console.log(window);
} }
} }
}; };

View File

@ -126,10 +126,10 @@ export default {
// password: '111111' // password: '111111'
// }, // },
loginForm: { loginForm: {
// username: "", //18882564006 username: "", //18882564006
// captcha: "", captcha: "",
username: "18882564006", //18882564006 //username: "18882564006", //18882564006
captcha: "111111", //captcha: "111111",
appVersion: "1.0.0", appVersion: "1.0.0",
system: "IOS", system: "IOS",
device: navigator.userAgent, device: navigator.userAgent,
@ -224,19 +224,21 @@ export default {
"basic YW5kcm9pZC1jbGllbnQ6YW5kcm9pZC1zZWNyZXQtMjAyMA==" "basic YW5kcm9pZC1jbGllbnQ6YW5kcm9pZC1zZWNyZXQtMjAyMA=="
} }
}).then(res => { }).then(res => {
console.log(res); // console.log(res);
if (res.data.c === 200) { if (res.data.c === 200) {
this.$store.dispatch("user/setToken", res.data.d.access_token); this.$store.dispatch("user/setToken", res.data.d.access_token);
this.$router.push({ this.$router.push({
path: this.redirect || "/", path: this.redirect || "/",
query: this.otherQuery query: this.otherQuery
}); });
this.$notify({ // if (res.data.c === 200) {
title: "成功", // this.$notify({
message: "登录成功", // title: "",
type: "success", // message: "",
duration: 2000 // type: "success",
}); // duration: 2000
// });
// }
} else { } else {
this.$notify.error(res.data.m); this.$notify.error(res.data.m);
} }

View File

@ -253,6 +253,7 @@
value="RESIDENT_SET_ADMIN" value="RESIDENT_SET_ADMIN"
></el-option> ></el-option>
<el-option label="居民管理" value="RESIDENT_ADMIN"></el-option> <el-option label="居民管理" value="RESIDENT_ADMIN"></el-option>
<el-option label="地区领导" value="WORKORDER_ADMIN"></el-option>
</el-select> </el-select>
</el-form-item> </el-form-item>
</el-col> </el-col>