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

/**
 * 人员出入库 - 分页列表
 */
export const F5_APIgetList = (data: any): any => {
  return async (dispatch: AppDispatch) => {
    const res = await http.post('cms/orderSite/user/page', data)
    if (res.code === 0) {
      const obj = {
        list: res.data.records,
        total: res.data.total
      }

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

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