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

/**
 * 借展管理-列表
 */
export const A4_APIList = (data: any, exportFlag = false): any => {
  if (exportFlag) return http.post('/cms/orderFile/page', data)
  return async (dispatch: AppDispatch) => {
    const res = await http.post('/cms/orderFile/page', data)
    if (res.code === 0) {
      const obj = {
        list: res.data.records,
        total: res.data.total
      }

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

export const A4_APIDownload = (data: number[], type: 1 | 2) => {
  return http.post(`cms/orderFile/downloadBatch?downloadType=${type}`, data)
}
