bep40 commited on
Commit
f4381fc
·
verified ·
1 Parent(s): 7d785f3

FIX: CK formula shows *1 (should be *0.65) + Excel/PDF 2nd download blocked on Chrome

Browse files
Files changed (1) hide show
  1. index.html +14 -6
index.html CHANGED
@@ -1680,7 +1680,8 @@ let blob=new Blob([csv],{type:'text/csv;charset=utf-8'});
1680
  let url=URL.createObjectURL(blob);
1681
  let a=document.createElement('a');
1682
  a.href=url;a.download='BaoGia_VAI_STUDIO_'+today.replace(/\//g,'-')+'.csv';
1683
- a.click();setTimeout(function(){URL.revokeObjectURL(url);},60000);
 
1684
  showToast('Đã tải báo giá Excel!');
1685
  }
1686
 
@@ -1712,8 +1713,8 @@ function exportQuoteCSV(qd){
1712
  let blob=new Blob([csv],{type:'text/csv;charset=utf-8'});
1713
  let url=URL.createObjectURL(blob);
1714
  let a=document.createElement('a');
1715
- a.href=url;a.download='BaoGia_'+(qd.customer.orderCode||'VAI_STUDIO')+'.csv';
1716
- a.click();setTimeout(function(){URL.revokeObjectURL(url);},60000);
1717
  showToast('Đã xuất file CSV (mở bằng Excel)!');
1718
  }
1719
  function openQuotation(){
@@ -2045,6 +2046,13 @@ function _vaiExcelParseExtras(){
2045
  txt.split(/[,;\n]+/).forEach(line=>{
2046
  line=(line||'').trim();if(!line)return;
2047
  let lo=line.toLowerCase().normalize('NFD').replace(/[\u0300-\u036f]/g,'').replace(/[đĐ]/g,'d');
 
 
 
 
 
 
 
2048
  let ck=lo.match(/^(ck|chiet khau|giam|discount)\s*([\d.,]+)\s*%?/);
2049
  if(ck){let v=parseFloat(ck[2].replace(/\./g,'').replace(',','.'));if(v>0&&v<=100)out.discountPercent=v;return;}
2050
  if(/coc|dat coc|deposit/.test(lo)){
@@ -2191,7 +2199,7 @@ try{
2191
  let buf=await wb.xlsx.writeBuffer();
2192
  let blob=new Blob([buf],{type:'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'});
2193
  let url=URL.createObjectURL(blob);
2194
- let a=document.createElement('a');a.href=url;a.download=(qd.customer.orderCode||'BG')+'.xlsx';a.click();setTimeout(function(){URL.revokeObjectURL(url);},60000);
2195
  showToast('Đã xuất file Excel số + công thức!');
2196
  }catch(e){
2197
  console.error('ExcelJS error:',e);
@@ -2653,8 +2661,8 @@ function exportDeliveryExcel(){
2653
  let blob = new Blob([csv],{type:'text/csv;charset=utf-8'});
2654
  let url = URL.createObjectURL(blob);
2655
  let a = document.createElement('a');
2656
- a.href = url; a.download = 'Giao_hang_VAI_STUDIO_'+today.replace(/\//g,'-')+'.csv';
2657
- a.click(); setTimeout(function(){URL.revokeObjectURL(url);},60000);
2658
  showToast('✅ Đã tải Excel giao hàng (CSV)!');
2659
  } catch(e){showToast('❌ Xuất Excel thất bại: '+e.message);}
2660
  }
 
1680
  let url=URL.createObjectURL(blob);
1681
  let a=document.createElement('a');
1682
  a.href=url;a.download='BaoGia_VAI_STUDIO_'+today.replace(/\//g,'-')+'.csv';
1683
+ window.open(url,'_blank');
1684
+ setTimeout(function(){URL.revokeObjectURL(url);},300000);
1685
  showToast('Đã tải báo giá Excel!');
1686
  }
1687
 
 
1713
  let blob=new Blob([csv],{type:'text/csv;charset=utf-8'});
1714
  let url=URL.createObjectURL(blob);
1715
  let a=document.createElement('a');
1716
+ window.open(url,'_blank');
1717
+ setTimeout(function(){URL.revokeObjectURL(url);},300000);
1718
  showToast('Đã xuất file CSV (mở bằng Excel)!');
1719
  }
1720
  function openQuotation(){
 
2046
  txt.split(/[,;\n]+/).forEach(line=>{
2047
  line=(line||'').trim();if(!line)return;
2048
  let lo=line.toLowerCase().normalize('NFD').replace(/[\u0300-\u036f]/g,'').replace(/[đĐ]/g,'d');
2049
+ // Brand-level CK: "Malloca CK 35%" - apply CK% globally for Excel formula
2050
+ let brandCkLine = lo.match(/^([a-z][a-z0-9\s\-]{0,30}?)\s+(ck|chiet khau|giam|discount)\s*([\d.,]+)\s*%?/);
2051
+ if(brandCkLine){
2052
+ let v=parseFloat(brandCkLine[3].replace(/\./g,'').replace(',','.'));
2053
+ if(v>0&&v<=100){out.discountPercent=v;out.brandCk=brandCkLine[1];return;}
2054
+ }
2055
+ // Global CK: "CK 35%" or "chiết khấu 30%"
2056
  let ck=lo.match(/^(ck|chiet khau|giam|discount)\s*([\d.,]+)\s*%?/);
2057
  if(ck){let v=parseFloat(ck[2].replace(/\./g,'').replace(',','.'));if(v>0&&v<=100)out.discountPercent=v;return;}
2058
  if(/coc|dat coc|deposit/.test(lo)){
 
2199
  let buf=await wb.xlsx.writeBuffer();
2200
  let blob=new Blob([buf],{type:'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'});
2201
  let url=URL.createObjectURL(blob);
2202
+ window.open(url,'_blank');setTimeout(function(){URL.revokeObjectURL(url);},300000);
2203
  showToast('Đã xuất file Excel số + công thức!');
2204
  }catch(e){
2205
  console.error('ExcelJS error:',e);
 
2661
  let blob = new Blob([csv],{type:'text/csv;charset=utf-8'});
2662
  let url = URL.createObjectURL(blob);
2663
  let a = document.createElement('a');
2664
+ window.open(url,'_blank');
2665
+ setTimeout(function(){URL.revokeObjectURL(url);},300000);
2666
  showToast('✅ Đã tải Excel giao hàng (CSV)!');
2667
  } catch(e){showToast('❌ Xuất Excel thất bại: '+e.message);}
2668
  }