import request from '@/utils/request'
// 网格查询机构
export function griddeptnum(data) {
  return request({
    url: '/system/gridSelect/info',
    method: 'get',
    params: data
  })
}

export function getDeptTree(data) {
  return request({
    url: '/system/user/deptTree',
    method: 'get',
    data: data
  })
}

export function delGrid(data) {
  return request({
    url: '/grid/region/delete',
    method: 'post',
    data: data
  })
}

export function getRegionDes(gridId) {
  return request({
    url: `/grid/region/${gridId}`,
    method: 'get'
  })
}

export function regionUpdate(data) {
  return request({
    url: `/grid/region/top/update`,
    method: 'post',
    data
  })
}

export function secRegionUpdate(data) {
  return request({
    url: `/grid/region/sec/update`,
    method: 'post',
    data
  })
}

export function getVirtualgrid(data) {
  return request({
    url: '/grid/virtual/list',
    method: 'get',
    params: data
  })
}

export function getCustManageData(data) {
  return request({
    url: '/system/gridSelect/list/custManage',
    method: 'get',
    params: data
  })
}

// 分页获取虚拟网格内客户列表
export function getVirCustManageData(data) {
  return request({
    url: '/grid/virtual/cust/list',
    method: 'get',
    params: data
  })
}

export function custManageOperate(data) {
  return request({
    url: '/system/gridSelect/list/custManage',
    method: 'put',
    params: data
  })
}

export function getVirtualgridDetail(gridId) {
  return request({
    url: `/grid/virtual/${gridId}`,
    method: 'get',
  })
}

export function upanddel(data) {
  return request({
    url: `/system/gridSelect/list/upanddel`,
    method: 'post',
    data: data
  })
}

export function deleteVirtual(data) {
  return request({
    url: `/grid/virtual/delete`,
    method: 'post',
    data: data
  })
}

export function getUserList(data) {
  return request({
    url: `/dept/user/list`,
    method: 'get',
    params: data
  })
}
// 更新虚拟网格客户导入方式/管户导入方式
export function updateVirtual(data) {
  return request({
    url: '/grid/virtual/update',
    method: 'post',
    data: data
  })
}

export const downloadFile = `/system/gridSelect/exportList`

export function cleanRedis(data) {
  return request({
    url: `/info/redis/clean`,
    method: 'post',
    data
  })
}

// 获取二级网格
export function getSecRedis(data) {
  return request({
    url: `/info/redis/sec/get`,
    method: 'get',
    params: data
  })
}


export function getStatedis(data) {
  return request({
    url: `/info/redis/state`,
    method: 'get',
    params: data
  })
}

export function getTopRedis(data) {
  return request({
    url: `/info/redis/top/get`,
    method: 'get',
    params: data
  })
}

// 获取虚拟网格
export function getVirtualRedis(data) {
  return request({
    url: `/info/redis/virtual/get`,
    method: 'get',
    params: data
  })
}

export function saveSecRedis(data) {
  return request({
    url: `/info/redis/sec/save`,
    method: 'post',
    data
  })
}

export function saveTopRedis(data) {
  return request({
    url: `/info/redis/top/save`,
    method: 'post',
    data
  })
}

// 暂存虚拟网格
export function saveVirtualRedis(data) {
  return request({
    url: `/info/redis/virtual/save`,
    method: 'post',
    data
  })
}

export function checkName(data) {
  return request({
    url: `/grid/region/check/name`,
    method: 'get',
    params: data
  })
}

export function checkVirtualName(data) {
  return request({
    url: `/grid/virtual/check/name`,
    method: 'get',
    params: data
  })
}

export function getAddressTree(data) {
  return request({
    url: `/address/getAddressTree`,
    method: 'get',
    params: data
  })
}
export function getAddressRegion(data) {
  return request({
    url: `/address/region`,
    method: 'get',
    params: data
  })
}
// 分页获取行政网格内客户列表
export function regionGridCustList(data) {
  return request({
    url: `/grid/region/cust/list`,
    method: 'get',
    params: data
  })
}
// 查询获取行政网格绑定客户经理列表
export function regionGridUserList(data) {
  return request({
    url: `/grid/region/cust/unbind/list`,
    method: 'get',
    params: data
  })
}
// 变动行政网格客户与客户经理绑定关系
export function custRegionUnbind(data) {
  return request({
    url: `/grid/region/cust/unbind`,
    method: 'post',
    data
  })
}
// 分页获取行政网格列表
export function getGrid(data) {
  return request({
    url: `/grid/region/list`,
    method: 'get',
    params: data
  })
}
// 创建特色网格
export function featureGridAdd(data) {
  return request({
    url: `/draw/grid/add`,
    method: 'post',
    data
  })
}

