import request from '@/utils/request'

// 查询固定资产列表
export function permanentList(query) {
  return request({
    url: '/asset/permanent/list',
    method: 'get',
    params: query
  })
}
// 查询合同信息列表
export function contractionList(query) {
  return request({
    url: '/contraction/info/list',
    method: 'get',
    params: query
  })
}
// 新增固定资产
export function addPermanent(data) {
  return request({
    url: '/asset/permanent/add',
    method: 'post',
    data: data
  })
}
// 查询固定资产详细
export function getPermanent(id) {
  return request({
    url: '/asset/permanent/get/' + id,
    method: 'get'
  })
}
// 修改固定资产
export function updatePermanent(data) {
  return request({
    url: '/asset/permanent/edit',
    method: 'post',
    data: data
  })
}
// 删除固定资产
export function delPermanent(id) {
  return request({
    url: '/asset/permanent/remove/' + id,
    method: 'get'
  })
}
//上传全局方法附件
export function commonAttach(data) {
  return request({
    url: '/common/attach',
    method: 'post',
    header: { "Content-Type": 'application/x-www-form-urlencoded' },
    data: data
  })
}
//上传全局方法附件
export function commonUpload(data) {
  return request({
    url: '/common/upload',
    method: 'post',
    header: { "Content-Type": 'application/x-www-form-urlencoded' },
    data: data
  })
}
//查询已上传附件
export const attachmentList = (data) => {
  return request({
    url: '/system/attachment/query',
    method: 'get',
    params: data
  })
}
//删除已上传附件
export function systemAttachment(ids) {
  if (ids != undefined) {
    return request({
      url: '/system/attachment/remove/' + ids,
      method: 'get'
    })
  }
}
// 新增合同信息
export function addInfo(data) {
  return request({
    url: '/contraction/info/add',
    method: 'post',
    data: data
  })
}
// 查询合同信息详细
export function getInfo(id) {
  return request({
    url: '/contraction/info/get/' + id,
    method: 'get'
  })
}
// 删除合同信息
export function delInfo(id) {
  return request({
    url: '/contraction/info/remove/' + id,
    method: 'get'
  })
}
// 修改合同信息
export function updateInfo(data) {
  return request({
    url: '/contraction/info/edit',
    method: 'post',
    data: data
  })
}
// 财务公开列表
export function financePublicList(query) {
  return request({
    url: '/villageAffairs/public/financePublicList',
    method: 'get',
    params: query
  })
}
// 零工公开列表
export function tempWorkerPublicList(query) {
  return request({
    url: '/villageAffairs/public/tempWorkerPublicList',
    method: 'get',
    params: query
  })
}
// 重大事项公开列表
export function majorEventPublicList(query) {
  return request({
    url: '/villageAffairs/public/majorEventPublicList',
    method: 'get',
    params: query
  })
}
// 财务公开详情
export function financePublicDetail(query) {
  return request({
    url: '/villageAffairs/public/financePublicDetail',
    method: 'get',
    params: query
  })
}
// 零工公开详情
export function tempWorkerPublicDetail(query) {
  return request({
    url: '/villageAffairs/public/tempWorkerPublicDetail',
    method: 'get',
    params: query
  })
}
// 重大事项公开详情
export function majorEventPublicDetail(query) {
  return request({
    url: '/villageAffairs/public/majorEventPublicDetail',
    method: 'get',
    params: query
  })
}

//获取区、镇、村地区
export function treeselectByUser(query) {
  return request({
    url: '/system/dept/treeselectByUser',
    method: 'get',
    params: query
  })
}
//获取账套列表
export function listByDeptId(query) {
  return request({
    url: '/finance/book/listByDeptId',
    method: 'get',
    params: query
  })
}

// 切换部门
export function changeDept(query) {
  return request({
    url: '/system/user/changeDept',
    method: 'get',
    params: query
  })
}
// 切换账套
export function changeBook(query) {
  return request({
    url: '/system/user/changeBook',
    method: 'get',
    params: query
  })
}
// 财务公开新增
export function openAdd(data) {
  return request({
    url: '/open/open/add',
    method: 'post',
    data: data
  })
}
// 财务公开修改
export function openEdit(data) {
  return request({
    url: '/open/open/edit',
    method: 'post',
    data: data
  })
}
// 零工公开新增
export function tempWorkerOpenAdd(data) {
  return request({
    url: '/subcontract/tempWorkerOpen/add',
    method: 'post',
    data: data
  })
}
// 财务公开修改
export function tempWorkerOpenEdit(data) {
  return request({
    url: '/subcontract/tempWorkerOpen/edit',
    method: 'post',
    data: data
  })
}
// 重大事项新增
export function majorEventOpenAdd(data) {
  return request({
    url: '/subcontract/majorEventOpen/add',
    method: 'post',
    data: data
  })
}
// 重大事项修改
export function majorEventOpenEdit(data) {
  return request({
    url: '/subcontract/majorEventOpen/edit',
    method: 'post',
    data: data
  })
}
// 财务公开删除
export function openRemove(id) {
  return request({
    url: '/open/open/remove/' + id,
    method: 'get'
  })
}
// 零工公开删除
export function tempWorkerOpenRemove(id) {
  return request({
    url: '/subcontract/tempWorkerOpen/remove/' + id,
    method: 'get'
  })
}
// 零工公开删除
export function majorEventOpenRemove(id) {
  return request({
    url: '/subcontract/majorEventOpen/remove/' + id,
    method: 'get'
  })
}

