Alexylva

Untitled

Dec 6th, 2021 (edited)
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. (function (c) {
  2.     (function(console){
  3.  
  4.         console.save = function(data, filename){
  5.  
  6.         if(!data) {
  7.             console.error('Console.save: No data')
  8.             return;
  9.         }
  10.  
  11.         if(!filename) filename = 'console.json'
  12.  
  13.         if(typeof data === "object"){
  14.             data = JSON.stringify(data, undefined, 4)
  15.         }
  16.  
  17.         var blob = new Blob([data], {type: 'text/json'}),
  18.             e    = document.createEvent('MouseEvents'),
  19.             a    = document.createElement('a')
  20.  
  21.         a.download = filename
  22.         a.href = window.URL.createObjectURL(blob)
  23.         a.dataset.downloadurl =  ['text/json', a.download, a.href].join(':')
  24.         e.initMouseEvent('click', true, false, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null)
  25.         a.dispatchEvent(e)
  26.      }
  27.     })(c);
  28.    
  29.     var pagesize = 5000, total = 10291, pages = Math.ceil(total / pagesize), data = [], response;
  30.     var url = "/ordermanagement/channel/all";
  31.     var json = {
  32.         "descriptionProvider": $("#descriptionProvider").val(),
  33.         "description": $("#description").val(),
  34.         "categoryId": $("#category").val(),
  35.         "subCategoryId": $("#subCategory").val(),
  36.         "business": $("#business").val(),
  37.         "advertisement": $("#advertisement").val(),
  38.         "freight": $("#freight").val(),
  39.         "shippingMode": $("#shippingMode").val(),
  40.         "channel": $("#channel").val(),
  41.         "status": $("#statusMl").val(),
  42.         "visits": $("#visits").val(),
  43.         "ean": $("#ean").val(),
  44.         "qtySales": $("#qtySales").val(),
  45.         "sku": $("#sku").val(),
  46.         "findSkuBy": $("#findSkuBy").is(":checked") ? "channelId" : "productSku",
  47.         "updatePriceByInterface": "-1",
  48.         "isPromotionalPrice": $("#isPromotionalPrice").val(),
  49.         "isKit": $("#isKit").val(),
  50.         "datePaused": $("#date_paused").val(),
  51.         "subStatus": $("#subStatus").val(),
  52.         "hasVariation": $("#hasVariation").val(),
  53.         "priceFrom": $("#priceFrom").val(),
  54.         "priceTo": $("#priceTo").val(),
  55.         "isBuybox": $("#isBuybox").val(),
  56.         "logisticType": $("#logisticType").val(),
  57.         "page": 1,
  58.         "pageSize": pagesize
  59.     }
  60.    
  61.  
  62.  
  63.     for(var i = 1; i <= pages ; i++) {
  64.         json.page = i;
  65.         loadPagination(ajaxEnvio, url, json, true, false, mountTable)['list'][0]
  66.             .forEach(
  67.                 elem => {if (elem) data.push(elem)}
  68.             );
  69.     }
  70.     console.save(data, "test.json");
  71. })(console);
Add Comment
Please, Sign In to add comment