/*
包含n个接口请求函数的模块
函数的返回值: promise对象
 */
import axios from 'axios'
import ajax from './ajax'

let BASE_URL

axios.get('static/Data/EnitySystem.data').then(async res => {
    if (res.status === 200) {
        BASE_URL = `${res.data ? res.data.ServerIP : ''}:${res.data ? res.data.ServerPort : ''}`
    }
})

// 登录
export const reqLogin = (data,reqName) => ajax(BASE_URL+'/login',data,'POST',reqName)

// 退出登录
export const reqLogout = (data) => ajax(BASE_URL+'/logout',data,'POST')

// 获取大屏
export const reqBigScreen= () => ajax(BASE_URL+'/v1/bigscreen')

// 获取设备
export const reqDevice= () => ajax(BASE_URL+'/v1/device')

// 获取预览信号源列表
export const reqPreviewSourceList= () => ajax(BASE_URL+'/v1/sourcePreview')

// 刷新视图
export const reqRefreshView = (data) => ajax(BASE_URL+'/v1/refreshView',data,'POST')

// 配置大屏
export const reqConfigBigScreen = (data) => ajax(BASE_URL+'/v1/bigscreen',data,'POST')

// 配置设备
export const reqConfigDevice = (data) => ajax(BASE_URL+'/v1/device',data,'POST')

// 发送指令
export const reqSendInstruction = (data) => ajax(BASE_URL+'/v1/instruction',data,'POST')

// 获取预案列表
export const reqGetPlanList= () => ajax(BASE_URL+'/v1/plan')

// 保存预案
export const reqSavePlan = (data) => ajax(BASE_URL+'/v1/plan',data,'POST')

// 申请预案
export const reqApplyPlan = (id,data) => ajax(BASE_URL+`/v1/plan/${id}`,data,'POST')

// 删除预案
export const reqDeletePlan = (id) => ajax(BASE_URL+`/v1/plan`,{id},'DELETE')
