import request from '@/utils/request'

// 查询价值评估等级下拉框
export function searchValue() {
  return request({
    url: '',
    method: 'post',
    data: {
      type: '1',
      name: 'dbo.客户关系管理系统_价值评估_查询数据_MESWORK'
    }
  })
}
// 地区查询
export function selectAdress() {
  return request({
    url: '',
    method: 'post',
    data: {
      type: '1',
      name: '发货管理_省份查询'
    }
  })
}
export function selectCustomer(AdressID, pageCurrent, pageSize) {
  return request({
    url: '',
    method: 'post',
    data: {
      type: '1',
      name: '客户关系管理系统_按地区查询_客户名称',
      param: '省份流水号=' + AdressID,
      Pagination: pageCurrent + '&' + pageSize
    }
  })
}
// 通过名称查
export function selectCustomerOfName(name, pageCurrent, pageSize) {
  return request({
    url: '',
    method: 'post',
    data: {
      type: '1',
      name: '客户关系管理系统_按客户名称查询_客户名称',
      param: '客户流水号=' + name,
      Pagination: pageCurrent + '&' + pageSize
    }
  })
}
export function selectMarketingManager(AdressID) {
  return request({
    url: '',
    method: 'post',
    data: {
      type: '1',
      name: '客户关系管理系统_按地区查询_营销经理',
      param: '省份流水号=' + AdressID
    }
  })
}
export function initCustomer() {
  return request({
    url: '',
    method: 'post',
    data: {
      type: '1',
      name: '客户关系管理系统_初始化查询_客户名称'
    }
  })
}
export function getTree() {
  return request({
    url: '',
    method: 'post',
    data: {
      type: 1,
      name: '人事档案管理_部门关系_查询节点',
      param: '子节点=0=int'
    }
  })
}
export function tree(data, pid) {
  const result = []
  let temp
  for (let i = 0; i < data.length; i++) {
    if (data[i].父节点 === pid) {
      const obj = { label: data[i].节点名称, id: data[i].子节点 }
      temp = tree(data, data[i].子节点)
      if (temp.length > 0) {
        obj.children = temp
      }
      result.push(obj)
    }
  }
  return result
}
export function getTablePeople(code) {
  return request({
    url: '',
    method: 'post',
    data: {
      type: 1,
      name: '人事档案管理_人员_部门与人员_查询数据_根据部门编号',
      param: '考核部门编号=' + code + '=int'
    }
  })
}
export function deleteCustomer(customerId) {
  return request({
    url: '',
    method: 'post',
    data: {
      type: '2',
      name: 'dbo.客户关系管理系统_客户_删除数据_MESWORK',
      param: '客户流水号=' + customerId
    }
  })
}
export function deleteMarketingManager(MarketingManagerId) {
  return request({
    url: '',
    method: 'post',
    data: {
      type: '2',
      name: '客户关系管理系统_营销经理_删除数据_MESWORK',
      param: '营销经理地区流水号=' + MarketingManagerId
    }
  })
}
export function addMarketingManager(MarketingManagerId, AdressID) {
  return request({
    url: '',
    method: 'post',
    data: {
      type: '2',
      name: '客户关系管理系统_营销经理_增加数据_MESWORK',
      param: '营销经理流水号=' + MarketingManagerId + '&省份流水号=' + AdressID
    }
  })
}
export function editMarketingManager(MarketingManagerId, AdressID) {
  return request({
    url: '',
    method: 'post',
    data: {
      type: '2',
      name: '客户关系管理系统_营销经理_修改数据_MESWORK',
      param: '营销经理流水号=' + MarketingManagerId + '&营销经理地区流水号=' + AdressID
    }
  })
}
export function addCustomer(AdressID, CustomerName, CallNumber, Fax, Adress, People, Email, BankAccount, DutyParagraph, Assessment, Remark, OpeningBank) {
  return request({
    url: '',
    method: 'post',
    data: {
      type: '2',
      name: '客户关系管理系统_客户_增加数据_MESWORK',
      param: '省份流水号=' + AdressID + '&客户名称=' + CustomerName + '&电话=' + CallNumber + '&传真=' + Fax + '&地址=' + Adress + '&联系人=' + People + '&电子邮箱=' + Email + '&银行账号=' + BankAccount + '&税号=' + DutyParagraph + '&价值评估流水号=' + Assessment + '&备注=' + Remark + '&开户行=' + OpeningBank
    }
  })
}
export function selectAdressOfID(AdressID) {
  return request({
    url: '',
    method: 'post',
    data: {
      type: '1',
      name: '客户关系管理系统_通过省份流水号查省份名称_查询数据_MESWORK',
      param: '省份流水号=' + AdressID
    }
  })
}
export function editCustomer(AdressID, CustomerName, CallNumber, Fax, Adress, People, Email, BankAccount, DutyParagraph, Assessment, Remark, ID, OpeningBank) {
  return request({
    url: '',
    method: 'post',
    data: {
      type: '2',
      name: '客户关系管理系统_客户_修改数据_MESWORK',
      param: '省份流水号=' + AdressID + '&客户名称=' + CustomerName + '&电话=' + CallNumber + '&传真=' + Fax + '&地址=' + Adress + '&联系人=' + People + '&电子邮箱=' + Email + '&银行账号=' + BankAccount + '&税号=' + DutyParagraph + '&价值评估流水号=' + Assessment + '&备注=' + Remark + '&客户流水号=' + ID + '&开户行=' + OpeningBank
    }
  })
}

