保存工作区合并前的本地开发现场 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{S as r,o as i,z as a}from"./index-D-ox0wtk.js";import{y as o}from"./skeleton-B4Z0R3jQ.js";import{i as s}from"./style-CBKkTdLU.js";import{t as c}from"./typography-xRg_3Gco.js";import{o as l}from"./shared-DZLPF0cC.js";var u=e(t(),1),d=`/api/private-operations/people`,f=e=>e===null?`未记录`:e.toLocaleString(`zh-CN`);function p(e){let[t,n]=(0,u.useState)(null);return(0,u.useEffect)(()=>{let t=!0;return e().then(r=>{t&&n({read:e,result:{data:r}})},r=>{t&&n({read:e,result:{error:r.message}})}),()=>{t=!1}},[e]),t?.read===e?t.result:null}var m=n();function h({client:e,state:t,members:n,initial:r,close:i,saved:s,recover:c}){let[f,h]=(0,u.useState)(r),g=(0,u.useRef)(null);(0,u.useLayoutEffect)(()=>{let e=g.current;return e.showModal(),()=>{e.close()}},[]);let _=t.user.role===`owner`,v=p((0,u.useCallback)(async()=>{let t=await e.api(d+`?`+new URLSearchParams({member:f.member,date:f.date}));if(t.member!==f.member||t.date!==f.date||!Number.isSafeInteger(t.revision))throw Error(`记录未完整返回`);return t},[e,f])),[y,b]=(0,u.useState)(null),[x,S]=(0,u.useState)(null),C=v&&`data`in v?v.data:null,w=y?.value??String(C?.total_count??``);function T(e){h(e),b(null),S(null)}function E(){T({...f})}async function D(t){if(t.preventDefault(),C){S(null);try{await e.mutate(d,{date:C.date,member:C.member,total_count:w,revision:C.revision}),s()}catch(e){S(e)}}}return(0,m.jsxs)(`dialog`,{ref:g,"aria-labelledby":`private-people-title`,className:`private-people-modal`,id:`private-people-dialog`,onCancel:t=>{t.preventDefault(),e.busy||i()},children:[(0,m.jsxs)(`div`,{className:`ops-heading`,children:[(0,m.jsx)(`h2`,{id:`private-people-title`,children:`记录人数`}),(0,m.jsx)(o,{"aria-label":`关闭`,"data-action":`private-people-close`,disabled:e.busy,onClick:i,children:`×`})]}),(0,m.jsxs)(`form`,{id:`private-people-form`,className:`ops-form`,onSubmit:D,children:[(0,m.jsxs)(`div`,{className:`ops-fields`,children:[(0,m.jsxs)(`label`,{children:[`日期`,(0,m.jsx)(`input`,{type:`date`,name:`date`,required:!0,max:t.today,value:f.date,onChange:e=>T({...f,date:e.target.value})})]}),_?(0,m.jsxs)(`label`,{children:[`员工`,(0,m.jsx)(`select`,{name:`member`,value:f.member,onChange:e=>T({...f,member:e.target.value}),children:n.map(e=>(0,m.jsxs)(`option`,{value:e.member,children:[e.label,e.enabled===!1&&`(已停用)`]},e.member))})]}):(0,m.jsxs)(`div`,{children:[(0,m.jsx)(`span`,{className:`muted`,children:`员工`}),(0,m.jsx)(`p`,{children:l.memberName(t,f.member)}),(0,m.jsx)(`input`,{type:`hidden`,name:`member`,value:f.member})]})]}),(0,m.jsxs)(`div`,{id:`private-people-fields`,children:[!v&&(0,m.jsx)(`p`,{className:`muted`,children:`正在读取记录…`}),v&&`error`in v&&(0,m.jsx)(a,{type:`error`,showIcon:!0,message:v.error,action:(0,m.jsx)(o,{"data-action":`private-people-retry`,onClick:E,children:`重新读取`})}),C&&(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(`p`,{className:`muted`,children:C.previous?`上次记录:`+C.previous.date+`,总人数 `+C.previous.total+`。`:`还没有更早的总人数记录,本次可作为基准。`}),(0,m.jsxs)(`div`,{className:`ops-fields`,children:[(0,m.jsxs)(`label`,{children:[`当天总人数(必填)`,(0,m.jsx)(`input`,{type:`number`,name:`total_count`,required:!0,min:`0`,max:`1000000`,step:`1`,inputMode:`numeric`,placeholder:`填写微信总人数`,value:w,onChange:e=>b({value:e.target.value,valid:e.target.validity.valid})})]}),(0,m.jsxs)(`div`,{children:[(0,m.jsx)(`span`,{className:`muted`,children:`今日新增人数(自动计算)`}),(0,m.jsx)(`p`,{id:`private-people-delta`,"aria-live":`polite`,children:C.previous?w?y?.valid===!1?`请填写有效的总人数`:Number(w)-C.previous.total+` 人`:`填写总人数后自动计算`:`首次记录,作为基准`})]})]}),(0,m.jsx)(`p`,{className:`muted`,children:`前一天没记录时,对比上一次有记录的日期。首次登记作为基准;补记或修改历史总人数后,后续增量会自动重算。人数减少时如实显示负数。`}),(0,m.jsxs)(`div`,{className:`ops-actions`,children:[(0,m.jsx)(o,{"data-action":`private-people-close`,disabled:e.busy,onClick:i,children:`取消`}),(0,m.jsx)(o,{type:`primary`,htmlType:`submit`,disabled:e.busy,children:`保存人数`})]})]})]}),(0,m.jsxs)(`div`,{"aria-live":`polite`,id:`private-people-error`,children:[x&&(0,m.jsx)(a,{type:`error`,showIcon:!0,message:x.message,action:x.status===409&&(0,m.jsx)(o,{"data-action":`private-people-retry`,onClick:E,children:`重新读取后核对`})}),e.pending()?.url===`/api/private-operations/people`&&!e.busy&&(0,m.jsx)(o,{"data-action":`retry`,onClick:()=>void c(),children:`恢复原操作`})]})]})]})}function g({data:e,open:t}){let n=e.rows.filter(e=>e.total!==null),r=new Set(n.map(e=>e.member)),i=e.members.filter(e=>r.has(e.member)),a=[...new Set(n.map(e=>e.date))].sort(),s=new Map(n.map(e=>[e.date+`|`+e.member,e]));return(0,m.jsxs)(mLine truncated
|
||||
Reference in new issue
Block a user