第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,10 @@
import{n as e}from"./rolldown-runtime-Dl_DZoUm.js";import{$n as t,A as n,An as r,At as i,C as a,Ct as o,D as s,E as c,En as l,F as u,Ft as d,Jt as f,Kn as p,M as m,N as h,Nt as g,O as _,On as v,Ot as y,P as b,Pt as x,Qn as S,R as C,Rt as w,St as T,T as E,Vt as D,Wt as O,Xn as k,Xt as A,Yn as j,Zn as M,Zt as ee,_t as te,b as ne,c as re,cn as ie,ct as N,d as ae,en as oe,j as se,jt as ce,k as le,kt as ue,l as de,mn as fe,mt as pe,nn as me,nt as he,pn as ge,qn as P,s as _e,st as ve,tn as ye,tr as be,un as xe,ut as Se,v as Ce,w as we,wn as F,xt as Te,y as Ee,z as De}from"./index-D422TGjj.js";import{_ as Oe,f as ke,g as Ae,h as je,m as Me,v as Ne}from"./TextArea-C-bIgxlu.js";import{n as Pe,t as I}from"./typography-B7akXptf.js";import{a as Fe,i as Ie,n as Le,t as Re}from"./drafts-C19ceuCj.js";import{a as ze,o as L,r as Be,s as Ve}from"./shared-Da74NgmJ.js";import{n as R,t as He}from"./useOrderForm-Ca3k84Sl.js";import{i as Ue,n as We,r as Ge,t as Ke}from"./LockOutlined-B5mVtuYn.js";import{t as z}from"./input-CKrxaItg.js";import{i as qe,r as Je,t as Ye}from"./checkbox-C-coepK7.js";import{c as Xe,g as Ze,m as Qe}from"./useForm-gd33qHRf.js";import{n as $e,t as et}from"./card-C-8yMAVJ.js";import{n as tt,r as nt,t as rt}from"./format-u4LYCVYL.js";import{t as it}from"./ReloadOutlined-V5yvnLUz.js";import{t as at}from"./space-Ck2eJ_iJ.js";var B=e(t()),V=e(be()),ot=V.forwardRef(function(e,t){var n=e.prefixCls,r=e.forceRender,i=e.className,a=e.style,o=e.children,s=e.isActive,c=e.role,l=e.classNames,u=e.styles,d=V.useState(s||r),f=v(d,2),p=f[0],m=f[1];return V.useEffect(function(){(r||s)&&m(!0)},[r,s]),p?V.createElement(`div`,{ref:t,className:(0,B.default)(`${n}-content`,P(P({},`${n}-content-active`,s),`${n}-content-inactive`,!s),i),style:a,role:c},V.createElement(`div`,{className:(0,B.default)(`${n}-content-box`,l?.body),style:u?.body},o)):null});ot.displayName=`PanelContent`;var st=[`showArrow`,`headerClass`,`isActive`,`onItemClick`,`forceRender`,`className`,`classNames`,`styles`,`prefixCls`,`collapsible`,`accordion`,`panelKey`,`extra`,`header`,`expandIcon`,`openMotion`,`destroyInactivePanel`,`children`],ct=V.forwardRef(function(e,t){var n=e.showArrow,r=n===void 0||n,i=e.headerClass,a=e.isActive,o=e.onItemClick,s=e.forceRender,c=e.className,u=e.classNames,d=u===void 0?{}:u,f=e.styles,m=f===void 0?{}:f,h=e.prefixCls,g=e.collapsible,_=e.accordion,v=e.panelKey,b=e.extra,x=e.header,C=e.expandIcon,w=e.openMotion,T=e.destroyInactivePanel,E=e.children,O=l(e,st),k=g===`disabled`,A=b!=null&&typeof b!=`boolean`,j=P(P(P({onClick:function(){o?.(v)},onKeyDown:function(e){(e.key===`Enter`||e.keyCode===y.ENTER||e.which===y.ENTER)&&o?.(v)},role:_?`tab`:`button`},`aria-expanded`,a),`aria-disabled`,k),`tabIndex`,k?-1:0),M=typeof C==`function`?C(e):V.createElement(`i`,{className:`arrow`}),ee=M&&V.createElement(`div`,S({className:`${h}-expand-icon`},[`header`,`icon`].includes(g)?j:{}),M),te=(0,B.default)(`${h}-item`,P(P({},`${h}-item-active`,a),`${h}-item-disabled`,k),c),ne=(0,B.default)(i,`${h}-header`,P({},`${h}-collapsible-${g}`,!!g),d.header),re=p({className:ne,style:m.header},[`header`,`icon`].includes(g)?{}:j);return V.createElement(`div`,S({},O,{ref:t,className:te}),V.createElement(`div`,re,r&&ee,V.createElement(`span`,S({className:`${h}-header-text`},g===`header`?j:{}),x),A&&V.createElement(`div`,{className:`${h}-extra`},b)),V.createElement(D,S({visible:a,leavedClassName:`${h}-content-hidden`},w,{forceRender:s,removeOnLeave:T}),function(e,t){var n=e.className,r=e.style;return V.createElement(ot,{ref:t,prefixCls:h,className:n,classNames:d,style:r,styles:m,isActive:a,forceRender:s,role:_?`tabpanel`:void 0},E)}))}),lt=[`children`,`label`,`key`,`collapsible`,`onItemClick`,`destroyInactivePanel`],ut=function(e,t){var n=t.prefixCls,r=t.accordion,i=t.collapsible,a=t.destroyInactivePanel,o=t.onItemClick,s=t.activeKey,c=t.openMotion,u=t.expandIcon;return e.map(function(e,t){var d=e.children,f=e.label,p=e.key,m=e.collapsible,h=e.onItemClick,g=e.destroyInactivePanel,_=l(e,lt),v=String(p??t),y=m??i,b=g??a,x=function(e){y!==`disabled`&&(o(e),h?.(e))},C=!1;return C=r?s[0]===v:s.indexOf(v)>-1,V.createElement(ct,S({},_,{prefixCls:n,key:v,panelKey:v,isActive:C,accordion:r,openMotion:c,expandIcon:u,header:f,collapsible:y,onItemClick:x,destroyInactivePanel:b}),d)})},dt=function(e,t,n){if(!e)return null;var r=n.prefixCls,i=n.accordion,a=n.collapsible,o=n.destroyInactivePanel,s=n.onItemClick,c=n.activeKey,l=n.openMotion,u=n.expandIcon,d=e.key||String(t),f=e.props,p=f.header,m=f.headerClass,h=f.destroyInactivePanel,g=f.collapsible,_=f.onItemClick,v=!1;v=i?c[0]===d:c.indexOf(d)>-1;var y=g??a,b={key:d,panelKey:d,header:p,headerClass:m,isActive:v,prefixCls:r,destroyInactivePanel:h??o,openMotion:l,accordion:i,children:e.props.children,onItemClick:function(e){y!==`disabled`&&(s(e),_?.(e))},expandIcon:u,collapsible:y};return typeof e.type==`string`?e:(Object.keys(b).forEach(function(e){b[e]===void 0&&delete b[e]}),V.cloneElement(e,b))};function ft(e,t,n){return Line truncated
&,
& > ${t}-header`]:{borderRadius:`${F(c)} ${F(c)} 0 0`}},"&:last-child":{[`
&,
& > ${t}-header`]:{borderRadius:`0 0 ${F(c)} ${F(c)}`}},[`> ${t}-header`]:Object.assign(Object.assign({position:`relative`,display:`flex`,flexWrap:`nowrap`,alignItems:`flex-start`,padding:a,color:m,lineHeight:_,cursor:`pointer`,transition:`all ${C}, visibility 0s`},f(e)),{[`> ${t}-header-text`]:{flex:`auto`},[`${t}-expand-icon`]:{height:E,display:`flex`,alignItems:`center`,paddingInlineEnd:y},[`${t}-arrow`]:Object.assign(Object.assign({},ee()),{fontSize:w,transition:`transform ${C}`,svg:{transition:`transform ${C}`}}),[`${t}-header-text`]:{marginInlineEnd:`auto`}}),[`${t}-collapsible-header`]:{cursor:`default`,[`${t}-header-text`]:{flex:`none`,cursor:`pointer`},[`${t}-expand-icon`]:{cursor:`pointer`}},[`${t}-collapsible-icon`]:{cursor:`unset`,[`${t}-expand-icon`]:{cursor:`pointer`}}},[`${t}-content`]:{color:p,backgroundColor:n,borderTop:O,[`& > ${t}-content-box`]:{padding:T},"&-hidden":{display:`none`}},"&-small":{[`> ${t}-item`]:{[`> ${t}-header`]:{padding:o,paddingInlineStart:S,[`> ${t}-expand-icon`]:{marginInlineStart:e.calc(b).sub(S).equal()}},[`> ${t}-content > ${t}-content-box`]:{padding:b}}},"&-large":{[`> ${t}-item`]:{fontSize:g,lineHeight:v,[`> ${t}-header`]:{padding:s,paddingInlineStart:r,[`> ${t}-expand-icon`]:{height:D,marginInlineStart:e.calc(x).sub(r).equal()}},[`> ${t}-content > ${t}-content-box`]:{padding:x}}},[`${t}-item:last-child`]:{borderBottom:0,[`> ${t}-content`]:{borderRadius:`0 0 ${F(c)} ${F(c)}`}},[`& ${t}-item-disabled > ${t}-header`]:{"\n &,\n & > .arrow\n ":{color:h,cursor:`not-allowed`}},[`&${t}-icon-position-end`]:{[`& > ${t}-item`]:{[`> ${t}-header`]:{[`${t}-expand-icon`]:{order:1,paddingInlineEnd:0,paddingInlineStart:y}}}}})}},vt=e=>{let{componentCls:t}=e,n=`> ${t}-item > ${t}-header ${t}-arrow`;return{[`${t}-rtl`]:{[n]:{transform:`rotate(180deg)`}}}},yt=e=>{let{componentCls:t,headerBg:n,borderlessContentPadding:r,borderlessContentBg:i,colorBorder:a}=e;return{[`${t}-borderless`]:{backgroundColor:n,border:0,[`> ${t}-item`]:{borderBottom:`1px solid ${a}`},[`
> ${t}-item:last-child,
> ${t}-item:last-child ${t}-header
`]:{borderRadius:0},[`> ${t}-item:last-child`]:{borderBottom:0},[`> ${t}-item > ${t}-content`]:{backgroundColor:i,borderTop:0},[`> ${t}-item > ${t}-content > ${t}-content-box`]:{padding:r}}}},bt=e=>{let{componentCls:t,paddingSM:n}=e;return{[`${t}-ghost`]:{backgroundColor:`transparent`,border:0,[`> ${t}-item`]:{borderBottom:0,[`> ${t}-content`]:{backgroundColor:`transparent`,border:0,[`> ${t}-content-box`]:{paddingBlock:n}}}}}},xt=O(`Collapse`,e=>{let t=ye(e,{collapseHeaderPaddingSM:`${F(e.paddingXS)} ${F(e.paddingSM)}`,collapseHeaderPaddingLG:`${F(e.padding)} ${F(e.paddingLG)}`,collapsePanelBorderRadius:e.borderRadiusLG});return[_t(t),yt(t),bt(t),vt(t),Ze(t)]},e=>({headerPadding:`${e.paddingSM}px ${e.padding}px`,headerBg:e.colorFillAlter,contentPadding:`${e.padding}px 16px`,contentBg:e.colorBgContainer,borderlessContentPadding:`${e.paddingXXS}px 16px ${e.padding}px`,borderlessContentBg:`transparent`})),St=Object.assign(V.forwardRef((e,t)=>{let{getPrefixCls:n,direction:r,expandIcon:i,className:a,style:s}=xe(`collapse`),{prefixCls:c,className:l,rootClassName:u,style:d,bordered:f=!0,ghost:p,size:m,expandIconPosition:h=`start`,children:g,destroyInactivePanel:_,destroyOnHidden:v,expandIcon:y}=e,b=te(e=>m??e??`middle`),x=n(`collapse`,c),S=n(),[C,w,T]=xt(x),E=V.useMemo(()=>h===`left`?`start`:h===`right`?`end`:h,[h]),D=y??i,O=V.useCallback((e={})=>{let t=typeof D==`function`?D(e):V.createElement(qe,{rotate:e.isActive?r===`rtl`?-90:90:void 0,"aria-label":e.isActive?`expanded`:`collapsed`});return ce(t,()=>({className:(0,B.default)(t.props?.className,`${x}-arrow`)}))},[D,x,r]),A=(0,B.default)(`${x}-icon-position-${E}`,{[`${x}-borderless`]:!f,[`${x}-rtl`]:r===`rtl`,[`${x}-ghost`]:!!p,[`${x}-${b}`]:b!==`middle`},a,l,u,w,T),j=V.useMemo(()=>Object.assign(Object.assign({},o(S)),{motionAppear:!1,leavedClassName:`${x}-content-hidden`}),[S,x]),M=V.useMemo(()=>g?k(g).map((e,t)=>{let n=e.props;if(n?.disabled){let r=e.key??String(t),i=Object.assign(Object.assign({},Te(e.props,[`disabled`])),{key:r,collapsible:n.collapsible??`disabled`});return ce(e,i)}return e}):null,[g]);return C(V.createElement(ht,Object.assign({ref:t,openMotion:j},Te(e,[`rootClassName`]),{expandIcon:O,prefixCls:x,className:A,style:Object.assign(Object.assign({},s),d),destroyInactivePanel:v??_}),M))}),{Panel:gt}),Ct=e=>e?typeof e==`function`?e():e:null,wt=e=>{let{componentCls:t,popoverColor:n,titleMinWidth:r,fontWeightStrong:i,innerPadding:a,boxShadowSecondary:o,colorTextHeading:s,borderRadiusLG:c,zIndexPopup:l,titleMarginBottom:u,colorBgElevated:d,popoverBg:f,titleBorderBottom:p,innerContentPadding:m,titlePadding:h}=e;return[{[t]:Object.assign(Object.assign({},A(e)),{position:`absolute`,top:0,left:{_skip_check_:!0,value:0},zIndex:l,fontWeight:`normal`,whiteSpace:`normal`,textAlign:`start`,cursor:`auto`,userSelect:`text`,"--valid-offset-x":`var(--arrow-offset-horizontal, var(--arrow-x))`,transformOrigin:`var(--valid-offset-x, 50%) var(--arrow-y, 50%)`,"--antd-arrow-background-color":d,width:`max-content`,maxWidth:`100vw`,"&-rtl":{direction:`rtl`},"&-hidden":{display:`none`},[`${t}-content`]:{position:`relative`},[`${t}-inner`]:{backgroundColor:f,backgroundClip:`padding-box`,borderRadius:c,boxShadow:o,padding:a},[`${t}-title`]:{minWidth:r,marginBottom:u,color:s,fontWeight:i,borderBottom:p,padding:h},[`${t}-inner-content`]:{color:n,padding:m}})},je(e,`var(--antd-arrow-background-color)`),{[`${t}-pure`]:{position:`relative`,maxWidth:`none`,margin:e.sizePopupArrow,display:`inline-block`,[`${t}-content`]:{display:`inline-block`}}}]},Tt=e=>{let{componentCls:t}=e;return{[t]:oe.map(n=>{let r=e[`${n}6`];return{[`&${t}-${n}`]:{"--antd-arrow-background-color":r,[`${t}-inner`]:{backgroundColor:r},[`${t}-arrow`]:{background:`transparent`}}}})}},Et=O(`Popover`,e=>{let{colorBgElevated:t,colorText:n}=e,r=ye(e,{popoverBg:t,popoverColor:n});return[wt(r),Tt(r),Se(r,`zoom-big`)]},e=>{let{lineWidth:t,controlHeight:n,fontHeight:r,padding:i,wireframe:a,zIndexPopupBase:o,borderRadiusLG:s,marginXS:c,lineType:l,colorSplit:u,paddingSM:d}=e,f=n-r,p=f/2,m=f/2-t,h=i;return Object.assign(Object.assign(Object.assign({titleMinWidth:177,zIndexPopup:o+30},Ae(e)),Me({contentRadius:s,limitVerticalRadius:!0})),{innerPadding:a?0:12,titleMarginBottom:a?0:c,titlePadding:a?`${p}px ${h}px ${m}px`:0,titleBorderBottom:a?`${t}px ${l} ${u}`:`none`,innerContentPadding:a?`${d}px ${h}px`:0})},{resetStyle:!1,deprecatedTokens:[[`width`,`titleMinWidth`],[`minWidth`,`titleMinWidth`]]}),Dt=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols==`function`)for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n},Ot=({title:e,content:t,prefixCls:n})=>!e&&!t?null:V.createElement(V.Fragment,null,e&&V.createElement(`div`,{className:`${n}-title`},e),t&&V.createElement(`div`,{className:`${n}-inner-content`},t)), Line truncated
0.58×(822+45)+55=558
769+558=1327`,value:r,onChange:e=>a(e.target.value),onKeyDown:e=>{(e.metaKey||e.ctrlKey)&&e.key===`Enter`&&r.trim()&&(e.preventDefault(),c(!1))}}),(0,W.jsxs)(at,{wrap:!0,style:{marginTop:8},children:[(0,W.jsx)(N,{type:`primary`,onClick:()=>c(!1),children:`识别并预填`}),o?.kind===`warning`&&(0,W.jsx)(N,{onClick:()=>c(!0),children:`按计算金额预填`}),r&&(0,W.jsx)(N,{onClick:()=>{a(``),s(null)},children:`清空公式`})]}),(0,W.jsx)(`p`,{className:`small muted`,children:`括号内是克工费;金价乘克重后加的是一件工费,再加的金额记为附加费。合计行只校验,不增加商品。客户、货盘及内部成本仍按实际填写。`}),o&&(0,W.jsx)(i,{role:`status`,type:o.kind===`note`?`success`:o.kind,message:o.title||(o.kind===`error`?o.lines[0]:``),description:o.kind===`error`?void 0:(0,W.jsx)(`div`,{children:o.lines.filter(Boolean).map((e,t)=>(0,W.jsx)(`p`,{children:e},t))})})]})}function Dn({order:e,error:t,onRetry:n,onPreview:r,onNew:i}){let{message:o}=a.useApp(),[s,c]=(0,V.useState)(!1),l=e.total!==void 0;async function u(){if(e.paper_number)try{await navigator.clipboard.writeText(e.paper_number),c(!0),o.success(`已复制纸单号 `+e.paper_number),window.setTimeout(()=>c(!1),1800)}catch{c(!1),o.info(`请手动选择纸单号复制`)}}return(0,W.jsx)(`div`,{className:`issued-page`,children:(0,W.jsx)(et,{className:`issued-card`,children:(0,W.jsx)(Ee,{status:`success`,title:`销售单据已生成`,subTitle:l?e.materialCostPending?`收款、费用和出库已记账;料费待补,补足购料后自动核算利润。`:`收款、费用、出库和利润已记账。`:t||`正在读取已生成的销售单…`,extra:(0,W.jsxs)(at,{direction:`vertical`,size:`large`,style:{width:`100%`},children:[l&&(0,W.jsxs)(`dl`,{className:`issued-summary`,"data-testid":`issued-summary`,children:[(0,W.jsxs)(`div`,{className:`issued-item`,children:[(0,W.jsx)(`dt`,{children:(0,W.jsx)(I.Text,{type:`secondary`,children:`纸单号`})}),(0,W.jsxs)(`dd`,{className:`issued-value-row`,children:[(0,W.jsx)(`span`,{className:`issued-value num`,"data-testid":`issued-paper-number`,children:e.paper_number||`未分配`}),e.paper_number&&(0,W.jsx)(ke,{title:s?`已复制`:`复制纸单号`,children:(0,W.jsx)(N,{type:`text`,size:`small`,className:`issued-copy-btn`,"aria-label":`复制纸单号`,icon:s?(0,W.jsx)(Ne,{}):(0,W.jsx)(Pe,{}),onClick:()=>void u()})})]})]}),(0,W.jsxs)(`div`,{className:`issued-item`,children:[(0,W.jsx)(`dt`,{children:(0,W.jsx)(I.Text,{type:`secondary`,children:`成交合计`})}),(0,W.jsx)(`dd`,{className:`issued-value issued-total num`,"data-testid":`issued-total`,children:tt(e.total??null,e.rounding_mode||`cent`)})]}),e.customer&&(0,W.jsxs)(`div`,{className:`issued-item`,children:[(0,W.jsx)(`dt`,{children:(0,W.jsx)(I.Text,{type:`secondary`,children:`客户`})}),(0,W.jsx)(`dd`,{className:`issued-value small`,children:e.customer})]})]}),(0,W.jsxs)(`div`,{className:`issued-actions`,children:[(0,W.jsx)(N,{type:`primary`,size:`large`,icon:(0,W.jsx)($t,{}),href:`/print/`+encodeURIComponent(e.id)+`?mode=full`,onClick:()=>{r().catch(e=>o.error(e.message))},target:`_blank`,rel:`noopener`,"data-action":`print-preview`,children:`打开打印预览`}),(0,W.jsx)(N,{size:`large`,icon:(0,W.jsx)($e,{}),onClick:i,"data-action":`new-order`,children:`开始新的一单`}),!l&&(0,W.jsx)(N,{size:`large`,onClick:n,children:`重新读取订单`})]}),(0,W.jsx)(N,{href:ae(`orders`)+`?order=`+encodeURIComponent(e.id),onClick:t=>{t.metaKey||t.ctrlKey||t.shiftKey||t.altKey||(t.preventDefault(),re(`orders`,{search:`?order=`+encodeURIComponent(e.id)}))},type:`link`,icon:(0,W.jsx)(Ft,{}),children:`查看订单详情`})]})})})})}function On(e){let{client:t,state:n}=e,r=de(`draft`),[i,a]=(0,V.useState)(r?null:{draft:Ie(window.localStorage,n.user.id),note:``});return(0,V.useEffect)(()=>{if(!r)return;let e=!0;return(async()=>{try{if(n.user.role!==`owner`)throw Error(`已有草稿由店主继续填写并开单;无单号的新开单流程照常使用。`);let i=await t.api(`/api/orders/`+encodeURIComponent(r));if(i.status!==`draft`)throw Error(`这张订单不是未开单的旧草稿,请在订单页查看。`);e&&a({draft:L.draftInputs(i),note:`正在继续填写旧草稿,生成销售单据后完成记账。`})}catch(t){e&&a({draft:Ie(window.localStorage,n.user.id),note:`旧草稿未能打开:`+t.message})}})(),()=>{e=!1}},[t,r,n.user.id,n.user.role]),i?(0,W.jsx)(kn,{...e,initialDraft:i.draft,initialNote:i.note}):(0,W.jsx)(`div`,{className:`page-loading`,children:(0,W.jsx)(ne,{tip:`正在读取旧草稿…`,children:(0,W.jsx)(`div`,{style:{height:60}})})})}function kn({client:e,state:t,session:n,refreshState:r,onAccountChanged:o,onRecoverOther:s,initialDraft:c,initialNote:l}){let{message:u}=a.useApp();_e(e);let{store:d,update:f,reset:p,ctx:m,poolError:h,loadPools:g}=He({client:e,state:t,session:n,initialDraft:c}),{form:_,summary:v}=d,[y,b]=(0,V.useState)(``),[x,S]=(0,V.useState)(!1),[C,w]=(0,V.useState)(null), Line truncated