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

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

/**
 * 藏品出库-创建订单
 */
export const C4_APIcreate = () => {
  return http.get('cms/orderSite/out/create')
}

/**
 * 藏品出库-提交
 */
export const C4_APIresubmit = (data: any) => {
  return http.post('cms/orderSite/out/apply', data)
}

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

/**
 * 藏品出库-审批
 */
export const C4_APIaduit = (data: any) => {
  return http.post('cms/orderSite/out/audit', data)
}
