import http from '@/utils/http'
import { AppDispatch } from '..'
/**
 * 线索管理-获取列表
 */
export const A2_APIgetList = (data: any, flag = false): any => {
  if (flag) return http.post('cms/clue/pageList', data)
  else {
    return async (dispatch: AppDispatch) => {
      const res = await http.post('cms/clue/pageList', data)
      if (res.code === 0) {
        const obj = {
          list: res.data.records,
          total: res.data.total
        }

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

/**
 * 线索管理-删除
 */
export const A2_APIdel = (id: number) => {
  return http.get(`cms/clue/remove/${id}`)
}

/**
 * 线索管理-新增
 */
export const A2_APIsave = (data: any) => {
  return http.post('cms/clue/save', data)
}

/**
 * 线索管理-获取详情
 */
export const A2_APIgetInfo = (id: number) => {
  return http.get(`cms/clue/detail/${id}`)
}
