import request from '@/utils/request';
import common from '@/utils/common';

//修改围栏进出记录
function updateRecord(data) {
    return request({
        url: '/api/equipment/fenceAccessRecord',
        method: 'put',
        data: data
    })
}

//新增围栏进出记录
function addRecord(data) {
    return request({
        url: '/api/equipment/fenceAccessRecord',
        method: 'post',
        data: data
    })
}



//获取围栏进出记录详细信息
function getRecordById(id) {
    return request({
        url: '/api/equipment/fenceAccessRecord/' + id,
        method: 'get'
    })
}

//查询围栏进出记录列表
function RecordList(data) {
    let queryParams = Object.assign({}, data);
    if (queryParams.Date && queryParams.Date.length) {
        queryParams.beginTime = common.DateFormat(queryParams.Date[0], 'yyyy-MM-dd');
        queryParams.endTime = common.DateFormat(queryParams.Date.length > 1 ? queryParams.Date[1] : '', 'yyyy-MM-dd');
    }
    delete queryParams['Date'];
    return request({
        url: '/api/equipment/fenceAccessRecord/list',
        method: 'get',
        params: queryParams
    })
}

//删除围栏进出记录
function DropRecord(ids) {
    return request({
        url: '/api/equipment/fenceAccessRecord/' + ids,
        method: 'delete'
    })
}


export default {
    updateRecord: updateRecord,
    addRecord: addRecord,
    getRecordById: getRecordById,
    RecordList: RecordList,
    DropRecord: DropRecord
}