import request from '@/utils/request'

const api = {
  tenantWidthLocation: '/system/sysLocationSetting/sys/location/list',
  correlationInfo: '/toy/improved/getCorrelationInfo/'
}
// 查询玩具待完善信息列表
export function listImproved(query) {
  return request({
    url: '/toy/improved/list',
    method: 'get',
    params: query
  })
}

// 查询玩具待完善信息列表
export function listAuditImproved(query) {
  return request({
    url: '/toy/improved/auditList',
    method: 'get',
    params: query
  })
}

// 查询玩具待完善信息详细
export function getImproved(id) {
  return request({
    url: '/toy/improved/' + id,
    method: 'get'
  })
}

// 查询玩具待完善信息详细
export function batchAudit(id) {
  return request({
    url: '/toy/improved/batchAudit/' + id,
    method: 'put'
  })
}

// 查询玩具待完善信息详细
export function selectListByKeyWordId(id) {
  return request({
    url: '/toy/improved/selectListByKeyWordId/' + id,
    method: 'get'
  })
}

// 新增玩具待完善信息
export function addImproved(data) {
  return request({
    url: '/toy/improved',
    method: 'post',
    data: data
  })
}

// 审核操作
export function batchPassOrNotPass(data) {
  return request({
    url: '/toy/improved/batchPassOrNotPass',
    method: 'post',
    data,
    transformRequest(data) {
      return data
    },
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  })
}

// 合并重复组
export function combinedRepeatGroup(data) {
  return request({
    url: '/toy/improved/combinedRepeatGroup',
    method: 'post',
    data: data
  })
}

// 释放重复组
export function releaseRepeatGroup(data) {
  return request({
    url: '/toy/improved/releaseRepeatGroup',
    method: 'post',
    data: data
  })
}

// 添加玩具到库
export function addToy(data) {
  return request({
    url: '/toy/improved/addToy/' + data,
    method: 'get'
  })
}

// 修改玩具待完善信息
export function updateImproved(data) {
  return request({
    url: '/toy/improved',
    method: 'put',
    data: data
  })
}

// 删除玩具待完善信息
export function delImproved(id) {
  return request({
    url: '/toy/improved/' + id,
    method: 'delete'
  })
}

// 批量导入excel文件
export function importExcel(data) {
  return request({
    url: '/toy/improved/import',
    method: 'post',
    data,
    transformRequest(data) {
      return data
    },
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  })
}

export function importImage(data) {
  return request({
    url: '/file/uploadByUploadTag',
    method: 'post',
    data,
    headers: {
      'repeatSubmit': false // 可重复提交
    }
  })
}
export function combinedGroup(data) {
  return request({
    url: '/toy/improved/combinedRepeatGroup',
    method: 'post',
    data
  })
}

// 查询幼儿园关联的位置
export function fetchTenantWidthLocation(params) {
  return request({
    url: api.tenantWidthLocation,
    method: 'get',
    params
  })
}
/**
 * 获取关联分类信息
 * @param id 待核对玩具id
 * @param platformId 关联的玩具id
 */
export function fetchCorrelationInfo(id, platformId) {
  return request({
    url: api.correlationInfo + id + '/' + platformId,
    method: 'get'
  })
}
