import request from '@/utils/request'
import settings from '@/settings'
const { flowablePrefix } = settings

/**
 * 代办任务查询
 * @param {*} data
 * @returns
 */
export function queryTaskApi (data) {
  return request({
    url: `${flowablePrefix}/V1/flowTaskManagement/queryPage`,
    method: 'post',
    data: data,
    requestType: 'json',
  })
}

/**
 * 查询流程类型
 * @param {*} data
 * @returns
 */
export function queryCategoryType (data) {
  return request({
    url: `${flowablePrefix}/V1/flowBusinessInteraction/queryType`,
    method: 'post',
    data: data,
    requestType: 'json',
  })
}

/**
 * 任务取消
 * @param {*} data
 * @returns
 */
export function taskCancelApi (data) {
  return request({
    url: `${flowablePrefix}/V1/flowTaskManagement/handlerHumanTask`,
    method: 'post',
    data: data,
    requestType: 'json',
  })
}

/**
 * 任务撤回
 * @param {*} data
 * @returns
 */
export function taskWithDrawApi (data) {
  return request({
    url: `${flowablePrefix}/V1/flowTaskManagement/handlerHumanTask`,
    method: 'post',
    data: data,
    requestType: 'json',
  })
}

/**
 * 任务查看
 * @param {*} data
 * @returns
 */
export function taskViewApi (data) {
  return request({
    url: `${flowablePrefix}/V1/flowTaskManagement/gettaskstartInfo`,
    method: 'post',
    data: data,
    requestType: 'json',
  })
}

/**
 * 任务追踪
 * @param {*} data
 * @returns
 */
export function taskTraceApi (data) {
  return request({
    url: `${flowablePrefix}/V1/flowTaskManagement/getTaskSvg`,
    method: 'post',
    data: data,
    requestType: 'json',
  })
}

/**
 * 任务提交
 * @param {*} data
 * @returns
 */
export function taskSubmitApi (data) {
  return request({
    url: `${flowablePrefix}/V1/flowTaskManagement/submit`,
    method: 'post',
    data: data,
    requestType: 'json',
  })
}

/**
 * 查询信息
 * @param {*} data
 * @returns
 */
export function taskAssigneeApi (data) {
  return request({
    url: `${flowablePrefix}/V1/flowBusinessInteraction/userQuery`,
    method: 'post',
    data: data,
    requestType: 'json',
  })
}

/**
 * 查询岗位信息
 * @param {*} data
 * @returns
 */
export function taskRoleApi (data) {
  return request({
    url: `${flowablePrefix}/V1/flowBusinessInteraction/roleQuery`,
    method: 'post',
    data: data,
    requestType: 'json',
  })
}

/**
 * 指派保存
 * @returns
 */
export function taskAssigneeSumitApi (data) {
  return request({
    url: `${flowablePrefix}/V1/flowTaskManagement/handleTaskWithAssignList`,
    method: 'post',
    data: data,
    requestType: 'json',
  })
}

/**
 * 获取子流程流程实例 信息
 * @param {*} params
 * @returns
 */
export function getChildFlowInstance (params) {
  return request({
    url: `${flowablePrefix}/V1/flowTaskManagement/getChildFlowInstance`,
    method: 'post',
    params,
  })
}

/**
 * 流程模型查询
 * @param {*} data
 * @returns
 */
export function queryProcModelApi (data) {
  return request({
    url: `${flowablePrefix}/V1//flowDefinitionManagement/query`,
    method: 'post',
    requestType: 'json',
    data: data
  })
}

/**
 * 通过流程模型id 查询xml
 * @param {*} data
 * @returns
 */
export function queryProcModelByIdApi (data) {
  return request({
    url: `${flowablePrefix}/V1/flowDefinitionManagement/design`,
    method: 'post',
    requestType: 'json',
    data: data
  })
}

/**
 * 查询关联页面查询信息
 * @param {} data
 */
