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

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

  /**
   * 工具类自动生成的方法
   * 工具作者: 杨志杰
   * AGV抽盘生成一张盘点单 
   */
  agvGenerateAssetInventory: function (agvAssetInventorySaveRequest) {
    var requestUrl = 'api/assetInventoryResource/agvGenerateAssetInventory';


    return new Promise((resolve, reject) => {
      $.ajax({
        url: Common.getApiUrl2(requestUrl),
        type: 'post',
        contentType: 'application/json',


        data: JSON.stringify(agvAssetInventorySaveRequest),

        beforeSend: function (request) {
          Common.addTokenToRequest(request);
        },
        success: function (data) {
          resolve(data);
        },
        error: function (XMLHttpRequest, textStatus, errorThrown) {
          reject(XMLHttpRequest);
        },
      });
    });
  },

  /**
   * 工具类自动生成的方法
   * 工具作者: 杨志杰
   * 盘点 
   */
  check: function (saveInventoryDto) {
    var requestUrl = 'api/assetInventoryResource/check';


    return new Promise((resolve, reject) => {
      $.ajax({
        url: Common.getApiUrl2(requestUrl),
        type: 'post',
        contentType: 'application/json',


        data: JSON.stringify(saveInventoryDto),

        beforeSend: function (request) {
          Common.addTokenToRequest(request);
        },
        success: function (data) {
          resolve(data);
        },
        error: function (XMLHttpRequest, textStatus, errorThrown) {
          reject(XMLHttpRequest);
        },
      });
    });
  },

  /**
   * 工具类自动生成的方法
   * 工具作者: 杨志杰
   * 生成合并盘点单 
   */
  consolidatedAssetInventory: function (assetInventoryRequest) {
    var requestUrl = 'api/assetInventoryResource/consolidatedAssetInventory';


    return new Promise((resolve, reject) => {
      $.ajax({
        url: Common.getApiUrl2(requestUrl),
        type: 'post',
        contentType: 'application/json',


        data: JSON.stringify(assetInventoryRequest),

        beforeSend: function (request) {
          Common.addTokenToRequest(request);
        },
        success: function (data) {
          resolve(data);
        },
        error: function (XMLHttpRequest, textStatus, errorThrown) {
          reject(XMLHttpRequest);
        },
      });
    });
  },

  /**
   * 工具类自动生成的方法
   * 工具作者: 杨志杰
   * 全公司每个部门生成一张盘点单 
   */
  departmentGeneratesCountSheet: function (assetInventoryDepartmentRequest) {
    var requestUrl = 'api/CheckVouchResource/generateCheckVouchByWarehouse';


    return new Promise((resolve, reject) => {
      $.ajax({
        url: Common.getApiUrl2(requestUrl),
        type: 'post',
        contentType: 'application/json',


        data: JSON.stringify(assetInventoryDepartmentRequest),

        beforeSend: function (request) {
          Common.addTokenToRequest(request);
        },
        success: function (data) {
          resolve(data);
        },
        error: function (XMLHttpRequest, textStatus, errorThrown) {
          reject(XMLHttpRequest);
        },
      });
    });
  },

  // 机器狗生成盘点单
  generateCheckVouchMechanicalDog: function (params) {
    var requestUrl = 'api/CheckVouchResource/generateCheckVouchMechanicalDog';
    return new Promise((resolve, reject) => {
      $.ajax({
        url: Common.getApiUrl2(requestUrl),
        type: 'post',
      contentType: 'application/json',
      data: JSON.stringify(params),
      beforeSend: function (request) {
        Common.addTokenToRequest(request);
      },
      success: function (data) {
        resolve(data);
      },
      error: function (XMLHttpRequest, textStatus, errorThrown) {
        reject(XMLHttpRequest);
      },
    });
  });
  },

  /**
   * 工具类自动生成的方法
   * 工具作者: 杨志杰
   * 根据条件查询盘点单 
   */
  findByAssetInventoryRequest: function (assetInventoryRequest) {
    var requestUrl = 'api/assetInventoryResource/findByAssetInventoryRequest';


    return new Promise((resolve, reject) => {
      $.ajax({
        url: Common.getApiUrl2(requestUrl),
        type: 'post',
        contentType: 'application/json',


        data: JSON.stringify(assetInventoryRequest),

        beforeSend: function (request) {
          Common.addTokenToRequest(request);
        },
        success: function (data) {
          resolve(data);
        },
        error: function (XMLHttpRequest, textStatus, errorThrown) {
          reject(XMLHttpRequest);
        },
      });
    });
  },

  /**
   * 工具类自动生成的方法
   * 工具作者: 杨志杰
   * 根据所属部门、使用部门、资产类别查询资产生成资产盘点明细

数据权限：功能：资产盘点， 功能项：发起盘点任务 
   */
  generateAssetInventoryLineByOrganizationAndCategory: function (assetInventoryLineGenerateRequest) {
    var requestUrl = 'api/assetInventoryResource/generateAssetInventoryLineByOrganizationAndCategory';


    return new Promise((resolve, reject) => {
      $.ajax({
        url: Common.getApiUrl2(requestUrl),
        type: 'post',
        contentType: 'application/json',


        data: JSON.stringify(assetInventoryLineGenerateRequest),

        beforeSend: function (request) {
          Common.addTokenToRequest(request);
        },
        success: function (data) {
          resolve(data);
        },
        error: function (XMLHttpRequest, textStatus, errorThrown) {
          reject(XMLHttpRequest);
        },
      });
    });
  },

  /**
   * 工具类自动生成的方法
   * 工具作者: 杨志杰
   * 抽盘生成一张盘点单 
   */
  generateCountSheetBySampling: function (assetInventoryDrawingRequest) {
    var requestUrl = 'api/CheckVouchResource/generateSpotCheckCheckVouchs';


    return new Promise((resolve, reject) => {
      $.ajax({
        url: Common.getApiUrl2(requestUrl),
        type: 'post',
        contentType: 'application/json',


        data: JSON.stringify(assetInventoryDrawingRequest),

        beforeSend: function (request) {
          Common.addTokenToRequest(request);
        },
        success: function (data) {
          resolve(data);
        },
        error: function (XMLHttpRequest, textStatus, errorThrown) {
          reject(XMLHttpRequest);
        },
      });
    });
  },

  /**
   * 工具类自动生成的方法
   * 工具作者: 杨志杰
   * 获取资产盘点的统计数据 <br>
x1 盘点单 (全部) x2 盘点单 (已完成) x3 盘点单 (未完成) 
   */
  getAssetInventoryStastic: function (tabQueryParam) {
    var requestUrl = 'api/assetInventoryResource/getAssetInventoryStastic';


    return new Promise((resolve, reject) => {
      $.ajax({
        url: Common.getApiUrl2(requestUrl),
        type: 'post',
        contentType: 'application/json',


        data: JSON.stringify(tabQueryParam),

        beforeSend: function (request) {
          Common.addTokenToRequest(request);
        },
        success: function (data) {
          resolve(data);
        },
        error: function (XMLHttpRequest, textStatus, errorThrown) {
          reject(XMLHttpRequest);
        },
      });
    });
  },

  /**
   * 工具类自动生成的方法
   * 工具作者: 杨志杰
   * 获取资产盘点进度 
   */
  getInventoryProgress: function (tabQueryParam) {
    var requestUrl = 'api/assetInventoryResource/getInventoryProgress';


    return new Promise((resolve, reject) => {
      $.ajax({
        url: Common.getApiUrl2(requestUrl),
        type: 'post',
        contentType: 'application/json',


        data: JSON.stringify(tabQueryParam),

        beforeSend: function (request) {
          Common.addTokenToRequest(request);
        },
        success: function (data) {
          resolve(data);
        },
        error: function (XMLHttpRequest, textStatus, errorThrown) {
          reject(XMLHttpRequest);
        },
      });
    });
  },

  /**
   * 工具类自动生成的方法
   * 工具作者: 杨志杰
   * 获取所属部门,使用部门,资产类别 
   */
  getOrganizationsAndOrganizationsAndCategory: function () {
    var requestUrl = 'api/assetInventoryResource/getOrganizationsAndOrganizationsAndCategory';


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

  /**
   * 工具类自动生成的方法
   * 工具作者: 杨志杰
   * 获取盘点单中已经选择的所属部门,使用部门,资产类别

数据权限：功能：资产盘点， 功能项：发起盘点任务 
   */
  getResponseOrganizationsAndOrganizationsAndCategory: function (assetInventoryId) {
    var requestUrl = 'api/assetInventoryResource/getResponseOrganizationsAndOrganizationsAndCategory';
    var paramCount = 0;
    if (assetInventoryId != null) {
      requestUrl += (paramCount > 0) ? '&' : '?';
      requestUrl += ('assetInventoryId=' + assetInventoryId);
      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);
        },
      });
    });
  },

  /**
   * 工具类自动生成的方法
   * 工具作者: 杨志杰
   * 根据单位Id查询盘点单 
   */
  list: function (range) {
    var requestUrl = 'api/assetInventoryResource/list';


    return new Promise((resolve, reject) => {
      $.ajax({
        url: Common.getApiUrl2(requestUrl),
        type: 'post',
        contentType: 'application/json',


        data: JSON.stringify(range),

        beforeSend: function (request) {
          Common.addTokenToRequest(request);
        },
        success: function (data) {
          resolve(data);
        },
        error: function (XMLHttpRequest, textStatus, errorThrown) {
          reject(XMLHttpRequest);
        },
      });
    });
  },

  /**
   * 工具类自动生成的方法
   * 工具作者: 杨志杰
   * 查询本公司的盘点单 
   */
  listAssetInventory: function (start, length, searchString) {
    var requestUrl = 'api/assetInventoryResource/listAssetInventory';
    var paramCount = 0;
    if (start != null) {
      requestUrl += (paramCount > 0) ? '&' : '?';
      requestUrl += ('start=' + start);
      paramCount++;
    }
    if (length != null) {
      requestUrl += (paramCount > 0) ? '&' : '?';
      requestUrl += ('length=' + length);
      paramCount++;
    }
    if (searchString != null) {
      requestUrl += (paramCount > 0) ? '&' : '?';
      requestUrl += ('searchString=' + searchString);
      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);
        },
      });
    });
  },

  /**
   * 工具类自动生成的方法
   * 工具作者: 杨志杰
   * 离线盘点数据上传 
   */
  offlineInventoryDataUpload: function (saveInventoryDto) {
    var requestUrl = 'api/assetInventoryResource/offlineInventoryDataUpload';


    return new Promise((resolve, reject) => {
      $.ajax({
        url: Common.getApiUrl2(requestUrl),
        type: 'post',
        contentType: 'application/json',


        data: JSON.stringify(saveInventoryDto),

        beforeSend: function (request) {
          Common.addTokenToRequest(request);
        },
        success: function (data) {
          resolve(data);
        },
        error: function (XMLHttpRequest, textStatus, errorThrown) {
          reject(XMLHttpRequest);
        },
      });
    });
  },

  /**
   * 工具类自动生成的方法
   * 工具作者: 杨志杰
   * 根据盘点单id查询盘点主表信息 
   */
  queryById: function (assetInventoryId) {
    var requestUrl = 'api/assetInventoryResource/queryById';
    var paramCount = 0;
    if (assetInventoryId != null) {
      requestUrl += (paramCount > 0) ? '&' : '?';
      requestUrl += ('assetInventoryId=' + assetInventoryId);
      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);
        },
      });
    });
  },

  /**
   * 工具类自动生成的方法
   * 工具作者: 杨志杰
   * 新增/更新盘点单 
   */
  save: function (assetInventoryDto) {
    var requestUrl = 'api/assetInventoryResource/save';


    return new Promise((resolve, reject) => {
      $.ajax({
        url: Common.getApiUrl2(requestUrl),
        type: 'post',
        contentType: 'application/json',


        data: JSON.stringify(assetInventoryDto),

        beforeSend: function (request) {
          Common.addTokenToRequest(request);
        },
        success: function (data) {
          resolve(data);
        },
        error: function (XMLHttpRequest, textStatus, errorThrown) {
          reject(XMLHttpRequest);
        },
      });
    });
  },

  /**
   * 工具类自动生成的方法
   * 工具作者: 杨志杰
   * 设置盘点单processed的状态 
   */
  setProcessed: function (id, processed) {
    var requestUrl = 'api/assetInventoryResource/setProcessed';
    var paramCount = 0;
    if (id != null) {
      requestUrl += (paramCount > 0) ? '&' : '?';
      requestUrl += ('id=' + id);
      paramCount++;
    }
    if (processed != null) {
      requestUrl += (paramCount > 0) ? '&' : '?';
      requestUrl += ('processed=' + processed);
      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);
        },
      });
    });
  },

  /**
   * 工具类自动生成的方法
   * 工具作者: 杨志杰
   * 静态盘点数据处理 
   */
  staticInventory: function (dto) {
    var requestUrl = 'api/assetInventoryResource/staticInventory';


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

  // 获取仓库列表
 getWarehouseList: function () {
    var requestUrl = 'api/WarehouseResource/all';


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