import request from '@/utils/request.js'
const preUrl = '/clientServices.do?iscrypt=1'
//获取用户所有流程
export function getUserAllProcess({ staffId, page, pageNum }) {
	return request({
		url: preUrl,
		method: 'post',
		data: {
			serviceId: 'bpm_2013V0100PHONE009',
			params: {
				staffId,
				page,
				pageNum
			}
		}
	})
}

//获取用户办结流程
export function getUserProcessed(params) {
	return request({
		url: preUrl,
		method: 'post',
		data: {
			serviceId: 'bpm_2013V0100PHONE003',
			params: {
				staffId: params.staffId,
				page: params.page,
				pageNum: params.pageNum,
				modelId: params.modelId, //流程类型
				control: params.control //流程控制方式 0 手写 1 引擎
			}
		}
	})
}

//获取用户待办流程
export function getUserProcess(params) {
	return request({
		url: preUrl,
		method: 'post',
		data: {
			serviceId: 'bpm_2013V0010PHONE001',
			params: {
				staffId: params.staffId,
				page: params.page,
				pageNum: params.pageNum,
				modelId: params.modelId, //流程类型
				control: params.control //流程控制方式 0 手写 1 引擎
			}
		}
	})
}

//获取用户在办流程
export function getUserProcessing(params) {
	return request({
		url: preUrl,
		method: 'post',
		data: {
			serviceId: 'bpm_2013V0100PHONE002',
			params: {
				staffId: params.staffId,
				page: params.page,
				pageNum: params.pageNum,
				modelId: params.modelId, //流程类型
				control: params.control //流程控制方式 0 手写 1 引擎
			}
		}
	})
}

//获取待办流程数
export function getUnProcessNum(userId, startTime) {
	return request({
		url: preUrl,
		method: 'post',
		data: {
			serviceId: 'bpm_2013V0100PHONE010',
			params: {
				staffId: userId, // useId
				startTime: startTime // 开始时间
			}
		}
	})
}

export function getProcessFlowInfo(userId, { tinsId, control }) {
	return request({
		url: preUrl,
		method: 'post',
		data: {
			serviceId: 'bpm_2013V0100PHONE005',
			params: {
				staffId: userId, // useId
				tinsid: tinsId, // process.tinsId
				control
			}
		}
	})
}

//获取流程详情
export function getProcessFormInfo(userId, insId) {
	return request({
		url: preUrl,
		method: 'post',
		data: {
			serviceId: 'bpm_2020V0100PHONE006',
			params: {
				userId, // useId
				insId // process.insId
			}
		}
	})
}
export function getProcessFormInfoInFlow(useId, {tinsId, insId, control}) {
	return request({
		url: preUrl,
		method: 'post',
		data: {
			serviceId: 'bpm_2013V0100PHONE006',
			params: {
				staffId: useId, // useId
				tinsid: tinsId,
				insId,
				control
			}
		}
	})
}

export function getProcessFlow(userId, { insId, control }) {
	return request({
		url: preUrl,
		method: 'post',
		data: {
			serviceId: 'bpm_2013V0100PHONE007',
			params: {
				staffId: userId, // useId
				insid: insId, // process.insId
				control
			}
		}
	})
}
// 提交 流程审批
export function submitProcessFlow(flow, form, control) {
	return request({
		url: preUrl,
		method: 'post',
		data: {
			serviceId: 'bpm_2013V0100PHONE008',
			params: {
				flow,
				form,
				control
			}
		}
	})
}

export function cancelProcessFlow(staffId, cancelRemark, {insId, control}) {return request({
		url: preUrl,
		method: 'post',
		data: {
			serviceId: 'bpm_20191025BpmClientCancelFlow',
			params: {
				staffId,
				cancelRemark,
				insId,
				control
			}
		}
	})
}