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

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

/**
 * 藏品注销-删除
 */
export const D8_APIdel = (id: number) => {
  return http.get(`cms/orderLogout/remove/${id}`)
}

/**
 * 藏品注销-创建订单
 */
export const D8_APIcreate = () => {
  return http.get('cms/orderLogout/create')
}

/**
 * 藏品注销-获取详情
 */
export const D8_APIgetInfo = (id: number) => {
  return http.get(`cms/orderLogout/detail/${id}`)
}

/**
 * 藏品注销-存草稿
 */
export const D8_APIsaveDraft = (data: any) => {
  return http.post('cms/orderLogout/saveDraft', data)
}

/**
 * 藏品注销-创建
 */
export const D8_APIsaveCreate = (data: any) => {
  return http.post('cms/orderLogout/saveCreate', data)
}

/**
 * 藏品注销-编辑保存
 */
export const D8_APIsaveApply = (data: any) => {
  return http.post('cms/orderLogout/saveApply', data)
}

/**
 * 藏品注销-审批
 */
export const D8_APIsaveAudit = (data: any) => {
  return http.post('cms/orderLogout/audit', data)
}

/**
 * 藏品注销-撤回订单
 */
export const D8_APIrevocation = (id: number) => {
  return http.get(`cms/orderLogout/revocation/${id}`)
}
