import request from '@/utils/request'

// 查询参数列表
export function listFlow(query) {
  return request({
    url: '/flowable/flow/list',
    method: 'post',
    data: query
  })
}

//保存流程定义
export function saveFlow(data) {
  return request({
    url: '/flowable/flow/save',
    method: 'post',
    data: data
  })
}

// 删除流程定义
export function delFlow(deployId) {
  return request({
    url: '/flowable/flow/' + deployId,
    method: 'post'
  })
}

//读取流程信息
export function readXml(deployId) {
  return request({
    url: '/flowable/flow/readXml/' + deployId,
    method: 'post'
  })
}

//改变流程状态
export function updateState(params) {
  return request({
    url: '/flowable/flow/updateState',
    method: 'post',
    data: params
  })
}

export function flowXmlAndNode(query) {
  return request({
    url: '/flowable/task/flowXmlAndNode',
    method: 'get',
    params: query
  })
}

export function getUserList(){
  return request({
    url: '/flowable/flow/getUserList',
    method: 'post'
  })
}

/**
 * 检查流程名称是否重复
 * @param data
 * @returns {*}
 */
export function checkIsExistFlowName(data) {
  return request({
    url: '/flowable/flow/checkIsExistFlowName',
    method: 'post',
    data: data
  })
}

/**
 * 查询审批流配置列表
 */
export function listFlowConfiguration(query) {
  return request({
    url: '/project/admissionRequest/listFlowConfiguration',
    method: 'get',
    params: query
  })
}

/**
 * 删除审批流配置
 * @param addressId
 * @returns {*}
 */
export function delFlowConfiguration(addressId) {
  return request({
    url: '/project/admissionRequest/' + addressId,
    method: 'delete'
  })
}

/**
 * 修改单个审批流配置状态
 */
export function changeFlowStatus(examineId, status) {
  const data = {
    examineId,
    status
  }
  return request({
    url: '/project/admissionRequest/changeFlowStatus',
    method: 'put',
    data: data
  })
}

/**
 *  新增审批流配置
 * @param data
 * @returns {*}
 */
export function addExamine(data) {
  return request({
    url: '/project/admissionRequest/addExamine',
    method: 'post',
    data: data
  })
}

/**
 *  修改审批流配置
 * @param data
 * @returns {*}
 */
export function updateExamine(data) {
  return request({
    url: '/project/admissionRequest/updateExamine',
    method: 'post',
    data: data
  })
}

/**
 *  查询单个审批流配置
 * @param id
 * @param version
 * @returns {*}
 */
export function getExamine(id,version) {
  console.log("id="+id+" ,version="+version)
  return request({
    url: '/project/admissionRequest/getInfo',
    method: 'post',
    data:{
      id:id,
      version:version
    }
  })
}

