2018-03-26打印库存变化

路径和文件名称设定:

    let fetchUrl;
    let pdfName;
    switch (payload.iv.humanizedType){
      case "Opening":
        fetchUrl = "http://ssr.stg.bindolabs.com/pdf/2";
        pdfName = "Inventory_opening.pdf";
        break;
      case "Adjustment by actual quantity":
        fetchUrl = "http://ssr.stg.bindolabs.com/pdf/3";
        pdfName = "Inventory_qty_adjustment.pdf";
        break;
      case "Adjustment by variance quantity":
        fetchUrl = "http://ssr.stg.bindolabs.com/pdf/4";
        pdfName = "Inventory_Variance_qty_adjustment.pdf";
        break;
      case "Cost adjustment":
        fetchUrl = "http://ssr.stg.bindolabs.com/pdf/5";
        pdfName = "Inventory_cost_adjustment.pdf";
        break;
    }  

download:

    function downloadFile(fileName, content){
      const aLink = document.createElement('a');
      aLink.download = fileName;
      aLink.href = URL.createObjectURL(content);
      aLink.click()
    }

    fetch(fetchUrl, {
      method: 'post',
      body: JSON.stringify(payload)
    }).then(r => r.blob()).then(content => {
      downloadFile(pdfName, content)
    })   

你可能感兴趣的:(2018-03-26打印库存变化)