import request from '@/utils/request'

//  查询 楼栋/单元/楼层/户号
export function getPhaseList(data) {
  return request({
    url: '/building/phase',
    method: 'get',
    params: data
  })
}

//  查询 楼栋/单元/楼层/户号
export function getBuildingList(data) {
  return request({
    url: '/building/building',
    method: 'get',
    params: data
  })
}

//  查询 楼栋/单元/楼层/户号
export function getUnitList(data) {
  return request({
    url: '/building/unit',
    method: 'get',
    params: data
  })
}

//  查询 楼栋/单元/楼层/户号
export function getLevelList(data) {
  return request({
    url: '/building/level',
    method: 'get',
    params: data
  })
}

//  查询 楼栋/单元/楼层/户号
export function getRoomNoList(data) {
  return request({
    url: '/building/roomno',
    method: 'get',
    params: data
  })
}

// 获取楼栋户主信息列表
export function buildingList(data) {
  return request({
    url: '/building/list',
    method: 'post',
    data: {
      phaseId: data.phaseId,
      buildingId: data.buildingId,
      unitId: data.unitId,
      levelId: data.levelId,
      roomNoId: data.roomNoId,
      ownerName: data.ownerName,
      ownerTel: data.ownerTel,
      idCard: data.idCard,
      pageNum: data.pageNum,
      pageSize: data.pageSize
    }
  })
}
// 认证通过户主信息
export function userPassCertification(data) {
  return request({
    url: 'userPassCertification',
    method: 'post',
    data: {
      ownerName: data.ownerName,
      ownerTel: data.ownerTel,
      pageNum: data.pageNum,
      pageSize: data.pageSize,
      verifyStatus: data.verifyStatus
    }
  })
}
// 修改停用或启用
export function updataPassCertification(data) {
  console.log('api: ', data)
  return request({
    url: '/updataPassCertification',
    method: 'post',
    data: {
      ownerTel: data.ownerTel,
      verifyStatus: data.verifyStatus
    }
  })
}

// 批量删除 楼栋户主信息
export function deleteBuilding(data) {
  return request({
    url: '/building/delete',
    method: 'delete',
    data
  })
}

// 添加楼栋户主信息
export function addBuilding(data) {
  return request({
    url: '/building/add',
    method: 'post',
    data: {
      phaseId: data.phaseId,
      buildingId: data.buildingId,
      unitId: data.unitId,
      levelId: data.levelId,
      roomNoId: data.roomNoId,
      ownerName: data.ownerName,
      ownerTel: data.ownerTel,
      roleId: data.roleId,
      gender: data.gender
    }
  })
}

// 修改楼栋户主信息
export function updateBuilding(data) {
  return request({
    url: '/building/update',
    method: 'put',
    data: {
      userVerifyId: data.userVerifyId,
      roleId: data.roleId,
      verifyStatus: data.verifyStatus,
      remark: data.remark
    }
  })
}

// 根据楼栋信息 id 查询
export function getByIdBuildingId(buildingId) {
  return request({
    url: '/building/verify/' + buildingId,
    method: 'get'
  })
}

// 获取楼栋户主信息列表
export function communityBuildinglist(data) {
  return request({
    url: '/buildinglist',
    method: 'post',
    data: {
      phase: data.phase,
      building: data.building,
      unit: data.unit,
      level: data.level,
      roomNo: data.roomNo,
      ownerName: data.ownerName,
      pageNum: data.pageNum,
      pageSize: data.pageSize
    }
  })
}
// 查询小区楼栋资料库
export function buildingHouse(data) {
  const config = {
    url: '/buildinghouse',
    method: 'post',
    data: {
      phase: data.phase,
      building: data.building,
      unit: data.unit,
      level: data.level,
      roomNo: data.roomNo
    }
  }
  return request(config)
}

// 查询小区楼栋资料库
export function communityBuildingAdd(data) {
  return request({
    url: '/communitybuilding/update',
    method: 'post',
    data: {
      phase: data.phase,
      updatePhase: data.updatePhase,
      building: data.building,
      updateBuilding: data.updateBuilding,
      unit: data.unit,
      updateUnit: data.updateUnit,
      level: data.level,
      updateLevel: data.updateLevel,
      roomNo: data.roomNo,
      updateRoomNo: data.updateRoomNo
    }
  })
}

// 下载excel模板
export function buildingDownloadExcel() {
  return request({
    url: '/building/downloadExcel',
    method: 'get',
    responseType: 'blob'
  })
}

// 添加当前期/栋/单元/层/户/节点
export function addNode(data) {
  return request({
    url: '/addnode',
    method: 'post',
    data: {
      id: data.id,
      name: data.name,
      type: data.type,
      nodeNumber: data.nodeNumber
    }
  })
}

// 删除当前期/栋/单元/层/户/节点
export function deleteNode(data) {
  return request({
    url: '/deletenode',
    method: 'post',
    data: {
      id: data.id,
      name: data.name,
      type: data.type,
      nodeNumber: data.nodeNumber
    }
  })
}
// 查新楼栋信息详情
export function buildingDetails(data) {
  return request({
    url: '/building/details',
    method: 'post',
    data: {
      id: data.userVerifyId
    }
  })
}
// 楼栋详情审核用户
export function verifyinfoAdd(data) {
  return request({
    url: '/user/verifyinfo/' + data.userVerifyId,
    method: 'put',
    params: {
      verifyStatus: data.status,
      roleState: data.roleId,
      remark: data.remark

    }
  })
}
