Spaces:
Running
Running
Ensure full dimension info in web quote data
Browse files- index.html +4 -1
index.html
CHANGED
|
@@ -2335,6 +2335,9 @@ total+=lineTotal;
|
|
| 2335 |
document.getElementById('quoteTotalCell').textContent=total.toLocaleString('vi-VN')+'đ';
|
| 2336 |
}
|
| 2337 |
|
|
|
|
|
|
|
|
|
|
| 2338 |
function getQuoteData(){
|
| 2339 |
let customer={
|
| 2340 |
name:document.getElementById('qcName').value||'',
|
|
@@ -2351,7 +2354,7 @@ let noteInput=document.querySelector(`.qt-note[data-idx="${i}"]`);
|
|
| 2351 |
let discPrice=discInput?parseInt(discInput.value.replace(/\D/g,''))||0:c.priceNum;
|
| 2352 |
return{
|
| 2353 |
stt:i+1, name:c.name, model:product.model||product.sku||'',
|
| 2354 |
-
specs:
|
| 2355 |
image:c.image, qty:c.qty, price:c.priceNum, discPrice:discPrice,
|
| 2356 |
total:discPrice*c.qty, note:noteInput?noteInput.value:''
|
| 2357 |
};
|
|
|
|
| 2335 |
document.getElementById('quoteTotalCell').textContent=total.toLocaleString('vi-VN')+'đ';
|
| 2336 |
}
|
| 2337 |
|
| 2338 |
+
|
| 2339 |
+
function vaiQuoteDimKey(k,v){let t=nVN(String(k||'')+' '+String(v||''));return /kich thuoc|dimension|size|rong|ngang|dai|sau|cao|height|width|depth|cut.?out|cat da|lo da|lap noi|lap am|am ban|lot long|phu bi|khoang tu|mat canh|quy cach|r\s*[x=]|w\s*[x=]|d\s*[x=]|h\s*[x=]/.test(t)}
|
| 2340 |
+
function vaiQuoteDimSummary(specs,limit=900){let parts=[],seen=new Set();function add(k,v){if(!k||v==null||v==='')return;let t=String(k)+': '+String(v),key=nVN(t).replace(/[^a-z0-9]/g,'');if(seen.has(key))return;seen.add(key);parts.push(t)};if(specs&&typeof specs==='object'){let e=Object.entries(specs);e.filter(x=>vaiQuoteDimKey(x[0],x[1])).forEach(x=>add(x[0],x[1]));e.filter(x=>!vaiQuoteDimKey(x[0],x[1])).slice(0,8).forEach(x=>add(x[0],x[1]));}else if(specs){String(specs).split(/[;\n]+/).filter(Boolean).sort((a,b)=>(vaiQuoteDimKey(b,'')?1:0)-(vaiQuoteDimKey(a,'')?1:0)).forEach(x=>{let key=nVN(x).replace(/[^a-z0-9]/g,'');if(!seen.has(key)){seen.add(key);parts.push(x.trim())}})}return parts.join('; ').slice(0,limit)}
|
| 2341 |
function getQuoteData(){
|
| 2342 |
let customer={
|
| 2343 |
name:document.getElementById('qcName').value||'',
|
|
|
|
| 2354 |
let discPrice=discInput?parseInt(discInput.value.replace(/\D/g,''))||0:c.priceNum;
|
| 2355 |
return{
|
| 2356 |
stt:i+1, name:c.name, model:product.model||product.sku||'',
|
| 2357 |
+
specs:vaiQuoteDimSummary(product.specs||{},900)||(product.summary||product.desc||'').slice(0,900),
|
| 2358 |
image:c.image, qty:c.qty, price:c.priceNum, discPrice:discPrice,
|
| 2359 |
total:discPrice*c.qty, note:noteInput?noteInput.value:''
|
| 2360 |
};
|