import http from '@/utils/http'
import { AppDispatch } from '..'
/**
 * 现状登记 - 获取分页列表
 */
export const E3_APIgetList = (data: any, exportFlag?: boolean): any => {
  if (exportFlag) return http.post('cms/orderPreserveCurrent/page', data)
  else {
    return async (dispatch: AppDispatch) => {
      const res = await http.post('cms/orderPreserveCurrent/page', data)
      if (res.code === 0) {
        const obj = {
          list: res.data.records,
          total: res.data.total
        }

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

/**
 * 现状登记-删除
 */
export const E3_APIdel = (id: number) => {
  return http.get(`cms/orderPreserveCurrent/remove/${id}`)
}

/**
 * 现状登记-创建订单
 */
export const E3_APIcreate = () => {
  return http.get('cms/orderPreserveCurrent/create')
}

/**
 * 现状登记-获取详情
 */
export const E3_APIgetInfo = (id: number) => {
  return http.get(`cms/orderPreserveCurrent/detail/${id}`)
}

/**
 * 现状登记-存草稿
 */
export const E3_APIsaveDraft = (data: any) => {
  return http.post('cms/orderPreserveCurrent/saveDraft', data)
}

/**
 * 现状登记-创建
 */
export const E3_APIsaveCreate = (data: any) => {
  return http.post('cms/orderPreserveCurrent/saveCreate', data)
}

/**
 * 现状登记-编辑保存
 */
export const E3_APIsaveApply = (data: any) => {
  return http.post('cms/orderPreserveCurrent/saveApply', data)
}

/**
 * 现状登记-审批
 */
export const E3_APIsaveAudit = (data: any) => {
  return http.post('cms/orderPreserveCurrent/audit', data)
}

/**
 * 现状登记-撤回订单
 */
export const E3_APIrevocation = (id: number) => {
  return http.get(`cms/orderPreserveCurrent/revocation/${id}`)
}
