import http from '@/utils/http'
import { AppDispatch } from '..'
/**
 * 文物修复 - 获取分页列表
 */
export const E4_APIgetList = (data: any, exportFlag?: boolean): any => {
  if (exportFlag) return http.post('cms/orderPreserveFix/page', data)
  else {
    return async (dispatch: AppDispatch) => {
      const res = await http.post('cms/orderPreserveFix/page', data)
      if (res.code === 0) {
        const obj = {
          list: res.data.records,
          total: res.data.total
        }

        dispatch({ type: 'E4/getList', payload: obj })
      }
    }
  }
}

/**
 * 文物修复-删除
 */
export const E4_APIdel = (id: number) => {
  return http.get(`cms/orderPreserveFix/remove/${id}`)
}

/**
 * 文物修复-创建订单
 */
export const E4_APIcreate = () => {
  return http.get('cms/orderPreserveFix/create')
}

/**
 * 文物修复-获取详情
 */
export const E4_APIgetInfo = (id: number) => {
  return http.get(`cms/orderPreserveFix/detail/${id}`)
}

/**
 * 文物修复-存草稿
 */
export const E4_APIsaveDraft = (data: any) => {
  return http.post('cms/orderPreserveFix/saveDraft', data)
}

/**
 * 文物修复-创建
 */
export const E4_APIsaveCreate = (data: any) => {
  return http.post('cms/orderPreserveFix/saveCreate', data)
}

/**
 * 文物修复-编辑保存
 */
export const E4_APIsaveApply = (data: any) => {
  return http.post('cms/orderPreserveFix/saveApply', data)
}

/**
 * 文物修复-审批
 */
export const E4_APIsaveAudit = (data: any) => {
  return http.post('cms/orderPreserveFix/audit', data)
}

/**
 * 文物修复-撤回订单
 */
export const E4_APIrevocation = (id: number) => {
  return http.get(`cms/orderPreserveFix/revocation/${id}`)
}
