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

/**
 * 藏品移库 - 分页列表
 */
export const F2_APIgetList = (data: any): any => {
  return async (dispatch: AppDispatch) => {
    const res = await http.post('cms/orderSite/move/page', data)
    if (res.code === 0) {
      const obj = {
        list: res.data.records,
        total: res.data.total
      }

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

/**
 * 藏品总账列表-分页
 */
export const F2_APIgetClueList = (data: any) => {
  return http.post('cms/orderSite/move/good/page', data)
}

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

/**
 * 自动分配空置仓位
 */
export const F2_APIgetShelfEmptyList = (params: any) => {
  return http.get('cms/orderSite/move/getStorageEmpty', { params })
}
