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

/**
 * 藏品注销 -获取分页列表
 */
export const D3_APIgetList = (data: any): any => {
  return async (dispatch: AppDispatch) => {
    const res = await http.post('cms/orderLogout/page', data)
    if (res.code === 0) {
      const obj = {
        list: res.data.records,
        total: res.data.total
      }

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

/**
 * 藏品注销-选择藏品
 */
export const D3_APIgetClueList = (data: any) => {
  return http.post('cms/orderLogout/good/getList', data)
}

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