第7项:按路由加载页面并核验登录和开单冷启动预算

This commit is contained in:
黄健铭 committed 2026-12-05 08:28:16 -08:00
1 parent f30905b236
commit 9367118e04
71 files changed
+1250 -454

No files matched your search

@@ -0,0 +1 @@
import{n as e}from"./rolldown-runtime-Dl_DZoUm.js";import{t}from"./receipt-BUADJAzs.js";import{i as n,n as r,r as i,t as a}from"./receipts-CjPRrg8S.js";import{c as o,l as s,p as c,s as l,tr as u,u as d,v as f}from"./index-D422TGjj.js";import{t as p}from"./settingsModel-DuLjBEgM.js";import{n as m,r as h}from"./materialQuote-B1yI_Tto.js";import{c as g,n as _,o as v,t as y}from"./shared-Da74NgmJ.js";import{a as b,i as x,n as S,o as C,r as w,s as T,t as E}from"./BusinessControls-B3wlV0Qu.js";import{a as D,d as O}from"./model-CDW0MnQe.js";var k=e(u(),1),A=f();function j(e){let t=e.lines?.[0];return!!t&&!(`line`in t)}function ee(e,t){let n=(t,n)=>h(t,n,v.memberKeys(e));function r(e,t){let n=t,r=[],i=[];if(!Array.isArray(e.materialSources)||e.materialSources.reduce((e,t)=>e+t.quantity,0)!==e.quantity||e.materialSources.reduce((e,t)=>e+t.amount,0)!==e.amount)throw Error(`原锁分来源克重或成本未完整读到,请重新读取。`);for(let t of e.materialSources){if(![`quantity`,`amount`,`basisAmount`,`basisMg`,`prefixMg`,`prefixAmount`].every(e=>Number.isSafeInteger(t[e])&&t[e]>=0)||!t.basisMg||!Array.isArray(t.allocations)||t.allocations.reduce((e,t)=>e+t.amount,0)!==t.amount)throw Error(`原锁分来源成本未完整读到,请重新读取。`);let e=Math.min(n,t.quantity);if(n-=e,!e){i.push({...t});continue}if(e===t.quantity){r.push({...t});continue}let a=y.poolMaterialAmount(t.basisAmount,t.basisMg,t.prefixMg+e)-t.prefixAmount,o=[],s=[],c=a;for(let e of t.allocations){let t=Math.min(c,e.amount);t&&o.push({...e,amount:t}),e.amount>t&&s.push({...e,amount:e.amount-t}),c-=t}if(c||a<0||a>t.amount)throw Error(`原锁分来源分币未完整读到,请重新读取。`);!a&&!o.length&&o.push({payer:t.allocations[0]?.payer||`owner`,amount:0});let l=[],u=[],d=e;for(let e of t.batches||[]){let t=Math.min(d,e.mg);t&&l.push({...e,mg:t}),e.mg>t&&u.push({...e,mg:e.mg-t}),d-=t}r.push({...t,quantity:e,amount:a,allocations:o,batches:l}),i.push({...t,quantity:t.quantity-e,amount:t.amount-a,allocations:s,batches:u,prefixMg:t.prefixMg+e,prefixAmount:t.prefixAmount+a})}if(n)throw Error(`实际耗料超过原锁来源克重。`);return{taken:r,rest:i}}function i(e){let t=String(e??``).trim();if(!/^\d+(?:\.\d{1,3})?$/.test(t))throw Error(`克重请填写正数,最多3位小数。`);let[n,r=``]=t.split(`.`),i=Number(n)*1e3+Number(r.padEnd(3,`0`));if(!Number.isSafeInteger(i)||i<=0)throw Error(`克重请填写大于0的有效数字。`);return i}function a(e,t,n){if(!U(e))return y.priceLockCost({lockedQuantity:K(e.locked_mg),quantity:t,buyRate:(Number(e.buy_rate)/100).toFixed(2),extraBuyRate:n});let a=e.materialPool,o=i(t),s=Math.min(o,e.locked_mg),c=Math.max(0,o-e.locked_mg),l=e.locked_mg-s;if(!a||typeof a.amount!=`number`||![`basisAmount`,`basisMg`,`prefixMg`,`prefixAmount`,`amount`].every(e=>typeof a[e]==`number`&&Number.isSafeInteger(a[e])&&a[e]>=0)||!a.basisMg)throw Error(`原锁料池成本来源未完整读到,请重新读取锁价单。`);let u=a.materialSources?r(a,s):null,d=u?u.taken.reduce((e,t)=>e+t.amount,0):y.poolMaterialAmount(a.basisAmount,a.basisMg,a.prefixMg+s)-a.prefixAmount,f=c?y.cents(n,`补重进货料价`):0;if(c&&!f)throw Error(`补重进货料价必须大于0。`);let p=c?Number((BigInt(c)*BigInt(f)+500n)/1000n):0,m=d,h=[];for(let t of u?u.taken.flatMap(e=>e.allocations):L(e)){let e=Math.min(m,t.amount);(e||!d&&!h.length)&&h.push({payer:t.payer,amount:e}),m-=e}if(m||d<0||d>a.amount)throw Error(`原锁料池成本分摊不完整,请重新读取锁价单。`);return{lockedMg:e.locked_mg,finalMg:o,originalUsedMg:s,extraMg:c,leftoverMg:l,originalPurchase:a.amount,originalUsedCost:d,extraCost:p,materialCost:d+p,leftoverCost:a.amount-d,allocations:h,...u?{materialSources:u.taken,leftoverMaterialSources:u.rest}:{}}}function o(e){let t=e.line,n=L(e)[0]?.payer||e.buy_payer||`owner`;return{...t,quantity:K(e.locked_mg),goldPrice:(e.sell_rate/100).toFixed(2),laborRate:(t.laborRate/100).toFixed(2),sale:(t.sale/100).toFixed(2),baseSale:((t.baseSale??t.sale)/100).toFixed(2),charges:(t.charges||[]).map(e=>({...e,amount:(e.amount/100).toFixed(2)})),payer:n,costParts:{material:(Number(e.material_amount)/100).toFixed(2),labor:``,accessories:`0`,other:`0`},costMaterial:{mode:`total`},costLabor:{mode:`total`},costPayers:{material:n,labor:`owner`}}}function s(e){return(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)(`div`,{className:`order-header`,children:[(0,A.jsx)(`div`,{className:`eyebrow`,children:`GOLD PRICE LOCK`}),(0,A.jsxs)(`h2`,{children:[e.customer,` · `,q(e).length,`件黄金锁价`]})]}),u(e),q(e).length===1?ee(e):``,(0,A.jsxs)(`p`,{className:`small muted`,children:[`预计报价 ¥`,G(e.estimated_total),`;交付时按最终克重、工费和附加项目重新结算,销售金价保持原锁价格。`]}),e.note?(0,A.jsx)(A.Fragment,{children:(0,A.jsx)(`p`,{children:e.note})}):``,e.status===`cancelled`?(0,A.jsx)(A.Fragment,{children:(0,A.jsxs)(`p`,{className:`note`,children:[`已作废 · `,e.cancelled_reaLine truncated