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

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

/**
 * 藏品编辑-删除
 */
export const C6_APIdel = (id: number) => {
  return http.get(`cms/orderEdit/remove/${id}`)
}

/**
 * 藏品编辑-创建订单
 */
export const C6_APIcreate = () => {
  return http.get('cms/orderEdit/create')
}

/**
 * 藏品编辑-获取详情
 */
export const C6_APIgetInfo = (id: number) => {
  return http.get(`cms/orderEdit/detail/${id}`)
}

/**
 * 藏品编辑-存草稿
 */
export const C6_APIsaveDraft = (data: any) => {
  return http.post('cms/orderEdit/saveDraft', data)
}

/**
 * 藏品编辑-创建
 */
export const C6_APIsaveCreate = (data: any) => {
  return http.post('cms/orderEdit/saveCreate', data)
}

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

/**
 * 藏品编辑-审批
 */
export const C6_APIsaveAudit = (data: any) => {
  return http.post('cms/orderEdit/audit', data)
}

/**
 * 藏品编辑-撤回订单
 */
export const C6_APIrevocation = (id: number) => {
  return http.get(`cms/orderEdit/revocation/${id}`)
}
