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

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

  /**
	 * 工具类自动生成的方法
	 * 工具作者: 杨志杰
	 * 读取CURD数据字典xml，如果simpleFilterSchemaLines节点不存在，则复制filterSchemaLines节点。 
	 */
  createDefaultSimpleFilterSchemaLines: function(){
    var requestUrl = 'CurdWindowResource/createDefaultSimpleFilterSchemaLines';


    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);
        },
      });
    });
  },

  /**
	 * 工具类自动生成的方法
	 * 工具作者: 杨志杰
	 * 删除数据 
	 */
  deleteData: function(tabDeleteData){
    var requestUrl = 'CurdWindowResource/delete';


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

  /**
	 * 工具类自动生成的方法
	 * 工具作者: 杨志杰
	 * 获取页签数据
TabQueryParam 
	 */
  getTabData: function(tabQueryParam){
    var requestUrl = 'CurdWindowResource/tabData';


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

  /**
	 * 工具类自动生成的方法
	 * 工具作者: 杨志杰
	 * 查询树类型数据 
	 */
  getTreeData: function(windowNo, tabIndex, parentId, parentColumnId){
    var requestUrl = 'CurdWindowResource/getTreeData';
    var paramCount = 0;
    if(windowNo != null){
      requestUrl += (paramCount > 0) ? '&' : '?';
      requestUrl += ('windowNo=' + windowNo);
      paramCount ++;
    }
    if(tabIndex != null){
      requestUrl += (paramCount > 0) ? '&' : '?';
      requestUrl += ('tabIndex=' + tabIndex);
      paramCount ++;
    }
    if(parentId != null){
      requestUrl += (paramCount > 0) ? '&' : '?';
      requestUrl += ('parentId=' + parentId);
      paramCount ++;
    }
    if(parentColumnId != null){
      requestUrl += (paramCount > 0) ? '&' : '?';
      requestUrl += ('parentColumnId=' + parentColumnId);
      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);
        },
      });
    });
  },

  /**
	 * 工具类自动生成的方法
	 * 工具作者: 杨志杰
	 * 获取窗口键值对 
	 */
  getWindowKeyValues: function(){
    var requestUrl = 'CurdWindowResource/getWindowKeyValues';


    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);
        },
      });
    });
  },

  /**
	 * 工具类自动生成的方法
	 * 工具作者: 杨志杰
	 * 查询子节点 
	 */
  listChildrenTreeItemData: function(windowNo, tabIndex, parentTreeItemId, parentColumnId){
    var requestUrl = 'CurdWindowResource/listChildrenTreeItemData';
    var paramCount = 0;
    if(windowNo != null){
      requestUrl += (paramCount > 0) ? '&' : '?';
      requestUrl += ('windowNo=' + windowNo);
      paramCount ++;
    }
    if(tabIndex != null){
      requestUrl += (paramCount > 0) ? '&' : '?';
      requestUrl += ('tabIndex=' + tabIndex);
      paramCount ++;
    }
    if(parentTreeItemId != null){
      requestUrl += (paramCount > 0) ? '&' : '?';
      requestUrl += ('parentTreeItemId=' + parentTreeItemId);
      paramCount ++;
    }
    if(parentColumnId != null){
      requestUrl += (paramCount > 0) ? '&' : '?';
      requestUrl += ('parentColumnId=' + parentColumnId);
      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);
        },
      });
    });
  },

  /**
	 * 工具类自动生成的方法
	 * 工具作者: 杨志杰
	 * 查询节点及其子节点 
	 */
  listTreeItemData: function(queryParam){
    var requestUrl = 'CurdWindowResource/listTreeItemData';


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

  /**
	 * 工具类自动生成的方法
	 * 工具作者: 杨志杰
	 * 从数据库加载页签数据 
	 */
  loadTabData: function(windowNo, tabIndex, recordId){
    var requestUrl = 'CurdWindowResource/Load';
    var paramCount = 0;
    if(windowNo != null){
      requestUrl += (paramCount > 0) ? '&' : '?';
      requestUrl += ('windowNo=' + windowNo);
      paramCount ++;
    }
    if(tabIndex != null){
      requestUrl += (paramCount > 0) ? '&' : '?';
      requestUrl += ('tabIndex=' + tabIndex);
      paramCount ++;
    }
    if(recordId != null){
      requestUrl += (paramCount > 0) ? '&' : '?';
      requestUrl += ('recordId=' + recordId);
      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);
        },
      });
    });
  },

  /**
	 * 工具类自动生成的方法
	 * 工具作者: 杨志杰
	 * 保存或者更新数据
TabSaveData 
	 */
  saveOrUpdateData: function(tabSaveData){
    var requestUrl = 'CurdWindowResource/saveOrUpdate';


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

  /**
	 * 工具类自动生成的方法
	 * 工具作者: 杨志杰
	 * 批量保存或者更新数据 
	 */
  saveOrUpdateDatas: function(tabSaveDatas){
    var requestUrl = 'CurdWindowResource/saveOrUpdateDatas';


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

  /**
	 * 工具类自动生成的方法
	 * 工具作者: 杨志杰
	 * 根据 WindowNo获取 Window 的定义 
	 */
  uniqueByNo: function(no){
    var requestUrl = 'CurdWindowResource/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);
        },
      });
    });
  },

  /**
	 * 工具类自动生成的方法
	 * 工具作者: 杨志杰
	 * <div>根据curd窗口编号获取用户自定义的CURD窗口的定义。</div>
<ul>
<li>根据角色Id获取角色对CURD窗口的特殊定义(隐藏、只读)</li>
<li>如果找不到，那么直接返回CURD窗口的定义</li>
<ul> 
	 */
  uniqueByNoWithRole: function(no){
    var requestUrl = 'CurdWindowResource/uniqueByNoWithRole';
    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);
        },
      });
    });
  },

  /**
	 * 工具类自动生成的方法
	 * 工具作者: 杨志杰
	 * <div>根据curd窗口编号获取用户自定义的CURD窗口的定义。</div>
<ul>
<li>根据工作流Id获取对CURD窗口的特殊定义(隐藏、只读)</li>
<li>如果找不到，那么直接返回CURD窗口的定义</li>
<ul> 
	 */
  uniqueByNoWithWorkflow: function(workflowId, taskInfoId, curdWindowNo){
    var requestUrl = 'CurdWindowResource/uniqueByNoWithWorkflow';
    var paramCount = 0;
    if(workflowId != null){
      requestUrl += (paramCount > 0) ? '&' : '?';
      requestUrl += ('workflowId=' + workflowId);
      paramCount ++;
    }
    if(taskInfoId != null){
      requestUrl += (paramCount > 0) ? '&' : '?';
      requestUrl += ('taskInfoId=' + taskInfoId);
      paramCount ++;
    }
    if(curdWindowNo != null){
      requestUrl += (paramCount > 0) ? '&' : '?';
      requestUrl += ('curdWindowNo=' + curdWindowNo);
      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);
        },
      });
    });
  },
};
