import request from '@/utils/request'
import constant from '@/constant'

function list(obj) {
  var formData = new FormData();

  for(var key in obj){
    formData.append(key,obj[key]);
  }
  
  return request.post(constant.serverUrl + "/bus/companyInfo/list",formData);
}

function pageList(formData) {
  return request.post(constant.serverUrl + "/bus/companyInfo/pageList", formData);
}

function loadChildren(formData) {
  return request.post(constant.serverUrl + "/bus/companyInfo/children",formData);
}

function create() {
  return request.get(constant.serverUrl + "/bus/companyInfo/create");
}

function edit(id) {
  return request.get(constant.serverUrl + "/bus/companyInfo/edit/" + id);
}

function add(formModel) {
  return request.post(constant.serverUrl + "/bus/companyInfo/add", formModel, {
    headers: {
      "Content-Type": "application/json"
    }
  });
}

function update(formModel) {
  return request.post(constant.serverUrl + "/bus/companyInfo/update", formModel, {
    headers: {
      "Content-Type": "application/json"
    }
  });
}

function remove(id) {
  return request.post(constant.serverUrl + "/bus/companyInfo/delete/" + id);
}

function batchRemove(idList) {
  return request.post(constant.serverUrl + "/bus/companyInfo/batchDelete", idList, {
    headers: {
      "Content-Type": "application/json"
    }
  });
}

function queryBindDeviceList(formData) {
  var objData = {};
  formData.forEach((value, key) => objData[key] = value);
  return request.get(constant.serverUrl + "/bus/companyInfo/queryBindDeviceList", {
    params: objData,
    headers: {
      "Content-Type": "application/json"
    }
  });
}

function bindDevice(formData) {
  return request.post(constant.serverUrl + "/bus/companyInfo/bindDevice", formData);
}

function unbindDevice(formData) {
  return request.post(constant.serverUrl + "/bus/companyInfo/unbindDevice", formData);
}

function treeList() {
  return request.post(constant.serverUrl + "/bus/companyInfo/treeList");
}

function isOpenMobilePayment(formData) {
  return request.post(constant.serverUrl + "/bus/companyInfo/isOpenMobilePayment",formData);
}



export default {
  list, create, edit, add, update, remove, batchRemove, pageList, queryBindDeviceList,
  bindDevice, unbindDevice,loadChildren,treeList,isOpenMobilePayment
}