第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{At as t,ct as n,tr as r,v as i}from"./index-D422TGjj.js";import{t as a}from"./card-C-8yMAVJ.js";import{t as o}from"./input-CKrxaItg.js";import{t as s}from"./space-Ck2eJ_iJ.js";import{t as c}from"./typography-B7akXptf.js";import{t as l}from"./ReloadOutlined-V5yvnLUz.js";import{r as u}from"./format-u4LYCVYL.js";import{o as d}from"./shared-Da74NgmJ.js";var f=e(r(),1),p=e=>typeof e==`number`&&Number.isSafeInteger(e),m=e=>p(e)&&e>=0,h=e=>typeof e==`object`&&!!e;function g(e,t){return/^\d{4}-(0[1-9]|1[0-2])$/.test(e)&&e>=`2000-01`&&e<=t.slice(0,7)}function _(){throw Error(`月度利润未完整返回,请重新读取。`)}function v(e,t,n){if(!h(e)||e.basis!==`orderDate`||e.month!==t||e.from!==t+`-01`||typeof e.date!=`string`||!/^\d{4}-\d{2}-\d{2}$/.test(e.date)||!e.date.startsWith(t)||e.date<e.from||e.date>n.today||!Array.isArray(e.rows))return _();let r=new Date(e.date+`T12:00:00Z`);if(Number.isNaN(r.getTime())||r.toISOString().slice(0,10)!==e.date)return _();let i=new Set(d.memberKeys(n).filter(e=>e!==`owner`)),a=e.rows.map(e=>{if(!h(e))return _();let{member:t,name:n,recordCount:r,orderCount:a,afterSaleCount:o,draftCount:s,unknownCostCount:c,unknownProfitCount:l,sales:u,knownTotalCost:d,knownProfit:f,profit:g,incomplete:v,shareRate:y,estimatedShare:b}=e;if(typeof t!=`string`||!i.delete(t)||typeof n!=`string`||!n||!m(r)||!m(a)||!m(o)||!m(s)||!m(c)||!m(l)||r!==a+o||!p(u)||!p(d)||!p(f)||typeof v!=`boolean`||!p(y)||y<0||y>100)return _();if(g===null){if(!v||b!==null)return _()}else{if(g!==f||v||!p(b))return _();let e=(BigInt(Math.abs(f))*BigInt(y)+50n)/100n;if(b!==Number(f<0?-e:e))return _()}return{member:t,profit:g,knownProfit:f,unknownProfitCount:l,shareRate:y,estimatedShare:b}});return i.size?_():{from:e.from,date:e.date,rows:a}}var y=i(),b=new WeakMap;function x({client:e,state:n}){return n.user.role===`owner`?(0,y.jsx)(S,{client:e,state:n},n.user.id):(0,y.jsx)(t,{type:`error`,showIcon:!0,message:`团队账目仅店主账号可查看。`})}function S({client:e,state:r}){let[i,p]=(0,f.useState)(()=>{let t=b.get(e);return{month:t?.user===r.user.id?t.month:r.today.slice(0,7)}}),[m,h]=(0,f.useState)(i.month),[_,x]=(0,f.useState)(null);(0,f.useEffect)(()=>{let t=!0;async function n(){try{if(!g(i.month,r.today))throw Error(`请选择2000年1月至本月之间的有效月份。`);let n=await e.api(`/api/team-profits?`+new URLSearchParams({month:i.month}));t&&x({request:i,report:v(n,i.month,r)})}catch(e){let n=e;t&&x({request:i,error:n.name===`AbortError`?`读取超时,请重试。`:n.message})}}return n(),()=>{t=!1}},[e,i,r]);let S=()=>p({month:i.month}),C=_&&`report`in _?_.report:null;return(0,y.jsxs)(`div`,{className:`team-profits-page`,children:[(0,y.jsxs)(`div`,{className:`page-heading`,children:[(0,y.jsxs)(`div`,{children:[(0,y.jsx)(`div`,{className:`eyebrow`,children:`TEAM PROFITS`}),(0,y.jsx)(c.Title,{level:1,children:`团队账目`}),(0,y.jsx)(c.Paragraph,{type:`secondary`,children:`按月核对助理净利润与预计分成。`})]}),(0,y.jsx)(n,{icon:(0,y.jsx)(l,{"aria-hidden":`true`}),"data-action":`team-funds-refresh`,onClick:S,children:`刷新`})]}),(0,y.jsx)(a,{className:`panel`,children:(0,y.jsx)(`form`,{id:`team-funds-filter`,onSubmit:t=>{t.preventDefault(),b.set(e,{user:r.user.id,month:m}),p({month:m})},children:(0,y.jsxs)(s,{align:`end`,wrap:!0,children:[(0,y.jsxs)(`label`,{className:`team-month-field`,children:[`月份`,(0,y.jsx)(o,{type:`month`,name:`month`,value:m,required:!0,min:`2000-01`,max:r.today.slice(0,7),onChange:e=>h(e.target.value)})]}),(0,y.jsx)(n,{type:`primary`,htmlType:`submit`,autoInsertSpace:!1,children:`查询`})]})})}),(0,y.jsx)(c.Paragraph,{type:`secondary`,children:`订单按开单日期、售后按记录日期计入;锁价单交付后计入利润。本月统计截至今天,成本或费用未补齐时显示待核算。`}),(0,y.jsxs)(`div`,{id:`team-funds-content`,"aria-live":`polite`,"aria-busy":_?.request!==i,children:[!_&&(0,y.jsx)(`p`,{children:`正在读取月度利润…`}),_&&`error`in _&&(0,y.jsx)(t,{type:`error`,showIcon:!0,message:_.error,action:(0,y.jsx)(n,{size:`small`,"data-action":`team-funds-refresh`,onClick:S,children:`重新读取`})}),C&&(0,y.jsxs)(a,{className:`panel`,title:(0,y.jsx)(`h2`,{children:`助理月度利润`}),extra:(0,y.jsxs)(`span`,{className:`muted`,children:[C.from,` 至 `,C.date]}),children:[(0,y.jsx)(`div`,{className:`team-profit-table`,children:(0,y.jsxs)(`table`,{children:[(0,y.jsx)(`thead`,{children:(0,y.jsxs)(`tr`,{children:[(0,y.jsx)(`th`,{scope:`col`,children:`成员`}),(0,y.jsx)(`th`,{scope:`col`,children:`月度净利润`}),(0,y.jsx)(`th`,{scope:`col`,children:`分成比例`}),(0,y.jsx)(`th`,{scope:`col`,children:`预计分成`})]})}),(0,y.jsx)(`tbody`,{children:C.rows.map(e=>(0,y.jsxs)(`tr`,{children:[(0,y.jsx)(`td`,{children:(0,y.jsx)(`strong`,{children:d.memberName(r,e.member)})}),(0,y.jsx)(`td`,{children:e.profit===null?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(`stro Line truncated