import request from '@/assets/js/workutils/workrequest'

// 发起事务
export const startList = (pageNo, pageSize, params) => {
  return request({
    url: '/bidprocurement/common-workclow/work/start-list',
    method: 'get',
    params: {
      ...params,
      pageNo,
      pageSize
    }
  })
}
// 待签事务
export const claimList = (pageNo, pageSize, params) => {
  return request({
    url: '/bidprocurement/common-workclow/work/claim-list',
    method: 'get',
    params: {
      ...params,
      pageNo,
      pageSize
    }
  })
}
// 待办事务
export const todoList = (data) => {
  return request({
    url: '/bidprocurement/common-workclow/act/ruTask/bid-todo-list',
    method: 'post',
    data
  })
}
// 办结事务
export const doneList = (data) => {
  return request({
    url: '/bidprocurement/common-workclow/act/hiRuTask/bid-done-list',
    method: 'post',
    data
  })
}
// 已发事务
export const sendList = (pageNo, pageSize, params) => {
  return request({
    url: '/bidprocurement/common-workclow/work/send-list',
    method: 'get',
    params: {
      ...params,
      pageNo,
      pageSize
    }
  })
}

export const claimTask = (taskId) => {
  return request({
    url: '/bidprocurement/common-workclow/work/claim-task',
    method: 'post',
    params: {
      taskId
    }
  })
}

export const revokeTask = (proInstanceId, nodId, businessKey, taskId) => {
  return request({
    url: '/bidprocurement/common-workclow/work/revoke-task',
    method: 'post',
    params: {
      proInstanceId,
      nodId,
      businessKey,
      taskId
    }
  })
}

export const completeTask = (data) => {
  return request({
    url: '/bidprocurement/common-workclow/work/complete-task',
    method: 'post',
    data
  })
}

// 工作流流程节点/初始化获取节点名称
export const getNodeNameByProcessDefinitionKey = (processDefinitionKey) => {
  return request({
    url: '/bidprocurement/common-workclow/actModeUser/getNodeNameByProcessDefinitionKey',
    method: 'post',
    params: {
      processDefinitionKey
    }
  })
}
// 工作流记录关联项目/根据主键查询
export const findProIdByBizId = (bizId) => {
  return request({
    url: '/bidprocurement/common-workclow/actProjectTask/findProIdByBizId?bizId=' + bizId,
    method: 'post'
  })
}

// 工作流流程节点/获取审核用户
export const getUserDepartByUserIdsRoleIds = (data) => {
  return request({
    url: '/bidprocurement/common-workclow/actModeUser/getUserDepartByUserIdsRoleIds',
    method: 'post',
    data
  })
}

// 工作流流程节点/获取下个节点数据
export const nextTasks = (taskId) => {
  return request({
    url: '/bidprocurement/common-workclow/actModeUser/nextTasks',
    method: 'post',
    params: {
      taskId
    }
  })
}

// 工作流流程节点/根据processDefinitionId和节点id 查询当前配置
export const getActModeUserByNodeIdProcessDefinitionKey = (nodeId, processDefinitionKey) => {
  return request({
    url: '/bidprocurement/common-workclow/actModeUser/getActModeUserByNodeIdProcessDefinitionKey',
    method: 'post',
    params: {
      nodeId,
      processDefinitionKey
    }
  })
}
// 流程信息
export const historyFlowList = (processInstanceId) => {
  return request({
    url: '/bidprocurement/common-workclow/act/hiRuTask/historyFlowList',
    method: 'post',
    params: {
      processInstanceId
    }
  })
}
// 已办历史，流程信息 *订单退回记录审批信息*
export const historyFlowListByBizId = (params) => {
  return request({
    url: '/bidprocurement/common-workclow/act/hiRuTask/historyFlowListByBizId',
    method: 'get',
    params
  })
}

// 查询工作流订阅消息列表
export const informListByProcessInstanceId = (processInstanceId) => {
  return request({
    url: '/bidprocurement/common-workclow/act/inform/informListByProcessInstanceId',
    method: 'get',
    params: {
      processInstanceId
    }
  })
}

// 改订阅消息状态  00未读  01已读
export const informUpdateStateById = (id) => {
  return request({
    url: '/bidprocurement/common-workclow/act/inform/informUpdateStateById',
    method: 'get',
    params: {
      id
    }
  })
}