// 查询零工登记列表
export function listOddjob(query) {
  return request({
    url: '/villageAffairs/public/oddjobList',
    method: 'get',
    params: query
  })
}

// 新增零工登记
export function addOddjob(data) {
  return request({
    url: '/subcontract/oddjob/add',
    method: 'post',
    data: data
  })
}

// 修改零工登记
export function updateOddjob(data) {
  return request({
    url: '/subcontract/oddjob/edit',
    method: 'post',
    data: data
  })
}

// 查询零工登记详细
export function getOddjob(id) {
  return request({
    url: '/subcontract/oddjob/get/' + id,
    method: 'get'
  })
}

// 删除零工登记
export function delOddjob(id) {
  return request({
    url: '/subcontract/oddjob/remove/' + id,
    method: 'get'
  })
}

// 财务公开榜
export function financialAmountPublicMonthList(query) {
  return request({
    url: '/villageAffairs/public/financialAmountPublicMonthList',
    method: 'get',
    params: query // ?bookId=<账套ID 必填>&yearMonth=<查询年月 必填 yyyy-MM>
  })
}

// 查询用户个人信息
export function getUserProfile() {
  return request({
    url: '/system/user/profile/get',
    method: 'get'
  })
}

// 修改用户个人信息
export function updateUserProfile(data) {
  return request({
    url: '/system/user/profile/edit',
    method: 'post',
    data: data
  })
}

// 用户密码重置
export function updateUserPwd(oldPassword, newPassword) {
  const data = {
    oldPassword,
    newPassword
  }
  return request({
    url: '/system/user/profile/updatePwd',
    method: 'post',
    params: data
  })
}

// 查询账套基本信息
export function bookInfo(bookId) {
  return request({
    url: `/villageAffairs/public/bookInfo/${bookId}`,
    method: 'get',
  })
}

// 查询科目余额表 可分页 需授权
export function trailBalanceList(query) {
  return request({
    url: '/finance/balance/list',
    method: 'get',
    params: query // ?startDate=<开始年月 yyyy-MM>&startSubjectId=<起始科目ID>&endSubjectId=<结束科目ID 如果需要查询单个科目 则设置为和startSubjectId一样即可>&filterZero=<bool 是否过滤掉余额为0结果>&showSubSubject=<bool 是否显示下级科目>&分页参数...
  })
}

export function getLoginBook() {
  return request({
    url: '/finance/book/getLoginBook',
    method: 'get'
  })
}

// 查询投票主题列表
export function listPoll(deptId , query) {
  return request({
    url: `/villageAffairs/public/poll/list/${deptId}`,
    method: 'get',
    params: query
  })
}

// 姓名, 账套ID, 身份证, 返回里会有个id字段
export function checkFarmer(data) {
  return request({
    url: '/register/checkFarmer',
    method: 'post',
    data: data,
  })
}

// 查询投票主题详细
export function getPoll(id) {
  return request({
    url: `/villageAffairs/public/poll/detail/${id}`,
    method: 'get'
  })
}

// 投票 id为主题ID, option为投票选项ID, 多个用,分隔, userId为认证后的农户ID
export function votePoll(id, data) {
  return request({
    url: `/villageAffairs/public/poll/vote/${id}`,
    method: 'post',
    params: data,
  })
}

// 新增投票主题
export function addPoll(data) {
  return request({
    url: '/poll/poll/add',
    method: 'post',
    data: data
  })
}

// 修改投票主题
export function updatePoll(data) {
  return request({
    url: '/poll/poll/edit',
    method: 'post',
    data: data
  })
}

// 删除投票主题
export function delPoll(id) {
  return request({
    url: '/poll/poll/remove/' + id,
    method: 'get'
  })
}

// 发布投票主题
export function publicPoll(id) {
  return request({
    url: '/poll/poll/publicPoll/'+ id,
    method: 'get'
  })
}
