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

const baseJson = [
  {
    id: 1,
    name: '安葬烈士',
    pcs: 1
  },
  {
    id: 2,
    name: '有名烈士',
    pcs: 1
  },
  {
    id: 3,
    name: '无名烈士',
    pcs: 1
  },
  {
    id: 4,
    name: '寻亲中',
    pcs: 1
  },
  {
    id: 5,
    name: '已找到',
    pcs: 1
  }
]

/**
 * 数据维护-获取列表
 */
export const A7_APIgetList = (id = 10): any => {
  return async (dispatch: AppDispatch) => {
    const res = await http.get(`cms/maintain/detail/${id}`)
    if (res.code === 0) {
      let arr: any = [...baseJson]

      if (res.data.rtf) {
        arr = JSON.parse(res.data.rtf)
      }
      dispatch({ type: 'A7/getList', payload: arr })
    }
  }
}

/**
 * 数据维护-编辑
 */
export const A7_APIsave = (data: any) => {
  return http.post('cms/maintain/edit', data)
}
