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

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

/**
 * 出库-删除
 */
export const D6_APIdel = (id: number) => {
  return http.get(`cms/orderOut/remove/${id}`)
}

/**
 * 出库-创建订单
 */
export const D6_APIcreate = () => {
  return http.get('cms/orderOut/create')
}

/**
 * 出库-获取详情
 */
export const D6_APIgetInfo = (id: number) => {
  return http.get(`cms/orderOut/detail/${id}`)
}

/**
 * 出库-存草稿
 */
export const D6_APIsaveDraft = (data: any) => {
  return http.post('cms/orderOut/saveDraft', data)
}

/**
 * 出库-创建
 */
export const D6_APIsaveCreate = (data: any) => {
  return http.post('cms/orderOut/saveCreate', data)
}

/**
 * 出库-编辑保存
 */
export const D6_APIsaveApply = (data: any) => {
  return http.post('cms/orderOut/saveApply', data)
}

/**
 * 出库-审批
 */
export const D6_APIsaveAudit = (data: any) => {
  return http.post('cms/orderOut/audit', data)
}

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