228 lines
5.3 KiB
TypeScript
228 lines
5.3 KiB
TypeScript
import { defHttp } from '/@/utils/http/axios';
|
|
import { useMessage } from "/@/hooks/web/useMessage";
|
|
|
|
const { createConfirm } = useMessage();
|
|
|
|
enum Api {
|
|
list = '/appmana/survDeviceDeploy/list',
|
|
save = '/appmana/survDeviceDeploy/add',
|
|
edit = '/appmana/survDeviceDeploy/edit',
|
|
deleteOne = '/appmana/survDeviceDeploy/delete',
|
|
deleteBatch = '/appmana/survDeviceDeploy/deleteBatch',
|
|
importExcel = '/appmana/survDeviceDeploy/importExcel',
|
|
exportXls = '/appmana/survDeviceDeploy/exportXls',
|
|
getYsToken = '/appmana/bigScreen/stationInfoWithCamera',
|
|
getValveStatus = '/appmana/survDeviceDeploy/getValveStatus',
|
|
sendDeviceCmd = '/appmana/survDeviceDeploy/sendDeviceCmd',
|
|
initDevice = '/appmana/survDeviceDeploy/initDevice',
|
|
getDeviceData = '/appmana/fDictDeviceDetail/getDeviceData',
|
|
getCamraInfo = '/appmana/survDeviceDeploy/stationInfoWithCamera',
|
|
cameraStartApi = '/appmana/survDeviceDeploy/cameraStart',
|
|
cameraStopApi = '/appmana/survDeviceDeploy/cameraStop',
|
|
getDeviceCateList = '/appmana/fDictDeviceCate/getDeviceCateList',
|
|
getDeviceList = '/appmana/survDeviceDeploy/getDeviceList',
|
|
syncRelays = '/api/farm/fDeviceDeployRelay/syncRelays',
|
|
getRelayList = '/appmana/survDeviceDeploy/getRelayList',
|
|
queryRelay = '/appmana/survDeviceDeploy/queryRelay',
|
|
}
|
|
|
|
/**
|
|
* 导出api
|
|
* @param params
|
|
*/
|
|
export const getExportUrl = Api.exportXls;
|
|
|
|
/**
|
|
* 导入api
|
|
*/
|
|
export const getImportUrl = Api.importExcel;
|
|
|
|
/**
|
|
* 列表接口
|
|
* @param params
|
|
*/
|
|
export const list = (params) => defHttp.get({ url: Api.list, params });
|
|
|
|
/**
|
|
* 删除单个
|
|
* @param params
|
|
* @param handleSuccess
|
|
*/
|
|
export const deleteOne = (params,handleSuccess) => {
|
|
return defHttp.delete({url: Api.deleteOne, params}, {joinParamsToUrl: true}).then(() => {
|
|
handleSuccess();
|
|
});
|
|
}
|
|
|
|
/**
|
|
* 批量删除
|
|
* @param params
|
|
* @param handleSuccess
|
|
*/
|
|
export const batchDelete = (params, handleSuccess) => {
|
|
createConfirm({
|
|
iconType: 'warning',
|
|
title: '确认删除',
|
|
content: '是否删除选中数据',
|
|
okText: '确认',
|
|
cancelText: '取消',
|
|
onOk: () => {
|
|
return defHttp.delete({url: Api.deleteBatch, data: params}, {joinParamsToUrl: true}).then(() => {
|
|
handleSuccess();
|
|
});
|
|
}
|
|
});
|
|
}
|
|
|
|
/**
|
|
* 保存或者更新
|
|
* @param params
|
|
* @param isUpdate
|
|
*/
|
|
export const saveOrUpdate = (params, isUpdate) => {
|
|
let url = isUpdate ? Api.edit : Api.save;
|
|
return defHttp.post({ url: url, params }, { isTransformResponse: false });
|
|
}
|
|
|
|
|
|
/**
|
|
* 获取token
|
|
* @param params
|
|
* @param isUpdate
|
|
*/
|
|
export const getYsToken = () => {
|
|
return defHttp.post({ url: Api.getYsToken }, { isTransformResponse: false });
|
|
}
|
|
|
|
/**
|
|
* 获取token
|
|
* @param params
|
|
* @param isUpdate
|
|
*/
|
|
export const getCamList = () => {
|
|
return defHttp.post({ url: Api.getCamraInfo }, { isTransformResponse: false });
|
|
}
|
|
|
|
|
|
/**
|
|
* 获取球阀状态
|
|
* @param params
|
|
* @param isUpdate
|
|
*/
|
|
export const getValveStatus = (params) => {
|
|
return defHttp.get({ url: Api.getValveStatus,params}, { isTransformResponse: false });
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
* 获取token
|
|
* @param params
|
|
* @param isUpdate
|
|
*/
|
|
export const sendDeviceCmd = (params) => {
|
|
return defHttp.post({ url: Api.sendDeviceCmd ,params}, { isTransformResponse: false });
|
|
}
|
|
|
|
|
|
/**
|
|
* 设备初始化
|
|
* @param params
|
|
* @param handleSuccess
|
|
*/
|
|
export const deviceInit = (params, handleSuccess) => {
|
|
createConfirm({
|
|
iconType: 'warning',
|
|
title: '确认初始化',
|
|
content: '该操作会删除当前已配置的指标,是否继续',
|
|
okText: '确认',
|
|
cancelText: '取消',
|
|
onOk: () => {
|
|
return defHttp.post({url: Api.initDevice, data: params}, {joinParamsToUrl: true}).then(() => {
|
|
handleSuccess();
|
|
});
|
|
}
|
|
});
|
|
}
|
|
|
|
|
|
/**
|
|
* 列表接口
|
|
* @param params
|
|
*/
|
|
export const getDeviceData = (params) => defHttp.get({ url: Api.getDeviceData, params }, { isTransformResponse: false });
|
|
|
|
|
|
/**
|
|
* 摄像头控制开始
|
|
* @param params
|
|
*/
|
|
export const cameraStart = (params) => {
|
|
return defHttp.post({ url: Api.cameraStartApi, params }, { isTransformResponse: false });
|
|
}
|
|
|
|
/**
|
|
* 摄像头控制结束
|
|
* @param params
|
|
*/
|
|
export const cameraStop = (params) => {
|
|
return defHttp.post({ url: Api.cameraStopApi, params }, { isTransformResponse: false });
|
|
}
|
|
|
|
|
|
/**
|
|
* 列表接口
|
|
* @param params
|
|
*/
|
|
export const getDeviceCateList = (params) => defHttp.get({ url: Api.getDeviceCateList, params });
|
|
|
|
|
|
/**
|
|
* 列表接口
|
|
* @param params
|
|
*/
|
|
export const getDeviceList = (params) => defHttp.post({ url: Api.getDeviceList, params });
|
|
|
|
/**
|
|
* 继电器同步
|
|
* @param params
|
|
* @param handleSuccess
|
|
*/
|
|
export const relaySync = (params, handleSuccess) => {
|
|
createConfirm({
|
|
iconType: 'warning',
|
|
title: '确认同步',
|
|
content: '该操作会删除所有当前已绑定继电器,是否继续',
|
|
okText: '确认',
|
|
cancelText: '取消',
|
|
onOk: () => {
|
|
return defHttp.post({url: Api.syncRelays, data: params}, {joinParamsToUrl: true}).then(() => {
|
|
handleSuccess();
|
|
});
|
|
}
|
|
});
|
|
}
|
|
|
|
|
|
/**
|
|
* 获取继电器列表
|
|
* @param params
|
|
* @param isUpdate
|
|
*/
|
|
export const getRelayList = (params) => {
|
|
return defHttp.get({ url: Api.getRelayList,params}, { isTransformResponse: false });
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
* 查询所有继电器
|
|
* @param params
|
|
* @param isUpdate
|
|
*/
|
|
export const sendRelayQuery = (params) => {
|
|
return defHttp.post({ url: Api.queryRelay, params }, { isTransformResponse: false });
|
|
}
|
|
|
|
|