import { AppDispatch } from '@/store'
import http from '@/utils/http'
import { APIbase } from '../layout'

/**
 * 事故登记 -获取分页列表
 */
export const G1_APIgetList = (data: any): any => {
  return async (dispatch: AppDispatch) => {
    const res = await http.post('cms/orderAccident/page', data)
    if (res.code === 0) {
      const obj = {
        list: res.data.records,
        total: res.data.total
      }

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

/**
 * 事故登记-藏品列表(取总账数据)-分页
 */
export const G1_APIgetClueList = (data: any) => {
  return http.post('cms/orderAccident/goodPage', data)
}

export const G1API_obj = {
  创建订单: () => APIbase('get', 'cms/orderAccident/create'),
  获取详情: (id: number) => APIbase('get', `cms/orderAccident/detail/${id}`),
  草稿: (data: any) => APIbase('post', `cms/orderAccident/saveDraft`, data),
  发起: (data: any) => APIbase('post', `cms/orderAccident/saveApply`, data),
  重新发起: (id: number) => APIbase('get', `cms/orderAccident/reissue/${id}`),
  审批: (data: any) => APIbase('post', `cms/orderAccident/audit`, data),
  撤回: (id: number) => APIbase('get', `cms/orderAccident/revocation/${id}`),
  删除: (id: number) => APIbase('get', `cms/orderAccident/remove/${id}`)
}
