保存工作区合并前的本地开发现场 ledger-route-sizes-389952f
This commit is contained in:
1 parent
389952f31c
commit
9952128ba4
45 files changed
+356
-321
No files matched your search
@@ -0,0 +1 @@
|
||||
import{n as e}from"./rolldown-runtime-Dl_DZoUm.js";import{n as t,t as n,useRead as r}from"./OrdersPage-DMGBXOU2.js";import{i,t as a}from"./react-1o5M9n0k.js";import{o}from"./shared-DZLPF0cC.js";import{l as s,s as c}from"./index-D-ox0wtk.js";import{t as l}from"./useOrderForm-Boa1k5nR.js";import{i as u,n as d,r as f,t as p}from"./EditFields-DxbwVQgn.js";var m=e(i(),1),h=a();function g(e,t){let n;try{n=JSON.parse(localStorage.getItem(e))}catch{return null}return n?.id===t&&Number.isSafeInteger(n.revision)&&Array.isArray(n.inputs?.lines)?n:null}function _(e,t,n,r){if(e.eligible!==!0)throw Error(e.reason||`这张订单暂不能修改,请重新读取订单后核对。`);if(e.order?.id!==t||!Number.isSafeInteger(e.revision)||!Array.isArray(e.inputs?.lines)||!Array.isArray(e.inputs.fee_items))throw Error(`订单修改资料未完整返回,请重新读取。`);if(e.financialEditable&&e.order.price_lock_id){let t=e.priceLock,n=e.inputs.lines,r=n.length>1?t?.lines:[t],i=new Set;if(!t||t.id!==e.order.price_lock_id||!/^\d{4}-\d{2}-\d{2}$/.test(t.date)||typeof t.financeRequiresApproval!=`boolean`||!Array.isArray(r)||!n.length||r.length!==n.length)throw Error(`锁价日期与成本修改资料未完整返回,请重新读取。`);for(let[t,a]of n.entries()){let o=r[t],s=o?.lineId||o?.id,c=a.price_lock_material||n.length===1&&e.inputs.price_lock_material,l=a.price_lock_extra_material||n.length===1&&e.inputs.price_lock_extra_material;if(![`pool`,`manual`].includes(o?.materialSource)||!Number.isSafeInteger(o.extraMg)||o.extraMg<0||![`pool`,`manual`].includes(c?.source)||o.extraMg>0&&!l||n.length>1&&(!a.lineId||a.lineId!==s||i.has(s)))throw Error(`锁价日期与成本修改资料未完整返回,请重新读取。`);i.add(s)}}let i=n?.revision??e.revision,a=n?.inputs||e.inputs,o=e.order;return{...e,id:t,order:o,originalInputs:e.inputs,user:r.user.id,revision:i,priceLock:e.priceLock||null,sameDayDirectEdit:e.requiresApproval===!1,inputs:{...a,...e.inputs.price_lock_material?{price_lock_material:a.price_lock_material||e.inputs.price_lock_material}:{},...e.inputs.price_lock_extra_material?{price_lock_extra_material:a.price_lock_extra_material||e.inputs.price_lock_extra_material}:{},internal_note:a.internal_note??e.inputs.internal_note??``,id:t,revision:i,paper_number:o.paper_number||``,paper_date:o.paper_date||``,fee_auto_initialized:!0},reason:n?.reason||``,verified:!!n?.verified&&i===e.revision,conflicted:i!==e.revision}}function v({entry:e,read:t,disabled:n}){let r=e.latest?.order;return(0,h.jsxs)(`section`,{className:`panel`,id:`order-edit-conflict`,role:`status`,children:[(0,h.jsx)(`h2`,{children:`订单已有新记录,请先核对`}),(0,h.jsx)(`p`,{children:`你正在填写的内容已保留。核对下方当前订单与表单后,再决定继续使用哪份内容。`}),r?(0,h.jsxs)(`details`,{open:!0,children:[(0,h.jsx)(`summary`,{children:`当前已保存的订单`}),(0,h.jsxs)(`p`,{children:[r.date,` · `,r.customer||`未填客户称呼`,` · 开单人 `,r.salesperson,` · `,r.payment_account,` · 成交 `,o.orderAmount(r.total,r.rounding_mode)]}),(0,h.jsxs)(`table`,{children:[(0,h.jsx)(`thead`,{children:(0,h.jsx)(`tr`,{children:[`商品`,`克重/数量`,`成交金额`,`货品成本`].map(e=>(0,h.jsx)(`th`,{children:e},e))})}),(0,h.jsx)(`tbody`,{children:r.lines.map((e,t)=>(0,h.jsxs)(`tr`,{children:[(0,h.jsx)(`td`,{children:e.name}),(0,h.jsx)(`td`,{children:e.unit===`g`?o.grams(e.quantity)+`g`:e.quantity+`件`}),(0,h.jsxs)(`td`,{children:[`¥`,o.yuan(e.sale)]}),(0,h.jsx)(`td`,{children:e.cost==null?`待补`:`¥`+o.yuan(e.cost)})]},t))})]}),(0,h.jsxs)(`p`,{children:[`实际费用 ¥`,o.yuan(r.directCost),`;客户单备注:`,r.note||`无`]}),r.internal_note&&(0,h.jsxs)(`p`,{children:[`内部备注:`,r.internal_note]})]}):(0,h.jsx)(`p`,{children:`重新读取最新订单后,核对原记录再继续。`}),(0,h.jsxs)(`div`,{className:`actions`,children:[r?(0,h.jsx)(`button`,{disabled:n,"data-action":`keep-order-edit`,onClick:()=>t(`keep`),children:`已核对,保留草稿继续修改`}):(0,h.jsx)(`button`,{disabled:n,"data-action":`reload-order-edit`,onClick:()=>t(`review`),children:`读取最新订单供核对`}),(0,h.jsx)(`button`,{disabled:n,"data-action":`reset-order-edit`,onClick:()=>t(`reset`),children:`改用当前订单内容`})]})]})}function y({client:e,state:r,session:i,refreshState:a,registerLeaveGuard:o,LockEditor:l}){let u=`mm-order-edit-active-`+r.user.id,d=s(`order`)||s(`id`)||localStorage.getItem(u)||``,f=`mm-order-edit-`+r.user.id+`-`+d,[p,y]=(0,m.useState)(null),[x,S]=(0,m.useState)(0),[C,w]=(0,m.useState)(``),[T,E]=(0,m.useState)(!1),[D,O]=(0,m.useState)(!1),k=(0,m.useRef)(!1),A=(0,m.useRef)(0),j=(0,m.useCallback)((t,n,i)=>{k.current&&e.user===r.user.id&&(localStorage.setItem(f,JSON.stringify({id:d,revision:t.revision,inputs:t,reason:n,verified:i})),localStorage.setItem(u,d))},[d,f,u,e,r.user.id]),{checkFailure:M}=t({client:e,state:r,id:d,watch:!!p&&!D,onLost:t=>{k.current=!1,sessionLine truncated
|
||||
Reference in new issue
Block a user