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

/**
 * 藏品征集-删除
 */
export const B1_APIdel = (id: number) => {
  return http.get(`cms/orderCollect/remove/${id}`)
}

/**
 * 藏品征集-创建订单
 */
export const B1_APIcreate = () => {
  return http.get('cms/orderCollect/create')
}

/**
 * 藏品征集-获取详情
 */
export const B1_APIgetInfo = (id: number) => {
  return http.get(`cms/orderCollect/detail/${id}`)
}

/**
 * 藏品征集-存草稿
 */
export const B1_APIsaveDraft = (data: any) => {
  return http.post('cms/orderCollect/saveDraft', data)
}

/**
 * 藏品征集-创建
 */
export const B1_APIsaveCreate = (data: any) => {
  return http.post('cms/orderCollect/saveCreate', data)
}

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

/**
 * 藏品征集-审批
 */
export const B1_APIsaveAudit = (data: any) => {
  return http.post('cms/orderCollect/audit', data)
}

/**
 * 藏品征集-撤回订单
 */
export const B1_APIrevocation = (id: number) => {
  return http.get(`cms/orderCollect/revocation/${id}`)
}

// --------------------------线索相关-----------------

/**
 * 藏品征集-线索-新增\编辑
 */
export const B1X_APIsave = (data: any) => {
  return http.post('cms/orderCollect/collect/save', data)
}

/**
 * 藏品征集-线索-详情
 */
export const B1X_APIgetInfo = (id: number) => {
  return http.get(`cms/orderCollect/collect/detail/${id}`)
}
