import http from '@/utils/http'
import { AppDispatch } from '..'

/**
 * 借展管理-列表
 */
export const F1_APIList = (data: any, exportFlag = false): any => {
  if (exportFlag) return http.post('/cms/orderExhibition/page', data)
  return async (dispatch: AppDispatch) => {
    const res = await http.post('/cms/orderExhibition/page', data)
    if (res.code === 0) {
      const obj = {
        list: res.data.records,
        total: res.data.total
      }

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

/**
 * 借展管理-删除
 */
export const F1_APIdel = (id: number) => {
  return http.get(`cms/orderExhibition/remove/${id}`)
}

/**
 * 借展管理-获取详情
 */
export const F1_APIgetInfo = (id: number) => {
  return http.get(`cms/orderExhibition/detail/${id}`)
}

/**
 * 借展管理-创建订单
 */
export const F1_APIcreate = () => {
  return http.get('/cms/orderExhibition/create')
}

/**
 * 借展管理-存草稿
 */
export const F1_APIsaveDraft = (data: any) => {
  return http.post('cms/orderExhibition/saveDraft', data)
}

/**
 * 借展管理-创建
 */
export const F1_APIsaveCreate = (data: any) => {
  return http.post('cms/orderExhibition/saveCreate', data)
}

/**
 * 借展管理-编辑保存
 */
export const F1_APIsaveApply = (data: any) => {
  return http.post('cms/orderExhibition/saveApply', data)
}

/**
 * 借展管理-审批
 */
export const F1_APIsaveAudit = (data: any) => {
  return http.post('cms/orderExhibition/audit', data)
}

/**
 * 借展管理-撤回
 */
export const F1_APIrevocation = (id: number) => {
  return http.get(`cms/orderExhibition/revocation/${id}`)
}
