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, isNeedBind}) {
  return await GET(`/work/getWorkMeter?page=${page}&park=${park}&keyword=${replaceSpecialIcon(keyword)}&isNeedBind=${isNeedBind}`);
}


// 获取商户下的电表，后台
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 handleOperateMeterMode = async function({ ids = [], mode, days, images, reason }) {
  return await PUT(`/equipment/batchSetMode`, { ids, mode, days, images, reason });
}

// 绑定时获取电表的最新信息
export const getWorkMeterDetail = async function(code = '') {
  return await GET(`/vx/getWorkMeterDetail?code=${code}`);
}

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

// 获取卡列表
export const getCardList = async function({park = "", keyword = "", page = 1}) {
  return await GET(`/equipment/getCardList?page=${page}&park=${park}&keyword=${replaceSpecialIcon(keyword)}`);
}


// 获取互感器列表
export const getCollectionList = async function({park = "", keyword = "", page = 1}) {
  return await GET(`/transformer/list/select?page=${page}&park=${park}&transformerId=${replaceSpecialIcon(keyword)}`);
}


// 获取库存电表列表
export const getInventoryMeter = async function({park = "", keyword = "", page = 1, status = 1}) {
  return await GET(`/electricity/list?page=${page}&park=${park}&keyword=${replaceSpecialIcon(keyword)}&status=${status}`);
}

// 新装电表
export const installMeter = async function(data) {
  return await POST(`/wx/workBench/installMeter`, data);
}

// 拆表
export const uninstallMeter = async function(data) {
  return await POST(`/flow/doMeterRemoveApproval`, data);
}

// 获取商户下的电表，后台
export const getCollectorList = async function(keyword) {
  return await GET(`/collector/list?collectorAddress=${replaceSpecialIcon(keyword)}`);
}

// 微信工单列表查询所有电表
export const getWorkOrderAllMeter = async function({ keyword, park, page = 1, size = 20 }) {
  return await GET(`/vx/getAllMeter?keyword=${replaceSpecialIcon(keyword)}&pid=${park}&page=${page}&size=${size}`,);
}