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

/**
 * 藏品鉴定-删除
 */
export const B2_APIdel = (id: number) => {
  return http.get(`cms/orderAuth/remove/${id}`)
}

/**
 * 藏品鉴定-创建订单
 */
export const B2_APIcreate = () => {
  return http.get('cms/orderAuth/create')
}

/**
 * 藏品鉴定-获取详情
 */
export const B2_APIgetInfo = (id: number) => {
  return http.get(`cms/orderAuth/detail/${id}`)
}

/**
 * 藏品鉴定-存草稿
 */
export const B2_APIsaveDraft = (data: any) => {
  return http.post('cms/orderAuth/saveDraft', data)
}

/**
 * 藏品鉴定-创建
 */
export const B2_APIsaveCreate = (data: any) => {
  return http.post('cms/orderAuth/saveCreate', data)
}

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

/**
 * 藏品鉴定-审批
 */
export const B2_APIsaveAudit = (data: any) => {
  return http.post('cms/orderAuth/audit', data)
}

/**
 * 藏品鉴定-撤回订单
 */
export const B2_APIrevocation = (id: number) => {
  return http.get(`cms/orderAuth/revocation/${id}`)
}

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

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

/**
 * 藏品鉴定-线索-详情
 */
export const B2X_APIgetInfo = (id: number) => {
  return http.get(`cms/orderAuth/collect/detail/${id}`)
}
