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

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

  /**
	 * 工具类自动生成的方法
	 * 工具作者: 杨志杰
	 * 自动运行流程和报表 
	 */
  autoRun: function(processReportExecutorDto){
    var requestUrl = 'ProcessReportResource/autoRun';
    return new Promise((resolve, reject) => {
      $.ajax({
        url: Common.getApiURL(requestUrl),
        type: 'post',
				
				
        data: JSON.stringify(processReportExecutorDto),
				
        beforeSend: function(request) {
          Common.addTokenToRequest(request);
        },
        success: function(data) {
          resolve(data);
        },
        error: function(XMLHttpRequest, textStatus, errorThrown) {
          reject(XMLHttpRequest);
        },
      });
    });
  },

  /**
	 * 工具类自动生成的方法
	 * 工具作者: 杨志杰
	 * 根据流程和报表Id的归档权限 (该接口暂时只和登录的用户角色有关，以后可以扩展为根据processReportId来划分) 
	 */
  getArchiveAuthority: function(processReportNo){
    var requestUrl = 'ProcessReportResource/getArchiveAuthority';
    var paramCount = 0;
    if(processReportNo != null){
      requestUrl += (paramCount > 0) ? '&' : '?';
      requestUrl += ('processReportNo=' + processReportNo);
      paramCount ++;
    }
    return new Promise((resolve, reject) => {
      $.ajax({
        url: Common.getApiURL(requestUrl),
        type: 'get',
				
				
				
				
        beforeSend: function(request) {
          Common.addTokenToRequest(request);
        },
        success: function(data) {
          resolve(data);
        },
        error: function(XMLHttpRequest, textStatus, errorThrown) {
          reject(XMLHttpRequest);
        },
      });
    });
  },

  /**
	 * 工具类自动生成的方法
	 * 工具作者: 杨志杰
	 *  
	 */
  getProcessReportKeyValues: function(){
    var requestUrl = 'ProcessReportResource/getProcessReportKeyValues';
    return new Promise((resolve, reject) => {
      $.ajax({
        url: Common.getApiURL(requestUrl),
        type: 'get',
				
        dataType: 'json',
				
				
        beforeSend: function(request) {
          Common.addTokenToRequest(request);
        },
        success: function(data) {
          resolve(data);
        },
        error: function(XMLHttpRequest, textStatus, errorThrown) {
          reject(XMLHttpRequest);
        },
      });
    });
  },

  /**
	 * 工具类自动生成的方法
	 * 工具作者: 杨志杰
	 * 运行Callout 
	 */
  runCallout: function(no, modelData){
    var requestUrl = 'ProcessReportResource/runCallout/{no}';
    if(no != null){
      requestUrl = requestUrl.replace('{no}', no);
    }
    return new Promise((resolve, reject) => {
      $.ajax({
        url: Common.getApiURL(requestUrl),
        type: 'post',
        contentType: 'application/json',
        dataType: 'json',
        data: JSON.stringify(modelData),
				
        beforeSend: function(request) {
          Common.addTokenToRequest(request);
        },
        success: function(data) {
          resolve(data);
        },
        error: function(XMLHttpRequest, textStatus, errorThrown) {
          reject(XMLHttpRequest);
        },
      });
    });
  },

  /**
	 * 工具类自动生成的方法
	 * 工具作者: 杨志杰
	 * 运行超链接报表 
	 */
  runHyperLinkReport: function(jasperFileName, token){
    var requestUrl = 'ProcessReportResource/runHyperLinkReport';
    var paramCount = 0;
    if(jasperFileName != null){
      requestUrl += (paramCount > 0) ? '&' : '?';
      requestUrl += ('jasperFileName=' + jasperFileName);
      paramCount ++;
    }
    if(token != null){
      requestUrl += (paramCount > 0) ? '&' : '?';
      requestUrl += ('token=' + token);
      paramCount ++;
    }
    return new Promise((resolve, reject) => {
      $.ajax({
        url: Common.getApiURL(requestUrl),
        type: 'get',
				
        dataType: 'octet-stream',
				
				
        beforeSend: function(request) {
          Common.addTokenToRequest(request);
        },
        success: function(data) {
          resolve(data);
        },
        error: function(XMLHttpRequest, textStatus, errorThrown) {
          reject(XMLHttpRequest);
        },
      });
    });
  },

  /**
	 * 工具类自动生成的方法
	 * 工具作者: 杨志杰
	 * 运行流程 
	 */
  runProcess: function(processResultData){
    var requestUrl = 'ProcessReportResource/runProcess';
    return new Promise((resolve, reject) => {
      $.ajax({
        url: Common.getApiURL(requestUrl),
        type: 'post',
        contentType: 'application/json',
        dataType: 'json',
        data: JSON.stringify(processResultData),
				
        beforeSend: function(request) {
          Common.addTokenToRequest(request);
        },
        success: function(data) {
          resolve(data);
        },
        error: function(XMLHttpRequest, textStatus, errorThrown) {
          reject(XMLHttpRequest);
        },
      });
    });
  },

  /**
	 * 工具类自动生成的方法
	 * 工具作者: 杨志杰
	 * 运行流程 
	 */
  runProcessByIds: function(no, recordIds){
    var requestUrl = 'ProcessReportResource/runProcessByIds/{no}';
    if(no != null){
      requestUrl = requestUrl.replace('{no}', no);
    }
    return new Promise((resolve, reject) => {
      $.ajax({
        url: Common.getApiURL(requestUrl),
        type: 'post',
        contentType: 'application/json',
        dataType: 'json',
        data: JSON.stringify(recordIds),
				
        beforeSend: function(request) {
          Common.addTokenToRequest(request);
        },
        success: function(data) {
          resolve(data);
        },
        error: function(XMLHttpRequest, textStatus, errorThrown) {
          reject(XMLHttpRequest);
        },
      });
    });
  },

  /**
	 * 工具类自动生成的方法
	 * 工具作者: 杨志杰
	 * 运行动态参数报表 
	 */
  runProcessDynamic: function(processResultData){
    var requestUrl = 'ProcessReportResource/runProcessDynamic';
    return new Promise((resolve, reject) => {
      $.ajax({
        url: Common.getApiURL(requestUrl),
        type: 'post',
        contentType: 'application/json',
        dataType: 'json',
        data: JSON.stringify(processResultData),
				
        beforeSend: function(request) {
          Common.addTokenToRequest(request);
        },
        success: function(data) {
          resolve(data);
        },
        error: function(XMLHttpRequest, textStatus, errorThrown) {
          reject(XMLHttpRequest);
        },
      });
    });
  },

  /**
	 * 工具类自动生成的方法
	 * 工具作者: 杨志杰
	 * 运行Callout 
	 */
  runProcessReportCallout: function(no, processReportDto){
    var requestUrl = 'ProcessReportResource/runProcessReportCallout/{no}';
    if(no != null){
      requestUrl = requestUrl.replace('{no}', no);
    }
    return new Promise((resolve, reject) => {
      $.ajax({
        url: Common.getApiURL(requestUrl),
        type: 'post',
        contentType: 'application/json',
        dataType: 'json',
        data: JSON.stringify(processReportDto),
				
        beforeSend: function(request) {
          Common.addTokenToRequest(request);
        },
        success: function(data) {
          resolve(data);
        },
        error: function(XMLHttpRequest, textStatus, errorThrown) {
          reject(XMLHttpRequest);
        },
      });
    });
  },

  /**
	 * 工具类自动生成的方法
	 * 工具作者: 杨志杰
	 * 根据流程和报表Id获取流程和报表的定义 
	 */
  uniqueByNo: function(no){
    var requestUrl = 'ProcessReportResource/uniqueByNo';
    var paramCount = 0;
    if(no != null){
      requestUrl += (paramCount > 0) ? '&' : '?';
      requestUrl += ('no=' + no);
      paramCount ++;
    }
    return new Promise((resolve, reject) => {
      $.ajax({
        url: Common.getApiURL(requestUrl),
        type: 'get',
				
        dataType: 'json',
				
				
        beforeSend: function(request) {
          Common.addTokenToRequest(request);
        },
        success: function(data) {
          resolve(data);
        },
        error: function(XMLHttpRequest, textStatus, errorThrown) {
          reject(XMLHttpRequest);
        },
      });
    });
  },
};
