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

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

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

/**
 * 藏品征集-线索新增|编辑
 */
export const B1_APIgoodsSave = (data: any) => {
  return http.post('cms/order/collect/add', data)
}

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