Commit e1466a36 by li_hongchao

网络请求整合封装

比中信息审核按新框架改造
parent 57414ac7
......@@ -7,195 +7,215 @@
* @FilePath: \指纹系统\founder_vue\src\App.vue
-->
<template>
<div id="app">
<router-view v-wechat-title="$route.meta.title"></router-view>
</div>
<div id="app">
<router-view v-wechat-title="$route.meta.title"></router-view>
</div>
</template>
<script>
export default {
created() {
logger.logo()
// console.log(document.body.scrollHeight)
var lett = this;
var lett = this
document.onkeydown = function (e) {
var key = window.event.keyCode;
var key = window.event.keyCode
if (key == 13) {
lett.$bus.emit("enter");
lett.$bus.emit('enter')
}
};
}
},
};
}
</script>
<style lang="scss">
/*每个页面公共css */
@import "assets/styles/main.scss";
#app {
height: 100%;
margin: 0;
padding: 0;
box-sizing: border-box;
}
@font-face {
font-family: "MicrosoftYaHei-Bold";
src: url("../src/assets/font/MSYHBD.ttf") format("truetype");
}
@font-face {
font-family: "MicrosoftYaHei";
src: url("../src/assets/font/MSYH.ttf") format("truetype");
}
.boxShadow {
position: fixed;
width: 100%;
height: 100%;
top: 0;
left: 0;
// background: url('~@/assets/img/shadow.png') 0 0 / cover;
z-index: -100;
opacity: 0.65;
}
// 滚动条的宽度
/deep/ .el-table__body-wrapper::-webkit-scrollbar {
width: 6px; // 横向滚动条
height: 6px; // 纵向滚动条 必写
}
.el-message {
z-index: 999999 !important;
}
// 滚动条的滑块
/deep/ .el-table__body-wrapper::-webkit-scrollbar-thumb {
background-color: #dadde0;
border-radius: 3px;
}
// 表头
/deep/ .has-gutter {
font-weight: normal;
th {
font-size: 14px;
font-family: MicrosoftYaHei;
color: #282f3c;
font-weight: normal;
}
}
// 修改多选框样式
/deep/ .el-checkbox.is-checked {
.el-checkbox__label {
color: #333333;
}
.el-checkbox__input.is-checked {
.el-checkbox__inner {
background: #055fe7;
border-color: #055fe7;
}
}
}
/*每个页面公共css */
@import "assets/styles/main.scss";
#app {
height: 100%;
margin: 0;
padding: 0;
box-sizing: border-box;
}
@font-face {
font-family: "MicrosoftYaHei-Bold";
src: url("../src/assets/font/MSYHBD.ttf") format("truetype");
}
@font-face {
font-family: "MicrosoftYaHei";
src: url("../src/assets/font/MSYH.ttf") format("truetype");
}
.boxShadow {
position: fixed;
width: 100%;
height: 100%;
top: 0;
left: 0;
// background: url('~@/assets/img/shadow.png') 0 0 / cover;
z-index: -100;
opacity: 0.65;
}
// 滚动条的宽度
/deep/ .el-table__body-wrapper::-webkit-scrollbar {
width: 6px; // 横向滚动条
height: 6px; // 纵向滚动条 必写
}
.el-message {
z-index: 999999 !important;
}
// 滚动条的滑块
/deep/ .el-table__body-wrapper::-webkit-scrollbar-thumb {
background-color: #dadde0;
border-radius: 3px;
}
// 表头
/deep/ .has-gutter {
font-weight: normal;
th {
font-size: 14px;
font-family: MicrosoftYaHei;
color: #282f3c;
font-weight: normal;
}
}
// 修改多选框样式
/deep/ .el-checkbox.is-checked {
.el-checkbox__label {
color: #333333;
}
.el-checkbox__input.is-checked {
.el-checkbox__inner {
background: #055fe7;
border-color: #055fe7;
}
}
}
</style>
<style lang="scss">
/deep/.el-message {
justify-content: flex-start !important;
}
/deep/ .el-message {
justify-content: flex-start !important;
}
.el-message-box__message {
margin: 23px 24px 17px 24px;
font-size: 14px;
font-family: MicrosoftYaHei;
color: #333333;
p {
line-height: 4rem !important;
}
}
.el-message-box__btns {
margin-bottom: 24px;
padding-bottom: 24px;
// 交换 确定 取消 按钮的位置
.el-button:nth-child(1) {
float: right;
margin-right: 23%;
width: 72px;
height: 40px;
background: #055fe7;
border-radius: 4px;
font-size: 14px;
font-family: MicrosoftYaHei;
color: #ffffff;
}
.el-button:nth-child(2) {
float: left;
margin-left: 23%;
width: 72px;
height: 40px;
background: #ffffff;
border-radius: 4px;
border: 1px solid #aeb5c2;
font-size: 14px;
font-family: MicrosoftYaHei;
color: #2e3846;
}
}
.screenSave {
margin-right: 0 !important;
// background: #ffffff!important;
// border-radius: 4px!important;
// border: 1px solid #aeb5c2!important;
// font-size: 14px!important;
// font-family: MicrosoftYaHei!important;
// color: #2e3846!important;
}
.el-message-box {
position: relative;
display: inline-block;
width: 26.25rem;
padding-bottom: 0.625rem;
vertical-align: middle;
background-color: #fff;
border-radius: 0.25rem;
border: 0.0625rem solid #ebeef5;
font-size: 1.125rem;
-webkit-box-shadow: 0 0.125rem 0.75rem 0 rgba(0, 0, 0, 0.1);
box-shadow: 0 0.125rem 0.75rem 0 rgba(0, 0, 0, 0.1);
text-align: left;
overflow: hidden;
-webkit-backface-visibility: hidden;
backface-visibility: hidden;
z-index: 99999;
}
.el-message-box__status {
display: none !important;
}
.el-popconfirm__main {
margin: 23px 24px 17px 24px;
font-size: 14px;
font-family: MicrosoftYaHei;
color: #333333;
}
.el-popconfirm__action {
margin-bottom: 24px;
padding-bottom: 24px;
// 交换 确定 取消 按钮的位置
.el-button:nth-child(1) {
float: right;
margin-right: 23%;
width: 72px;
height: 32px;
background: #055fe7;
border-radius: 4px;
font-size: 14px;
font-family: MicrosoftYaHei;
color: #ffffff;
}
.el-button:nth-child(2) {
float: left;
margin-left: 23%;
width: 72px;
height: 32px;
background: #ffffff;
border-radius: 4px;
border: 1px solid #aeb5c2;
font-size: 14px;
font-family: MicrosoftYaHei;
color: #2e3846;
}
}
.el-message-box__message {
margin: 23px 24px 17px 24px;
font-size: 14px;
font-family: MicrosoftYaHei;
color: #333333;
p {
line-height: 4rem !important;
}
}
.el-message-box__btns {
margin-bottom: 24px;
padding-bottom: 24px;
// 交换 确定 取消 按钮的位置
.el-button:nth-child(1) {
float: right;
margin-right: 23%;
width: 72px;
height: 40px;
background: #055fe7;
border-radius: 4px;
font-size: 14px;
font-family: MicrosoftYaHei;
color: #ffffff;
}
.el-button:nth-child(2) {
float: left;
margin-left: 23%;
width: 72px;
height: 40px;
background: #ffffff;
border-radius: 4px;
border: 1px solid #aeb5c2;
font-size: 14px;
font-family: MicrosoftYaHei;
color: #2e3846;
}
}
.screenSave {
margin-right: 0 !important;
// background: #ffffff!important;
// border-radius: 4px!important;
// border: 1px solid #aeb5c2!important;
// font-size: 14px!important;
// font-family: MicrosoftYaHei!important;
// color: #2e3846!important;
}
.el-message-box {
position: relative;
display: inline-block;
width: 26.25rem;
padding-bottom: 0.625rem;
vertical-align: middle;
background-color: #fff;
border-radius: 0.25rem;
border: 0.0625rem solid #ebeef5;
font-size: 1.125rem;
-webkit-box-shadow: 0 0.125rem 0.75rem 0 rgba(0, 0, 0, 0.1);
box-shadow: 0 0.125rem 0.75rem 0 rgba(0, 0, 0, 0.1);
text-align: left;
overflow: hidden;
-webkit-backface-visibility: hidden;
backface-visibility: hidden;
z-index: 99999;
}
.el-message-box__status {
display: none !important;
}
.el-popconfirm__main {
margin: 23px 24px 17px 24px;
font-size: 14px;
font-family: MicrosoftYaHei;
color: #333333;
}
.el-popconfirm__action {
margin-bottom: 24px;
padding-bottom: 24px;
// 交换 确定 取消 按钮的位置
.el-button:nth-child(1) {
float: right;
margin-right: 23%;
width: 72px;
height: 32px;
background: #055fe7;
border-radius: 4px;
font-size: 14px;
font-family: MicrosoftYaHei;
color: #ffffff;
}
.el-button:nth-child(2) {
float: left;
margin-left: 23%;
width: 72px;
height: 32px;
background: #ffffff;
border-radius: 4px;
border: 1px solid #aeb5c2;
font-size: 14px;
font-family: MicrosoftYaHei;
color: #2e3846;
}
}
</style>
......@@ -8,6 +8,8 @@
*/
import Vue from 'vue'
import './plugins/axios'
import fHttp from './request/http.js'
import NetUtil from './netmgr/NetUtil'
import App from './App.vue'
import router from './router'
import store from './store'
......@@ -65,6 +67,8 @@ Vue.prototype.$util = Util
window.util = Util
window.logger = LoggerUtil
window.user = UserUtil
window.fHttp = fHttp
window.NetUtil = NetUtil
Vue.use(VueWechatTitle)
Vue.use(VueClipboard)
Vue.use(VueBus)
......
const api = {
api: '/api',
security: '/security'
}
export default api
import bzxxsh from '../netmgr/bzxxgl/bzxxsh'
export default {
bzxxsh
}
const api = {
bzxxsh: '/api/hit',
}
export default api
import addrType from '../../netmgr/NetAddressType'
export function queryShList(_that, _parameter) {
return _that.$axios({
method: 'post',
url: api.bzxxsh + '/queryAllSh',
headers: {
'Content-Type': 'application/json'
},
data: _parameter
})
const _path = {
bzxxsh: addrType.api + '/hit',
}
export default {
shList(_parameter) {
return fHttp.postJson(_path.bzxxsh + '/queryAllSh', _parameter)
},
sh(_parameter) {
return fHttp.postJson(_path.bzxxsh + '/udateShzt', _parameter)
},
export function bzxxSh(_that, _parameter) {
return _that.$axios({
method: 'post',
url: api.bzxxsh + '/udateShzt',
headers: {
'Content-Type': 'application/json'
},
data: _parameter
})
}
updateJrzg(_parameter) {
return fHttp.postJson(_path.bzxxsh + '/updateJrzg', _parameter)
},
export function bzxxZg(_that, _parameter) {
return _that.$axios({
method: 'post',
url: api.bzxxsh + '/updateJrzg',
headers: {
'Content-Type': 'application/json'
},
data: _parameter
})
}
plsb(_parameter) { // 批量上报
return fHttp.postJson(_path.bzxxsh + '/insertBeach', _parameter)
},
export function bzxxPlSb(_that, _parameter) { // 批量上报
return _that.$axios({
method: 'post',
url: api.bzxxsh + '/insertBeach',
headers: {
'Content-Type': 'application/json'
},
data: _parameter
})
}
......@@ -98,7 +98,6 @@ _axios.interceptors.response.use(
if (error) {
hideLoading();
}
// NProgress.done();
return Promise.reject(error);
}
);
......
import axios from 'axios'
import {Message, MessageBox} from 'element-ui'
import qs from 'qs'
import {ACCESS_TOKEN} from '../store/mutation-types'
import router from '../router'
import {showLoading, hideLoading} from '@/utils/requestLoading'
// debugger
axios.defaults.timeout = 0
axios.defaults.headers = {
'X-Requested-With': 'XMLHttpRequest',
'Content-Type': 'application/json'
}
axios.defaults.responseType = 'json'
var instance = axios.create({// post 常规请求
headers: {
'Content-Type': 'multipart/form-data'
}
})
var json = axios.create({ // post json
headers: {
'Content-Type': 'application/json'
}
})
var down = axios.create({ // 文件下载
headers: {
'Content-Type': 'application/json'
},
})
// 初始化参数
let initConfig = (config) => {
if (config.url.indexOf('/login/myLoginForm') <= 0) {
const token = localStorage.getItem(ACCESS_TOKEN)
if (token) {
config.headers['Authorization'] = token // 让每个请求携带自定义 token 请根据实际情况自行修改
config.headers.BrowserHeader = 'H5'
}
}
config.cancelToken = new axios.CancelToken(cancel => {
if (!window._axiosPromiseArr) {
window._axiosPromiseArr = []
}
window._axiosPromiseArr.push({cancel})
})
// 判断当前请求是否设置了不显示Loading,默认显示
if (config.loading !== false) {
showLoading(config.loadingTarget) // 如果设置了targer,使用设置的target,比如el-table
}
// console.log('initConfig', config)
return config
}
let onError = (error) => {
if (error) {
hideLoading()
}
let result = {
code: -1,
message: ''
}
if (error.toString().indexOf('400') > 0) {
result.code = 400
result.message = '失败(400):客户端错误!'
} else if (error.toString().indexOf('403') > 0) {
result.code = 403
result.message = '失败(403):您的权限不足!'
} else if (error.toString().indexOf('404') > 0) {
result.code = 404
result.message = '失败(404):网络请求不存在!'
} else if (error.toString().indexOf('500') > 0) {
result.code = 500
result.message = '失败(500):服务器异常!'
} else if (error.toString().indexOf('501') > 0) {
result.code = 501
result.message = '失败(501):您的操作被取消或不允许提交!'
} else if (error.toString().indexOf('timeout') > 0) {
result.code = -1
result.message = '请求超时,请检查网络连接!'
} else if (error.toString().indexOf('Cancel') > 0) {
result.code = -1
result.message = '取消请求成功!'
} else {// 其他未知异常
result.code = -1
result.message = '未知错误:' + error.toString()
}
let errorMsg = error + '-------' + result.message
// Promise.reject(new Error(errorMsg))
logger.error(errorMsg)
return result
}
let onResponse = (response) => {
if (!response) return
if (response.headers && response.headers.token) localStorage.setItem(ACCESS_TOKEN, response.headers.token)
if (response.config && response.config.loading !== false) hideLoading(response.config.loadingTarget)
let status = response.data.code
let message = response.data.message
if (status === 0) {
// return response.data
} else if (status === '200') {
response.data.code = 0
} else if (status === 401) {
response.data.message = message === '未登录' ? '登陆超时,请重新登录!' : message
} else {
response.data.message = '未知异常:' + message
}
return response.data
}
// request 请求拦截器
axios.interceptors.request.use(
config => {
config.headers['Content-Type'] = 'application/json'
config = initConfig(config)
return config
}, onError)
// response 响应拦截器
axios.interceptors.response.use(onResponse, onError)
instance.interceptors.request.use(
config => {
config = initConfig(config)
return config
}, onError)
instance.interceptors.response.use(onResponse, onError)
json.interceptors.request.use(
config => {
config.headers['Content-Type'] = 'application/json'
config = initConfig(config)
return config
}, onError)
json.interceptors.response.use(onResponse, onError)
var resTimer
let handleError = (response) => {
if (!response) return
let code = response.code
let message = response.message
switch (code) {
case 401:
if (resTimer) clearTimeout(resTimer)
resTimer = setTimeout(() => {
hideLoading()
MessageBox.confirm(message, '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
confirmButtonClass: 'screenSave',
closeOnPressEscape: false,
closeOnClickModal: false,
showCancelButton: false,
showClose: false,
type: 'warning'
}).then(() => {
localStorage.removeItem('token')
router.replace('/Login')
}).catch(() => {
})
}, 500)
break
}
Message({
message: message,
type: 'error'
})
}
let parseResponse = (resolve, reject, response) => {
if (response && response.code === 0) {
resolve(response)
} else {
handleError(response)
resolve(response)
}
}
export default {
/**
* 封装get方法
*/
get(url, params) {
return new Promise((resolve, reject) => {
axios
.get(url, {
params: params
})
.then(response => {
logger.net(data, url, response)
parseResponse(resolve, reject, response)
})
.catch(err => {
Promise.reject(err)
})
})
},
/**
* 封装post请求
*/
post(url, params) {
return new Promise((resolve, reject) => {
axios.post(url, qs.stringify(params))
.then(response => {
logger.net(data, url, response)
parseResponse(resolve, reject, response)
})
.catch(err => {
Promise.reject(err)
})
})
},
/**
* 封装post请求 multipart/form-data
*/
postform(url, data) {
return new Promise((resolve, reject) => {
instance.post(url, data).then(response => {
logger.net(data, url, response)
parseResponse(resolve, reject, response)
})
}).catch(err => {
Promise.reject(err)
})
},
/**
* 封装post请求 文件下载
*/
postdown(url, data) {
return new Promise((resolve, reject) => {
down.post(url, data).then(response => {
logger.net(data, url, response)
parseResponse(resolve, reject, response)
})
}).catch(err => {
Promise.reject(err)
})
},
/**
* 封装post请求 json格式
*/
postJson(url, data) {
return new Promise((resolve, reject) => {
json.post(url, data).then(response => {
logger.net(data, url, response)
parseResponse(resolve, reject, response)
})
}).catch(err => {
Promise.reject(err)
})
},
cancel() {// 取消当前网络请求
if (window._axiosPromiseArr) {
window._axiosPromiseArr.forEach((ele, index) => {// 切换路由时,关闭当前页面请求
if (ele) {
ele.cancel()
delete window._axiosPromiseArr[index]
}
})
}
},
// get, post, postform, postdown, postJson
}
......@@ -6,45 +6,45 @@
* @Description: In User Settings Edit
* @FilePath: \指纹系统\founder_vue\src\router\index.js
*/
import Vue from "vue";
import VueRouter from "vue-router";
import store from "../store";
import { getToken } from "../utils/auth";
import { Message } from "element-ui";
import indexRoutes from "./modules/index";
import Vue from 'vue'
import VueRouter from 'vue-router'
import store from '../store'
import {getToken} from '../utils/auth'
import {Message} from 'element-ui'
import indexRoutes from './modules/index'
const originalPush = VueRouter.prototype.push;
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
if (location && typeof location == "string" && location.indexOf("http") != -1)
return window.location.open(location, "_self");
return originalPush.call(this, location).catch(err => err);
};
if (location && typeof location == 'string' && location.indexOf('http') != -1)
return window.location.open(location, '_self')
return originalPush.call(this, location).catch(err => err)
}
const originalResolve = VueRouter.prototype.resolve;
const originalResolve = VueRouter.prototype.resolve
VueRouter.prototype.pushToTab = function pushToTab(location) {
if (!location) return;
if (location && typeof location == "string" && location.indexOf("http") != -1)
return window.open(location, "_blank");
const { href } = originalResolve.call(this, location);
window.open(href, "_blank");
};
if (!location) return
if (location && typeof location == 'string' && location.indexOf('http') != -1)
return window.open(location, '_blank')
const {href} = originalResolve.call(this, location)
window.open(href, '_blank')
}
Vue.use(VueRouter);
Vue.use(VueRouter)
const mainRouters = [
...indexRoutes,
{
path: "*",
name: "error",
component: () => import("@/views/index/error.vue")
path: '*',
name: 'error',
component: () => import('@/views/index/error.vue')
},
];
]
const router = new VueRouter({
// mode: "history",
// base: process.env.BASE_URL,
routes: mainRouters
});
})
// router.beforeEach((to, from, next) => {
// const token = getToken();
......@@ -66,24 +66,34 @@ const router = new VueRouter({
// });
router.beforeEach((to, from, next) => {
// if(window._axiosPromiseArr){
// window._axiosPromiseArr.forEach((ele, index) => {// 切换路由时,关闭当前页面请求
// if (ele) {
// ele.cancel()
// delete window._axiosPromiseArr[index]
// }
// })
// }
fHttp.cancel() // 切换路由时,关闭当前页面所有请求
if (from.name == 'ryzwbj' || from.name == 'ajzwbj') {
sessionStorage.clear()
}
store.commit('loading/setPreRoute', from.name)
let token = localStorage.getItem('token');
let token = localStorage.getItem('token')
if (to.path != '/Login' && to.path != '/') {
if (token) {
next();
next()
} else {
next('/Login')
}
} else {
if (localStorage.getItem('token')) {
next('/index');
}else{
next();
next('/index')
} else {
next()
}
}
})
export default router;
export default router
export const ACCESS_TOKEN = 'token'
export const USER_TYPE = 'userInfo'
// export const CONTENT_WIDTH_TYPE = {
// Fluid: 'Fluid',
// Fixed: 'Fixed'
// }
export default function PrintLog(title, content, tag) {
if (!title && !content) {
return
}
if (!tag) {
tag = '^_^'
}
// console.log('')
console.log('----------------------------' + tag + '----------------------------')
if (title && content) {
console.log(' 标题:', title)
console.log(' 内容:', content)
} else if (title) {
console.log(' ', title)
} else if (content) {
console.log(' ', content)
}
console.log('----------------------------' + tag + '----------------------------')
console.log('')
}
export function PrintNetInfo(url, request, response) {
var tag = '^_^'
// console.log('')
console.log('----------------------------' + tag + '----------------------------')
if (url) {
console.log(' 请求接口:', url)
}
if (request) {
console.log(' 请求参数:', request)
}
if (response) {
console.log(' 请求结果:', response)
}
console.log('----------------------------' + tag + '----------------------------')
console.log('')
}
......@@ -76,23 +76,52 @@ const _LOGO3 = '
' \n' +
' '
const LOGOS = {_LOGO1, _LOGO2, _LOGO3}
const LOGOS = [_LOGO1, _LOGO2, _LOGO3]
export default {
net(request, url, response) {
if (!this.isOpenLog()) return
console.log(TOP_LEFT_CORNER + DOUBLE_DIVIDER)
console.log(HORIZONTAL_LINE + ' ' + url)
console.log(MIDDLE_CORNER + SINGLE_DIVIDER)
console.log(HORIZONTAL_LINE + ' ' + formatJson(request))
console.log(MIDDLE_CORNER + SINGLE_DIVIDER)
console.log(HORIZONTAL_LINE + ' ' + formatJson(response))
console.log(BOTTOM_LEFT_CORNER + DOUBLE_DIVIDER)
},
json(val) {
// console.log('json', Math.random() * 3)
if (!this.isOpenLog()) return
console.log(TOP_LEFT_CORNER + DOUBLE_DIVIDER)
console.info(formatJson(val))
console.log(BOTTOM_LEFT_CORNER + DOUBLE_DIVIDER)
},
info(tag, val) {
if (!this.isOpenLog()) return
if (val) {
console.log(tag, TOP_LEFT_CORNER + DOUBLE_DIVIDER)
console.log(tag + ' '+ HORIZONTAL_LINE , val)
console.log(tag, BOTTOM_LEFT_CORNER + DOUBLE_DIVIDER)
} else {
console.log(TOP_LEFT_CORNER + DOUBLE_DIVIDER)
console.log(HORIZONTAL_LINE + ' ', tag)
console.log(BOTTOM_LEFT_CORNER + DOUBLE_DIVIDER)
}
},
error(val) {
if (!this.isOpenLog()) return
console.error(TOP_LEFT_CORNER + DOUBLE_DIVIDER)
console.error(HORIZONTAL_LINE + ' ' + val)
console.error(BOTTOM_LEFT_CORNER + DOUBLE_DIVIDER)
},
logo() {
Math.random() * 3
let index = Math.floor((Math.random() * LOGOS.length))
console.log(LOGOS[index])
},
isOpenLog() {
return true
return process.env.NODE_ENV === 'development' ? true : false
}
}
......@@ -102,8 +131,8 @@ const TOP_LEFT_CORNER = '┌'
const BOTTOM_LEFT_CORNER = '└'
const MIDDLE_CORNER = '├'
const HORIZONTAL_LINE = '│'
const DOUBLE_DIVIDER = '────────────────────────────────────────────────────────'
const SINGLE_DIVIDER = '┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄'
const DOUBLE_DIVIDER = '──────────────────────────────────────────────────────────────────────────────────────'
const SINGLE_DIVIDER = '┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄'
var formatJson = function (json, options) {
var reg = null,
......
import PrintLog from './LogcatUtil'
const _DEFAULT_KEYS = [
'公安厅',
......@@ -10,7 +9,7 @@ const _DEFAULT_KEYS = [
'中队',
]
const _TAG = '\\src\\utils\\LogcatUtil.js'
const _TAG = 'src/utils/ZzjgUtil.js'
export default {
......@@ -47,15 +46,15 @@ export default {
let parseStr = function (keyArrs, content) {
if (!keyArrs) {
if (isOpenLogger()) PrintLog('解析关键字', '解析关键字为空', _TAG)
if (isOpenLogger()) logger.info('解析关键字', '解析关键字为空', _TAG)
return []
}
if (!content || content === '' || content === 'null') {
if (isOpenLogger()) PrintLog('解析内容', '解析内容为空', _TAG)
if (isOpenLogger()) logger.info('解析内容', '解析内容为空', _TAG)
return []
}
if (isOpenLogger()) PrintLog('解析关键字', keyArrs, _TAG)
if (isOpenLogger()) PrintLog('解析内容', content, _TAG)
if (isOpenLogger()) logger.info('解析关键字', keyArrs, _TAG)
if (isOpenLogger()) logger.info('解析内容', content, _TAG)
let arrs = []
let temp = content
......@@ -79,7 +78,7 @@ let parseStr = function (keyArrs, content) {
if (arrs.length === 0) {
arrs.push(content)
}
if (isOpenLogger()) PrintLog('解析结果', arrs, _TAG)
if (isOpenLogger()) logger.info('解析结果', arrs, _TAG)
return arrs
}
......
......@@ -47,17 +47,7 @@ axios.interceptors.response.use(
type: "warning",
})
.then(() => {
if (relUrlIp == '47.92.225.109') {
// window.open('http://47.92.225.109:8300/#/login', '_blank')
window.location.href = 'http://47.92.225.109:8300/#/login';
} else if (relUrlIp == '26.3.13.120') {
window.location.href = 'http://26.3.13.120:8050/#/login';
} else if (relUrlIp == '10.142.16.177') {
window.location.href = 'http://10.142.16.177:8050/#/login';
} else {
// window.open('http://localhost:8080/#/login', '_blank')
window.location.href = 'http://localhost:8080/#/login';
}
})
}
if (status < 0) {
......@@ -151,9 +141,6 @@ export function postform (url, data) {
/**
* 封装post请求 文件下载
* @param url
* @param data
* @returns {Promise}
*/
export function postdown (url, data) {
return new Promise((resolve, reject) => {
......
......@@ -41,8 +41,6 @@
</template>
<script>
import PrintLog from '../../utils/LogcatUtil'
import {bzxxPlSb, bzxxSh, bzxxZg} from '../../netmgr/bzxxgl/bzxxsh'
export default {
name: 'BzxxsfOpt',
......@@ -146,7 +144,7 @@ export default {
init() {
var _that = this
_that.isStRole = _that.isSt
console.log('bzxxsfOpt-isSt', _that.isSt)
// logger.info('bzxxsfOpt-isSt', _that.isSt)
_that.initShItem()
},
/**
......@@ -236,8 +234,6 @@ export default {
break
}
console.log('ruleForm @@@@@@@@@@@@@@@@@@@@@@@', _that.parentRuleForm)
if (_path) {
let query = {
isFromSh: 'true',
......@@ -347,7 +343,7 @@ export default {
doSh(fhzt, shzt, desc = '') {
let TITLE = '审核'
let _that = this
PrintLog('item:', JSON.stringify(_that.shInfo))
logger.info('item:', JSON.stringify(_that.shInfo))
var ruleForm = {}
ruleForm.querytype = _that.shInfo.querytype
ruleForm.id = _that.shInfo.id
......@@ -356,20 +352,30 @@ export default {
ruleForm.des = desc
ruleForm.level = _that.getLevel()
PrintLog(TITLE + '请求参数', ruleForm)
// PrintLog(TITLE + '请求参数', ruleForm)
bzxxSh(_that, ruleForm).then(res => {
PrintLog(TITLE + '返回结果', res, _that.TAG)
if (res.data.code === 0) {
_that.$emit('refresh', _that.shInfo)
_that.initShItem()
} else {
NetUtil.bzxxsh
.sh(ruleForm)
.then(res => {
if (res.code === 0) {
_that.$emit('refresh', _that.shInfo)
_that.initShItem()
}
})
}
}).catch(err => {
PrintLog(TITLE + '异常', err, _that.TAG)
_that.$message.error('异常' + err)
})
// bzxxSh(_that, ruleForm).then(res => {
// PrintLog(TITLE + '返回结果', res, _that.TAG)
// if (res.data.code === 0) {
// _that.$emit('refresh', _that.shInfo)
// _that.initShItem()
// } else {
//
// }
// }).catch(err => {
// PrintLog(TITLE + '异常', err, _that.TAG)
// _that.$message.error('异常' + err)
// })
},
doZg(zgzt, desc = '') {
......@@ -382,20 +388,32 @@ export default {
ruleForm.des = desc
ruleForm.level = _that.getLevel()
PrintLog(TITLE + '请求参数', ruleForm)
// PrintLog(TITLE + '请求参数', ruleForm)
// PrintLog(TITLE + '接口', 'updateJrzg')
bzxxZg(_that, ruleForm).then(res => {
PrintLog(TITLE + '返回结果', res, _that.TAG)
if (res.data.code === 0) {
_that.$emit('refresh', _that.shInfo)
_that.initShItem()
} else {
NetUtil.bzxxsh
.updateJrzg(ruleForm)
.then(res => {
// PrintLog(TITLE + '返回结果', res, _that.TAG)
if (res.code === 0) {
_that.$emit('refresh', _that.shInfo)
_that.initShItem()
}
})
// bzxxZg(_that, ruleForm).then(res => {
// PrintLog(TITLE + '返回结果', res, _that.TAG)
// if (res.data.code === 0) {
// _that.$emit('refresh', _that.shInfo)
// _that.initShItem()
// } else {
//
// }
// }).catch(err => {
// PrintLog(TITLE + '异常', err, _that.TAG)
// })
}
}).catch(err => {
PrintLog(TITLE + '异常', err, _that.TAG)
})
},
doPlSb() {
......@@ -409,21 +427,31 @@ export default {
ruleForm.status = '3'
ruleForm.level = _that.getLevel()
PrintLog(TITLE + '请求参数', ruleForm, _that.TAG)
// PrintLog(TITLE + '请求参数', ruleForm, _that.TAG)
// PrintLog(TITLE + '接口', '/api/hit/insertBeach', _that.TAG)
bzxxPlSb(_that, ruleForm)
NetUtil.bzxxsh
.bzxxPlSb(ruleForm)
.then(res => {
PrintLog(TITLE + '返回结果', res, _that.TAG)
if (res.data.code === 0) {
// PrintLog(TITLE + '返回结果', res, _that.TAG)
if (res.code === 0) {
_that.$emit('refresh', _that.shInfo)
_that.initShItem()
}
})
.catch(err => {
PrintLog(TITLE + '异常', err.toString(), _that.TAG)
this.$message.error('失败原因:' + err.toString())
})
// bzxxPlSb(_that, ruleForm)
// .then(res => {
// PrintLog(TITLE + '返回结果', res, _that.TAG)
// if (res.data.code === 0) {
// _that.$emit('refresh', _that.shInfo)
// _that.initShItem()
// }
// })
// .catch(err => {
// PrintLog(TITLE + '异常', err.toString(), _that.TAG)
// this.$message.error('失败原因:' + err.toString())
// })
},
},
}
......
......@@ -333,8 +333,6 @@
<script>
import Cascader from '@/components/Cascader.vue'
import bzxxsfOpt from '../bzxxgl/BzxxsfOpt.vue'
import PrintLog from '../../utils/LogcatUtil'
import {queryShList, bzxxPlSb} from '../../netmgr/bzxxgl/bzxxsh'
import ZzjgUtil from '../../utils/ZzjgUtil.js'
export default {
......@@ -440,7 +438,7 @@ export default {
// _that.initTestData()
_that.getData()
console.log('bzxxsH-isSt', _that.isSt)
// console.log('bzxxsH-isSt', _that.isSt)
},
computed: {
roleArr() {
......@@ -487,7 +485,7 @@ export default {
item.width = item.width * scalePercent
_that.checkedProps.push(item.prop)
})
PrintLog('tableColumns', _that.tableColumns)
logger.info('tableColumns', _that.tableColumns)
},
changeCheckbox(val) {
let _that = this
......@@ -496,7 +494,7 @@ export default {
item.isShow = val.indexOf(item.prop) >= 0
}
)
PrintLog('checkedProps', _that.checkedProps)
logger.info('checkedProps', _that.checkedProps)
},
getShState(info) {
let _that = this
......@@ -559,7 +557,7 @@ export default {
kk: ''
})
}
console.log('initTestData', JSON.stringify(_that.tableDate))
// console.log('initTestData', JSON.stringify(_that.tableDate))
},
commitShAction() { // 确定
......@@ -643,7 +641,7 @@ export default {
for (let key in _that.ruleForm) {
_that.ruleForm[key] = ''
}
PrintLog('resetForm-ruleForm', JSON.stringify(_that.ruleForm))
logger.info('resetForm-ruleForm', JSON.stringify(_that.ruleForm))
_that.getData()
},
bzxxsfOptRefresh(data) {
......@@ -695,28 +693,38 @@ export default {
_that.ruleForm.level = _that.getLevel()
PrintLog('查询审核列表' + '请求参数', JSON.stringify(_that.ruleForm), _that.TAG)
PrintLog('查询审核列表' + '接口', '/api/hit/queryAllSh', _that.TAG)
// PrintLog('查询审核列表' + '请求参数', JSON.stringify(_that.ruleForm), _that.TAG)
// PrintLog('查询审核列表' + '接口', '/api/hit/queryAllSh', _that.TAG)
queryShList(_that, _that.ruleForm)
NetUtil.bzxxsh.shList(_that.ruleForm)
.then(res => {
PrintLog('查询审核列表' + '返回结果', res, _that.TAG)
if (res.data.code === 0) {
logger.json(res.data)
_that.tableDate = res.data.ret.rows
_that.total = res.data.ret.total
if (res.code === 0) {
_that.tableDate = res.ret.rows
_that.total = res.ret.total
_that.totalPage = Math.ceil(_that.total / _that.pageSize)
} else {
_that.tableDate = []
_that.total = 0
_that.totalPage = 0
_that.refreshItemsData()
}
_that.refreshItemsData()
})
.catch(err => {
PrintLog('查询审核列表' + '异常', err.toString(), _that.TAG)
this.$message.error('失败原因:' + err.toString())
})
// queryShList(_that, _that.ruleForm)
// .then(res => {
// PrintLog('查询审核列表' + '返回结果', res, _that.TAG)
// if (res.code === 0) {
// // logger.json(res.data)
// _that.tableDate = res.data.ret.rows
// _that.total = res.data.ret.total
// _that.totalPage = Math.ceil(_that.total / _that.pageSize)
// } else {
// _that.tableDate = []
// _that.total = 0
// _that.totalPage = 0
// }
// _that.refreshItemsData()
// })
// .catch(err => {
// PrintLog('查询审核列表' + '异常', err, _that.TAG)
// this.$message.error('失败原因:' + err.toString())
// })
},
onSbxxListener() {
......@@ -771,20 +779,29 @@ export default {
// ruleForm.username = username
ruleForm.level = _that.getLevel()
PrintLog(TITLE + '请求参数', ruleForm, _that.TAG)
PrintLog(TITLE + '接口', '/api/hit/insertBeach', _that.TAG)
// PrintLog(TITLE + '请求参数', ruleForm, _that.TAG)
// PrintLog(TITLE + '接口', '/api/hit/insertBeach', _that.TAG)
bzxxPlSb(_that, ruleForm)
NetUtil.bzxxsh
.plsb(ruleForm)
.then(res => {
PrintLog(TITLE + '返回结果', res, _that.TAG)
if (res.data.code === 0) {
// PrintLog(TITLE + '返回结果', res, _that.TAG)
if (res.code === 0) {
_that.getData()
}
})
.catch(err => {
PrintLog(TITLE + '异常', err.toString(), _that.TAG)
this.$message.error('失败原因:' + err.toString())
})
// bzxxPlSb(_that, ruleForm)
// .then(res => {
// PrintLog(TITLE + '返回结果', res, _that.TAG)
// if (res.data.code === 0) {
// _that.getData()
// }
// })
// .catch(err => {
// PrintLog(TITLE + '异常', err.toString(), _that.TAG)
// this.$message.error('失败原因:' + err.toString())
// })
},
onFztmSuccess(e) {
......@@ -811,7 +828,7 @@ export default {
})
_that.fztm_ytmh = _that.fztm_ytmh.join(',')
}
PrintLog('fztm_ytmh', _that.fztm_ytmh)
// PrintLog('fztm_ytmh', _that.fztm_ytmh)
}
},
watch: {
......
......@@ -217,8 +217,6 @@
<script>
import {mapState} from 'vuex'
import ImageEd from '@/components/ImageEd.vue'
import PrintLog from '../../utils/LogcatUtil'
import {bzxxSh} from '../../netmgr/bzxxgl/bzxxsh'
export default {
name: 'fhxxLT',
......@@ -557,25 +555,19 @@ export default {
ruleForm.des = _that.fhyj
ruleForm.level = _that.curLevel
PrintLog(TITLE + '请求参数', ruleForm)
// PrintLog(TITLE + '接口', 'udateShzt')
bzxxSh(_that, ruleForm).then(res => {
PrintLog(TITLE + '返回结果', res, _that.TAG)
if (res.data.code === 0) {
// _that.$router.go(-1)//返回上一层
let _path = _that.curLevel === '0' ? '/dsBzxxsh' : '/stBzxxsh' // 市级 0 省级 1 字段名:level
_that.$router.replace({
path: _path,
query: {
formData: _that.formData
}
})
}
}).catch(err => {
PrintLog(TITLE + '异常', err, _that.TAG)
_that.$message.error('异常' + err)
})
NetUtil.bzxxsh
.sh(ruleForm)
.then(res => {
if (res.code === 0) {
let _path = _that.curLevel === '0' ? '/dsBzxxsh' : '/stBzxxsh' // 市级 0 省级 1 字段名:level
_that.$router.replace({
path: _path,
query: {
formData: _that.formData
}
})
}
})
},
},
......
......@@ -206,8 +206,6 @@
<script>
import {mapState} from 'vuex'
import ImageEd from '@/components/ImageEd.vue'
import {bzxxSh} from '../../netmgr/bzxxgl/bzxxsh'
import PrintLog from '../../utils/LogcatUtil'
export default {
name: 'fhxxLT',
......@@ -603,23 +601,19 @@ export default {
ruleForm.des = _that.fhyj
ruleForm.level = _that.curLevel
PrintLog(TITLE + '请求参数', ruleForm)
// PrintLog(TITLE + '接口', 'udateShzt')
bzxxSh(_that, ruleForm).then(res => {
PrintLog(TITLE + '返回结果', res, _that.TAG)
if (res.data.code === 0) {
let _path = _that.curLevel === '0' ? '/dsBzxxsh' : '/stBzxxsh' // 市级 0 省级 1 字段名:level
_that.$router.replace({
path: _path,
query: {
formData: _that.formData
}
})
}
}).catch(err => {
PrintLog(TITLE + '异常', err, _that.TAG)
_that.$message.error('异常' + err)
})
NetUtil.bzxxsh
.sh(ruleForm)
.then(res => {
if (res.code === 0) {
let _path = _that.curLevel === '0' ? '/dsBzxxsh' : '/stBzxxsh' // 市级 0 省级 1 字段名:level
_that.$router.replace({
path: _path,
query: {
formData: _that.formData
}
})
}
})
},
},
destroyed() {
......
......@@ -225,8 +225,6 @@
<script>
import { mapState } from 'vuex'
import ImageEd from '@/components/ImageEd.vue'
import PrintLog from '../../utils/LogcatUtil'
import { bzxxSh } from '../../netmgr/bzxxgl/bzxxsh'
export default {
name: 'fhxxLT',
......@@ -613,24 +611,19 @@ export default {
ruleForm.des = _that.fhyj
ruleForm.level = _that.curLevel
PrintLog(TITLE + '请求参数', ruleForm)
// PrintLog(TITLE + '接口', 'udateShzt')
bzxxSh(_that, ruleForm).then(res => {
PrintLog(TITLE + '返回结果', res, _that.TAG)
if (res.data.code === 0) {
let _path = _that.curLevel === '0' ? '/dsBzxxsh' : '/stBzxxsh' // 市级 0 省级 1 字段名:level
_that.$router.replace({
path: _path,
query: {
formData: _that.formData
}
})
}
}).catch(err => {
PrintLog(TITLE + '异常', err, _that.TAG)
_that.$message.error('异常' + err)
})
NetUtil.bzxxsh
.sh(ruleForm)
.then(res => {
if (res.code === 0) {
let _path = _that.curLevel === '0' ? '/dsBzxxsh' : '/stBzxxsh' // 市级 0 省级 1 字段名:level
_that.$router.replace({
path: _path,
query: {
formData: _that.formData
}
})
}
})
},
},
......
Markdown is supported
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