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

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

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

/**
 * 藏品入藏-已入馆藏品列表-分页
 */
export const B4_APIgetClueList = (data: any) => {
  return http.post('cms/order/hide/house/getList', data)
}

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