import request from '@/utils/request'

// 小区下拉
export function getAreaList(query) {
  return request({
    url: '/zdsz/area/getAreaList',
    method: 'get',
    params: query
  })
}
// 查询小区管理列表
export function listArea(query) {
  return request({
    url: '/zdsz/area/list',
    method: 'get',
    params: query
  })
}

// 查询小区管理详细
export function getArea(id) {
  return request({
    url: '/zdsz/area/' + id,
    method: 'get'
  })
}

// 新增小区管理
export function addArea(data) {
  return request({
    url: '/zdsz/area',
    method: 'post',
    data: data
  })
}

// 修改小区管理
export function updateArea(data) {
  return request({
    url: '/zdsz/area',
    method: 'put',
    data: data
  })
}

// 删除小区管理
export function delArea(id) {
  return request({
    url: '/zdsz/area/' + id,
    method: 'delete'
  })
}
export function getAreas(district) {
  return request({
    url: '/zdsz/area/getAreaList',
    method: 'get',
    params:{district:district}
  })
}
// 小区导入滚动条监控接口
export function flushProgress() {
  return request({
    url: '/zdsz/area/flushProgress',
    method: 'get',
  })
}
// 小区导入滚动条停止监控接口
export function clearFlushProgress() {
  return request({
    url: '/zdsz/area/clearFlushProgress',
    method: 'get',
  })
}
export function formatTimestampToDateString(timestamp) {
  let date = new Date(timestamp);
  let year = date.getFullYear();
  let month = date.getMonth() + 1;
  let day = date.getDate();

  function addLeadingZero(number) {
    return number < 10 ? '0' + number : number;
  }

  return year + '-' + addLeadingZero(month) + '-' + addLeadingZero(day);
}
