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