import request from "@/utils/httpRequest";
import { FLOW_PATH as prefix } from "../AppPath";

export default {
	list: function (params) {
		return request({
			url: prefix + "/flowable/task/list",
			method: "get",
			params: params,
		});
	},
	start: function (data) {
		return request({
			url: prefix + "/flowable/task/start",
			method: "post",
			data: data,
		});
	},

	todoList: function (params) {
		return request({
			url: prefix + "/flowable/task/todo",
			method: "get",
			params: params,
		});
	},

	historicList: function (params) {
		return request({
			url: prefix + "/flowable/task/historic",
			method: "get",
			params: params,
		});
	},

	historicTaskList: function (procInsId) {
		return request({
			url: prefix + "/flowable/task/historicTaskList",
			method: "get",
			params: { procInsId: procInsId },
		});
	},

	myApplyedList: function (params) {
		return request({
			url: prefix + "/flowable/task/myApplyed",
			method: "get",
			params: params,
		});
	},

	getTaskDef: function (params) {
		return request({
			url: prefix + "/flowable/task/getTaskDef",
			method: "get",
			params: params,
		});
	},

	delegate: function (taskId, userId) {
		return request({
			url: prefix + "/flowable/task/delegate",
			method: "put",
			params: { taskId: taskId, userId: userId },
		});
	},

	callback: function (params) {
		return request({
			url: prefix + "/flowable/task/callback",
			method: "put",
			params: params,
		});
	},

	audit: function (data) {
		return request({
			url: prefix + "/flowable/task/audit",
			method: "post",
			headers: {
				"Content-Type":
					"application/x-www-form-urlencoded; charset=utf-8",
			},
			data: data,
		});
	},

	backNodes: function (taskId) {
		return request({
			url: prefix + "/flowable/task/backNodes",
			method: "put",
			params: { taskId: taskId },
		});
	},

	back: function (params) {
		return request({
			url: prefix + "/flowable/task/back",
			method: "put",
			params: params,
		});
	},

	transfer: function (taskId, userId) {
		return request({
			url: prefix + "/flowable/task/transfer",
			method: "put",
			params: { taskId: taskId, userId: userId },
		});
	},

	addSignTask: function (data) {
		return request({
			url: prefix + "/flowable/task/addSignTask",
			method: "post",
			headers: {
				"Content-Type":
					"application/x-www-form-urlencoded; charset=utf-8",
			},
			data: data,
		});
	},
	getFlowChart: function (processInstanceId) {
		return request({
			url: prefix + "/flowable/task/getFlowChart",
			method: "get",
			params: { processInstanceId: processInstanceId },
		});
	},

	urge: function (data) {
		return request({
			url: prefix + "/flowable/task/urge",
			method: "post",
			headers: {
				"Content-Type":
					"application/x-www-form-urlencoded; charset=utf-8",
			},
			data: data,
		});
	},

	getTaskDefInfo(params) {
		return request({
			url: prefix + "/flowable/task/getTaskDefInfo",
			method: "get",
			params: params,
		});
	},

	getTaskNameByProcInsId(procInsId) {
		return request({
			url: prefix + "/flowable/task/getTaskNameByProcInsId",
			method: "get",
			params: { procInsId: procInsId },
		});
	},

	getTaskAuditUsersByprocInstId(procInsId) {
		return request({
			url: prefix + "/flowable/task/getTaskAuditUsersByprocInstId",
			method: "get",
			params: { procInsId: procInsId },
		});
	},

	//根据procInsId获取发起审批时间，只限于报销流程
	getApprovalTimeByProcInsId(procInsId) {
		return request({
			url: prefix + "/flowable/task/getApprovalTimeByProcInsId",
			method: "get",
			params: { procInsId: procInsId },
		});
	},
};
