import axios from '@/common/services/axios-instance'
const reqSuffix = '' // '/a.manage'
class WorkdayService {
  // 获取列表
  // 已通过列表数据源获取

  // 删除
  deleteDocs(ids) {
    return axios({
      url: `api/framework/v1/workcalendar/calendars/${ids}`,
      method: 'delete',
    })
  }

  // 获取工作日历
  getDoc(params) {
    return axios({
      url: `api/framework/v1/workcalendar/find/calendar${reqSuffix}`,
      // url: `api/framework/v1/workcalendar/find/${params.id}/calendar${reqSuffix}`,
      method: 'get',
      params,
    })
  }

  // 初始化对应年份日历
  initWorkDay(params) {
    return axios({
      url: `api/framework/v1/workcalendar/init/item${reqSuffix}`,
      method: 'get',
      params,
    })
  }

  // 获取工作时间
  getWorkTime(params) {
    return axios({
      url: `api/framework/v1/worktime/find/byCode${reqSuffix}`,
      // url: `api/framework/v1/workcalendar/find/${params.id}/calendar${reqSuffix}`,
      method: 'get',
      params: {
        ...params,
      },
    })
  }

  // 新建 or 更新
  saveWorkTime(params) {
    return axios({
      url: `api/framework/v1/worktime/save${reqSuffix}`,
      method: 'post',

      ...params,
    })
  }

  // 新建 or 更新
  saveDoc(params) {
    return axios({
      url: `api/framework/v1/workcalendar/save${reqSuffix}`,
      method: 'post',

      ...params,
    })
  }
}

export default new WorkdayService()
