import http from '@/utils/http'
import { AppDispatch } from '..'
/**
 * 烈士档案-获取列表
 */
export const A4_APIgetList = (data: any, flag = false): any => {
  if (flag) return http.post('cms/relic/pageList', data)
  else {
    return async (dispatch: AppDispatch) => {
      const res = await http.post('cms/relic/pageList', data)
      if (res.code === 0) {
        const obj = {
          list: res.data.records,
          total: res.data.total
        }

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

/**
 * 烈士档案-删除
 */
export const A4_APIdel = (id: number) => {
  return http.get(`cms/relic/remove/${id}`)
}

/**
 * 烈士档案-新增
 */
export const A4_APIsave = (data: any) => {
  return http.post('cms/relic/save', data)
}

/**
 * 烈士档案-获取详情
 */
export const A4_APIgetInfo = (id: number) => {
  return http.get(`cms/relic/detail/${id}`)
}
