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

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

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

/**
 * 藏品鉴定-藏品列表(取总账数据)-分页
 */
export const B3_APIgetClueList = (data: any) => {
  return http.post('cms/order/auth/good/getList', data)
}

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