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

This commit is contained in:
黄健铭 committed 2026-12-05 08:25:22 -08:00
1 parent c6ad648d7e
commit f9cd68c569
71 files changed
+1250 -454

No files matched your search

+1
View File
@@ -0,0 +1 @@
import{n as e}from"./rolldown-runtime-Dl_DZoUm.js";import{s as t,tr as n,v as r}from"./index-D422TGjj.js";import{i,n as a,r as o,t as s}from"./controls-B86-JfYz.js";import{i as c,n as l,r as u,t as d}from"./settingsModel-DuLjBEgM.js";import{i as f,t as p}from"./shared-Da74NgmJ.js";import{i as m,n as h,o as g,t as _}from"./BusinessControls-B3wlV0Qu.js";var v=e(n(),1),y=r();function b(e){let{name:t,amount:n,payer:r,enabled:i,byQuantity:a}=c(e);return{name:t,amount:n,payer:r,enabled:i===`true`,byQuantity:a===`true`}}function x({shop:e,client:t,members:n,team:r,busy:c,onBusy:l,dirty:g,onDirty:x,onSaved:S,notice:C}){let w=f.presetCatalog(e.costPresets),[T,E]=(0,v.useState)(``),[D,O]=(0,v.useState)(null),[k,A]=(0,v.useState)(!1),[j,M]=(0,v.useState)(``);function N(){k||g&&!window.confirm(`成本修改尚未保存,放弃修改?`)||(O(null),x(!1),M(``))}function P(n,r=``){if(c||t.busy||t.pending())return;let i=w[r]||{name:``,amount:`0`,payer:`order`,enabled:!0,byQuantity:!1};O({action:n,kind:r||`custom_`+crypto.randomUUID(),original:i,revision:e.revision}),x(!1),M(``)}async function F(e){if(e.preventDefault(),!D||k)return;let n=!1;try{if(c||t.busy||t.pending())throw Error(`请先确认当前操作,再保存成本`);let r=D.action===`delete`?null:b(e.currentTarget);if(r){if(r.name=r.name.trim(),!r.name||r.name.length>40)throw Error(`成本名称请填写1~40字`);if(p.cents(r.amount,`成本`)>1e8)throw Error(`成本最多1000000元`)}A(!0),l(!0),M(``);let i=await t.mutate(`/api/shop-settings`,{revision:D.revision,costPresets:{[D.kind]:r}});n=!0,O(null),x(!1),await S(i.shopSettings),C(D.action===`delete`?`成本项目已删除`:`成本项目已保存`)}catch(e){let t=n?`成本已经保存,请刷新页面核对`:d(e);M(t),C(t,!0)}finally{A(!1),l(!1)}}let I=Object.entries(w).filter(([,e])=>e.name.toLocaleLowerCase().includes(T.trim().toLocaleLowerCase()));return(0,y.jsxs)(`section`,{id:`shop-cost-manager`,className:`shop-cost-manager`,children:[(0,y.jsxs)(`div`,{className:`panel-title`,children:[(0,y.jsxs)(`div`,{children:[(0,y.jsx)(`h3`,{children:`勾选成本管理`}),(0,y.jsx)(`p`,{className:`small muted`,children:`自行添加需要的项目。删除后不再用于新单,历史订单成本保留。`})]}),(0,y.jsx)(s,{action:`shop-cost-add`,className:`primary`,onClick:()=>P(`add`),children:`+ 新增成本`})]}),(0,y.jsxs)(`label`,{className:`shop-cost-search`,children:[`搜索成本`,(0,y.jsx)(m,{type:`search`,id:`shop-cost-search`,placeholder:`输入成本名称`,autoComplete:`off`,value:T,onChange:e=>E(e.target.value)})]}),(0,y.jsx)(`div`,{id:`shop-cost-list`,children:I.length?(0,y.jsx)(`div`,{className:`table-wrap`,children:(0,y.jsx)(h,{className:`shop-cost-table`,columns:[{title:`成本名称`},{title:`金额/单价`},{title:`付款人`},{title:`计费方式`},{title:`状态`},{title:`操作`}],rows:I.map(([e,t])=>({key:e,attributes:{"data-cost-row":e},cells:[(0,y.jsx)(y.Fragment,{children:(0,y.jsx)(`strong`,{children:t.name})}),(0,y.jsxs)(y.Fragment,{children:[`¥`,t.amount]}),t.payer===`order`?`订单归属人`:n.find(e=>e.member===t.payer)?.label||`待确认`,t.byQuantity?`单价 × 数量`:`每单一次`,t.enabled?`启用`:`停用`,(0,y.jsx)(y.Fragment,{children:(0,y.jsxs)(`div`,{className:`actions`,children:[(0,y.jsx)(s,{action:`shop-cost-edit`,className:`quiet`,"data-kind":e,onClick:()=>P(`edit`,e),children:`编辑`}),(0,y.jsx)(s,{action:`shop-cost-delete`,className:`danger`,"data-kind":e,onClick:()=>P(`delete`,e),children:`删除`})]})})]}))})}):(0,y.jsx)(`p`,{className:`empty`,children:Object.keys(w).length?`没有匹配的成本项目。`:`还没有勾选成本,点击“新增成本”添加。`})}),D&&(0,y.jsxs)(o,{id:`shop-cost-dialog`,close:N,children:[(0,y.jsx)(s,{className:`dialog-close`,action:`shop-cost-close`,"aria-label":`关闭成本编辑`,onClick:N,children:`×`}),(0,y.jsx)(`h2`,{children:{add:`新增成本`,delete:`删除成本`,edit:`编辑成本`}[D.action]}),(0,y.jsxs)(`form`,{id:`shop-cost-form`,onSubmit:F,onChange:e=>{let t=b(e.currentTarget);x(Object.keys(t).some(e=>t[e]!==D.original[e]))},children:[D.action===`delete`?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsxs)(`p`,{children:[`删除“`,(0,y.jsx)(`strong`,{children:D.original.name}),`”?`]}),(0,y.jsx)(`p`,{className:`muted`,children:`删除后不会再出现在新单勾选项里,已开订单、成本和流水保留。`})]}):(0,y.jsxs)(`div`,{className:`grid two`,children:[(0,y.jsx)(i,{label:`成本名称`,name:`name`,defaultValue:D.original.name,required:!0,maxLength:40,disabled:k}),(0,y.jsx)(i,{label:`金额/单价(元)`,name:`amount`,type:`number`,defaultValue:D.original.amount,required:!0,min:0,max:1e6,step:`0.01`,disabled:k}),(0,y.jsx)(a,{label:`付款人`,name:`payer`,defaultValue:D.original.payer,options:[[`order`,`订单归属人`],...u(n,D.original.payer,r)],disabled:k}),(0,y.jsx)(a,{label:`计费方式`,name:`byQuantity`,defaultValue:String(D.original.byQuantity),options:[[`false`,`每单一次 Line truncated