PageSourceSearch

https://nekowa.com/assets/LaborReceiptFormPage-Du629b9-.js

js nekowa.com collected 2026-10-02 01:37:32 UTC 34,903 bytes, 1 lines download raw bytes

1import{S as Re,G as W,bL as Te,F as Pe,H as De,E as Ue,bM as _e,bN as Be,V as _,bI as X,bO as Le,j as e,T as Me,d as he,i as pe,bo as Oe,e as He,bP as ze}from"./index-BqXoy4fy.js";import{r as d,u as Ge,c as qe}from"./react-DBTFCQ9V.js";import{l as ge,m as E,E as I,t as M,j as fe,s as Ye}from"./firebase-DUmv6NEE.js";import{I as Xe,P as Ve,B as We,a as Je,v as Ke,g as Qe}from"./BankAccountInput-nfuoivLb.js";import{C as Ze}from"./CreditBalanceBadge-D75EsrmY.js";import{S as er}from"./CreditConfirmDialogs-BgQug1vB.js";import{I as V}from"./ImagePreview-COtiKfH5.js";import{a as rr}from"./format-CdRYU-v6.js";import{w as tr,o as sr,F as ar,j as nr,f as ve,am as O,bj as lr,S as ir,bk as or,a as cr,q as je,N as dr,aG as mr}from"./utils-DRBGurlB.js";import"./index-8JwjhRSi.js";const F=317,xr=4,ur=[48271,81371,57349,69403];function br(x,s){let i=x*s>>>0;return i=(i>>>16^i)>>>0,i=i*73244475>>>0,i=(i>>>16^i)>>>0,(i%F+F)%F}function hr(x){if(x<0||x>99999)throw new Error(`feistelEncrypt: input ${x} out of range [0, 99999]`);let s=x;do{let i=Math.floor(s/F),g=s%F;for(let h=0;h<xr;h++){const t=g,y=(i+br(g,ur[h]))%F;i=t,g=y}s=i*F+g}while(s>=1e5);return s}const pr=(x,s,i=!1)=>{let g;if(s==="50")g=x>=Re?Math.round(x*W[s]):0;else{const y=x*W[s];g=y>Te?Math.round(y):0}let h=0;i||(h=x>=(s==="50"?De:Ue)?Math.round(x*Pe):0);const t=x-g-h;return{withholdingTax:g,healthInsurance:h,netAmount:t}},gr=[{value:"本國籍(台灣)",label:"本國籍(台灣)"},{value:"外籍(居留滿183天)",label:"外籍(居留滿183天)"},{value:"外籍(居留未滿183天)",label:"外籍(居留未滿183天)"}],fr=[{value:"transfer",label:"匯款"},{value:"cash",label:"現金"}],Ne=x=>{const s={...x};return Object.keys(s).forEach(i=>{s[i]===void 0&&delete s[i]}),s},ye=async x=>{const s=He(),i=ze(x),h=new Date().toISOString().slice(2,7).replace("-",""),t=await Ye(s,async w=>{const B=await w.get(i),S=(B.exists()?B.data().count:0)+1;return w.set(i,{count:S,lastUpdated:I()},{merge:!0}),S}),y=hr(t%1e5),f=String(y).padStart(5,"0");return`NKL${h}${f}`},$r=({mode:x="create"})=>{var xe,ue;const s=d.useId(),i=Ge(),{id:g}=qe(),h=x==="edit"&&!!g,[t,y]=d.useState(_e),[f,w]=d.useState(Be),[B,J]=d.useState(h),[S,K]=d.useState(!1),[H,Q]=d.useState(!1),[z,v]=d.useState(null),[u,Z]=d.useState({}),[R,ee]=d.useState(null),[T,re]=d.useState(null),[P,te]=d.useState(null),[vr,A]=d.useState(!1),[se,ae]=d.useState(""),[ne,le]=d.useState(""),[ie,oe]=d.useState(""),[ke,G]=d.useState(!1),[q,we]=d.useState(!1),[j,ce]=d.useState(!1);d.useEffect(()=>{h&&g&&Ce(g)},[h,g]),d.useEffect(()=>{Ee()},[]);const Ce=async r=>{try{const a=_();if(!a)throw new Error("Company ID not set");const n=X(a),l=await ge(E(n,r));if(l.exists()){const c=l.data();if(["sending","send_failed","pending","completed","voided","signed"].includes(c.status)){v({type:"error",message:"此勞報單狀態不允許編輯"}),i(`/labor-receipts/${r}`);return}y({...c,id:l.id}),c.fieldConfig&&(w(c.fieldConfig),ce(!0))}else v({type:"error",message:"找不到此勞報單"}),i("/labor-receipts")}catch(a){console.error("Error loading receipt:",a),v({type:"error",message:"載入失敗"})}finally{J(!1)}},Ee=async()=>{try{const r=_();if(!r)return;const a=Le(r),n=await ge(a);n.exists()&&w(n.data())}catch(r){console.error("Error loading field config:",r)}},o=d.useCallback((r,a)=>{y(n=>{const l={...n,[r]:a};if(r==="paymentAmount"||r==="incomeType"||r==="hasSecondGenHealthInsurance"){const c=r==="paymentAmount"?a:n.paymentAmount||0,b=r==="incomeType"?a:n.incomeType||"50",p=r==="hasSecondGenHealthInsurance"?a:n.hasSecondGenHealthInsurance||!1,{withholdingTax:m,healthInsurance:k,netAmount:N}=pr(c,b,p);l.withholdingTax=m,l.healthInsurance=k,l.netAmount=N}return l}),u[r]&&Z(n=>{const l={...n};return delete l[r],l})},[u]),Y=(r,a,n,l)=>{if(a(r),r){const c=new FileReader;c.onloadend=()=>{n(c.result)},c.readAsDataURL(r)}else n(""),o(l,"")},de=(r,a)=>{w(n=>({...n,fields:{...n.fields,[r]:{...n.fields[r],enabled:a}}}))},Ie=(r,a,n)=>{w(l=>({...l,fields:{...l.fields,[r]:{...l.fields[r],[a]:n}}}))},Fe=()=>{var a,n,l,c,b,p,m,k,N,D,$;const r={};return(a=t.signerEmail)!=null&&a.trim()?/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t.signerEmail)||(r.signerEmail="請輸入有效的電子郵件格式"):r.signerEmail="請輸入電子郵件",(n=t.serviceDescription)!=null&&n.trim()||(r.serviceDescription="請輸入勞務內容"),t.servicePeriodStart||(r.servicePeriodStart="請選擇勞務期間起始日"),t.servicePeriodEnd||(r.servicePeriodEnd="請選擇勞務期間結束日"),(!t.paymentAmount||t.paymentAmount<=0)&&(r.paymentAmount="請輸入付款金額"),t.paymentDate||(r.paymentDate="請選擇付款日期"),t.fillingMode==="company_fill"&&((l=t.signerName)!=null&&l.trim()||(r.signerName="請輸入姓名"),(c=t.signerIdNumber)!=null&&c.trim()?
1Ke(t.signerIdNumber,"taiwan")||(r.signerIdNumber=Qe("taiwan")):r.signerIdNumber="請輸入身分證字號",(b=t.signerPhone)!=null&&b.trim()||(r.signerPhone="請輸入聯絡電話"),(p=t.signerAddress)!=null&&p.trim()||(r.signerAddress="請輸入現居地址"),(m=t.signerRegAddress)!=null&&m.trim()||(r.signerRegAddress="請輸入戶籍地址"),t.paymentMethod!=="cash"&&((k=t.bankCode)!=null&&k.trim()||(r.bankCode="請選擇銀行"),(N=t.bankAccountNumber)!=null&&N.trim()||(r.bankAccountNumber="請輸入銀行帳號"),(D=t.bankAccountName)!=null&&D.trim()||(r.bankAccountName="請輸入戶名"),(!j||f.fields.payment.bankBranch!==!1)&&!(($=t.bankBranch)!=null&&$.trim())&&(r.bankBranch="請選擇分行"),(!j||f.fields.bankbook.enabled)&&!P&&!t.bankbookUrl&&(r.bankbook="請上傳存摺封面")),(!j||f.fields.idPhotos.enabled)&&(!R&&!t.idFrontUrl&&(r.idFront="請上傳身分證正面"),!T&&!t.idBackUrl&&(r.idBack="請上傳身分證反面"))),Z(r),Object.keys(r).length===0},me=async r=>{const a=pe(),n=_(),l={},c=fe(a,"uploadLaborReceiptImage"),b=async(m,k)=>{const N=new FileReader,D=new Promise((U,be)=>{N.onload=()=>{const $e=N.result.split(",")[1];U($e)},N.onerror=()=>be(new Error("Failed to read file"))});N.readAsDataURL(m);const $=await D,C=await c({companyId:n,receiptId:r,imageType:k,imageData:$});if(!C.data.success||!C.data.url)throw new Error(C.data.error||"上傳失敗");return C.data.url},p=[];return R&&p.push(b(R,"id_front").then(m=>{l.idFrontUrl=m})),T&&p.push(b(T,"id_back").then(m=>{l.idBackUrl=m})),P&&p.push(b(P,"bankbook").then(m=>{l.bankbookUrl=m})),await Promise.all(p),l},Se=async()=>{K(!0);try{const r=_();if(!r)throw new Error("Company ID not set");const n=he().currentUser;if(!n)throw new Error("User not authenticated");const l=X(r);let c=t.id,b=t.serialNumber;h||(b=await ye(r),c=E(l).id);const p={...t,serialNumber:b,status:"draft",fieldConfig:j?f:void 0,updatedAt:I()};h||(p.createdBy=n.uid,p.createdAt=I()),await M(E(l,c),Ne(p),{merge:!0});let m={};(R||T||P)&&(A(!0),m=await me(c),A(!1),Object.keys(m).length>0&&await M(E(l,c),{...m,updatedAt:I()},{merge:!0})),v({type:"success",message:"草稿已儲存"}),i("/labor-receipts")}catch(r){console.error("Error saving draft:",r),v({type:"error",message:r.message||"儲存失敗"})}finally{K(!1),A(!1)}},Ae=async()=>{var r;if(!Fe()){v({type:"error",message:"請填寫必填欄位"});return}Q(!0);try{const a=_();if(!a)throw new Error("Company ID not set");const l=he().currentUser;if(!l)throw new Error("User not authenticated");const c=X(a);let b=t.id,p=t.serialNumber;(!h||!p)&&(p=await ye(a),b=b||E(c).id);const m={...t,serialNumber:p,status:"draft",fieldConfig:j?f:void 0,updatedAt:I()};h||(m.createdBy=l.uid,m.createdAt=I()),await M(E(c,b),Ne(m),{merge:!0});const k=pe(),N=fe(k,"sendLaborReceiptEmail"),$=R||T||P?(async()=>{A(!0);const U=await me(b);A(!1),Object.keys(U).length>0&&await M(E(c,b),{...U,updatedAt:I()},{merge:!0})})():Promise.resolve(),C=N({companyId:a,receiptId:b});await Promise.all([$,C]),Oe("labor_receipt_sent"),v({type:"success",message:"確認信已發送"}),G(!1),i("/labor-receipts")}catch(a){console.error("Error sending email:",a);const n=a.message||((r=a.details)==null?void 0:r.message)||"";n.includes("INSUFFICIENT_CREDITS")?v({type:"error",message:"點數不足,請先儲值後再發送"}):n.includes("OPERATION_IN_PROGRESS")?v({type:"error",message:"操作進行中,請稍後再試"}):v({type:"error",message:n||"發送失敗"})}finally{Q(!1),A(!1)}},L=r=>rr(r,{symbol:!1});return B?e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsx("div",{className:"w-8 h-8 border-4 border-[var(--accent)]/30 border-t-[var(--accent)] rounded-full animate-spin"})}):e.jsxs("div",{className:"p-6 max-w-3xl mx-auto",children:[e.jsxs("div",{className:"flex items-center gap-4 mb-6",children:[e.jsx("button",{onClick:()=>i("/labor-receipts"),className:"p-2 text-[var(--text-muted)] hover:text-[var(--text-primary)] hover:bg-[var(--bg-card-alt)] rounded-lg transition-colors",children:e.jsx(tr,{size:20})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h1",{className:"text-xl font-bold text-[var(--text-primary)]",children:h?"編輯勞報單":"建立勞報單"}),t.serialNumber&&e.jsx("p",{className:"text-xs text-[var(--text-muted)] font-mono",children:t.serialNumber})]}),e.jsx(Ze,{showRefresh:!0})]}),e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("button",{type:"button",onClick:()=>o("fillingMode","signer_fill"),className:`p-4 border-2 rounded-xl text-left transition-all ${t.fillingMode==="signer_fill"?"border-[var(--accent)] bg-[var(--accent)]/10":"border-[var(--border)] hover:border-[var(--accent)]/50 bg-[var(--bg-card)]"}`,children:[e.jsx("div",{className:"font-medium text-[var(--text-primary)] text-sm",children:"所得人自行填寫"}),e.jsx("div",{className:"text-xs text-[var(--text-muted)] mt-1",children:"簽署ä
1ººå¡«å¯«å€‹äººè³‡æ–™"})]}),e.jsxs("button",{type:"button",onClick:()=>o("fillingMode","company_fill"),className:`p-4 border-2 rounded-xl text-left transition-all ${t.fillingMode==="company_fill"?"border-[var(--accent)] bg-[var(--accent)]/10":"border-[var(--border)] hover:border-[var(--accent)]/50 bg-[var(--bg-card)]"}`,children:[e.jsx("div",{className:"font-medium text-[var(--text-primary)] text-sm",children:"公司預先填寫"}),e.jsx("div",{className:"text-xs text-[var(--text-muted)] mt-1",children:"簽署人僅需確認簽名"})]})]}),e.jsxs("div",{className:"bg-[var(--bg-card)] border border-[var(--border)] rounded-xl p-5",children:[e.jsxs("h2",{className:"text-sm font-semibold text-[var(--text-primary)] mb-4 flex items-center gap-2 uppercase tracking-wide",children:[e.jsx(sr,{size:16}),"簽署人資訊"]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsxs("label",{htmlFor:`${s}-0`,className:"block text-xs font-medium text-[var(--text-muted)] mb-1.5",children:["電子郵件 ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("input",{id:`${s}-0`,type:"email",value:t.signerEmail||"",onChange:r=>o("signerEmail",r.target.value),placeholder:"[email protected]",className:`w-full px-3 py-2.5 text-sm bg-[var(--bg-page)] border rounded-lg focus:outline-none focus:ring-2 focus:ring-[var(--accent)]/50 ${u.signerEmail?"border-red-500":"border-[var(--border)]"}`}),u.signerEmail&&e.jsx("p",{className:"text-xs text-red-500 mt-1",children:u.signerEmail})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[e.jsxs("div",{children:[e.jsxs("label",{htmlFor:`${s}-1`,className:"block text-xs font-medium text-[var(--text-muted)] mb-1.5",children:["國籍 ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("select",{id:`${s}-1`,value:t.signerNationality||"本國籍(台灣)",onChange:r=>o("signerNationality",r.target.value),className:"w-full px-3 py-2.5 text-sm bg-[var(--bg-page)] border border-[var(--border)] rounded-lg focus:outline-none focus:ring-2 focus:ring-[var(--accent)]/50",children:gr.map(r=>e.jsx("option",{value:r.value,children:r.label},r.value))})]}),e.jsxs("div",{children:[e.jsxs("label",{htmlFor:`${s}-2`,className:"block text-xs font-medium text-[var(--text-muted)] mb-1.5",children:["所得類別 ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsxs("select",{id:`${s}-2`,value:t.incomeType||"50",onChange:r=>o("incomeType",r.target.value),className:"w-full px-3 py-2.5 text-sm bg-[var(--bg-page)] border border-[var(--border)] rounded-lg focus:outline-none focus:ring-2 focus:ring-[var(--accent)]/50",children:[e.jsx("option",{value:"50",children:"50 薪資 (5%)"}),e.jsx("option",{value:"9A",children:"9A 執行業務 (10%)"}),e.jsx("option",{value:"9B",children:"9B 稿費 (10%)"})]})]}),e.jsxs("div",{children:[e.jsxs("label",{htmlFor:`${s}-3`,className:"block text-xs font-medium text-[var(--text-muted)] mb-1.5",children:["二代健保 ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsxs("select",{id:`${s}-3`,value:t.hasSecondGenHealthInsurance?"yes":"no",onChange:r=>o("hasSecondGenHealthInsurance",r.target.value==="yes"),className:"w-full px-3 py-2.5 text-sm bg-[var(--bg-page)] border border-[var(--border)] rounded-lg focus:outline-none focus:ring-2 focus:ring-[var(--accent)]/50",children:[e.jsx("option",{value:"no",children:"須扣繳"}),e.jsx("option",{value:"yes",children:"免扣繳"})]})]})]}),e.jsxs("div",{className:"bg-blue-500/5 border border-blue-500/15 rounded-lg px-4 py-3.5",children:[e.jsx("p",{className:"text-xs font-semibold text-blue-400 mb-2",children:"115年度(2026)扣繳規則"}),e.jsxs("div",{className:"grid grid-cols-2 gap-x-5 gap-y-1.5",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-13 text-[var(--text-muted)] mb-0.5",children:"代扣所得稅"}),e.jsx("p",{className:"text-14 text-[var(--text-primary)]",children:(t.incomeType||"50")==="50"?e.jsxs(e.Fragment,{children:["稅率 5%,給付 ≥ ",e.jsx("strong",{children:"$90,501"})," 起扣"]}):e.jsxs(e.Fragment,{children:["稅率 10%,給付 > ",e.jsx("strong",{children:"$20,000"})," 起扣"]})})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-13 text-[var(--text-muted)] mb-0.5",children:"二代健保補充保費"}),e.jsx("p",{className:"text-14 text-[var(--text-primary)]",children:(t.incomeType||"50")==="50"?e.jsxs(e.Fragment,{children:["費率 2.11%,給付 ≥ ",e.jsx("strong",{children:"$29,500"})," 起扣"]}):e.jsxs(e.Fragment,{children:["費率 2.11%,給付 ≥ ",e.jsx("strong",{children:"$20,000"})," 起扣"]})})]})]})]}),t.fillingMode==="company_fill"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"border-t border-[var(--border)] pt-4 mt-4",children:[e.jsx("p",{className:"text-xs text-[var(--text-muted)] mb-3",children:"所得人個人資料"}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsxs("label",{htmlFor:`${s}-4`,className:"block text-xs font-medium text-[var(--text-muted)] mb-1.5",children:["姓名 ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("input",{id:`${s}-4`,type:"text",value:t.signerName||"",onChange:r=>o("signerName",r.target.value),placeholder:"本名",className:`date-input-dark w-full px-3 py-2.5 text-sm bg-[var(--bg-page)] border rounded-lg focus:outline-none focus:ring-2 focus:ring-[var(--accent)]/50 ${u.signerName?"border-red-500":"border-[var(--border)]"}`}),u.signerName&&e.jsx("p",{className:"text-xs text-red-500 mt-1",children:u.signerName})]}),e.jsxs("div",{children:[e.jsxs("label",{htmlFor:`${s}-0`,className:"block text-xs font-medium text-[var(--text-muted)] mb-1.5",children:["身分證字號 ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx(Xe,{id:`${s}-0`,value:t.signerIdNumber||"",onChange:r=>o("signerIdNumber",r),error:!!u.signerIdNumber,errorMessage:u.signerIdNumber,format:"taiwan"})]}),e.jsxs("div",{children:[e.jsxs("label",{htmlFor:`${s}-1`,className:"block text-xs font-medium text-[var(--text-muted)] mb-1.5",children:["聯絡電話 ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx(Ve,{id:`${s}-1`,value:t.signerPhone||"",onChange:r=>o("signerPhone",r),placeholder:"請輸入電話號碼",error:!!u.signerPhone}),u.signerPhone&&e.jsx("p",{className:"text-xs text-red-500 mt-1",children:u.signerPhone})]})]})]}),e.jsxs("div",{children:[e.jsxs("label",{htmlFor:`${s}-5`,className:"block text-xs font-medium text-[var(--text-muted)] mb-1.5",children:["現居地址 ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("input",{id:`${s}-5`,type:"text",value:t.signerAddress||"",onChange:r=>o("signerAddress",r.target.value),placeholder:"現居地址",className:"w-full px-3 py-2.5 text-sm bg-[var(--bg-page)] border border-[var(--border)] rounded-lg focus:outline-none focus:ring-2 focus:ring-[var(--accent)]/50"})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-1.5",children:[e.jsxs("span",{className:"block text-xs font-medium text-[var(--text-muted)]",children:["戶籍地址 ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsxs("label",{className:"flex items-center gap-1.5 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:t.signerRegAddress===t.signerAddress&&!!t.signerAddress,onChange:r=>{r.target.checked&&t.signerAddress&&o("signerRegAddress",t.signerAddress)},className:"w-3.5 h-3.5 rounded border-gray-400"}),e.jsx("span",{className:"text-xs text-[var(--text-muted)]",children:"同現居地址"})]})]}),e.jsx("input",{"aria-label":"戶籍地址",type:"text",value:t.signerRegAddress||"",onChange:r=>o("signerRegAddress",r.target.value),placeholder:"戶籍地址",className:"w-full px-3 py-2.5 text-sm bg-[var(--bg-page)] border border-[var(--border)] rounded-lg focus:outline-none focus:ring-2 focus:ring-[var(--accent)]/50"})]})]})]})]}),e.jsxs("div",{className:"bg-[var(--bg-card)] border border-[var(--border)] rounded-xl p-5",children:[e.jsxs("h2",{className:"text-sm font-semibold text-[var(--text-primary)] mb-4 flex items-center gap-2 uppercase tracking-wide",children:[e.jsx(ar,{size:16}),"勞務內容"]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsxs("label",{htmlFor:`${s}-6`,className:"block text-xs font-medium text-[var(--text-muted)] mb-1.5",children:["勞務描述 ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("textarea",{id:`${s}-6`,value:t.serviceDescription||"",onChange:r=>o("serviceDescription",r.target.value),placeholder:"請描述勞務內容...",rows:2,className:`w-full px-3 py-2.5 text-sm bg-[var(--bg-page)] border rounded-lg focus:outline-none focus:ring-2 focus:ring-[var(--accent)]/50 resize-none ${u.serviceDescription?"border-red-500":"border-[var(--border)]"}`}),u.serviceDescription&&e.jsx("p",{className:"text-xs text-red-500 mt-1",children:u.serviceDescription})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsxs("label",{htmlFor:`${s}-7`,className:"block text-xs font-medium text-[var(--text-muted)] mb-1.5",children:["期間起 ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("input",{id:`${s}-7`,type:"date",value:t.servicePeriodStart||"",onChange:r=>o("servicePeriodStart",r.target.value),className:`date-input-dark w-full px-3 py-2.5 text-sm bg-[var(--bg-page)] border rounded-lg focus:outline-none focus:ring-2 focus:ring-[var(--accent)]/50 ${u.servicePeriodStart?"border-red-500":"border-[var(--border)]"}`})]}),e.jsxs("div",{children:[e.jsxs("label",{htmlFor:`${s}-8`,className:"block text-xs font-medium text-[var(--text-muted)] mb-1.5",children:["期間迄 ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("input",{id:`${s}-8`,type:"date",value:t.servicePeriodEnd||"",onChange:r=>o("servicePeriodEnd",r.target.value),className:`date-input-dark w-full px-3 py-2.5 text-sm bg-[var(--bg-page)] border rounded-lg focus:outline-none focus:ring-2 focus:ring-[var(--accent)]/50 ${u.servicePeriodEnd?"border-red-500":"border-[var(--border)]"}`})]})]})]})]}),e.jsxs("div",{className:"bg-[var(--bg-card)] border border-[var(--border)] rounded-xl p-5",children:[e.jsxs("h2",{className:"text-sm font-semibold text-[var(--text-primary)] mb-4 flex items-center gap-2 uppercase tracking-wide",children:[e.jsx(nr,{size:16}),"金額與付款"]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3 mb-4",children:[e.jsxs("div",{children:[e.jsxs("label",{htmlFor:`${s}-9`,className:"block text-xs font-medium text-[var(--text-muted)] mb-1.5",children:["付款金額 (未稅) ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsxs("div",{className:"relative",children:[e.jsx("span",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-[var(--text-muted)] text-sm",children:"$"}),e.jsx("input",{id:`${s}-9`,type:"number",value:t.paymentAmount||"",onChange:r=>o("paymentAmount",Number(r.target.value)),placeholder:"0",min:"0",className:`w-full pl-7 pr-3 py-2.5 text-sm bg-[var(--bg-page)] border rounded-lg focus:outline-none focus:ring-2 focus:ring-[var(--accent)]/50 ${u.paymentAmount?"border-red-500":"border-[var(--border)]"}`})]})]}),e.jsxs("div",{children:[e.jsxs("label",{htmlFor:`${s}-10`,className:"block text-xs font-medium text-[var(--text-muted)] mb-1.5",children:["付款日期 ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("input",{id:`${s}-10`,type:"date",value:t.paymentDate||"",onChange:r=>o("paymentDate",r.target.value),className:"w-full px-3 py-2.5 text-sm bg-[var(--bg-page)] border border-[var(--border)] rounded-lg focus:outline-none focus:ring-2 focus:ring-[var(--accent)]/50"})]})]}),e.jsxs("div",{className:"bg-[var(--bg-page)] rounded-lg p-4 space-y-2 text-sm",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-[var(--text-muted)]",children:"付款金額"}),e.jsxs("span",{className:"text-[var(--text-primary)]",children:["$",L(t.paymentAmount||0)]})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsxs("span",{className:"text-[var(--text-muted)]",children:["代扣所得稅 (",W[t.incomeType||"50"]*100,"%)",t.with
1holdingTax===0&&(t.paymentAmount||0)>0&&e.jsx("span",{className:"text-xs ml-1",children:"(未達起扣點)"})]}),e.jsxs("span",{className:"text-red-500",children:["-$",L(t.withholdingTax||0)]})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsxs("span",{className:"text-[var(--text-muted)]",children:["二代健保 (2.11%)",t.healthInsurance===0&&(t.paymentAmount||0)>0&&e.jsx("span",{className:"text-xs ml-1",children:"(未達門檻)"})]}),e.jsxs("span",{className:"text-red-500",children:["-$",L(t.healthInsurance||0)]})]}),e.jsxs("div",{className:"border-t border-[var(--border)] pt-2 flex justify-between items-center",children:[e.jsx("span",{className:"font-medium text-[var(--text-primary)]",children:"實領金額"}),e.jsxs("span",{className:"text-lg font-bold text-[var(--accent)]",children:["$",L(t.netAmount||0)]})]})]}),e.jsxs("div",{className:"mt-4 pt-4 border-t border-[var(--border)]",children:[e.jsxs("span",{id:`${s}-g1`,className:"block text-xs font-medium text-[var(--text-muted)] mb-2",children:["付款方式 ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("div",{role:"group","aria-labelledby":`${s}-g1`,className:"flex gap-4",children:fr.map(r=>e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[e.jsx("input",{type:"radio",name:"paymentMethod",value:r.value,checked:t.paymentMethod===r.value||!t.paymentMethod&&r.value==="transfer",onChange:a=>o("paymentMethod",a.target.value),className:"w-4 h-4 text-[var(--accent)]"}),e.jsx("span",{className:"text-sm text-[var(--text-primary)]",children:r.label})]},r.value))}),t.paymentMethod==="cash"&&e.jsx("p",{className:"text-xs text-yellow-500 mt-2",children:"現金付款不需填寫銀行資料"})]})]}),t.fillingMode==="company_fill"&&t.paymentMethod!=="cash"&&e.jsxs("div",{className:"bg-[var(--bg-card)] border border-[var(--border)] rounded-xl p-5",children:[e.jsxs("h2",{className:"text-sm font-semibold text-[var(--text-primary)] mb-4 flex items-center gap-2 uppercase tracking-wide",children:[e.jsx(ve,{size:16}),"銀行資料 ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(We,{bankCode:t.bankCode||"",bankName:t.bankName||"",branchCode:((xe=t.bankBranch)==null?void 0:xe.split(" ")[0])||"",branchName:((ue=t.bankBranch)==null?void 0:ue.split(" ").slice(1).join(" "))||t.bankBranch||"",onBankChange:(r,a)=>{o("bankCode",r),o("bankName",a)},onBranchChange:(r,a)=>{o("bankBranch",r?`${r} ${a}`:a)},showBranch:!0,branchRequired:!j||f.fields.payment.bankBranch!==!1}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsxs("label",{htmlFor:`${s}-2`,className:"block text-xs font-medium text-[var(--text-muted)] mb-1.5",children:["帳號 ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx(Je,{id:`${s}-2`,value:t.bankAccountNumber||"",onChange:r=>o("bankAccountNumber",r),placeholder:"銀行帳號"})]}),e.jsxs("div",{children:[e.jsxs("label",{htmlFor:`${s}-11`,className:"block text-xs font-medium text-[var(--text-muted)] mb-1.5",children:["戶名 ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("input",{id:`${s}-11`,type:"text",value:t.bankAccountName||"",onChange:r=>o("bankAccountName",r.target.value),placeholder:"帳戶戶名",className:"w-full px-3 py-2.5 text-sm bg-[var(--bg-page)] border border-[var(--border)] rounded-lg focus:outline-none focus:ring-2 focus:ring-[var(--accent)]/50"})]})]})]})]}),t.fillingMode==="company_fill"&&(!j||f.fields.idPhotos.enabled)&&e.jsxs("div",{className:"bg-[var(--bg-card)] border border-[var(--border)] rounded-xl p-5",children:[e.jsxs("h2",{className:"text-sm font-semibold text-[var(--text-primary)] mb-4 flex items-center gap-2 uppercase tracking-wide",children:[e.jsx(O,{size:16}),"身分證影本 ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("span",{className:"block text-xs font-medium text-[var(--text-muted)] mb-1.5",children:"正面"}),se||t.idFrontUrl?e.jsx(V,{src:se||t.idFrontUrl||"",alt:"身分證正面",onRemove:()=>{ee(null),ae(""),o("idFrontUrl","")}}):e.jsx("div",{className:"border-2 border-dashed border-[var(--border)] rounded-lg p-3 text-center hover:border-[var(--accent)] transition-colors",children:e.jsxs("label",{className:"cursor-pointer",children:[e.jsx(O,{size:20,className:"mx-auto text-[var(--text-muted)] mb-1"}),e.jsx("p",{className:"text-xs text-[var(--text-muted)]",children:"點擊上傳"}),e.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:r=>{var a;return Y(((a=r.target.files)==null?void 0:a[0])||null,ee,ae,"idFrontUrl")}})]})})]}),e.jsxs("div",{children:[e.jsx("span",{className:"block text-xs font-medium text-[var(--text-muted)] mb-1.5",children:"反面"}),ne||t.idBackUrl?e.jsx(V,{src:ne||t.idBackUrl||"",alt:"身分證反面",onRemove:()=>{re(null),le(""),o("idBackUrl","")}}):e.jsx("div",{className:"border-2 border-dashed border-[var(--border)] rounded-lg p-3 text-center hover:border-[var(--accent)] transition-colors",children:e.jsxs("label",{className:"cursor-pointer",children:[e.jsx(O,{size:20,className:"mx-auto text-[var(--text-muted)] mb-1"}),e.jsx("p",{className:"text-xs text-[var(--text-muted)]",children:"點擊上傳"}),e.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:r=>{var a;return Y(((a=r.target.files)==null?void 0:a[0])||null,re,le,"idB
1ackUrl")}})]})})]})]})]}),t.fillingMode==="company_fill"&&t.paymentMethod!=="cash"&&(!j||f.fields.bankbook.enabled)&&e.jsxs("div",{className:"bg-[var(--bg-card)] border border-[var(--border)] rounded-xl p-5",children:[e.jsxs("h2",{className:"text-sm font-semibold text-[var(--text-primary)] mb-4 flex items-center gap-2 uppercase tracking-wide",children:[e.jsx(ve,{size:16}),"存摺封面 ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("div",{className:"flex justify-center",children:e.jsx("div",{className:"w-1/2",children:ie||t.bankbookUrl?e.jsx(V,{src:ie||t.bankbookUrl||"",alt:"存摺封面",onRemove:()=>{te(null),oe(""),o("bankbookUrl","")}}):e.jsx("div",{className:"border-2 border-dashed border-[var(--border)] rounded-lg p-4 text-center hover:border-[var(--accent)] transition-colors",children:e.jsxs("label",{className:"cursor-pointer block py-2",children:[e.jsx(O,{size:24,className:"mx-auto text-[var(--text-muted)] mb-2"}),e.jsx("p",{className:"text-xs text-[var(--text-muted)]",children:"點擊上傳存摺封面"}),e.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:r=>{var a;return Y(((a=r.target.files)==null?void 0:a[0])||null,te,oe,"bankbookUrl")}})]})})})})]}),e.jsxs("div",{className:"bg-[var(--bg-card)] border border-[var(--border)] rounded-xl p-5",children:[e.jsxs("h2",{className:"text-sm font-semibold text-[var(--text-primary)] mb-3 flex items-center gap-2 uppercase tracking-wide",children:[e.jsx(lr,{size:16}),"備註"]}),e.jsx("textarea",{"aria-label":"其他需要說明的事項...",value:t.note||"",onChange:r=>o("note",r.target.value),placeholder:"其他需要說明的事項...",rows:2,className:"w-full px-3 py-2.5 text-sm bg-[var(--bg-page)] border border-[var(--border)] rounded-lg focus:outline-none focus:ring-2 focus:ring-[var(--accent)]/50 resize-none"})]}),e.jsxs("div",{className:"bg-[var(--bg-card)] border border-[var(--border)] rounded-xl overflow-hidden",children:[e.jsxs("button",{type:"button",onClick:()=>we(!q),className:"w-full px-5 py-3 flex items-center justify-between text-left hover:bg-[var(--bg-card-alt)] transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ir,{size:16,className:"text-[var(--text-muted)]"}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-sm font-semibold text-[var(--text-primary)]",children:"簽收欄位設定"}),e.jsx("p",{className:"text-xs text-[var(--text-muted)]",children:j?"自訂設定":"公司預設"})]})]}),q?e.jsx(or,{size:16,className:"text-[var(--text-muted)]"}):e.jsx(cr,{size:16,className:"text-[var(--text-muted)]"})]}),q&&e.jsxs("div",{className:"px-5 pb-5 border-t border-[var(--border)]",children:[e.jsxs("div",{className:"flex items-center justify-between py-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-[var(--text-primary)]",children:"覆寫預設設定"}),e.jsx("p",{className:"text-xs text-[var(--text-muted)]",children:"為此勞報單使用自訂欄位"})]}),e.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[e.jsx("input",{"aria-label":"覆寫預設設定",type:"checkbox",checked:j,onChange:r=>ce(r.target.checked),className:"sr-only peer"}),e.jsx("div",{className:"w-10 h-5 bg-[var(--border)] peer-focus:outline-none peer-focus:ring-2 peer-focus:ring-[var(--accent)]/50 rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-4 after:w-4 after:transition-all peer-checked:bg-[var(--accent)]"})]})]}),j&&e.jsxs("div",{className:"space-y-3 pt-3 border-t border-[var(--border)]",children:[e.jsx("p",{className:"text-xs text-[var(--text-muted)]",children:t.fillingMode==="company_fill"?"關閉的欄位將不需要填寫":"選擇要求簽署人填寫的欄位"}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm text-[var(--text-secondary)]",children:"身分證影本"}),e.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[e.jsx("input",{"aria-label":"要求身分證影本",type:"checkbox",checked:f.fields.idPhotos.enabled,onChange:r=>de("idPhotos",r.target.checked),className:"sr-only peer"}),e.jsx("div",{className:"w-8 h-4 bg-[var(--border)] peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-3 after:w-3 after:transition-all peer-checked:bg-[var(--accent)]"})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm text-[var(--text-secondary)]",children:"分行代號"}),e.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[e.jsx("input",{"aria-label":"要求分行代號",type:"checkbox",checked:f.fields.payment.bankBranch!==!1,onChange:r=>Ie("payment","bankBranch",r.target.checked),className:"sr-only peer"}),e.jsx("div",{className:"w-8 h-4 bg-[var(--border)] peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-3 after:w-3 after:transition-all peer-checked:bg-[var(--accent)]"})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm text-[var(--text-secondary)]",children:"存摺封面"}),e.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[e.jsx("input",{"aria-label":"要求存摺封面",type:"checkbox",checked:f.fields.bankbook.enabled,onChange:r=>de("bankbook",r.target.checked),className:"sr-only peer"}),e.jsx("div",{className:"w-8 h-4 bg-[var(--border)] peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-3 after:w-3 after:transition-all peer-checked:bg-[var(--accent)]"})]})]})]})]})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row justify-end gap-2 pt-3",children:[e.jsx("button",{type:"button",onClick:()=>i("/labor-receipts"),className:"px-5 py-2 text-sm font-medium text-[var(--text-secondary)] bg-[var(--bg-card)] border border-[var(--border)] rounded-lg hover:bg-[var(--bg-card-alt)] transition-colors",children:"取消"}),e.jsxs("button",{type:"button",onClick:Se,disabled:S||H,className:"flex items-center justify-center gap-2 px-5 py-2 text-sm font-medium text-[var(--text-primary)] bg-[var(--bg-card)] border border-[var(--border)] rounded-lg hover:bg-[var(--bg-card-alt)] transition-colors disabled:opacity-50",children:[S?e.jsx(je,{size:14,className:"animate-spin"}):e.jsx(dr,{size:14}),"儲存草稿"]}),e.jsxs("button",{type:"button",onClick:()=>G(!0),disabled:S||H,className:"flex items-center justify-center gap-2 px-5 py-2 text-sm font-medium text-[var(--button-text)] bg-[var(--accent)] rounded-lg hover:bg-[var(--accent-hover)] transition-colors disabled:opacity-50",children:[H?e.jsx(je,{size:14,className:"animate-spin"}):e.jsx(mr,{size:14}),"寄出確認信"]})]})]}),e.jsx(er,{isOpen:ke,onClose:()=>G(!1),onConfirm:Ae,signerEmail:t.signerEmail||"",serialNumber:t.serialNumber}),z&&e.jsx(Me,{message:z.message,type:z.type,onClose:()=>v(null)})]})};export{$r as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.