import http from '@/utils/http'
import { AppDispatch } from '..'
/**
 * 古桥档案-获取列表
 */
export const A1_APIgetList = (data: any, flag = false): any => {
  if (flag) return http.post('cms/bridge/pageList', data)
  else {
    return async (dispatch: AppDispatch) => {
      const res = await http.post('cms/bridge/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_APIdel = (id: number) => {
  return http.get(`cms/bridge/remove/${id}`)
}

/**
 * 古桥档案-新增
 */
export const A1_APIsave = (data: any) => {
  return http.post('cms/bridge/save', data)
}

/**
 * 古桥档案-获取详情
 */
export const A1_APIgetInfo = (id: number) => {
  return http.get(`cms/bridge/detail/${id}`)
}

// ----------------附件管理---------------------

/**
 * 古桥档案-附件管理-获取列表
 */
export const A1_APIfileGetList = (data: any) => {
  return http.post('cms/bridgeFile/getList', data)
}

/**
 * 古桥档案--附件管理-删除
 */
export const A1_APIfileDel = (id: number) => {
  return http.get(`cms/bridgeFile/remove/${id}`)
}

/**
 * 古桥档案--附件管理-编辑用途
 */
export const A1_APIfileSave = (data: any) => {
  return http.post('cms/bridgeFile/save', data)
}

// ----------------维护记录---------------------

/**
 * 古桥档案-维护记录-获取列表
 */
export const A1_APIlogGetList = (data: any) => {
  return http.post('cms/maintain/getList', data)
}

/**
 * 古桥档案--维护记录-删除
 */
export const A1_APIlogDel = (id: number) => {
  return http.get(`cms/maintain/remove/${id}`)
}

/**
 * 古桥档案--维护记录-新增、编辑
 */
export const A1_APIlogSave = (data: any) => {
  return http.post('cms/maintain/save', data)
}

/**
 * 古桥档案--维护记录-获取详情
 */
export const A1_APIlogGetInfo = (id: number) => {
  return http.get(`cms/maintain/detail/${id}`)
}
