import { Common } from 'pc-component-v3';

/**
 * 工具类自动生成的API，请勿做任何修改，请勿做任何修改，请勿做任何修改（重要的事情说3遍）
 * 工具作者: 杨志杰
 *  
 */
export default {

  /**
	 * 工具类自动生成的方法
	 * 工具作者: 杨志杰
	 * 弃审 
	 */
  abandonWorkflow: function(dto){
    var requestUrl = 'api/WorkflowResource/abandonWorkflow';


    return new Promise((resolve, reject) => {
      $.ajax({
        url: Common.getApiUrl2(requestUrl),
        type: 'post',
        contentType: 'application/json',
				
				
        data: JSON.stringify(dto),
				
        beforeSend: function(request) {
          Common.addTokenToRequest(request);
        },
        success: function(data) {
          resolve(data);
        },
        error: function(XMLHttpRequest, textStatus, errorThrown) {
          reject(XMLHttpRequest);
        },
      });
    });
  },

  /**
	 * 工具类自动生成的方法
	 * 工具作者: 杨志杰
	 * 在审批的过程中判断是否下一个节点是否需要选择用户。 
	 */
  calculatePreviousUserSelect: function(processInstanceId, previousUserSelectCalculateRequest){
    var requestUrl = 'api/WorkflowResource/calculatePreviousUserSelect';
    var paramCount = 0;
    if(processInstanceId != null){
      requestUrl += (paramCount > 0) ? '&' : '?';
      requestUrl += ('processInstanceId=' + processInstanceId);
      paramCount ++;
    }


    return new Promise((resolve, reject) => {
      $.ajax({
        url: Common.getApiUrl2(requestUrl),
        type: 'post',
        contentType: 'application/json',
        dataType: 'json',
				
        data: JSON.stringify(previousUserSelectCalculateRequest),
				
        beforeSend: function(request) {
          Common.addTokenToRequest(request);
        },
        success: function(data) {
          resolve(data);
        },
        error: function(XMLHttpRequest, textStatus, errorThrown) {
          reject(XMLHttpRequest);
        },
      });
    });
  },

  /**
	 * 工具类自动生成的方法
	 * 工具作者: 杨志杰
	 * 计算哪些用户选择项可以执行(发起审批之前调用) 
	 */
  calculateUserSelect: function(userSelectCalculateRequest){
    var requestUrl = 'api/WorkflowResource/calculateUserSelect';


    return new Promise((resolve, reject) => {
      $.ajax({
        url: Common.getApiUrl2(requestUrl),
        type: 'post',
        contentType: 'application/json',
				
				
        data: JSON.stringify(userSelectCalculateRequest),
				
        beforeSend: function(request) {
          Common.addTokenToRequest(request);
        },
        success: function(data) {
          resolve(data);
        },
        error: function(XMLHttpRequest, textStatus, errorThrown) {
          reject(XMLHttpRequest);
        },
      });
    });
  },

  /**
	 * 工具类自动生成的方法
	 * 工具作者: 杨志杰
	 * <div>判断页签、子页签中是否存在有一个字段可编辑，有就返回true。</div> 
	 */
  canEditByWorkflow: function(workflowId, curdWindowNo, taskId){
    var requestUrl = 'api/WorkflowResource/canEditByWorkflow';
    var paramCount = 0;
    if(workflowId != null){
      requestUrl += (paramCount > 0) ? '&' : '?';
      requestUrl += ('workflowId=' + workflowId);
      paramCount ++;
    }
    if(curdWindowNo != null){
      requestUrl += (paramCount > 0) ? '&' : '?';
      requestUrl += ('curdWindowNo=' + curdWindowNo);
      paramCount ++;
    }
    if(taskId != null){
      requestUrl += (paramCount > 0) ? '&' : '?';
      requestUrl += ('taskId=' + taskId);
      paramCount ++;
    }


    return new Promise((resolve, reject) => {
      $.ajax({
        url: Common.getApiUrl2(requestUrl),
        type: 'get',
        contentType: 'application/json',
				
				
				
				
        beforeSend: function(request) {
          Common.addTokenToRequest(request);
        },
        success: function(data) {
          resolve(data);
        },
        error: function(XMLHttpRequest, textStatus, errorThrown) {
          reject(XMLHttpRequest);
        },
      });
    });
  },

  /**
	 * 工具类自动生成的方法
	 * 工具作者: 杨志杰
	 * 根据表单请求查询Form 
	 */
  findForm: function(formRequest){
    var requestUrl = 'api/WorkflowResource/findForm';


    return new Promise((resolve, reject) => {
      $.ajax({
        url: Common.getApiUrl2(requestUrl),
        type: 'post',
        contentType: 'application/json',
				
				
        data: JSON.stringify(formRequest),
				
        beforeSend: function(request) {
          Common.addTokenToRequest(request);
        },
        success: function(data) {
          resolve(data);
        },
        error: function(XMLHttpRequest, textStatus, errorThrown) {
          reject(XMLHttpRequest);
        },
      });
    });
  },

  /**
	 * 工具类自动生成的方法
	 * 工具作者: 杨志杰
	 * 完成任务 
	 */
  finishTask: function(taskId){
    var requestUrl = 'api/WorkflowResource/finishTask';
    var paramCount = 0;
    if(taskId != null){
      requestUrl += (paramCount > 0) ? '&' : '?';
      requestUrl += ('taskId=' + taskId);
      paramCount ++;
    }


    return new Promise((resolve, reject) => {
      $.ajax({
        url: Common.getApiUrl2(requestUrl),
        type: 'get',
        contentType: 'application/json',
				
        dataType: 'json',
				
				
        beforeSend: function(request) {
          Common.addTokenToRequest(request);
        },
        success: function(data) {
          resolve(data);
        },
        error: function(XMLHttpRequest, textStatus, errorThrown) {
          reject(XMLHttpRequest);
        },
      });
    });
  },

  /**
	 * 工具类自动生成的方法
	 * 工具作者: 杨志杰
	 * 查询流程的评论信息 
	 */
  getProcessInstanceDescription: function(processInstanceId, recordId){
    var requestUrl = 'api/WorkflowResource/ProcessInstanceDescription';
    var paramCount = 0;
    if(processInstanceId != null){
      requestUrl += (paramCount > 0) ? '&' : '?';
      requestUrl += ('processInstanceId=' + processInstanceId);
      paramCount ++;
    }
    if(recordId != null){
      requestUrl += (paramCount > 0) ? '&' : '?';
      requestUrl += ('recordId=' + recordId);
      paramCount ++;
    }


    return new Promise((resolve, reject) => {
      $.ajax({
        url: Common.getApiUrl2(requestUrl),
        type: 'get',
        contentType: 'application/json',
				
				
				
				
        beforeSend: function(request) {
          Common.addTokenToRequest(request);
        },
        success: function(data) {
          resolve(data);
        },
        error: function(XMLHttpRequest, textStatus, errorThrown) {
          reject(XMLHttpRequest);
        },
      });
    });
  },

  /**
	 * 工具类自动生成的方法
	 * 工具作者: 杨志杰
	 * 获取需要审批任务的数量 
	 */
  getStasticCount: function(){
    var requestUrl = 'api/WorkflowResource/StasticCount';


    return new Promise((resolve, reject) => {
      $.ajax({
        url: Common.getApiUrl2(requestUrl),
        type: 'get',
        contentType: 'application/json',
				
				
				
				
        beforeSend: function(request) {
          Common.addTokenToRequest(request);
        },
        success: function(data) {
          resolve(data);
        },
        error: function(XMLHttpRequest, textStatus, errorThrown) {
          reject(XMLHttpRequest);
        },
      });
    });
  },


  /**
	 * 工具类自动生成的方法
	 * 工具作者: 杨志杰
	 * 根据工作流定义Id和taskId查询下一个用户任务 
	 */
  getUserTask: function(chooseTask){
    var requestUrl = 'api/WorkflowResource/getUserTask';


    return new Promise((resolve, reject) => {
      $.ajax({
        url: Common.getApiUrl2(requestUrl),
        type: 'post',
        contentType: 'application/json',
				
				
        data: JSON.stringify(chooseTask),
				
        beforeSend: function(request) {
          Common.addTokenToRequest(request);
        },
        success: function(data) {
          resolve(data);
        },
        error: function(XMLHttpRequest, textStatus, errorThrown) {
          reject(XMLHttpRequest);
        },
      });
    });
  },

  /**
	 * 工具类自动生成的方法
	 * 工具作者: 杨志杰
	 * 查询类别查询任务 
	 */
  listByAssigneeIdCategory: function(category){
    var requestUrl = 'api/WorkflowResource/listByAssigneeIdCategory';
    var paramCount = 0;
    if(category != null){
      requestUrl += (paramCount > 0) ? '&' : '?';
      requestUrl += ('category=' + category);
      paramCount ++;
    }


    return new Promise((resolve, reject) => {
      $.ajax({
        url: Common.getApiUrl2(requestUrl),
        type: 'get',
        contentType: 'application/json',
				
        dataType: 'json',
				
				
        beforeSend: function(request) {
          Common.addTokenToRequest(request);
        },
        success: function(data) {
          resolve(data);
        },
        error: function(XMLHttpRequest, textStatus, errorThrown) {
          reject(XMLHttpRequest);
        },
      });
    });
  },

  /**
	 * 工具类自动生成的方法
	 * 工具作者: 杨志杰
	 * 根据工作流定义Id查询所有的用户任务 
	 */
  listUserTask: function(deploymentId){
    var requestUrl = 'api/WorkflowResource/listUserTask';


    return new Promise((resolve, reject) => {
      $.ajax({
        url: Common.getApiUrl2(requestUrl),
        type: 'post',
        contentType: 'application/json',
				
				
        data: JSON.stringify(deploymentId),
				
        beforeSend: function(request) {
          Common.addTokenToRequest(request);
        },
        success: function(data) {
          resolve(data);
        },
        error: function(XMLHttpRequest, textStatus, errorThrown) {
          reject(XMLHttpRequest);
        },
      });
    });
  },

  /**
	 * 工具类自动生成的方法
	 * 工具作者: 杨志杰
	 * 根据工作流名称查询用户任务 
	 */
  listUserTaskByWorkflowName: function(workflowName){
    var requestUrl = 'api/WorkflowResource/listUserTaskByWorkflowName';


    return new Promise((resolve, reject) => {
      $.ajax({
        url: Common.getApiUrl2(requestUrl),
        type: 'post',
        contentType: 'application/json',
				
				
        data: JSON.stringify(workflowName),
				
        beforeSend: function(request) {
          Common.addTokenToRequest(request);
        },
        success: function(data) {
          resolve(data);
        },
        error: function(XMLHttpRequest, textStatus, errorThrown) {
          reject(XMLHttpRequest);
        },
      });
    });
  },

  /**
	 * 工具类自动生成的方法
	 * 工具作者: 杨志杰
	 * 设置阅览内容已经阅读 
	 */
  processTaskInfo: function(taskInfoId){
    var requestUrl = 'api/WorkflowResource/processTaskInfo';
    var paramCount = 0;
    if(taskInfoId != null){
      requestUrl += (paramCount > 0) ? '&' : '?';
      requestUrl += ('taskInfoId=' + taskInfoId);
      paramCount ++;
    }


    return new Promise((resolve, reject) => {
      $.ajax({
        url: Common.getApiUrl2(requestUrl),
        type: 'get',
        contentType: 'application/json',
				
				
				
				
        beforeSend: function(request) {
          Common.addTokenToRequest(request);
        },
        success: function(data) {
          resolve(data);
        },
        error: function(XMLHttpRequest, textStatus, errorThrown) {
          reject(XMLHttpRequest);
        },
      });
    });
  },

  /**
	 * 工具类自动生成的方法
	 * 工具作者: 杨志杰
	 * 获取文件服务器bpmn文件夹下的所有工作流文件 
	 */
  queryBpmn: function(){
    var requestUrl = 'api/WorkflowResource/queryBpmn';


    return new Promise((resolve, reject) => {
      $.ajax({
        url: Common.getApiUrl2(requestUrl),
        type: 'get',
        contentType: 'application/json',
				
        dataType: 'json',
				
				
        beforeSend: function(request) {
          Common.addTokenToRequest(request);
        },
        success: function(data) {
          resolve(data);
        },
        error: function(XMLHttpRequest, textStatus, errorThrown) {
          reject(XMLHttpRequest);
        },
      });
    });
  },


  /**
	 * 工具类自动生成的方法
	 * 工具作者: 杨志杰
	 * 在审批的过程中(用户任务)判断(选择下一个节点选择用户)是否显示。 
	 */
  reCalculatePreviousUserSelect: function(processInstanceId, previousUserSelectCalculateRequest){
    var requestUrl = 'api/WorkflowResource/reCalculatePreviousUserSelect';
    var paramCount = 0;
    if(processInstanceId != null){
      requestUrl += (paramCount > 0) ? '&' : '?';
      requestUrl += ('processInstanceId=' + processInstanceId);
      paramCount ++;
    }


    return new Promise((resolve, reject) => {
      $.ajax({
        url: Common.getApiUrl2(requestUrl),
        type: 'post',
        contentType: 'application/json',
				
				
        data: JSON.stringify(previousUserSelectCalculateRequest),
				
        beforeSend: function(request) {
          Common.addTokenToRequest(request);
        },
        success: function(data) {
          resolve(data);
        },
        error: function(XMLHttpRequest, textStatus, errorThrown) {
          reject(XMLHttpRequest);
        },
      });
    });
  },

  /**
	 * 工具类自动生成的方法
	 * 工具作者: 杨志杰
	 * 设置流程变量 
	 */
  setBooleanVariable: function(processInstanceId, variableName, variableValue){
    var requestUrl = 'api/WorkflowResource/setBooleanVariable';
    var paramCount = 0;
    if(processInstanceId != null){
      requestUrl += (paramCount > 0) ? '&' : '?';
      requestUrl += ('processInstanceId=' + processInstanceId);
      paramCount ++;
    }
    if(variableName != null){
      requestUrl += (paramCount > 0) ? '&' : '?';
      requestUrl += ('variableName=' + variableName);
      paramCount ++;
    }
    if(variableValue != null){
      requestUrl += (paramCount > 0) ? '&' : '?';
      requestUrl += ('variableValue=' + variableValue);
      paramCount ++;
    }


    return new Promise((resolve, reject) => {
      $.ajax({
        url: Common.getApiUrl2(requestUrl),
        type: 'get',
        contentType: 'application/json',
				
				
				
				
        beforeSend: function(request) {
          Common.addTokenToRequest(request);
        },
        success: function(data) {
          resolve(data);
        },
        error: function(XMLHttpRequest, textStatus, errorThrown) {
          reject(XMLHttpRequest);
        },
      });
    });
  },

  /**
	 * 工具类自动生成的方法
	 * 工具作者: 杨志杰
	 * 审批 
	 */
  setChoice: function(chooseTask){
    var requestUrl = 'api/WorkflowResource/SetChoice';


    return new Promise((resolve, reject) => {
      $.ajax({
        url: Common.getApiUrl2(requestUrl),
        type: 'post',
        contentType: 'application/json',
				
				
        data: JSON.stringify(chooseTask),
				
        beforeSend: function(request) {
          Common.addTokenToRequest(request);
        },
        success: function(data) {
          resolve(data);
        },
        error: function(XMLHttpRequest, textStatus, errorThrown) {
          reject(XMLHttpRequest);
        },
      });
    });
  },

  /**
	 * 工具类自动生成的方法
	 * 工具作者: 杨志杰
	 * 设置阅览内容已经阅读 
	 */
  setViewInfoProcessed: function(viewInfo){
    var requestUrl = 'api/WorkflowResource/ProcessedViewInfo';


    return new Promise((resolve, reject) => {
      $.ajax({
        url: Common.getApiUrl2(requestUrl),
        type: 'post',
        contentType: 'application/json',
				
				
        data: JSON.stringify(viewInfo),
				
        beforeSend: function(request) {
          Common.addTokenToRequest(request);
        },
        success: function(data) {
          resolve(data);
        },
        error: function(XMLHttpRequest, textStatus, errorThrown) {
          reject(XMLHttpRequest);
        },
      });
    });
  },

  /**
	 * 工具类自动生成的方法
	 * 工具作者: 杨志杰
	 * 启动工作流 
	 */
  startWorkflow: function(workflowStartParam){
    var requestUrl = 'api/WorkflowExtResource/startWorkflow';


    return new Promise((resolve, reject) => {
      $.ajax({
        url: Common.getApiUrl2(requestUrl),
        type: 'post',
        contentType: 'application/json',
				
				
        data: JSON.stringify(workflowStartParam),
				
        beforeSend: function(request) {
          Common.addTokenToRequest(request);
        },
        success: function(data) {
          resolve(data);
        },
        error: function(XMLHttpRequest, textStatus, errorThrown) {
          reject(XMLHttpRequest);
        },
      });
    });
  },

  /**
	 * 工具类自动生成的方法
	 * 工具作者: 杨志杰
	 * 转批 
	 */
  transfer: function(transferTaskDto){
    var requestUrl = 'api/WorkflowResource/transfer';


    return new Promise((resolve, reject) => {
      $.ajax({
        url: Common.getApiUrl2(requestUrl),
        type: 'post',
        contentType: 'application/json',
				
				
        data: JSON.stringify(transferTaskDto),
				
        beforeSend: function(request) {
          Common.addTokenToRequest(request);
        },
        success: function(data) {
          resolve(data);
        },
        error: function(XMLHttpRequest, textStatus, errorThrown) {
          reject(XMLHttpRequest);
        },
      });
    });
  },

  /**
	 * 工具类自动生成的方法
	 * 工具作者: 杨志杰
	 * 根据任务Id和用户Id查询历史任务信息 
	 */
  uniqueHistoryTaskInfoByTaskIdUserId: function(taskId){
    var requestUrl = 'api/WorkflowResource/uniqueHistoryTaskInfoByTaskIdUserId';
    var paramCount = 0;
    if(taskId != null){
      requestUrl += (paramCount > 0) ? '&' : '?';
      requestUrl += ('taskId=' + taskId);
      paramCount ++;
    }


    return new Promise((resolve, reject) => {
      $.ajax({
        url: Common.getApiUrl2(requestUrl),
        type: 'post',
        contentType: 'application/json',
				
				
				
				
        beforeSend: function(request) {
          Common.addTokenToRequest(request);
        },
        success: function(data) {
          resolve(data);
        },
        error: function(XMLHttpRequest, textStatus, errorThrown) {
          reject(XMLHttpRequest);
        },
      });
    });
  },

  /**
	 * 工具类自动生成的方法
	 * 工具作者: 杨志杰
	 * 根据任务Id和用户Id查询任务信息 
	 */
  uniqueTaskInfoByTaskIdUserId: function(taskId){
    var requestUrl = 'api/WorkflowResource/uniqueTaskInfoByTaskIdUserId';
    var paramCount = 0;
    if(taskId != null){
      requestUrl += (paramCount > 0) ? '&' : '?';
      requestUrl += ('taskId=' + taskId);
      paramCount ++;
    }


    return new Promise((resolve, reject) => {
      $.ajax({
        url: Common.getApiUrl2(requestUrl),
        type: 'post',
        contentType: 'application/json',
				
				
				
				
        beforeSend: function(request) {
          Common.addTokenToRequest(request);
        },
        success: function(data) {
          resolve(data);
        },
        error: function(XMLHttpRequest, textStatus, errorThrown) {
          reject(XMLHttpRequest);
        },
      });
    });
  },
};
