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

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

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

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

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

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