PageSourceSearch

https://seodoon-church-admin.web.app/assets/BudgetRequestListPage-BTjBRlBA.js

js seodoon-church-admin.web.app collected 2026-10-03 12:37:20 UTC 7,962 bytes, 1 lines download raw bytes

1import{j as e}from"./vendor-data-Z5doMMu-.js";import{b as Y,f as _,r as o}from"./vendor-react-zNM0AU50.js";import{u as E}from"./index-D1K3lVhu.js";import{b as v}from"./budgetRequestService-C_9tMGTu.js";import{f as N,C as P}from"./financeConstants-CXKUiVP8.js";import{z as c,_ as B,b as F,af as M,ak as z,a4 as H,T as $,ar as G,aa as U,g as K}from"./vendor-ui-CW5bJ11U.js";import{A as O}from"./index.esm-NBNS-BUx.js";/* empty css                        */import"./vendor-firebase-Da9KY1q_.js";import"./vendor-charts-08G1rM8P.js";const W={draft:{label:"초안",color:"text-gray-700",bgColor:"bg-gray-100"},submitted:{label:"부장승인대기",color:"text-yellow-700",bgColor:"bg-yellow-100"},dept_approved:{label:"본회계승인대기",color:"text-blue-700",bgColor:"bg-blue-100"},approved:{label:"승인완료",color:"text-green-700",bgColor:"bg-green-100"},rejected:{label:"반려",color:"text-red-700",bgColor:"bg-red-100"},paid:{label:"지급완료",color:"text-purple-700",bgColor:"bg-purple-100"}};function ne({embedded:J=!1}){const h=Y(),[w]=_(),{user:a}=E(),i=(a==null?void 0:a.churchId)||"seodoon-church",[y,j]=o.useState(!0),[x,C]=o.useState([]),[Q,R]=o.useState([]),[l,p]=o.useState({fiscalYear:new Date().getFullYear().toString(),departmentId:"",status:w.get("status")||""}),[u,S]=o.useState(""),g=(a==null?void 0:a.position)||"",q=g.includes("부장"),A=g==="본회계"||g.includes("회계"),I=q||A;o.useEffect(()=>{b()},[i,l.fiscalYear,l.departmentId,l.status]);const b=async()=>{try{j(!0);const t=await v.getBudgetRequests(i,{fiscalYear:l.fiscalYear,departmentId:l.departmentId||void 0,status:l.status||void 0});C(t)}catch(t){console.error("예산 신청 목록 로드 실패:",t),c.error("예산 신청 목록을 불러오는데 실패했습니다")}finally{j(!1)}},d=o.useMemo(()=>{if(!u)return x;const t=u.toLowerCase();return x.filter(s=>{var r,m,n;return((r=s.title)==null?void 0:r.toLowerCase().includes(t))||((m=s.departmentName)==null?void 0:m.toLowerCase().includes(t))||((n=s.requesterName)==null?void 0:n.toLowerCase().includes(t))})},[x,u]),k=async t=>{if(confirm("정말 삭제하시겠습니까?"))try{await v.deleteBudgetRequest(i,t),c.success("삭제되었습니다"),b()}catch(s){console.error("삭제 실패:",s),c.error(s.message||"삭제에 실패했습니다")}},D=async t=>{try{await v.submitBudgetRequest(i,t,(a==null?void 0:a.uid)||"",(a==null?void 0:a.name)||""),c.success("제출되었습니다"),b()}catch(s){console.error("제출 실패:",s),c.error(s.message||"제출에 실패했습니다")}},f=o.useMemo(()=>{const t=d.length,s=d.filter(n=>["submitted","dept_approved"].includes(n.status)).length,r=d.filter(n=>["approved","paid"].includes(n.status)).length,m=d.reduce((n,L)=>n+L.amount,0);return{total:t,pending:s,approved:r,totalAmount:m}},[d]),T=o.useMemo(()=>[{field:"status",headerName:"상태",width:130,headerCheckboxSelection:!0,checkboxSelection:!0,cellRenderer:t=>{const s=W[t.value];return e.jsx("span",{className:`px-2 py-1 text-xs font-medium rounded ${s.bgColor} ${s.color}`,children:s.label})}},{field:"departmentName",headerName:"부서",width:120,cellRenderer:t=>e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(B,{className:"w-3.5 h-3.5 text-gray-400"}),e.jsx("span",{children:t.value})]})},{field:"title",headerName:"제목",flex:1,minWidth:200,cellRenderer:t=>{var s;return e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-gray-900",children:t.value}),((s=t.data)==null?void 0:s.budgetItemName)&&e.jsx("p",{className:"text-xs text-gray-500",children:t.data.budgetItemName})]})}},{field:"amount",headerName:"금액",width:130,cellRenderer:t=>e.jsxs("div",{className:"flex items-center gap-1 font-medium text-blue-600",children:[e.jsx(F,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:N(t.value)})]})},{field:"requesterName",headerName:"신청자",width:100},{field:"requestedAt",headerName:"신청일",width:110,cellRenderer:t=>{var r;const s=t.value||((r=t.data)==null?void 0:r.createdAt);return s?new Date(s).toLocaleDateString("ko-KR"):"-"}},{headerName:"",width:120,sortable:!1,filter:!1,cellRenderer:t=>{const s=t.data;return e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("button",{onClick:()=>h(`/finance/requests/${s.id}/edit`),className:"p-1.5 text-blue-600 hover:bg-blue-50 rounded",title:["draft","rejected"].includes(s.status)?"수정":"보기",children:["draft","rejected"].includes(s.status)?e.jsx(M,{className:"w-4 h-4"}):e.jsx(z,{className:"w-4 h-4"})}),s.status==="draft"&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>D(s.id),className:"p-1.5 text-green-600 hover:bg-green-50 rounded",title:"제출",children:e.jsx(H,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>k(s.id),className:"p-1.5 text-red-600 hover:bg-red-50 rounded",title:"삭제",children:e.jsx($,{className:"w-4 h-4"})})]})]})}}],[]);return e.jsxs("div",{className:"p-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-gray-900",children:"예산 신청"}),e.jsxs("p",{className:"text-sm text-gray-500 mt-1",children:["총 ",f.total,"건 | 승인대기 ",f.pending,"건 | 합계 ",N(f.totalAmount)]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[I&&e.jsxs("button",{onClick:()=>h("/finance/requests/approval"),className:"flex items-center gap-2 px-4 py-2 border border-blue-600 text-blue-600 rounded-lg hover:bg-blue-50",children:[e.jsx(G,{className:"w-4 h-4"}),"승인 관리"]}),e.jsxs("button",{onClick:()=>h("/finance/requests/new"),className:"flex items-center gap-2 px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700",children:[e.jsx(U,{className:"w-4 h-4"}),"예산 신청"]})]})]}),e.jsx("div",{className:"bg-white rounded-lg shadow-sm border border-gray-100 p-4 mb-4",children:e.jsxs("div",{className:"flex flex-wrap items-center gap-4",children:[e.jsxs("div",{className:"relative flex-1 min-w-[200px]",children:[e.jsx(K,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400"}),e.jsx("input",{type:"text",placeholder:"제목, 부서, 신청자 검색...",value:u,onChange:t=>S(t.target.value),className:"w-full pl-9 pr-4 py-2 border border-gray-200 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-blue-500"})]}),e.jsx("select",{value:l.fiscalYear,onChange:t=>p(s=>({...s,fiscalYear:t.target.value})),className:"px-3 py-2 border border-gray-200 rounded-lg text-sm",children:[...Array(3)].map((t,s)=>{const r=new Date().getFullYear()-s;return e.jsxs("option",{value:r.toString(),children:[r,"년"]},r)})}),e.jsxs("select",{value:l.departmentId,onChange:t=>p(s=>({...s,departmentId:t.target.value})),className:"px-3 py-2 border border-gray-200 rounded-lg text-sm",children:[e.jsx("option",{value:"",children:"전체 부서"}),P.map(t=>e.jsx("option",{value:t.id,children:t.name},t.id))]}),e.jsxs("select",{value:l.status,onChange:t=>p(s=>({...s,status:t.target.value})),className:"px-3 py-2 border border-gray-200 rounded-lg text-sm",children:[e.jsx("option",{value:"",children:"전체 상태"}),e.jsx("option",{value:"draft",children:"초안"}),e.jsx("option",{value:"submitted",children:"부장승인대기"}),e.jsx("option",{value:"dept_approved",children:"본회계승인대기"}),e.jsx("option",{value:"approved",children:"승인완료"}),e.jsx("option",{value:"rejected",children:"반려"}),e.jsx("option",{value:"paid",children:"지급완료"})]})]})}),e.jsx("div",{className:"bg-white rounded-lg shadow-sm border border-gray-100",children:e.jsx("div",{className:"ag-theme-alpine",style:{height:"calc(100vh - 320px)",width:"100%"},children:e.jsx(O,{rowData:d,columnDefs:T,defaultColDef:{sortable:!0,filter:!0,resizable:!0},rowSelection:"multiple",onSelectionChanged:t=>R(t.api.getSelectedRows()),animateRows:!0,loading:y,overlayNoRowsTemplate:"<span class='text-gray-400'>예산 신청 내역이 없습니다</span>"})})})]})}export{ne as BudgetRequestListPage};

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.