import microRequest from '../../utils/micro_request';

const workflowPath = import.meta.env.VITE_WORKFLOW;
const sciPath = import.meta.env.VITE_SCIENTIFIC;

export function useExecutionApi() {
  return {
    // 全部流程（如需）
    getAllList(query: object) {
      return microRequest.postRequest(workflowPath, 'Execution', 'GetList', query);
    },
    // 我发起的
    getOwnStartList(query: object) {
      return microRequest.postRequest(workflowPath, 'Execution', 'GetOwnStartList', query);
    },
    // 待我审批
    getOwnApproveList(query: object) {
      return microRequest.postRequest(workflowPath, 'Execution', 'GetOwnApproveList', query);
    },
    // 审批历史
    getOwnApprovedList(query: object) {
      return microRequest.postRequest(workflowPath, 'Execution', 'GetOwnApprovedList', query);
    },
    // 抄送我的
    getOwnCcList(query: object) {
      return microRequest.postRequest(workflowPath, 'Execution', 'GetOwnCcList', query);
    },
    // 流程实例详情
    getInstanceById(query: object) {
      return microRequest.postRequest(workflowPath, 'Execution', 'GetInstanceById', query);
    },
    // 流程参与者（审批记录）
    getParticipantByProcInstID(query: object) {
      return microRequest.postRequest(workflowPath, 'Execution', 'GetParticipantByProcInstID', query);
    },
    // 审批
    approve(query?: object) {
      return microRequest.postRequest(sciPath, 'Workflow', 'Approve', query);
    },
    // 批量审批
    batchApprove(query?: object) {
      return microRequest.postRequest(sciPath, 'Workflow', 'BatchApprove', query);
    },
    // 撤回
    withdraw(query?: object) {
      return microRequest.postRequest(workflowPath, 'Execution', 'WithdrawTask', query);
    }
  };
}

