import http from '@/http'

export const list = params => http.get('/api/v1/self-appraisal/list', { params }) // 单位绩效评价计划列表

// 当前绩效评价待自评列表、已自评列表
const listUrl = {
  1: '/api/v1/self-appraisal/pending-list/',
  2: '/api/v1/self-appraisal/appraisaled-list/'
}
export const selfProList = (state, planId, params) => http.get(`${listUrl[state]}${planId}`, { params })
export const templateDetail = projectCode => http.get(`/api/v1/self-appraisal/get-appraisal-template-detail/${projectCode}`) // 获取自评模版详情
export const submitSelfAppraisal = data => http.post(`/api/v1/self-appraisal/submit-self-appraisal`, data) // 提交自评
export const editSelfAppraisal = data => http.post(`/api/v1/self-appraisal/edit-self-appraisal`, data) // 重新修改自评

const exportUrls = {
  1: '/api/v1/self-appraisal/score/export',
  2: '/api/v1/re-appraisal/score/export',
  3: '/api/v1/verify/score/export'
}
export const exportScore = (state, params) => http.get(exportUrls[state], { params, responseType: 'blob' }) // 导出

export const selfAppasialGetNotSealedPdf = (data) => http.post(`/api/v1/self-appraisal/getNotSealedPdf`, data)

// 暂存
const draftUrls = {
  1: '/api/v1/self-appraisal/draft-self-appraisal',
  2: '/api/v1/re-appraisal/draft-reAppraisal',
  3: '/api/v1/verify/draft-verify'
}
export const saveDraft = (state, data) => http.post(draftUrls[state], data) // 评分暂存
export const draftDetail = params => http.get(`/api/v1/self-appraisal/get-draft`, { params }) // -获取草稿评分详情

