/*
 * @Author: zc
 * @description 流程管理
 * @version: 
 * @Date: 2022-08-26 14:43:22
 * @LastEditors: Please set LastEditors
 * @LastEditTime: 2022-11-10 13:24:01
 */
import request from '/@/utils/request';
/**
 * @description 根据姓名模糊查询用户
 * @param {object} params
 * @return {*}
 */
export const queryUser = (params?: object) => {
	return request({
		url: '/api/v1/User/withOrg',
		method: 'get',
		params: params,
	});
};
/**
 * 分页查询流程模板
 * @param {object} params
 * @return {*}
 */
export const workflowList = (params?: object) => {
	return request({
		url: '/api/v1/Workflow/definition',
		method: 'get',
		params: params,
	});
};
/**
 * 新增流程模板草稿
 * @param {object} data
 * @returns {*}
 */
export const workflowAdd = (data: object) => {
	return request({
		url: '/api/v1/Workflow/definition',
		method: 'post',
		data
	});
};
/**
 * @description 查询流程模板详情
 * @param {string} id
 * @return {*}
 */
export const getWorkFlowDetail = (id: string | string[]) => {
	return request({
		url: `/api/v1/Workflow/definition/${id}`,
		method: 'get',
	});
};
/**
 * @description 更新流程模板草稿
 * @param {object} data
 * @return {*}
 */
export const workflowUpdate = (data: object) => {
	return request({
		url: '/api/v1/Workflow/definition',
		method: 'put',
		data
	});
};
/**
 * @description 删除草稿
 * @param {string} id
 * @return {*}
 */
export const workflowDelete = (id: string) => {
	return request({
		url: `/api/v1/Workflow/definition/${id}`,
		method: 'delete'
	});
};
/**
 * @description 发布（列表操作）
 * @param {string} id
 * @return {*}
 */
export const publishOnList = (id: string) => {
	return request({
		url: `/api/v1/Workflow/definition/${id}/publish`,
		method: 'post'
	});
};
/**
 * @description 发布（保存并发布）
 * @param {object} data
 * @return {*}
 */
export const publish = (data: object) => {
	return request({
		url: '/api/v1/Workflow/definition/publish',
		method: 'post',
		data
	});
};
/**
 * @description 启用流程模板
 * @param {string} id
 * @return {*}
 */
export const workflowEnable = (id: string) => {
	return request({
		url: `/api/v1/Workflow/definition/${id}/enable`,
		method: 'post',
	});
};
/**
 * @description 禁用流程模板
 * @param {string} id
 * @return {*}
 */
export const workflowDisable = (id: string) => {
	return request({
		url: `/api/v1/Workflow/definition/${id}/disable`,
		method: 'post'
	});
};
/**
 * @description 基础信息
 * @param {object} params
 * @return {*}
 */
export const baseData = (params?: object) => {
	return request({
		url: '/api/v1/Workflow/base-data',
		method: 'get',
		params: params,
	});
};
/**
 * @description 根据基础信息查询下拉框数据
 * @param {string} handlerType
 * @return {*}
 */
export const getSelectList = (handlerType?: string) => {
	return request({
		url: `/api/v1/Workflow/handlerclassify/${handlerType}`,
		method: 'get',
	});
};
/**
 * @description 分页查询流程
 * @param {object} params
 * @return {*}
 */
export const workflowPaged = (params?: object) => {
	return request({
		url: '/api/v1/Workflow',
		method: 'get',
		params: params,
	});
};
/**
 * @description 查询当前流程下一节点参数
 * @param {string} workflowId
 * @return {*}
 */
export const workflowNextSteps = (workflowId: string) => {
	return request({
		url: `/api/v1/Workflow/${workflowId}/nextsteps`,
		method: 'get',
	});
};
/**
 * @description 查询当前流程下一个节点配置
 * @param {object} params
 * @return {*}
 */
export const workflowStepOptions = (params: object) => {
	return request({
		url: `/api/v1/Workflow/step-options`,
		method: 'get',
		params
	});
};
/**
 * @description 办理节点
 * @param {object} data
 * @return {*}
 */
export const workflowNext = (data: object) => {
	return request({
		url: '/api/v1/Workflow/next',
		method: 'post',
		data
	});
};
/**
 * @description 跳转至任意节点
 * @param {object} data
 * @return {*}
 */
export const workflowJump = (data: object) => {
	return request({
		url: '/api/v1/Workflow/jump',
		method: 'post',
		data
	});
};
/**
 * @description 获取跳转参数
 * @param {string} workflowId
 * @return {*}
 */
export const workflowGetJump = (workflowId: string) => {
	return request({
		url: `/api/v1/Workflow/${workflowId}/jump`,
		method: 'get'
	});
};
/**
 * @description 终止流程
 * @param {object} data
 * @return {*}
 */
export const workflowTerminate = (data: object) => {
	return request({
		url: `/api/v1/Workflow/terminate`,
		method: 'post',
		data
	});
};
/**
 * @description 获取撤回参数
 * @param {string} workflowId
 * @return {*}
 */
export const workflowRecallParams = (workflowId: string) => {
	return request({
		url: `/api/v1/Workflow/${workflowId}/recall`,
		method: 'get',
	});
};
/**
 * @description 退回（返回之前一个节点）
 * @param {object} data
 * @return {*}
 */
export const workflowPrevious = (data: object) => {
	return request({
		url: `/api/v1/Workflow/previous`,
		method: 'post',
		data
	});
};
/**
 * @description 撤回至任意节点
 * @param {object} data
 * @return {*}
 */
export const workflowRecall = (data: object) => {
	return request({
		url: `/api/v1/Workflow/recall`,
		method: 'post',
		data
	});
};
/**
 * @description 补充（工单）
 * @param {object} data
 * @return {*}
 */
export const supplement = (data: object) => {
	return request({
		url: '/api/v1/Workflow/supplement',
		method: 'post',
		data
	});
};
/**
 * @description 查询流程流转记录
 * @param {string} workflowId
 * @return {*}
 */
export const workflowTraces = (workflowId: string) => {
	return request({
		url: `/api/v1/Workflow/${workflowId}/traces`,
		method: 'get',
	});
};
/**
 * @description 分页查询最新版本号的模板
 * @param {object} params
 * @return {*}
 */
export const WorkflowLatest = (params:object) => {
	return request({
		url: `/api/v1/Workflow/latest`,
		method: 'get',
		params
	});
};
/**
 * @description 查询所有工作流模块
 * @return {*}
 */
export const wfmodules = () => {
	return request({
		url: `/api/v1/Workflow/wfmodules`,
		method: 'get',
	});
};
/**
 * @description 为工作流业务匹配或取消流程模板
 * @param {object} data
 * @return {*}
 */
export const wfmodulesMatch = (data:object) => {
	return request({
		url: `/api/v1/Workflow/wfmodule/match`,
		method: 'put',
		data
	});
};
/**
 * @description 获取重办参数
 * @param {string} workflowId
 */
export const workflowRedoParams= (workflowId: string) => {
	return request({
		url: `/api/v1/Workflow/${workflowId}/redo`,
		method: 'get'
	});
};
/**
 * @description 流程撤销 （工单撤销）
 * @param {object} data
 */
export const workflowCancel = (data: object) => {
	return request({
		url: `/api/v1/Workflow/cancel`,
		method: 'post',
		data
	});
};