import request from "@/utils/request";

// 保存流程定义
export function saveFlowData(data: object) {
  return request({
    url: "/api/v1/definition/save",
    method: "post",
    data: data,
  });
}

// 获取流程定义详情
export function getFlowDataInfo(id: string) {
  return request({
    url: `/api/v1/definition/get/${id}`,
    method: "get",
  });
}

export function addRoleUser(queryParams: object) {
  return request({
    url: "/api/v1/flowRole/add",
    method: "post",
    data: queryParams,
  });
}

export function queryRoleUser(queryParams: object) {
  return request({
    url: "/api/v1/flowRole/userPage",
    method: "post",
    data: queryParams,
  });
}
export function delRoleUser(queryParams: object) {
  return request({
    url: "/api/v1/flowRole/delUser",
    method: "post",
    data: queryParams,
  });
}
export function delRole(queryParams: object) {
  return request({
    url: "/api/v1/flowRole/delRole",
    method: "post",
    data: queryParams,
  });
}

// 获取流程角色列表
export function getRoleList(queryParams: object) {
  return request({
    url: "/api/v1/flowRole/list",
    method: "post",
    data: {},
  });
}

// 流程定义列表查询
export function queryFlowDataList(queryParams: object) {
  return request({
    url: "/api/v1/definition/list",
    method: "post",
    data: queryParams,
  });
}

// 下一节点人员 type 1 流程 2 任务
export function getNextUser(type: string, id: string) {
  return request({
    url: `/api/v1/flowTask/nextUsers/${type}/${id}`,
    method: "get",
  });
}


export function audit(data: object) {
  return request({
    url: `/api/v1/flowTask/audit`,
    method: "post",
    data: data,
  });
}

// 查看流程记录
export function queryFlowRecord(insId: string) {
  return request({
    url: `/api/v1/flowTask/list/${insId}`,
    method: "get",
  });
}

// 提交流程
export function submitFlow(data: object) {
  return request({
    url: `/api/v1/flowTask/startFlow`,
    method: "post",
    data: data,
  });
}
// 流程撤销
export function cancelFlow(data: object) {
  return request({
    url: `/api/v1/flowTask/cancelFlow`,
    method: "post",
    data: data,
  });
}
