/**
 * 安检详情 API（调用 af-safecheck 接口）
 * 固定用法，供 XInspectionDetailDrawer 内置使用
 */
import { post } from '@vue2-client/services/api/restTools'
import { runLogic } from '@vue2-client/services/api/common'

const SERVICE_NAME = 'af-safecheck'

export const getInspectionFullDetail = async (paperId) => {
  const response = await post('api/af-safecheck/logic/getCheckResult', { paperId })
  if (response && (response.checkPaper || response.defectList || response.templateJson || response.checkResultJson)) {
    return response
  }
  throw new Error('API返回数据格式不正确')
}
export const fetchHistoryList = async (userinfoId) => {
  return post('api/af-safecheck/logic/getSafecheckHistoryList', { f_userinfo_id: userinfoId })
}

export const approveInspection = async (params) => {
  return runLogic('checkOrderReview', {
    paperId: params.paperId,
    reviewStatus: params.reviewStatus,
    approvedNote: params.approvedNote,
    user: params.user
  }, SERVICE_NAME)
}
