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

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

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

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

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