mirror of
https://gitee.com/beecue/fastbee.git
synced 2025-12-18 00:45:55 +08:00
大屏展示
This commit is contained in:
168
vue/src/api/bigScreen/api.js
Normal file
168
vue/src/api/bigScreen/api.js
Normal file
@@ -0,0 +1,168 @@
|
||||
|
||||
/*
|
||||
* @LastEditors: Please set LastEditors
|
||||
* @LastEditTime: 2022-04-28 10:25:38
|
||||
*/
|
||||
import axios from 'axios';
|
||||
import UtilVar from "@/config/UtilVar";
|
||||
import router from '@/router'
|
||||
|
||||
let baseUrl = UtilVar.baseUrl
|
||||
const CancelToken = axios.CancelToken;
|
||||
export { baseUrl };
|
||||
// axios.defaults.withCredentials = true;
|
||||
// 添加请求拦截器
|
||||
axios.interceptors.request.use(function (config) {
|
||||
// 在发送请求之前做些什么 传token
|
||||
let token = localStorage.getItem("token");
|
||||
config.headers.common['Content-Type'] = "application/json;charset=utf-8";
|
||||
config.headers.common['token'] = token; //Authorization
|
||||
return config;
|
||||
}, function (error) {
|
||||
// 对请求错误做些什么
|
||||
console.log(error)
|
||||
return Promise.reject(error);
|
||||
});
|
||||
/**
|
||||
* @响应拦截
|
||||
*/
|
||||
axios.interceptors.response.use(response => {
|
||||
|
||||
if (response.status !== 200) {
|
||||
return Promise.reject(response)
|
||||
}
|
||||
/**
|
||||
* @code 登录过期 token验证失败 根据后端调
|
||||
*/
|
||||
if (response.data.code == UtilVar.code) {
|
||||
// router.push("/login")
|
||||
}
|
||||
return response.data
|
||||
}, error => {
|
||||
// console.log('axiosError',error);
|
||||
let err = {
|
||||
success: false,
|
||||
msg: "未知异常,请联系管理员!"
|
||||
}
|
||||
return Promise.reject(err)
|
||||
})
|
||||
|
||||
let configs_ENC = {
|
||||
headers: { 'enc': UtilVar.ENC }
|
||||
}
|
||||
//处理是否加密数据
|
||||
let isEncryptionParam = (params) => {
|
||||
return params
|
||||
|
||||
}
|
||||
export const GET = async (url, params) => {
|
||||
try {
|
||||
params = isEncryptionParam(params)
|
||||
const data = await axios.get(`${baseUrl}${url}`, {
|
||||
params: params,
|
||||
headers: configs_ENC.headers
|
||||
}, configs_ENC);
|
||||
return data;
|
||||
} catch (error) {
|
||||
return error;
|
||||
}
|
||||
}
|
||||
//没有基地址 访问根目录下文件
|
||||
|
||||
export const GETNOBASE = async (url, params) => {
|
||||
try {
|
||||
const data = await axios.get(url, {
|
||||
params: params,
|
||||
});
|
||||
return data;
|
||||
} catch (error) {
|
||||
return error;
|
||||
}
|
||||
}
|
||||
export const POST = async (url, params) => {
|
||||
try {
|
||||
params = isEncryptionParam(params)
|
||||
const data = await axios.post(`${baseUrl}${url}`, params, configs_ENC);
|
||||
return data;
|
||||
} catch (error) {
|
||||
return error;
|
||||
}
|
||||
}
|
||||
export const PUT = async (url, params) => {
|
||||
try {
|
||||
params = isEncryptionParam(params)
|
||||
const data = await axios.put(`${baseUrl}${url}`, params, configs_ENC);
|
||||
return data;
|
||||
} catch (error) {
|
||||
return error;
|
||||
}
|
||||
}
|
||||
export const DELETE = async (url, params) => {
|
||||
// console.log(params)
|
||||
try {
|
||||
params = isEncryptionParam(params)
|
||||
const data = await axios.delete(`${baseUrl}${url}`, { data: params, headers: configs_ENC.headers }, configs_ENC);
|
||||
return data;
|
||||
} catch (error) {
|
||||
return error;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @文件类型提交方法
|
||||
*/
|
||||
let configs = {
|
||||
headers: { 'Content-Type': 'multipart/form-data' },
|
||||
|
||||
}
|
||||
export const FILESubmit = async (url, params, config) => {
|
||||
try {
|
||||
const data = await axios.post(`${baseUrl}${url}`, params, {
|
||||
...configs,
|
||||
cancelToken: new CancelToken(function executor(c) {
|
||||
config.setCancel && config.setCancel(c)
|
||||
}),
|
||||
onUploadProgress: (e) => {
|
||||
if (e.total > 0) {
|
||||
e.percent = e.loaded / e.total * 100;
|
||||
}
|
||||
// console.log(config)
|
||||
config.onProgress && config.onProgress(e)
|
||||
},
|
||||
|
||||
});
|
||||
return data;
|
||||
} catch (err) {
|
||||
return err;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 下载文档流
|
||||
* @param {config.responseType} 下载文件流根据后端 配置 arraybuffer || blod
|
||||
*/
|
||||
export const FILE = async (config = {}, body, params) => {
|
||||
try {
|
||||
const data = await axios({
|
||||
method: config.method || 'get',
|
||||
url: `${baseUrl}${config.url}`,
|
||||
data: body,
|
||||
params: params,
|
||||
responseType: config.responseType || 'blob',
|
||||
onDownloadProgress: (e) => {
|
||||
// console.log(e,e.currentTarget)
|
||||
// if (e.currentTarget.response.size > 0) {
|
||||
// e.percent = e.loaded / e.currentTarget.response.size * 100;
|
||||
// }
|
||||
// event.srcElement.getResponseHeader('content-length')
|
||||
config.onProgress && config.onProgress(e)
|
||||
},
|
||||
});
|
||||
return data;
|
||||
} catch (err) {
|
||||
return err;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
46
vue/src/api/bigScreen/index.js
Normal file
46
vue/src/api/bigScreen/index.js
Normal file
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* @Author: daidai
|
||||
* @Date: 2021-12-09 10:47:56
|
||||
* @LastEditors: Please set LastEditors
|
||||
* @LastEditTime: 2022-04-27 16:32:31
|
||||
* @FilePath: \web-pc\src\api\index.js
|
||||
*/
|
||||
|
||||
|
||||
import { currentList,
|
||||
currentPage,
|
||||
currentSave,
|
||||
currentUpdate,
|
||||
currentDelete,
|
||||
currentSelect,
|
||||
currentSelectList,
|
||||
|
||||
currentPOST,
|
||||
currentGET,
|
||||
currentApi
|
||||
|
||||
} from './modules'
|
||||
import {
|
||||
GETNOBASE,
|
||||
GET
|
||||
} from './api'
|
||||
|
||||
|
||||
export {
|
||||
GETNOBASE,
|
||||
GET
|
||||
}
|
||||
|
||||
|
||||
export {
|
||||
currentApi,
|
||||
currentList,
|
||||
currentPage,
|
||||
currentSave,
|
||||
currentUpdate,
|
||||
currentDelete,
|
||||
currentSelect,
|
||||
currentSelectList,
|
||||
currentPOST,
|
||||
currentGET
|
||||
}
|
||||
97
vue/src/api/bigScreen/modules/index.js
Normal file
97
vue/src/api/bigScreen/modules/index.js
Normal file
@@ -0,0 +1,97 @@
|
||||
/*
|
||||
* @Author: daidai
|
||||
* @Date: 2021-12-23 11:18:37
|
||||
* @LastEditors: Please set LastEditors
|
||||
* @LastEditTime: 2022-04-28 15:10:45
|
||||
* @FilePath: \web-pc\src\api\modules\index.js
|
||||
*/
|
||||
import * as API from "../api";
|
||||
|
||||
export const paramType ={
|
||||
'big1':"/bigscreen/countUserNum", //用户总览
|
||||
'big2':"/bigscreen/countDeviceNum", //设备总览
|
||||
'big3':"/bigscreen/sbtx", //设备提醒
|
||||
'big4':"/bigscreen/alarmNum", //报警次数
|
||||
'big5':'/bigscreen/ssyj',//实时预警
|
||||
'big6':'/bigscreen/installationPlan',// 安装计划
|
||||
'big7':'/bigscreen/ranking',// 报警排名
|
||||
'big8':'/bigscreen/centermap',// //中间地图
|
||||
|
||||
}
|
||||
/****************** 通用增删改查 ********************* */
|
||||
/**
|
||||
* 通用列表
|
||||
* @param {*} param
|
||||
*/
|
||||
export const currentList = (key,param)=> {
|
||||
return API.GET(paramType[key]+"/list", param)
|
||||
}
|
||||
export const currentPage = (key,param)=> {
|
||||
return API.GET(paramType[key]+"/page", param)
|
||||
}
|
||||
/**
|
||||
* 查询可选择的列表
|
||||
* @param {*} param
|
||||
*/
|
||||
export const currentSelectList= (key,param)=> {
|
||||
return API.GET(paramType[key]+"/selectList", param)
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 通用新增
|
||||
* @param {*} param
|
||||
*/
|
||||
export const currentSave= (key,param)=> {
|
||||
return API.POST(paramType[key]+"/save", param)
|
||||
}
|
||||
/**
|
||||
* 通用修改
|
||||
* @param {*} param
|
||||
*/
|
||||
export const currentUpdate= (key,param) => {
|
||||
return API.POST(paramType[key]+"/update", param)
|
||||
}
|
||||
|
||||
/**
|
||||
* 通用删除
|
||||
* @param {*} param
|
||||
*/
|
||||
export const currentDelete= (key,param) => {
|
||||
return API.POST(paramType[key]+"/delete", param)
|
||||
}
|
||||
|
||||
/**
|
||||
* 通用获取所有不分页
|
||||
* @param {*} param
|
||||
*/
|
||||
export const currentSelect= (key,param)=> {
|
||||
return API.GET(paramType[key]+"/select", param)
|
||||
}
|
||||
|
||||
/**
|
||||
* 通用GET
|
||||
* @param {*} param
|
||||
*/
|
||||
export const currentGET= (key,param)=> {
|
||||
return API.GET(paramType[key], param)
|
||||
}
|
||||
/**
|
||||
* 通用POST
|
||||
* @param {*} param
|
||||
*/
|
||||
export const currentPOST= (key,param)=> {
|
||||
return API.POST(paramType[key], param)
|
||||
}
|
||||
// 通用接口集合
|
||||
export const currentApi={
|
||||
currentList,
|
||||
currentPage,
|
||||
currentSave,
|
||||
currentUpdate,
|
||||
currentDelete,
|
||||
currentSelect,
|
||||
currentSelectList,
|
||||
currentPOST,
|
||||
currentGET
|
||||
}
|
||||
Reference in New Issue
Block a user