// 暂存特色网格
export function featureGridStash(data) {
  return request({
    url: `/draw/grid/add`,
    method: 'post',
    data
  })
}

// 修改特色网格
export function featureGridUpdate(data) {
  return request({
    url: `/draw/grid/edit`,
    method: 'post',
    data
  })
}

// 分页获取特色网格列表
export function getFeaturegrid(data) {
  return request({
    url: `/draw/grid/list`,
    method: 'get',
    params: data
  })
}

// 获取网格列表（用于客群创建，简化查询）
export function getSimpleGridList(data) {
  return request({
    url: `/draw/grid/simpleList`,
    method: 'get',
    params: data
  })
}

// 删除网格
export function featureGridDelete(data) {
  return request({
    url: `/draw/grid/delete`,
    method: 'post',
    data
  })
}

// 分页获取特色网格内客户列表
export function featureGridCustList(data) {
  return request({
    url: `/draw/grid/cust/list`,
    method: 'get',
    params: data
  })
}

// 变动特色网格客户与客户经理绑定关系
export function custUnbind(data) {
  return request({
    url: `/draw/grid/cust/unbind`,
    method: 'post',
    data
  })
}

// 获取特色网格信息
export function getDrawDes(gridId) {
  return request({
    url: `/draw/grid/${gridId}`,
    method: 'get'
  })
}

// 获取特色网格暂存信息
export function getDrawTopRedis(data) {
  return request({
    url: `/info/redis/draw/get`,
    method: 'get',
    params: data
  })
}

// 获取特色网格预计客户数
export function shapeCustCount(data) {
  return request({
    url: `/draw/grid/cust/count`,
    method: 'get',
    params: data
  })
}

// 暂存特色网格
export function drawSave(data) {
  return request({
    url: `/info/redis/draw/save`,
    method: 'post',
    data
  })
}

// 变动虚拟网格客户与客户经理绑定关系
export function custVirUnbind(data) {
  return request({
    url: `/grid/virtual/cust/unbind`,
    method: 'post',
    data
  })
}

// 虚拟网格手动添加客户与客户经理关系
export function virtualCustAdd(data) {
  return request({
    url: `/grid/virtual/cust/add`,
    method: 'post',
    data
  })
}

// 查询虚拟网格内客户列表，手动绑定关系用
export function virtualCustSearch(data) {
  return request({
    url: `/grid/virtual/cust/search`,
    method: 'get',
    params: data
  })
}

// 导入创建一级网格信息
export function importData(data) {
  return request({
    url: '/grid/region/template/import',
    method: 'post',
    data,
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
  })
}

//下载一级模板
export function fileTemplate() {
  return request({
    url: `/grid/region/template/export`,
    method: 'post',
    responseType: 'blob'
  })
}

//创建一级网格模板
export function templateCreate(data) {
  return request({
    url: `/grid/region/template/create`,
    method: 'post',
    data
  })
}
//一级导出
export function resultExport(data) {
  return request({
    url: `/grid/region/template/result/export`,
    method: 'post',
    responseType: 'blob',
    timeout: 30000,
    data
  })
}


// 导入创建二级网格信息
export function importSecData(data) {
  return request({
    url: '/grid/region/template/sec/import',
    method: 'post',
    data,
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
  })
}
//下载二级模板
export function fileSecTemplate() {
  return request({
    url: `/grid/region/template/sec/export`,
    method: 'post',
    responseType: 'blob'
  })
}
//创建二级网格模板
export function templateSecCreate(data) {
  return request({
    url: `/grid/region/template/sec/create`,
    method: 'post',
    data
  })
}

//一级导出
export function secResultExport(data) {
  return request({
    url: `/grid/region/template/sec/result/export`,
    method: 'post',
    responseType: 'blob',
    timeout: 30000,
    data
  })
}

// 查询网格下拉
export function getGridList(data) {
  return request({
    url: `/grid/region/transfer/sec/grid`,
    method: 'get',
    params: data
  })
}

// 移出网格
export function removeGridApi(data) {
  return request({
    url: `/grid/region/transfer/add`,
    method: 'post',
    data
  })
}
