import request from '@/utils/request'
import { AxiosPromise } from 'axios'

// apiUrl 流程定义(实例)
const api = {
	listCategory: '/v1/process/list-category', // 获取所有分类流程定义列表
	updateStateId: '/v1/process/update-state', // 根据流程定义ID更新流程状态
	updateSortId: '/v1/process/update-sort', // 根据流程定义ID更新排序
	delete: '/v1/process/delete', // 根据流程定义ID删除流程定义相关信息
	create: '/v1/process/create', // 创建添加
	get: '/v1/process/get', // 查询Id信息
	clone: '/v1/process/clone' // 查询 id 克隆流程定义信息
}

function flowDefinitionListCategoryApi(data: any): AxiosPromise {
	return request({
		url: api.listCategory,
		method: 'post',
		data
	})
}

function flowDefinitionUpdateStateIdApi(data: any): AxiosPromise {
	return request({
		url: `${api.updateStateId}-${data.id}`,
		method: 'post'
	})
}

function flowDefinitionUpdateSortIdApi(data: any): AxiosPromise {
	return request({
		url: `${api.updateStateId}-${data.id}`,
		method: 'post'
	})
}
function flowDefinitionDeleteApi(data: any): AxiosPromise {
	return request({
		url: api.delete,
		method: 'post',
		data
	})
}

function flowDefinitionCreateApi(data: any): AxiosPromise {
	return request({
		url: api.create,
		method: 'post',
		data
	})
}

function flowDefinitionGetApi(data: any): AxiosPromise {
	return request({
		url: api.get,
		method: 'post',
		data
	})
}

function flowDefinitionCloneApi(data: any): AxiosPromise {
	return request({
		url: api.get,
		method: 'post',
		data
	})
}

export default {
	flowDefinitionListCategoryApi,
	flowDefinitionUpdateStateIdApi,
	flowDefinitionUpdateSortIdApi,
	flowDefinitionDeleteApi,
	flowDefinitionCreateApi,
	flowDefinitionGetApi,
	flowDefinitionCloneApi
}
