// 我是接口方法 js
import axios from 'axios'
import QS from 'qs'

// 常用接口常量

export const URL_ADD = process.env.API_ROOT

export const UPLOAD_URL = 'http://10.174.240.17:9082'

export const WINDOW_ADD = '/ease-flow-console-v2'

export const ERR_OK = '1' //成功

export const VALIDATE_ERROR = '-2'  //工单校验失败

export const ORDER_REPEAT = '1007' //工单重复

export const USER_NO_JURISDICTION = '1006' //用户无权限

export const KMFQ_USER = '878' //昆明发起

export const KMSH_USER = '879' //昆明审核/879

export const YNSH_USER = '881' //云南审核/881

export const KETJ_USER = '986' //可研提交

export const KYSH_USER = '2261' //可研审核

export const JZFX_KMDS = '4548' //集中分析 昆明地市

/* 在线协作中的状态码 */
export const STATUE_CODE_UNCOMMIT = 0 //状态码未提交

export const JZGH_CODE = '03' //集中规划的编码

export const JZGH_SUB_KY = '02' //集中规划子阶段编码   可研

export const JZGH_SUB_SJ = '03'

export const JZGH_SUB_BG = '04'

export const JZGH_SUB_KR = '05'

export const CHECK_FOUR_STAGES = [JZGH_SUB_SJ, JZGH_SUB_BG, JZGH_SUB_KR]

export const JZGH_XQBG_NODEID = 'jt0613fd4dbce3402ca0905a28ec4fae0e' //需求变更选择需求点时的节点id

export const MEDICAL_RECORD_LIBRARY_NODEID =
  'jtef8bb9f175864a7b876e4bb2fed444e8' //病历库按钮显示的节点id

export const CALL_OTHER_ORDER = [
  'jta629bfe696b646d2a45fbec10e0f993f',
  'jtc90bf4367b614082bc38ef1e3d0e6433',
  'jt4c010e659af14afb863e1d6b80e3d81c',
  'jt7b81d34e110e450a9eb4ff56a045413a'
] //调用其他工单

export const QUALITY_CHECKING = 'jtff26036ac4604d7f90c94cbf2245fc34' //质检组节点id 自动质检

export const JZGH_BG_FIELDS = [
  'demcha_dem_name',
  'demcha_order_code',
  'demcha_dem_id'
] //变更回填字段

// 数据字典表中的常量
export const ORDER_TYPE = 'order_type'

export const ORDER_STATUS = 'order_status'

export const OREDER_SUB_TYPE = 'order_sub_type'

export const OREDER_STATE = 'order_state'


// get
export const _get = req => {
  return axios.get(req.url, {
    //批量操作中  是单写的 ajax  也需要加X-Authorization-Key
    params: req.data
  })
}

// post
export const _post = req => {
  return axios({
    method: 'post',
    url: `${req.url}`,
    data: QS.stringify(req.data)
  })
}

export const ajax = function (url = '', data = {}, type = 'GET') {
  url = URL_ADD + url
  if (type == 'GET') {
    return axios.get(url, {
      params: data,
    })
  } else {
    return axios({
      method: 'post',
      url: url,
      data: data,
    })
  }
}



