import apis from '../utils/request';
import { replaceSpecialIcon } from '../utils/index'
const { GET, POST, PUT, DELETE } = apis

// 获取电表列表
export const getMeterList = async function() {
  return await GET('/wx/getMeterList');
}

// 获取表计详情
export const getMeterDetail = async function({ tenement, id }) {
  return await GET(`/wx/getMeterDetail/${tenement}/${id}`);
}

// 获取某一商户的电表列表
export const getTenementMeterList = async function(tid) {
  return await GET(`/wx/getMeterList/${tid}`);
}

// 获取某一园区下的电表列表
export const getParkMeterList = async function({park = "", keyword = "", page = 1}) {
  return await GET(`/equipment/getOperateMeterList?page=${page}&park=${park}&keyword=${replaceSpecialIcon(keyword)}`);
}

// 获取某一园区下的简洁电表列表
export const getParkSimpleMeterList = async function({park = "", keyword = "", page = 1}) {
  return await GET(`/work/getWorkMeter?page=${page}&park=${park}&keyword=${replaceSpecialIcon(keyword)}`);
}


// 获取商户下的电表，后台
export const getBackTenementMeters = async function(park, tenement) {
  return await GET(`/vx/getWorkMeterDetails?park=${park}&tenement=${tenement}`);
}

// 拉合闸
export const handleOperateMeterSwitch = async function({ ids = [], status }) {
  return await PUT(`/equipment/batchSwtich`, { ids, status });
}
// 绑定时获取电表的最新信息
export const getWorkMeterDetail = async function(code = '') {
  return await GET(`/vx/getWorkMeterDetail?code=${code}`);
}