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

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'
export function getToken() {
return Cookies.get(TokenKey)
// return Cookies.get(TokenKey)
return localStorage.getItem(TokenKey)
}
export function setToken(token) {
return Cookies.set(TokenKey, token)
// return Cookies.set(TokenKey, token)
return localStorage.setItem(TokenKey,token)
}
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: '账号验证不通过',
200103: '账号已被禁用',
200010: '权限资源不存在',
401: '未经授权',
401: '未在APP进行实名认证,暂无访问权限',
403: '无访问权限',
404: '接口不存在',
400001: '请求参数错误',

View File

@ -1,15 +1,15 @@
import axios from 'axios'
import { MessageBox, Message } from 'element-ui'
import store from '@/store'
import { getToken } from '@/utils/auth'
import { errorCodeMap } from '@/utils/index'
import axios from "axios";
import { MessageBox, Message } from "element-ui";
import store from "@/store";
import { getToken } from "@/utils/auth";
import { errorCodeMap } from "@/utils/index";
// 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(
@ -20,23 +20,23 @@ service.interceptors.request.use(
// let each request carry token
// ['X-Token'] is a custom headers key
// please modify it according to the actual situation
config.headers['Authorization'] = `bearer ${getToken()}`
config.headers["Authorization"] = `bearer ${getToken()}`;
}
return config
return config;
},
error => {
// do something with request error
console.log(error) // for debug
return Promise.reject(error)
console.log(error); // for debug
return Promise.reject(error);
}
)
);
// response interceptor
service.interceptors.response.use(
/**
* If you want to get http information such as headers or status
* Please return response => response
*/
*/
/**
* 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
*/
response => {
const res = response.data
const res = response.data;
// if the custom code is not 20000, it is judged as an error.
if (res.c !== 200) {
if (res.c === 500) {
// console.log(123);
Message({
message: errorCodeMap(res.c),
type: 'error',
type: "error",
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;
@ -75,20 +70,21 @@ service.interceptors.response.use(
})
})
}
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 {
return res
return res;
}
},
error => {
console.log('err' + error) // for debug
console.log("err" + error); // for debug
Message({
message: '服务器连接失败,请稍后重试',
type: 'error',
message: "服务器连接失败,请稍后重试",
type: "error",
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-col :xs="24" :lg="24" :sm="24" style="color:#787878;margin-bottom:20px"
><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"
>更新时间{{ new Date() | parseTime("{y}-{m}-{d} {h}:00:00") }}</span
></el-col
@ -93,30 +100,30 @@ export default {
// }
getStatisticalData() {
statisticalData(this.listQuery).then(res => {
this.statisticalData = {
all: 318,
平均办结时间: 61722,
平均受理时间: 22349,
未受理量: 0,
未受理率: 0,
按时受理量: 318,
按时受理率: 1.0,
超时受理量: 0,
超时受理率: 0.0,
按时办结量: 307,
按时办结率: 1.0,
超时办结量: 0,
超时办结率: 0.0,
未办结量: 11,
未办结率: 0.0346,
非常满意量: 274,
非常满意率: 0.8925,
满意量: 33,
满意率: 0.1075,
不满意量: 0,
不满意率: 0.0
};
// this.statisticalData = res.d;
// this.statisticalData = {
// all: 318,
// : 61722,
// : 22349,
// : 0,
// : 0,
// : 318,
// : 1.0,
// : 0,
// : 0.0,
// : 307,
// : 1.0,
// : 0,
// : 0.0,
// : 11,
// : 0.0346,
// : 274,
// : 0.8925,
// : 33,
// : 0.1075,
// : 0,
// : 0.0
// };
this.statisticalData = res.d;
});
},
formatUnit(key, value) {
@ -147,6 +154,10 @@ export default {
: Math.floor(((timeStamp % 86400) % 3600) % 60)
}`;
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'
// },
loginForm: {
// username: "", //18882564006
// captcha: "",
username: "18882564006", //18882564006
captcha: "111111",
username: "", //18882564006
captcha: "",
//username: "18882564006", //18882564006
//captcha: "111111",
appVersion: "1.0.0",
system: "IOS",
device: navigator.userAgent,
@ -224,19 +224,21 @@ export default {
"basic YW5kcm9pZC1jbGllbnQ6YW5kcm9pZC1zZWNyZXQtMjAyMA=="
}
}).then(res => {
console.log(res);
// console.log(res);
if (res.data.c === 200) {
this.$store.dispatch("user/setToken", res.data.d.access_token);
this.$router.push({
path: this.redirect || "/",
query: this.otherQuery
});
this.$notify({
title: "成功",
message: "登录成功",
type: "success",
duration: 2000
});
// if (res.data.c === 200) {
// this.$notify({
// title: "",
// message: "",
// type: "success",
// duration: 2000
// });
// }
} else {
this.$notify.error(res.data.m);
}

View File

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