diff --git a/src/api/alarm.js b/src/api/alarm.js index 5202a0d..14f61d1 100644 --- a/src/api/alarm.js +++ b/src/api/alarm.js @@ -35,7 +35,7 @@ return request({ url: 'well/watchDataByAlarm', method: 'get', - data: { + params: { id: id } }) @@ -46,6 +46,7 @@ return request({ url: 'alarm/export', method: 'get', + timeout: 120000, params, responseType: 'blob' // 这一步也很关键,一定要加上 responseType 值为 blob }) diff --git a/src/api/alarm.js b/src/api/alarm.js index 5202a0d..14f61d1 100644 --- a/src/api/alarm.js +++ b/src/api/alarm.js @@ -35,7 +35,7 @@ return request({ url: 'well/watchDataByAlarm', method: 'get', - data: { + params: { id: id } }) @@ -46,6 +46,7 @@ return request({ url: 'alarm/export', method: 'get', + timeout: 120000, params, responseType: 'blob' // 这一步也很关键,一定要加上 responseType 值为 blob }) diff --git a/src/api/concentrator.js b/src/api/concentrator.js index 5e6caef..9013bdf 100644 --- a/src/api/concentrator.js +++ b/src/api/concentrator.js @@ -56,6 +56,7 @@ return request({ url: 'concentrator/batchExport', method: 'get', + timeout: 120000, params, responseType: 'blob' // 这一步也很关键,一定要加上 responseType 值为 blob }) diff --git a/src/api/alarm.js b/src/api/alarm.js index 5202a0d..14f61d1 100644 --- a/src/api/alarm.js +++ b/src/api/alarm.js @@ -35,7 +35,7 @@ return request({ url: 'well/watchDataByAlarm', method: 'get', - data: { + params: { id: id } }) @@ -46,6 +46,7 @@ return request({ url: 'alarm/export', method: 'get', + timeout: 120000, params, responseType: 'blob' // 这一步也很关键,一定要加上 responseType 值为 blob }) diff --git a/src/api/concentrator.js b/src/api/concentrator.js index 5e6caef..9013bdf 100644 --- a/src/api/concentrator.js +++ b/src/api/concentrator.js @@ -56,6 +56,7 @@ return request({ url: 'concentrator/batchExport', method: 'get', + timeout: 120000, params, responseType: 'blob' // 这一步也很关键,一定要加上 responseType 值为 blob }) diff --git a/src/api/data.js b/src/api/data.js index 264dc56..08d447c 100644 --- a/src/api/data.js +++ b/src/api/data.js @@ -25,16 +25,18 @@ return request({ url: 'welldata/export', method: 'get', + timeout: 120000, params, responseType: 'blob' // 这一步也很关键,一定要加上 responseType 值为 blob }) } -// 批量导出井盖数据 +// 批量导出液位数据 export function batchExportLiquidData(params) { return request({ url: 'liquiddata/export', method: 'get', + timeout: 120000, params, responseType: 'blob' // 这一步也很关键,一定要加上 responseType 值为 blob }) diff --git a/src/api/alarm.js b/src/api/alarm.js index 5202a0d..14f61d1 100644 --- a/src/api/alarm.js +++ b/src/api/alarm.js @@ -35,7 +35,7 @@ return request({ url: 'well/watchDataByAlarm', method: 'get', - data: { + params: { id: id } }) @@ -46,6 +46,7 @@ return request({ url: 'alarm/export', method: 'get', + timeout: 120000, params, responseType: 'blob' // 这一步也很关键,一定要加上 responseType 值为 blob }) diff --git a/src/api/concentrator.js b/src/api/concentrator.js index 5e6caef..9013bdf 100644 --- a/src/api/concentrator.js +++ b/src/api/concentrator.js @@ -56,6 +56,7 @@ return request({ url: 'concentrator/batchExport', method: 'get', + timeout: 120000, params, responseType: 'blob' // 这一步也很关键,一定要加上 responseType 值为 blob }) diff --git a/src/api/data.js b/src/api/data.js index 264dc56..08d447c 100644 --- a/src/api/data.js +++ b/src/api/data.js @@ -25,16 +25,18 @@ return request({ url: 'welldata/export', method: 'get', + timeout: 120000, params, responseType: 'blob' // 这一步也很关键,一定要加上 responseType 值为 blob }) } -// 批量导出井盖数据 +// 批量导出液位数据 export function batchExportLiquidData(params) { return request({ url: 'liquiddata/export', method: 'get', + timeout: 120000, params, responseType: 'blob' // 这一步也很关键,一定要加上 responseType 值为 blob }) diff --git a/src/api/device.js b/src/api/device.js index 1e6d588..63fe6ec 100644 --- a/src/api/device.js +++ b/src/api/device.js @@ -77,6 +77,7 @@ return request({ url: 'device/batchExport', method: 'get', + timeout: 120000, params, responseType: 'blob' // 这一步也很关键,一定要加上 responseType 值为 blob }) diff --git a/src/api/alarm.js b/src/api/alarm.js index 5202a0d..14f61d1 100644 --- a/src/api/alarm.js +++ b/src/api/alarm.js @@ -35,7 +35,7 @@ return request({ url: 'well/watchDataByAlarm', method: 'get', - data: { + params: { id: id } }) @@ -46,6 +46,7 @@ return request({ url: 'alarm/export', method: 'get', + timeout: 120000, params, responseType: 'blob' // 这一步也很关键,一定要加上 responseType 值为 blob }) diff --git a/src/api/concentrator.js b/src/api/concentrator.js index 5e6caef..9013bdf 100644 --- a/src/api/concentrator.js +++ b/src/api/concentrator.js @@ -56,6 +56,7 @@ return request({ url: 'concentrator/batchExport', method: 'get', + timeout: 120000, params, responseType: 'blob' // 这一步也很关键,一定要加上 responseType 值为 blob }) diff --git a/src/api/data.js b/src/api/data.js index 264dc56..08d447c 100644 --- a/src/api/data.js +++ b/src/api/data.js @@ -25,16 +25,18 @@ return request({ url: 'welldata/export', method: 'get', + timeout: 120000, params, responseType: 'blob' // 这一步也很关键,一定要加上 responseType 值为 blob }) } -// 批量导出井盖数据 +// 批量导出液位数据 export function batchExportLiquidData(params) { return request({ url: 'liquiddata/export', method: 'get', + timeout: 120000, params, responseType: 'blob' // 这一步也很关键,一定要加上 responseType 值为 blob }) diff --git a/src/api/device.js b/src/api/device.js index 1e6d588..63fe6ec 100644 --- a/src/api/device.js +++ b/src/api/device.js @@ -77,6 +77,7 @@ return request({ url: 'device/batchExport', method: 'get', + timeout: 120000, params, responseType: 'blob' // 这一步也很关键,一定要加上 responseType 值为 blob }) diff --git a/src/api/job.js b/src/api/job.js index c830320..3503e5d 100644 --- a/src/api/job.js +++ b/src/api/job.js @@ -36,6 +36,7 @@ return request({ url: 'job/export', method: 'get', + timeout: 120000, params, responseType: 'blob' // 这一步也很关键,一定要加上 responseType 值为 blob }) diff --git a/src/api/alarm.js b/src/api/alarm.js index 5202a0d..14f61d1 100644 --- a/src/api/alarm.js +++ b/src/api/alarm.js @@ -35,7 +35,7 @@ return request({ url: 'well/watchDataByAlarm', method: 'get', - data: { + params: { id: id } }) @@ -46,6 +46,7 @@ return request({ url: 'alarm/export', method: 'get', + timeout: 120000, params, responseType: 'blob' // 这一步也很关键,一定要加上 responseType 值为 blob }) diff --git a/src/api/concentrator.js b/src/api/concentrator.js index 5e6caef..9013bdf 100644 --- a/src/api/concentrator.js +++ b/src/api/concentrator.js @@ -56,6 +56,7 @@ return request({ url: 'concentrator/batchExport', method: 'get', + timeout: 120000, params, responseType: 'blob' // 这一步也很关键,一定要加上 responseType 值为 blob }) diff --git a/src/api/data.js b/src/api/data.js index 264dc56..08d447c 100644 --- a/src/api/data.js +++ b/src/api/data.js @@ -25,16 +25,18 @@ return request({ url: 'welldata/export', method: 'get', + timeout: 120000, params, responseType: 'blob' // 这一步也很关键,一定要加上 responseType 值为 blob }) } -// 批量导出井盖数据 +// 批量导出液位数据 export function batchExportLiquidData(params) { return request({ url: 'liquiddata/export', method: 'get', + timeout: 120000, params, responseType: 'blob' // 这一步也很关键,一定要加上 responseType 值为 blob }) diff --git a/src/api/device.js b/src/api/device.js index 1e6d588..63fe6ec 100644 --- a/src/api/device.js +++ b/src/api/device.js @@ -77,6 +77,7 @@ return request({ url: 'device/batchExport', method: 'get', + timeout: 120000, params, responseType: 'blob' // 这一步也很关键,一定要加上 responseType 值为 blob }) diff --git a/src/api/job.js b/src/api/job.js index c830320..3503e5d 100644 --- a/src/api/job.js +++ b/src/api/job.js @@ -36,6 +36,7 @@ return request({ url: 'job/export', method: 'get', + timeout: 120000, params, responseType: 'blob' // 这一步也很关键,一定要加上 responseType 值为 blob }) diff --git a/src/api/well.js b/src/api/well.js index 55380fc..5a7af1e 100644 --- a/src/api/well.js +++ b/src/api/well.js @@ -76,6 +76,7 @@ return request({ url: 'well/batchExport', method: 'get', + timeout: 120000, params, responseType: 'blob' // 这一步也很关键,一定要加上 responseType 值为 blob }) diff --git a/src/api/alarm.js b/src/api/alarm.js index 5202a0d..14f61d1 100644 --- a/src/api/alarm.js +++ b/src/api/alarm.js @@ -35,7 +35,7 @@ return request({ url: 'well/watchDataByAlarm', method: 'get', - data: { + params: { id: id } }) @@ -46,6 +46,7 @@ return request({ url: 'alarm/export', method: 'get', + timeout: 120000, params, responseType: 'blob' // 这一步也很关键,一定要加上 responseType 值为 blob }) diff --git a/src/api/concentrator.js b/src/api/concentrator.js index 5e6caef..9013bdf 100644 --- a/src/api/concentrator.js +++ b/src/api/concentrator.js @@ -56,6 +56,7 @@ return request({ url: 'concentrator/batchExport', method: 'get', + timeout: 120000, params, responseType: 'blob' // 这一步也很关键,一定要加上 responseType 值为 blob }) diff --git a/src/api/data.js b/src/api/data.js index 264dc56..08d447c 100644 --- a/src/api/data.js +++ b/src/api/data.js @@ -25,16 +25,18 @@ return request({ url: 'welldata/export', method: 'get', + timeout: 120000, params, responseType: 'blob' // 这一步也很关键,一定要加上 responseType 值为 blob }) } -// 批量导出井盖数据 +// 批量导出液位数据 export function batchExportLiquidData(params) { return request({ url: 'liquiddata/export', method: 'get', + timeout: 120000, params, responseType: 'blob' // 这一步也很关键,一定要加上 responseType 值为 blob }) diff --git a/src/api/device.js b/src/api/device.js index 1e6d588..63fe6ec 100644 --- a/src/api/device.js +++ b/src/api/device.js @@ -77,6 +77,7 @@ return request({ url: 'device/batchExport', method: 'get', + timeout: 120000, params, responseType: 'blob' // 这一步也很关键,一定要加上 responseType 值为 blob }) diff --git a/src/api/job.js b/src/api/job.js index c830320..3503e5d 100644 --- a/src/api/job.js +++ b/src/api/job.js @@ -36,6 +36,7 @@ return request({ url: 'job/export', method: 'get', + timeout: 120000, params, responseType: 'blob' // 这一步也很关键,一定要加上 responseType 值为 blob }) diff --git a/src/api/well.js b/src/api/well.js index 55380fc..5a7af1e 100644 --- a/src/api/well.js +++ b/src/api/well.js @@ -76,6 +76,7 @@ return request({ url: 'well/batchExport', method: 'get', + timeout: 120000, params, responseType: 'blob' // 这一步也很关键,一定要加上 responseType 值为 blob }) diff --git a/src/store/getters.js b/src/store/getters.js index 93860ed..1a3b943 100644 --- a/src/store/getters.js +++ b/src/store/getters.js @@ -18,6 +18,8 @@ wellTypes: state => state.user.wellTypes, // 用户支持的闸井类型 deviceTypes: state => state.user.deviceTypes, // 用户支持的设备类型 communications: state => state.user.communications, // 用户支持的通讯方式 - area: state => state.user.area // 用户所在区域 + area: state => state.user.area, // 用户所在区域 + lng: state => state.user.lng, // 纬度 + lat: state => state.user.lat // 经度 } export default getters diff --git a/src/api/alarm.js b/src/api/alarm.js index 5202a0d..14f61d1 100644 --- a/src/api/alarm.js +++ b/src/api/alarm.js @@ -35,7 +35,7 @@ return request({ url: 'well/watchDataByAlarm', method: 'get', - data: { + params: { id: id } }) @@ -46,6 +46,7 @@ return request({ url: 'alarm/export', method: 'get', + timeout: 120000, params, responseType: 'blob' // 这一步也很关键,一定要加上 responseType 值为 blob }) diff --git a/src/api/concentrator.js b/src/api/concentrator.js index 5e6caef..9013bdf 100644 --- a/src/api/concentrator.js +++ b/src/api/concentrator.js @@ -56,6 +56,7 @@ return request({ url: 'concentrator/batchExport', method: 'get', + timeout: 120000, params, responseType: 'blob' // 这一步也很关键,一定要加上 responseType 值为 blob }) diff --git a/src/api/data.js b/src/api/data.js index 264dc56..08d447c 100644 --- a/src/api/data.js +++ b/src/api/data.js @@ -25,16 +25,18 @@ return request({ url: 'welldata/export', method: 'get', + timeout: 120000, params, responseType: 'blob' // 这一步也很关键,一定要加上 responseType 值为 blob }) } -// 批量导出井盖数据 +// 批量导出液位数据 export function batchExportLiquidData(params) { return request({ url: 'liquiddata/export', method: 'get', + timeout: 120000, params, responseType: 'blob' // 这一步也很关键,一定要加上 responseType 值为 blob }) diff --git a/src/api/device.js b/src/api/device.js index 1e6d588..63fe6ec 100644 --- a/src/api/device.js +++ b/src/api/device.js @@ -77,6 +77,7 @@ return request({ url: 'device/batchExport', method: 'get', + timeout: 120000, params, responseType: 'blob' // 这一步也很关键,一定要加上 responseType 值为 blob }) diff --git a/src/api/job.js b/src/api/job.js index c830320..3503e5d 100644 --- a/src/api/job.js +++ b/src/api/job.js @@ -36,6 +36,7 @@ return request({ url: 'job/export', method: 'get', + timeout: 120000, params, responseType: 'blob' // 这一步也很关键,一定要加上 responseType 值为 blob }) diff --git a/src/api/well.js b/src/api/well.js index 55380fc..5a7af1e 100644 --- a/src/api/well.js +++ b/src/api/well.js @@ -76,6 +76,7 @@ return request({ url: 'well/batchExport', method: 'get', + timeout: 120000, params, responseType: 'blob' // 这一步也很关键,一定要加上 responseType 值为 blob }) diff --git a/src/store/getters.js b/src/store/getters.js index 93860ed..1a3b943 100644 --- a/src/store/getters.js +++ b/src/store/getters.js @@ -18,6 +18,8 @@ wellTypes: state => state.user.wellTypes, // 用户支持的闸井类型 deviceTypes: state => state.user.deviceTypes, // 用户支持的设备类型 communications: state => state.user.communications, // 用户支持的通讯方式 - area: state => state.user.area // 用户所在区域 + area: state => state.user.area, // 用户所在区域 + lng: state => state.user.lng, // 纬度 + lat: state => state.user.lat // 经度 } export default getters diff --git a/src/store/modules/user.js b/src/store/modules/user.js index be4b513..6c8877a 100644 --- a/src/store/modules/user.js +++ b/src/store/modules/user.js @@ -13,7 +13,9 @@ wellTypes: [], // 支持闸井类型 deviceTypes: [], // 支持设备类型 communications: [], // 支持通讯方式 - area: '' // 默认地区 + area: '', // 默认地区 + lng: '', + lat: '' }, mutations: { SET_TOKEN: (state, token) => { @@ -48,6 +50,12 @@ }, SET_AREA: (state, area) => { state.area = area + }, + SET_LNG: (state, lng) => { + state.lng = parseFloat(lng) + }, + SET_LAT: (state, lat) => { + state.lat = parseFloat(lat) } }, @@ -111,6 +119,8 @@ reject('该用户不支持任何通讯方式') } commit('SET_AREA', data.area) + commit('SET_LNG', data.lng) + commit('SET_LAT', data.lat) resolve(response) }).catch(error => { reject(error) diff --git a/src/api/alarm.js b/src/api/alarm.js index 5202a0d..14f61d1 100644 --- a/src/api/alarm.js +++ b/src/api/alarm.js @@ -35,7 +35,7 @@ return request({ url: 'well/watchDataByAlarm', method: 'get', - data: { + params: { id: id } }) @@ -46,6 +46,7 @@ return request({ url: 'alarm/export', method: 'get', + timeout: 120000, params, responseType: 'blob' // 这一步也很关键,一定要加上 responseType 值为 blob }) diff --git a/src/api/concentrator.js b/src/api/concentrator.js index 5e6caef..9013bdf 100644 --- a/src/api/concentrator.js +++ b/src/api/concentrator.js @@ -56,6 +56,7 @@ return request({ url: 'concentrator/batchExport', method: 'get', + timeout: 120000, params, responseType: 'blob' // 这一步也很关键,一定要加上 responseType 值为 blob }) diff --git a/src/api/data.js b/src/api/data.js index 264dc56..08d447c 100644 --- a/src/api/data.js +++ b/src/api/data.js @@ -25,16 +25,18 @@ return request({ url: 'welldata/export', method: 'get', + timeout: 120000, params, responseType: 'blob' // 这一步也很关键,一定要加上 responseType 值为 blob }) } -// 批量导出井盖数据 +// 批量导出液位数据 export function batchExportLiquidData(params) { return request({ url: 'liquiddata/export', method: 'get', + timeout: 120000, params, responseType: 'blob' // 这一步也很关键,一定要加上 responseType 值为 blob }) diff --git a/src/api/device.js b/src/api/device.js index 1e6d588..63fe6ec 100644 --- a/src/api/device.js +++ b/src/api/device.js @@ -77,6 +77,7 @@ return request({ url: 'device/batchExport', method: 'get', + timeout: 120000, params, responseType: 'blob' // 这一步也很关键,一定要加上 responseType 值为 blob }) diff --git a/src/api/job.js b/src/api/job.js index c830320..3503e5d 100644 --- a/src/api/job.js +++ b/src/api/job.js @@ -36,6 +36,7 @@ return request({ url: 'job/export', method: 'get', + timeout: 120000, params, responseType: 'blob' // 这一步也很关键,一定要加上 responseType 值为 blob }) diff --git a/src/api/well.js b/src/api/well.js index 55380fc..5a7af1e 100644 --- a/src/api/well.js +++ b/src/api/well.js @@ -76,6 +76,7 @@ return request({ url: 'well/batchExport', method: 'get', + timeout: 120000, params, responseType: 'blob' // 这一步也很关键,一定要加上 responseType 值为 blob }) diff --git a/src/store/getters.js b/src/store/getters.js index 93860ed..1a3b943 100644 --- a/src/store/getters.js +++ b/src/store/getters.js @@ -18,6 +18,8 @@ wellTypes: state => state.user.wellTypes, // 用户支持的闸井类型 deviceTypes: state => state.user.deviceTypes, // 用户支持的设备类型 communications: state => state.user.communications, // 用户支持的通讯方式 - area: state => state.user.area // 用户所在区域 + area: state => state.user.area, // 用户所在区域 + lng: state => state.user.lng, // 纬度 + lat: state => state.user.lat // 经度 } export default getters diff --git a/src/store/modules/user.js b/src/store/modules/user.js index be4b513..6c8877a 100644 --- a/src/store/modules/user.js +++ b/src/store/modules/user.js @@ -13,7 +13,9 @@ wellTypes: [], // 支持闸井类型 deviceTypes: [], // 支持设备类型 communications: [], // 支持通讯方式 - area: '' // 默认地区 + area: '', // 默认地区 + lng: '', + lat: '' }, mutations: { SET_TOKEN: (state, token) => { @@ -48,6 +50,12 @@ }, SET_AREA: (state, area) => { state.area = area + }, + SET_LNG: (state, lng) => { + state.lng = parseFloat(lng) + }, + SET_LAT: (state, lat) => { + state.lat = parseFloat(lat) } }, @@ -111,6 +119,8 @@ reject('该用户不支持任何通讯方式') } commit('SET_AREA', data.area) + commit('SET_LNG', data.lng) + commit('SET_LAT', data.lat) resolve(response) }).catch(error => { reject(error) diff --git a/src/utils/request.js b/src/utils/request.js index c88ea76..17173bb 100644 --- a/src/utils/request.js +++ b/src/utils/request.js @@ -3,19 +3,20 @@ import store from '../store' import { getToken } from '@/utils/auth' +// =>设置在POST请求中基于请求主体向服务器发送内容的格式,默认是RAW,项目中常用的是URL-ENCODEED格式 + // 创建axios实例 const service = axios.create({ baseURL: process.env.BASE_API, // api 的 base_url - timeout: 50000 // 请求超时时间 + timeout: 30000, // 请求超时时间 + headers: { 'Content-Type': 'appliction/x-www-form-urlencoded' } }) // request拦截器 service.interceptors.request.use( config => { if (store.getters.token) { - console.log('request.js gettoken') config.headers['token'] = getToken() // 让每个请求携带自定义token 请根据实际情况自行修改 - console.log(config.headers['token']) } return config }, @@ -33,9 +34,10 @@ * code为非200是抛错 可结合自己业务进行修改 */ const res = response.data + // 如果返回值类型是Blob if (res instanceof Blob) { return response - } else if (res.code !== 200) { + } else if (res.code !== 200) { // 判断状态码 // 50008:非法的token; 50012:其他客户端登录了; 50014:Token 过期了; if (res.code === 401 || res.code === 50012 || res.code === 50014) { MessageBox.confirm( @@ -80,14 +82,16 @@ }) } } else { - console.log('错误:' + error.response.data.message) // for debug - // Message.error(error.response.data.message) - Message({ - showClose: true, - message: error.response.data.message, - type: 'error', - duration: 3000 - }) + if (error.response) { + console.log('错误:' + error.response.data.message) // for debug + // Message.error(error.response.data.message) + Message({ + showClose: true, + message: error.response.data.message, + type: 'error', + duration: 3000 + }) + } } return Promise.reject(error) diff --git a/src/api/alarm.js b/src/api/alarm.js index 5202a0d..14f61d1 100644 --- a/src/api/alarm.js +++ b/src/api/alarm.js @@ -35,7 +35,7 @@ return request({ url: 'well/watchDataByAlarm', method: 'get', - data: { + params: { id: id } }) @@ -46,6 +46,7 @@ return request({ url: 'alarm/export', method: 'get', + timeout: 120000, params, responseType: 'blob' // 这一步也很关键,一定要加上 responseType 值为 blob }) diff --git a/src/api/concentrator.js b/src/api/concentrator.js index 5e6caef..9013bdf 100644 --- a/src/api/concentrator.js +++ b/src/api/concentrator.js @@ -56,6 +56,7 @@ return request({ url: 'concentrator/batchExport', method: 'get', + timeout: 120000, params, responseType: 'blob' // 这一步也很关键,一定要加上 responseType 值为 blob }) diff --git a/src/api/data.js b/src/api/data.js index 264dc56..08d447c 100644 --- a/src/api/data.js +++ b/src/api/data.js @@ -25,16 +25,18 @@ return request({ url: 'welldata/export', method: 'get', + timeout: 120000, params, responseType: 'blob' // 这一步也很关键,一定要加上 responseType 值为 blob }) } -// 批量导出井盖数据 +// 批量导出液位数据 export function batchExportLiquidData(params) { return request({ url: 'liquiddata/export', method: 'get', + timeout: 120000, params, responseType: 'blob' // 这一步也很关键,一定要加上 responseType 值为 blob }) diff --git a/src/api/device.js b/src/api/device.js index 1e6d588..63fe6ec 100644 --- a/src/api/device.js +++ b/src/api/device.js @@ -77,6 +77,7 @@ return request({ url: 'device/batchExport', method: 'get', + timeout: 120000, params, responseType: 'blob' // 这一步也很关键,一定要加上 responseType 值为 blob }) diff --git a/src/api/job.js b/src/api/job.js index c830320..3503e5d 100644 --- a/src/api/job.js +++ b/src/api/job.js @@ -36,6 +36,7 @@ return request({ url: 'job/export', method: 'get', + timeout: 120000, params, responseType: 'blob' // 这一步也很关键,一定要加上 responseType 值为 blob }) diff --git a/src/api/well.js b/src/api/well.js index 55380fc..5a7af1e 100644 --- a/src/api/well.js +++ b/src/api/well.js @@ -76,6 +76,7 @@ return request({ url: 'well/batchExport', method: 'get', + timeout: 120000, params, responseType: 'blob' // 这一步也很关键,一定要加上 responseType 值为 blob }) diff --git a/src/store/getters.js b/src/store/getters.js index 93860ed..1a3b943 100644 --- a/src/store/getters.js +++ b/src/store/getters.js @@ -18,6 +18,8 @@ wellTypes: state => state.user.wellTypes, // 用户支持的闸井类型 deviceTypes: state => state.user.deviceTypes, // 用户支持的设备类型 communications: state => state.user.communications, // 用户支持的通讯方式 - area: state => state.user.area // 用户所在区域 + area: state => state.user.area, // 用户所在区域 + lng: state => state.user.lng, // 纬度 + lat: state => state.user.lat // 经度 } export default getters diff --git a/src/store/modules/user.js b/src/store/modules/user.js index be4b513..6c8877a 100644 --- a/src/store/modules/user.js +++ b/src/store/modules/user.js @@ -13,7 +13,9 @@ wellTypes: [], // 支持闸井类型 deviceTypes: [], // 支持设备类型 communications: [], // 支持通讯方式 - area: '' // 默认地区 + area: '', // 默认地区 + lng: '', + lat: '' }, mutations: { SET_TOKEN: (state, token) => { @@ -48,6 +50,12 @@ }, SET_AREA: (state, area) => { state.area = area + }, + SET_LNG: (state, lng) => { + state.lng = parseFloat(lng) + }, + SET_LAT: (state, lat) => { + state.lat = parseFloat(lat) } }, @@ -111,6 +119,8 @@ reject('该用户不支持任何通讯方式') } commit('SET_AREA', data.area) + commit('SET_LNG', data.lng) + commit('SET_LAT', data.lat) resolve(response) }).catch(error => { reject(error) diff --git a/src/utils/request.js b/src/utils/request.js index c88ea76..17173bb 100644 --- a/src/utils/request.js +++ b/src/utils/request.js @@ -3,19 +3,20 @@ import store from '../store' import { getToken } from '@/utils/auth' +// =>设置在POST请求中基于请求主体向服务器发送内容的格式,默认是RAW,项目中常用的是URL-ENCODEED格式 + // 创建axios实例 const service = axios.create({ baseURL: process.env.BASE_API, // api 的 base_url - timeout: 50000 // 请求超时时间 + timeout: 30000, // 请求超时时间 + headers: { 'Content-Type': 'appliction/x-www-form-urlencoded' } }) // request拦截器 service.interceptors.request.use( config => { if (store.getters.token) { - console.log('request.js gettoken') config.headers['token'] = getToken() // 让每个请求携带自定义token 请根据实际情况自行修改 - console.log(config.headers['token']) } return config }, @@ -33,9 +34,10 @@ * code为非200是抛错 可结合自己业务进行修改 */ const res = response.data + // 如果返回值类型是Blob if (res instanceof Blob) { return response - } else if (res.code !== 200) { + } else if (res.code !== 200) { // 判断状态码 // 50008:非法的token; 50012:其他客户端登录了; 50014:Token 过期了; if (res.code === 401 || res.code === 50012 || res.code === 50014) { MessageBox.confirm( @@ -80,14 +82,16 @@ }) } } else { - console.log('错误:' + error.response.data.message) // for debug - // Message.error(error.response.data.message) - Message({ - showClose: true, - message: error.response.data.message, - type: 'error', - duration: 3000 - }) + if (error.response) { + console.log('错误:' + error.response.data.message) // for debug + // Message.error(error.response.data.message) + Message({ + showClose: true, + message: error.response.data.message, + type: 'error', + duration: 3000 + }) + } } return Promise.reject(error) diff --git a/src/views/overview/overview.vue b/src/views/overview/overview.vue index e83fdf4..07ff6bf 100644 --- a/src/views/overview/overview.vue +++ b/src/views/overview/overview.vue @@ -186,9 +186,11 @@ '2': 'well-sewage', '3': 'well-gas', '4': 'well-heat', - '5': 'well-power' + '5': 'well-power', + '6': 'well-heat', + '7': 'well-sewage' }, // 井类型图标字典 - center: [117.190186, 39.125595], // 地图中心 + center: [this.$store.getters.lng, this.$store.getters.lat], // 地图中心 zoom: 12, // 地图缩放比例 markers: [], // 井列表标注marker alarmList: [], // 报警列表 @@ -212,7 +214,7 @@ }, // 显示报警详情气泡内容 currentWindow: { visible: false, // 窗体显示与否 - position: [116.4, 39.9], + position: [this.$store.getters.lng, this.$store.getters.lat], windowType: 'info' // 窗体类型:详情info或报警alarm }, // 当前窗体属性 infoWindowClass: 'nomal-info-window', @@ -297,7 +299,6 @@ const isAlarm = this.listQuery.isAlarm let center = [] // 查询全部井,是否匹配 - debugger for (const marker of this.markers) { let show = true // 关键字不为空,且没有匹配成功,不显示