import request from '@/utils/request'

// 查询固定资产列表
export function listPermanent (query) {
  return request({
    url: '/api/asset/permanent/list',
    method: 'get',
    params: query
  })
}

// 查询固定资产详细
export function getPermanent (id) {
  return request({
    url: '/api/asset/permanent/get/' + id,
    method: 'get'
  })
}

// 查询固定资产详细
export function getPermanentOpen (id) {
  return request({
    url: '/api/open/asset/get/' + id,
    method: 'get'
  })
}


export function updatePermanentGeo (id, geo) {
  return request({
    url: '/api/asset/permanent/editGeo?id=' + id + "&geo=" + geo,
    method: 'post',
  })
}

export function updatePermanent (data) {
  return request({
    url: '/api/asset/permanent/edit',
    method: 'post',
    data: data
  })
}

// 新增固定资产
export function addPermanent (data) {
  return request({
    url: '/api/asset/permanent/add',
    method: 'post',
    data: data
  })
}

// 作废固定资产
export function updateScrapFunc (id) {
  return request({
    url: '/api/asset/permanent/updateScrap/' + id,
    method: 'get'
  })
}

// 出售固定资产
export function updateSaleFunc (id) {
  return request({
    url: '/api/asset/permanent/updateSale/' + id,
    method: 'get'
  })
}


// 修改数量
export function updateQuantityFunc (data) {
  data.quantity = data.changeValue;
  return request({
    url: '/api/asset/permanent/updateQuantity',
    method: 'post',
    data: data
  })
}

// 修改原值
export function updateOriginalValueFunc (data) {
  data.originalValue = data.changeValue;
  return request({
    url: '/api/asset/permanent/updateOriginalValuePermanent',
    method: 'post',
    data: data
  })
}

//修改折旧方式
export function updateDepreciationMethodFunc (data) {
  data.depreciationType = data.changeValue;
  return request({
    url: '/api/asset/permanent/updateDepreciationMethod',
    method: 'post',
    data: data
  })
}


//修改预计使用年数
export function updateExpectedYearsFunc (data) {
  data.expectedYears = data.changeValue;
  return request({
    url: '/api/asset/permanent/updateExpectedYears',
    method: 'post',
    data: data
  })
}

//修改已折旧年数
export function updateDepreciationYearsFunc (data) {
  data.depreciationYears = data.changeValue;
  return request({
    url: '/api/asset/permanent/updateDepreciationYears',
    method: 'post',
    data: data
  })
}

//修改累计折旧
export function updateDepreciationValueFunc (data) {
  data.depreciationValue = data.changeValue;
  return request({
    url: '/api/asset/permanent/updateDepreciationValue',
    method: 'post',
    data: data
  })
}

//修改残值率
export function updateResidualsRateFunc (data) {
  data.residualsRate = data.changeValue;
  return request({
    url: '/api/asset/permanent/updateResidualsRate',
    method: 'post',
    data: data
  })
}

// 删除固定资产
export function delPermanent (id) {
  return request({
    url: '/api/asset/permanent/remove/' + id,
    method: 'get'
  })
}

// 导出固定资产
export function exportPermanent (query) {
  return request({
    url: '/api/asset/permanent/export',
    method: 'get',
    params: query
  })
}

export function exportPermanentWord (query) {
  return request({
    url: '/api/asset/permanent/exportWord',
    method: 'get',
    params: query
  })
}

// 查询当前账套空间数据
export function getPermanentList (id) {
  return request({
    url: '/api/asset/permanent/getPermanentList/' + id,
    method: 'get'
  })
}


// 根据多选ids查询固定资产列表
export function getPermanentListByIds (ids) {
  return request({
    url: '/api/asset/permanent/getPermanentListByIds/' + ids,
    method: 'get'
  })
}

// 根据deptId查询资产列表
export function getPermanentListByDeptId (deptId) {
  return request({
    url: '/api/asset/permanent/getPermanentListByDeptId/' + deptId,
    method: 'get',
  })
}
export function getPermanentListNew (query) {
  return request({
    url: '/api/asset/permanent/list',
    method: 'get',
    params: query
  })
}
// 从凭证生成
export function genFromVoucher (data) {
  return request({
    url: '/api/asset/permanent/genFromVoucher',
    method: 'post',
    params: data
  })
}

// 清空空间字段
export function clearTheGeom (id) {
  return request({
    url: '/api/asset/permanent/clear/' + id,
    method: 'get',
  })
}

// 查询固定资产科目
export function getPermanentSubject (ids) {
  return request({
    url: '/api/asset/permanent/getPermanentSubject/' + ids,
    method: 'get'
  })
}
