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

/**
 * 人员出入库-列表
 */
export const D3_APIList = (data: any, exportFlag = false): any => {
  if (exportFlag) return http.post('/cms/orderMember/page', data)
  return async (dispatch: AppDispatch) => {
    const res = await http.post('/cms/orderMember/page', data)
    if (res.code === 0) {
      const obj = {
        list: res.data.records,
        total: res.data.total
      }

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

/**
 * 人员出入库-删除
 */
export const D3_APIdel = (id: number) => {
  return http.get(`cms/orderMember/remove/${id}`)
}

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

/**
 * 人员出入库-创建订单
 */
export const D3_APIcreate = () => {
  return http.get('/cms/orderMember/create')
}

/**
 * 人员出入库-存草稿
 */
export const D3_APIsaveDraft = (data: any) => {
  return http.post('cms/orderMember/saveDraft', data)
}

/**
 * 人员出入库-创建
 */
export const D3_APIsaveCreate = (data: any) => {
  return http.post('cms/orderMember/saveCreate', data)
}

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

/**
 * 人员出入库-审批
 */
export const D3_APIsaveAudit = (data: any) => {
  return http.post('cms/orderMember/audit', data)
}

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