import request from '@/utils/request'

// 保存打卡
export function addAttendance(data) {
  return request({
    url: '/attendance/v1/record',
    method: 'post',
    data: data
  })
}

export function getAttendanceList(data) {
  return request({
    url: '/attendance/v1/record-list',
    method: 'post',
    data: data
  })
}

// 获取同组人员列表
export function getUserList(params) {
  return request({
    url: '/system/user/list',
    method: 'get',
    params: params
  })
}

// 添加上岗记录
export function addPostRecord (data) {
  return request({
    url: '/attendance/postRecord/direct',
    method: 'post',
    data: data
  })
}

// 新增：获取上岗记录列表
export function getPostRecordList (params) {
  return request({
    url: '/attendance/postRecord/list',
    method: 'get',
    params: params
  })
}
// 获取班组上岗列表
export function listgroupbyTimeanduserid () {
  return request({
    url: `/attendance/postRecord/listgroupbyTimeanduserid`,
    method: 'get'
  })
}

// 新增：更新上岗记录
export function updatePostRecord (data) {
  return request({
    url: '/attendance/postRecord/direct',
    method: 'put',
    data: data
  })
}

// 查询通道和区域
export function dataConfigTree (level) {
  return request({
    url: '/dataConfig/dataConfigTree',
    method: 'get',
    data: {
      treeType: 'POSITION',
      maxLevel: level
    }
  })
}
// 查询通道和区域
export function areaList () {
  return request({
    url: '/attendance/area/list',
    method: 'post'
  })
}

//查询班组成员
export function memberList (data) {
  return request({
    url: '/attendance/record/list',
    method: 'get',
    data: data
  })
}

//批量新增考勤班组成员
export function addMember (data) {
  return request({
    url: '/attendance/record/add/list',
    method: 'post',
    data
  })
}

//查询最后一次上岗区域
export function queryLastTime (data) {
  return request({
    url: '/attendance/postRecord/query-last-time',
    method: 'get',
    data: data
  })
}

//查询上班打卡和下班打卡是否可以点击
export function queryClickAble () {
  return request({
    url: '/attendance/v1/getRecordType',
    method: 'get',
  })
}
