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

/**
 * 库房设置 - 获取分页列表
 */
export const C2_APIgetList = (data: any): any => {
  return async (dispatch: AppDispatch) => {
    const res = await http.post('cms/goodsFile/page', data)
    if (res.code === 0) {
      const obj = {
        list: res.data.records,
        total: res.data.total
      }

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

/**
 * 删除附件
 */
export const API_C2dels = (data: number[]) => {
  return http.post('cms/goodsFile/removes', data)
}

/**
 * 藏品详情-附件列表(没有分页，给详情用)
 */
export const API_goodFileList = (id: number) => {
  return http.get(`cms/goods/file/${id}`)
}

/**
 * 批量下载
 */
export const API_C2downS = (data: number[], type: 1 | 2) => {
  return http.post(`cms/goodsFile/downloadBatch?downloadType=${type}`, data)
}

/**
 * 设置-批量设置
 */
export const API_C2setFile = (data: any) => {
  return http.post('cms/goodsFile/setting', data)
}

/**
 * 藏品附件-根据ids数组拿列表
 */
export const API_C2getListByIds = (data: string[]) => {
  return http.post('cms/goodsFile/getList', data)
}
