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

/**
 *根据Type获取预约记录列表 1-展馆预约记录 2-活动预约记录
 */
export const B_APIgetList = (data: { pageNum: number; pageSize: number; type: number }): any => {
  return async (dispatch: AppDispatch) => {
    const res = await http.post('museum/appointment/page', data)
    if (res.code === 0) {
      const obj = {
        list: res.data.records,
        total: res.data.total
      }
      dispatch({ type: 'B/getList', payload: obj })
    }
  }
}

/**
 * 预约记录-获取详情
 */
export const B_APIgetInfo = (id: number) => {
  return http.post(`museum/appointment/info/${id}`)
}

/**
 * 预约记录-删除
 */
export const B_APIdel = (id: number) => {
  return http.post(`museum/appointment/del/${id}`)
}

/**
 * 导出Excel Type 1-展馆预约记录 2-活动预约记录
 */
export const B_APIexportExcel = (type: number) => {
  // return `baseURL/api/museum/appointment/exportExcel?type=${type}`
  return http.get(`${baseURL}/api/museum/appointment/exportExcel?type=` + type, {
    responseType: 'blob'
  })
}

/**
 * 导出Excel Type 1-展馆预约记录 2-活动预约记录
 */
// export const B_APIexportExcel = (type: number) => {
//   return `baseURL/api/museum/appointment/exportExcel?type=${type}`
// }
