import http from '@/utils/http'
import { AppDispatch } from '..'
/**
 * 获取 相机列表 表格列表（存到仓库）
 */
export const A1_APIgetlist = (data: any): any => {
  return async (dispatch: AppDispatch) => {
    const res = await http.post('cms/camera/pageList', data)
    if (res.code === 0) {
      const obj = {
        list: res.data.records,
        total: res.data.total
      }
      dispatch({ type: 'A1/getList', payload: obj })
    }
  }
}

/**
 * 获取 相机列表 表格列表（导出表格）
 */
export const A1_APIgetlistDerive = (data: any) => {
  return http.post('cms/camera/pageList', data)
}

/**
 * 删除单个表格数据
 */
export const A1_APIremove = (id: number) => {
  return http.get(`cms/camera/remove/${id}`)
}

/**
 * 新增/修改
 */
export const A1_APIadd = (data: any) => {
  return http.post('cms/camera/save', data)
}

/**
 * 通过id获取详情
 */
export const A1_APIgetInfo = (id: number) => {
  return http.get(`cms/camera/detail/${id}`)
}

/**
 * 根据sn查询
 */
export const A1_APIcheckSN = (cameraSns: string) => {
  return http.get(`cms/camera/findBySn/${cameraSns}`)
}