export function queryRefPageApi (data) {
  return request({
    url: `${flowablePrefix}/V1/flowBusinessInteraction/getAssociatePageQuery`,
    method: 'post',
    requestType: 'json',
    data: data
  })
}


/**
 *
 * @param {*} data
 * @returns
 */
export function queryBusinessData (data) {
  return request({
    url: `${flowablePrefix}/V1/flowBusinessInteraction/queryBusinessData`,
    method: 'post',
    requestType: 'json',
    data: data
  })
}

/**
 * 流程模型保存草稿
 */
export function saveModelApi (data) {
  return request({
    url: `${flowablePrefix}/V1/flowDefinitionManagement/insert`,
    method: 'post',
    requestType: 'json',
    data: data
  })
}

/**
 * 流程模型删除
 * @param {*} data
 * @returns
 */
export function deleteModelApi (data) {
  return request({
    url: `${flowablePrefix}/V1/flowDefinitionManagement/deleteModel`,
    method: 'post',
    requestType: 'json',
    data: data
  })
}

/**
 * 查询流程模型是否存在
 * @param {*} data
 * @returns
 */
export function queryProcessModelApi (data) {
  return request({
    url: `${flowablePrefix}/V1/flowDefinitionManagement/findCategoryModel?category=${data.category}`,
    method: 'get',
    // data: data
  })
}

/**
 * 流程模型部署
 * @param {*} data
 * @returns
 */
export function processModelDeployApi (data) {
  return request({
    url: `${flowablePrefix}/V1//flowDefinitionManagement/publish`,
    method: 'post',
    requestType: 'json',
    data: data
  })
}

/**
 * 导出
 * @param {*} data
 * @returns
 */
export function exportModelApi (data) {
  return request({
    url: `${flowablePrefix}/V1/flowDefinitionManagement/designList`,
    method: 'post',
    requestType: 'json',
    data: data
  })
}

/**
 * 导入
 * @param {*} data
 * @returns
 */
export function importModelApi (data) {
  return request({
    url: `${flowablePrefix}/V1/flowDefinitionManagement/saveDisigenBach`,
    method: 'post',
    requestType: 'json',
    data: data
  })
}


/**
 * 流程版本管理
 * @param {*} data
 * @returns
 */
export function versionCtlModelApi (data) {
  return request({
    url: `${flowablePrefix}/V1/flowDefinitionManagement/getModelHistListById`,
    method: 'post',
    requestType: 'json',
    data: data
  })
}

/**
 * 删除历史流程模型
 * @param {*} data
 */
export function deleteHiModelApi (data) {
  return request({
    url: `${flowablePrefix}/V1/flowDefinitionManagement/deleteModelInHis`,
    method: 'post',
    requestType: 'json',
    data: data
  })
}

/**
 * 历史流程模型部署
 * @param {*} data
 * @returns
 */
export function deployHiModelApi (data) {
  return request({
    url: `${flowablePrefix}/V1/flowDefinitionManagement/publishInHistory`,
    method: 'post',
    requestType: 'json',
    data: data
  })
}

/**
 * 查询子流程信息
 * @param {*} data
 * @returns
 */
export function queryCallActivityApi (data) {
  return request({
    url: `${flowablePrefix}/V1/flowDefinitionManagement/processDefQuery`,
    method: 'post',
    requestType: 'json',
    data: data
  })
}

/**
 * 查询流程条件参数
 * @param {*} data
 * @returns
 */
export function queryBusinessParamApi (data) {
  return request({
    url: `${flowablePrefix}/V1/flowBusinessInteraction/getBusinessParamQuery`,
    method: 'post',
    requestType: 'json',
    data: data
  })
}

/**
 * 判断流程模型编号是否存在
 * @param {*} data
 */
export function procModelExistApi (data) {
  return request({
    url: `${flowablePrefix}/V1/flowDefinitionManagement/hasModel`,
    method: 'post',
    requestType: 'json',
    data: data
  })
}
