import request from '@/utils/request'

//新增组态项目
export const addProject = (data) => {
    return request({
        url: '/cs-harmonic-boot/csconfiguration/add',
        method: 'post',
        data,
    })
}

// 修改组态项目
export const updateProject = (data) => {
    return request({
        url: '/cs-harmonic-boot/csconfiguration/audit',
        method: 'post',
        data,
    })
}

//组态项目分页查询
export const queryProjectPage = (data) => {
    return request({
        url: '/cs-harmonic-boot/csconfiguration/queryPage',
        method: 'post',
        data: Object.assign(
            {
                orderBy: '',
                pageNum: 1,
                pageSize: 999,
                searchBeginTime: '',
                searchEndTime: '',
                searchState: 0,
                searchValue: '',
                sortBy: '',
            },
            data
        ),
    })
}

// 新增组态页面
export const addCsPage = (data) => {
    return request({
        url: '/cs-harmonic-boot/cspage/add',
        method: 'post',
        data: data,
    })
}

// 修改组态页面
export const updateCsPage = (data) => {
    return request({
        url: '/cs-harmonic-boot/cspage/audit',
        method: 'post',
        data: data,
    })
}

// 组态页面分页查询
export const queryCsPagePage = (data) => {
    return request({
        url: '/cs-harmonic-boot/cspage/queryPage',
        method: 'post',
        data: Object.assign(
            {
                orderBy: '',
                pageNum: 0,
                pageSize: 0,
                pid: '',
                searchBeginTime: '',
                searchEndTime: '',
                searchState: 0,
                searchValue: '',
                sortBy: '',
            },
            data
        ),
    })
}

// 上传图片
export const uploadImage = (file) => {
    let form = new FormData()
    form.append('file', file)
    return request({
        url: '/cs-harmonic-boot/csconfiguration/uploadImage',
        method: 'post',
        header: {
            'Content-Type': 'multipart/form-data',
        },
        data: form,
    })
}

// 获取监测点指标
export const getMonitorPointIndex = (lineId) => {
    let form = new FormData()
    form.append('lineId', lineId)

    return request({
        url: '/cs-harmonic-boot/lineTarget/target',
        method: 'post',
        header: {
            'Content-Type': 'application/x-www-form-urlencoded',
        },
        data: form,
    })
}

// 获取指标数据类型和相别
export const getDataTypeAndPhase = ({ name, pid }) => {
    let form = new FormData()
    form.append('name', name)
    form.append('pid', pid)
    return request({
        url: '/cs-harmonic-boot/lineTarget/targetDetail',
        method: 'post',
        header: {
            'Content-Type': 'application/x-www-form-urlencoded',
        },
        data: form,
    })
}

// 治理终端台账树

export const getTerminalTree = (data) => {
    return request({
        url: '/cs-device-boot/csLedger/lineTree',
        method: 'post',
        data,
    })
}

export const getLineData = (id) => {
    let data = new FormData()
    data.append('id', id)
    return request({
        url: '/cs-harmonic-boot/lineTarget/lineData',
        method: 'post',
        header: {
            'Content-Type': 'application/x-www-form-urlencoded',
        },
        data: data,
    })
}
