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

/**
 * 藏品盘点-列表
 */
export const D7_APIList = (data: any, exportFlag = false): any => {
  if (exportFlag) return http.post('/cms/orderCheck/page', data)
  return async (dispatch: AppDispatch) => {
    const res = await http.post('/cms/orderCheck/page', data)
    if (res.code === 0) {
      const obj = {
        list: res.data.records,
        total: res.data.total
      }

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

export const D7_APIGoodList = (data: any) => {
  return http.post('/cms/orderCheck/goods/getList', data)
}

/**
 * 藏品盘点-删除
 */
export const D7_APIdel = (id: number) => {
  return http.get(`cms/orderCheck/remove/${id}`)
}

/**
 * 藏品盘点-获取详情
 */
export const D7_APIgetInfo = (id: number) => {
  return http.get(`cms/orderCheck/detail/${id}`)
}

/**
 * 藏品盘点-创建订单
 */
export const D7_APIcreate = () => {
  return http.get('/cms/orderCheck/create')
}

/**
 * 藏品盘点-存草稿
 */
export const D7_APIsaveDraft = (data: any) => {
  return http.post('cms/orderCheck/saveDraft', data)
}

/**
 * 藏品盘点-创建
 */
export const D7_APIsaveCreate = (data: any) => {
  return http.post('cms/orderCheck/saveCreate', data)
}

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

/**
 * 藏品盘点-审批
 */
export const D7_APIsaveAudit = (data: any) => {
  return http.post('cms/orderCheck/audit', data)
}

/**
 * 出库-撤回订单
 */
export const D7_APIrevocation = (id: number) => {
  return http.get(`cms/orderCheck/revocation/${id}`)
}
