44 lines
32 KiB
JavaScript
44 lines
32 KiB
JavaScript
import{I as c,C as E,j as e}from"./index-DWp6u1Ix.js";import{a as n,t as X,T as v,u as q,i as g,v as J,w as R,C as Q,x as W,y as Y,z as Z,B as U,D as ee}from"./icons-BLu1UXn4.js";import"./react-Cfa4jLPc.js";function de({currentUser:m,onSaveCheckSession:B,checkSessions:w,tickets:j,onUpdateTicketStatus:L}){const[x,b]=n.useState("dashboard"),[u,P]=n.useState(c[0].id),[y,_]=n.useState(125400),[C,H]=n.useState("เต็มถัง"),[S,M]=n.useState(""),[$,O]=n.useState(""),[z,F]=n.useState({1:!0,2:!1,3:!1,4:!1}),[f,k]=n.useState(()=>{const s={};return E.forEach(t=>{s[t.id]={itemId:t.id,itemName:t.name,status:"พร้อมใช้",severity:t.severity}}),s}),[D,I]=n.useState(""),N=c.find(s=>s.id===u)||c[0],G=(s,t)=>{k(a=>({...a,[s]:{...a[s],status:t,problemDetails:t==="พร้อมใช้"||t==="ไม่เกี่ยวข้องกับรถคันนี้"?void 0:a[s].problemDetails}}))},T=(s,t,a)=>{k(r=>({...r,[s]:{...r[s],[t]:a}}))},K=s=>{F(t=>({...t,[s]:!t[s]}))},d=(()=>{let s=0,t=0,a=[],r=[];return Object.values(f).forEach(l=>{!["พร้อมใช้","ไม่มีประจำรถ","ไม่เกี่ยวข้องกับรถคันนี้"].includes(l.status)&&(l.severity==="critical"?(s++,a.push(`${l.itemName} (${l.status})`)):l.severity==="important"&&(t++,r.push(`${l.itemName} (${l.status})`)))}),s>0?{status:"ไม่พร้อมปฏิบัติการ",reason:`พบอุปกรณ์วิกฤตทำงานผิดปกติหรือชำรุดจำนวน ${s} รายการ: ${a.slice(0,2).join(", ")}${a.length>2?"...":""}`,criticalIssuesCount:s,importantIssuesCount:t}:t>0?{status:"พร้อมใช้งานแบบมีข้อจำกัด",reason:`มีอุปกรณ์ทั่วไปไม่พร้อมใช้หรือจำนวนไม่เพียงพอ ${t} รายการ: ${r.slice(0,2).join(", ")}${r.length>2?"...":""}`,criticalIssuesCount:s,importantIssuesCount:t}:{status:"พร้อมปฏิบัติการ",reason:"อุปกรณ์วิกฤตและระบบพื้นฐานพยาบาลผ่านการประเมินความพร้อม 100%",criticalIssuesCount:s,importantIssuesCount:t}})(),V=()=>{const s=new Date().toISOString().split("T")[0],t=new Date().toTimeString().split(" ")[0].substring(0,5),a={id:`acs_${Date.now()}`,date:s,timeStart:new Date(Date.now()-900*1e3).toTimeString().split(" ")[0].substring(0,5),timeEnd:t,shift:new Date().getHours()>=8&&new Date().getHours()<16?"เช้า":new Date().getHours()>=16&&new Date().getHours()<24?"บ่าย":"ดึก",ambulanceId:u,plateNo:N.plateNo,unitId:N.unitId,unitName:N.unitName,checkerUsername:m.username,checkerName:m.fullName,checkerRole:m.role,coCheckerName:S||void 0,overallStatus:d.status,remarks:$||void 0,mileage:y,fuelLevel:C,results:Object.values(f)};B(a),I(`ตรวจสภาพรถพยาบาล ${u} สำเร็จ! ประมวลผลสถานะ: ${d.status}`),setTimeout(()=>I(""),4e3),b("dashboard"),window.scrollTo({top:0,behavior:"smooth"})},h=(()=>{const s={};return[...w].sort((a,r)=>r.id.localeCompare(a.id)).forEach(a=>{s[a.ambulanceId]||(s[a.ambulanceId]=a)}),c.map(a=>{const r=s[a.id];return{...a,latestCheckDate:r?.date||"ยังไม่ได้ตรวจ",latestCheckTime:r?.timeEnd||"",latestCheckBy:r?.checkerName||"",overallStatus:r?.overallStatus||"ยังไม่ได้ตรวจ",issuesCount:r?.results.filter(l=>!["พร้อมใช้","ไม่มีประจำรถ","ไม่เกี่ยวข้องกับรถคันนี้"].includes(l.status)).length||0}})})(),p=s=>s==="ยังไม่ได้ตรวจ"?c.length-Object.keys(w.reduce((t,a)=>(t[a.ambulanceId]=!0,t),{})).length:h.filter(t=>t.overallStatus===s).length;return e.jsxs("div",{className:"space-y-6",children:[D&&e.jsxs("div",{className:"fixed top-24 right-4 z-50 bg-emerald-600 text-white px-6 py-3.5 rounded-xl shadow-xl flex items-center gap-3 animate-bounce",children:[e.jsx(X,{className:"w-5 h-5"}),e.jsx("span",{className:"font-semibold",children:D})]}),e.jsxs("div",{className:"flex border border-slate-200/60 bg-white p-2 rounded-2xl shadow-xs gap-2",children:[e.jsxs("button",{onClick:()=>b("dashboard"),className:`flex-1 md:flex-initial flex items-center justify-center gap-2 px-5 py-2.5 rounded-xl text-xs md:text-sm font-bold transition-all cursor-pointer
|
|
${x==="dashboard"?"bg-indigo-600 text-white shadow-md shadow-indigo-500/20":"text-slate-600 hover:text-slate-800 hover:bg-slate-50"}
|
|
`,children:[e.jsx(v,{className:"w-4 h-4"})," แดชบอร์ดรถพยาบาล"]}),e.jsxs("button",{onClick:()=>b("check-form"),className:`flex-1 md:flex-initial flex items-center justify-center gap-2 px-5 py-2.5 rounded-xl text-xs md:text-sm font-bold transition-all cursor-pointer
|
|
${x==="check-form"?"bg-indigo-600 text-white shadow-md shadow-indigo-500/20":"text-slate-600 hover:text-slate-800 hover:bg-slate-50"}
|
|
`,children:[e.jsx(q,{className:"w-4 h-4"})," แบบฟอร์มตรวจความพร้อมรถ"]}),e.jsxs("button",{onClick:()=>b("tickets"),className:`flex-1 md:flex-initial flex items-center justify-center gap-2 px-5 py-2.5 rounded-xl text-xs md:text-sm font-bold transition-all cursor-pointer
|
|
${x==="tickets"?"bg-indigo-600 text-white shadow-md shadow-indigo-500/20":"text-slate-600 hover:text-slate-800 hover:bg-slate-50"}
|
|
`,children:[e.jsx(g,{className:"w-4 h-4"})," รายการซ่อมบำรุง (",j.filter(s=>s.status!=="ปิดรายการ").length,")"]})]}),x==="dashboard"&&e.jsxs("div",{className:"space-y-6 animate-fadeIn",children:[e.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-4",children:[e.jsxs("div",{className:"bg-white p-4 rounded-2xl shadow-sm border border-slate-100 flex items-center gap-3",children:[e.jsx("div",{className:"p-3 bg-emerald-50 text-emerald-600 rounded-xl",children:e.jsx(J,{className:"w-6 h-6"})}),e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-slate-400 font-bold",children:"พร้อมปฏิบัติการ"}),e.jsxs("div",{className:"text-xl md:text-2xl font-black text-slate-800",children:[p("พร้อมปฏิบัติการ")," คัน"]})]})]}),e.jsxs("div",{className:"bg-white p-4 rounded-2xl shadow-sm border border-slate-100 flex items-center gap-3",children:[e.jsx("div",{className:"p-3 bg-amber-50 text-amber-600 rounded-xl",children:e.jsx(g,{className:"w-6 h-6"})}),e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-slate-400 font-bold font-sans",children:"พร้อมใช้มีข้อจำกัด"}),e.jsxs("div",{className:"text-xl md:text-2xl font-black text-slate-800",children:[p("พร้อมใช้งานแบบมีข้อจำกัด")," คัน"]})]})]}),e.jsxs("div",{className:"bg-white p-4 rounded-2xl shadow-sm border border-slate-100 flex items-center gap-3",children:[e.jsx("div",{className:"p-3 bg-red-50 text-red-600 rounded-xl",children:e.jsx(R,{className:"w-6 h-6"})}),e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-slate-400 font-bold",children:"ไม่พร้อมใช้"}),e.jsxs("div",{className:"text-xl md:text-2xl font-black text-slate-800",children:[p("ไม่พร้อมปฏิบัติการ")," คัน"]})]})]}),e.jsxs("div",{className:"bg-white p-4 rounded-2xl shadow-sm border border-slate-100 flex items-center gap-3",children:[e.jsx("div",{className:"p-3 bg-slate-50 text-slate-400 rounded-xl",children:e.jsx(Q,{className:"w-6 h-6"})}),e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-slate-400 font-bold",children:"ยังไม่ได้ตรวจประจำเวร"}),e.jsxs("div",{className:"text-xl md:text-2xl font-black text-slate-800",children:[p("ยังไม่ได้ตรวจ")," คัน"]})]})]})]}),e.jsxs("div",{className:"bg-white rounded-2xl shadow-sm border border-slate-100 overflow-hidden",children:[e.jsx("div",{className:"p-4 md:p-5 border-b border-slate-100 bg-slate-50 flex items-center justify-between",children:e.jsxs("div",{children:[e.jsx("h3",{className:"text-base font-bold text-slate-800",children:"สถานะความพร้อมรถพยาบาลปัจจุบัน"}),e.jsx("p",{className:"text-xs text-slate-500 mt-0.5",children:"แสดงข้อมูลจากการประเมินครั้งล่าสุดของแต่ละคันในระบบ"})]})}),e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-left border-collapse text-xs md:text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"bg-slate-100/50 text-slate-600 font-bold border-b border-slate-100",children:[e.jsx("th",{className:"py-3 px-4",children:"รหัส / ทะเบียนรถ"}),e.jsx("th",{className:"py-3 px-3",children:"หน่วยงานผู้ควบคุม"}),e.jsx("th",{className:"py-3 px-3 text-center",children:"ประเภทรถ"}),e.jsx("th",{className:"py-3 px-3",children:"เวลาที่ตรวจล่าสุด"}),e.jsx("th",{className:"py-3 px-3",children:"ผู้ตรวจสภาพ"}),e.jsx("th",{className:"py-3 px-3 text-center",children:"สถานะความพร้อม"}),e.jsx("th",{className:"py-3 px-3 text-center",children:"รายงานปัญหา"})]})}),e.jsx("tbody",{className:"divide-y divide-slate-100 text-slate-700 font-medium",children:h.map(s=>e.jsxs("tr",{className:"hover:bg-slate-50/50 transition-colors",children:[e.jsx("td",{className:"py-3.5 px-4",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(v,{className:"w-4 h-4 text-slate-400"}),e.jsxs("div",{children:[e.jsx("div",{className:"font-bold text-slate-800",children:s.id}),e.jsx("div",{className:"text-[10px] text-slate-400 font-mono font-semibold",children:s.plateNo})]})]})}),e.jsx("td",{className:"py-3.5 px-3",children:e.jsx("span",{className:"bg-slate-100 px-2.5 py-1 rounded-lg text-slate-600 font-semibold",children:s.unitName})}),e.jsx("td",{className:"py-3.5 px-3 text-center",children:e.jsx("span",{className:`px-2 py-0.5 rounded text-[10px] font-bold ${s.type==="ALS"?"bg-red-100 text-red-800 border border-red-200":"bg-blue-100 text-blue-800 border border-blue-200"}`,children:s.type})}),e.jsxs("td",{className:"py-3.5 px-3 font-mono text-slate-500 text-xs",children:[s.latestCheckDate," ",s.latestCheckTime&&`| ${s.latestCheckTime} น.`]}),e.jsx("td",{className:"py-3.5 px-3 text-slate-600 truncate max-w-[130px]",title:s.latestCheckBy,children:s.latestCheckBy||e.jsx("span",{className:"text-slate-300",children:"-"})}),e.jsx("td",{className:"py-3.5 px-3 text-center",children:e.jsxs("span",{className:`inline-flex items-center gap-1.5 px-3 py-1 rounded-full text-xs font-bold border shadow-sm
|
|
${s.overallStatus==="พร้อมปฏิบัติการ"?"bg-emerald-50 text-emerald-700 border-emerald-200":""}
|
|
${s.overallStatus==="พร้อมใช้งานแบบมีข้อจำกัด"?"bg-amber-50 text-amber-700 border-amber-200":""}
|
|
${s.overallStatus==="ไม่พร้อมปฏิบัติการ"?"bg-red-50 text-red-700 border-red-200":""}
|
|
${s.overallStatus==="ยังไม่ได้ตรวจ"?"bg-slate-50 text-slate-400 border-slate-200":""}
|
|
`,children:[e.jsx("span",{className:`w-2 h-2 rounded-full
|
|
${s.overallStatus==="พร้อมปฏิบัติการ"?"bg-emerald-600":""}
|
|
${s.overallStatus==="พร้อมใช้งานแบบมีข้อจำกัด"?"bg-amber-500":""}
|
|
${s.overallStatus==="ไม่พร้อมปฏิบัติการ"?"bg-red-600":""}
|
|
${s.overallStatus==="ยังไม่ได้ตรวจ"?"bg-slate-400":""}
|
|
`}),s.overallStatus]})}),e.jsx("td",{className:"py-3.5 px-3 text-center",children:s.issuesCount>0?e.jsxs("span",{className:"bg-rose-100 text-rose-700 font-black text-xs px-2.5 py-1 rounded-full border border-rose-200 animate-pulse",children:["⚠️ พบจุดชำรุด ",s.issuesCount," แห่ง"]}):e.jsx("span",{className:"text-slate-400 text-xs font-semibold",children:"ปกติ"})})]},s.id))})]})})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[e.jsxs("div",{className:"bg-white rounded-2xl shadow-sm border border-slate-100 p-5 space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between border-b border-slate-50 pb-2",children:[e.jsxs("h4",{className:"font-bold text-slate-800 flex items-center gap-2",children:[e.jsx(g,{className:"w-4 h-4 text-rose-600"})," แจ้งเตือนรถพยาบาลวิกฤต/ฉุกเฉิน"]}),e.jsx("span",{className:"text-[10px] bg-red-50 text-red-600 font-bold px-2 py-0.5 rounded-full border border-red-200",children:"ต้องการแก้ไขด่วน"})]}),e.jsx("div",{className:"space-y-2.5",children:h.filter(s=>s.overallStatus==="ไม่พร้อมปฏิบัติการ"||s.issuesCount>0).length===0?e.jsx("div",{className:"text-center py-6 text-slate-400 text-xs font-medium",children:"✨ ระบบไม่พบปัญหาเร่งด่วนในรถกู้ชีพพยาบาลทุกคัน"}):h.filter(s=>s.overallStatus==="ไม่พร้อมปฏิบัติการ"||s.issuesCount>0).map(s=>e.jsxs("div",{className:"flex items-center justify-between bg-red-50/30 p-3 rounded-xl border border-red-100",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"text-xs font-bold text-slate-800",children:[s.id," (",s.plateNo,")"]}),e.jsxs("div",{className:"text-[10px] text-slate-500 mt-1",children:["ค่ายดูแล: ",s.unitName," | ตรวจโดย: ",s.latestCheckBy||"ระบบ"]})]}),e.jsx("div",{className:"text-right",children:e.jsxs("span",{className:"bg-red-100 text-red-800 text-[10px] font-black px-2 py-1 rounded border border-red-200 uppercase tracking-wide",children:["ไม่พร้อมใช้ (",s.issuesCount," ปัญหา)"]})})]},s.id))})]}),e.jsxs("div",{className:"bg-white rounded-2xl shadow-sm border border-slate-100 p-5 space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between border-b border-slate-50 pb-2",children:[e.jsxs("h4",{className:"font-bold text-slate-800 flex items-center gap-2",children:[e.jsx(W,{className:"w-4 h-4 text-amber-600"})," ยา/เวชภัณฑ์ใกล้หมดอายุ"]}),e.jsx("span",{className:"text-[10px] bg-amber-50 text-amber-700 font-bold px-2 py-0.5 rounded-full border border-amber-200",children:"ตรวจสอบดวงชะตาเวชภัณฑ์"})]}),e.jsxs("div",{className:"space-y-2.5",children:[e.jsxs("div",{className:"flex items-center justify-between bg-amber-50/40 p-3 rounded-xl border border-amber-100",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-xs font-bold text-slate-800",children:"แผ่น Defibrillator Pads (หมดอายุ)"}),e.jsx("div",{className:"text-[10px] text-slate-400 mt-1",children:"รถ: NRT-06 | ทะเบียน: บท-8855 สุราษฎร์ธานี"})]}),e.jsx("div",{className:"text-right",children:e.jsx("span",{className:"text-xs font-extrabold text-amber-700",children:"หมดอายุ 24 วันข้างหน้า"})})]}),e.jsxs("div",{className:"flex items-center justify-between bg-amber-50/40 p-3 rounded-xl border border-amber-100",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-xs font-bold text-slate-800",children:"ท่อช่วยหายใจ ET Tube ขนาด 7.5"}),e.jsx("div",{className:"text-[10px] text-slate-400 mt-1",children:"รถ: NRT-01 | ทะเบียน: กข-9988 สุราษฎร์ธานี"})]}),e.jsx("div",{className:"text-right",children:e.jsx("span",{className:"text-xs font-extrabold text-slate-500",children:"เหลือ 65 วัน"})})]})]})]})]})]}),x==="check-form"&&e.jsxs("div",{className:"bg-white rounded-2xl shadow-sm border border-slate-100 p-5 md:p-6 space-y-6 animate-fadeIn",children:[e.jsxs("div",{className:"border-b border-slate-100 pb-4",children:[e.jsxs("h3",{className:"text-lg font-bold text-slate-800 flex items-center gap-2",children:[e.jsx(v,{className:"w-5 h-5 text-blue-600"})," แบบฟอร์มบันทึกการตรวจสอบความพร้อมรถประจำเวร"]}),e.jsx("p",{className:"text-xs text-slate-500 mt-1",children:"เลือกหมายเลขรถพยาบาลและกรอกข้อมูลตรวจสอบทางเทคนิคและอุปกรณ์กู้ชีพ"})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4 bg-slate-50 p-4 rounded-xl border border-slate-100",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-bold text-slate-500 mb-1",children:"เลือกรถกู้ชีพพยาบาล"}),e.jsx("select",{value:u,onChange:s=>P(s.target.value),className:"w-full py-2 px-3 border border-slate-200 rounded-lg text-xs font-bold text-slate-700 outline-none focus:ring-1 focus:ring-blue-500 bg-white",children:c.map(s=>e.jsxs("option",{value:s.id,children:[s.id," - ",s.plateNo," (",s.unitName,")"]},s.id))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-bold text-slate-500 mb-1",children:"เลขไมล์รถล่าสุด (กิโลเมตร)"}),e.jsx("input",{type:"number",value:y,onChange:s=>_(Number(s.target.value)),className:"w-full py-2 px-3 border border-slate-200 rounded-lg text-xs font-bold text-slate-700 outline-none focus:ring-1 focus:ring-blue-500 bg-white"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-bold text-slate-500 mb-1",children:"ระดับน้ำมันเชื้อเพลิง"}),e.jsxs("select",{value:C,onChange:s=>H(s.target.value),className:"w-full py-2 px-3 border border-slate-200 rounded-lg text-xs font-bold text-slate-700 outline-none focus:ring-1 focus:ring-blue-500 bg-white",children:[e.jsx("option",{value:"เต็มถัง",children:"เต็มถัง (100%)"}),e.jsx("option",{value:"3/4 ถัง",children:"3/4 ถัง (75%)"}),e.jsx("option",{value:"ครึ่งถัง",children:"ครึ่งถัง (50%)"}),e.jsx("option",{value:"1/4 ถัง",children:"1/4 ถัง (25% - ควรแจ้งเติมด่วน)"})]})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-bold text-slate-500 mb-1",children:"ชื่อผู้ร่วมตรวจสอบ (ถ้ามี)"}),e.jsx("input",{type:"text",placeholder:"เช่น นายเอกชัย กู้ชีพทีมบ่าย",value:S,onChange:s=>M(s.target.value),className:"w-full py-2 px-3 border border-slate-200 rounded-lg text-xs font-bold text-slate-700 outline-none focus:ring-1 focus:ring-blue-500 bg-white"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-bold text-slate-500 mb-1",children:"บทบาทหน้าที่ของคุณ"}),e.jsxs("div",{className:"py-2 px-3 bg-slate-100 rounded-lg border border-slate-200 text-xs font-bold text-slate-600",children:[m.role," - ",m.fullName]})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h4",{className:"text-xs font-black text-slate-400 uppercase tracking-widest border-b border-slate-100 pb-1",children:"หัวข้อตรวจประเมินแยกหมวด"}),[1,2,3,4].map(s=>{const t=s===1?"หมวด 1: ยานพาหนะ ความปลอดภัย และเอกสารประจำรถ":s===2?"หมวด 2: เครื่องมือแพทย์ อุปกรณ์ช่วยชีวิตและการเฝ้าสัญญาณผู้ป่วย":s===3?"หมวด 3: อุปกรณ์เคลื่อนย้ายผู้ป่วยและการตรึงผู้บาดเจ็บ":"หมวด 4: ยาฉุกเฉิน สารน้ำ และเวชภัณฑ์พกพาประจำรถ",a=E.filter(l=>l.category===s),r=z[s];return e.jsxs("div",{className:"border border-slate-100 rounded-2xl overflow-hidden shadow-sm",children:[e.jsxs("button",{type:"button",onClick:()=>K(s),className:"w-full flex items-center justify-between p-4 bg-slate-50 border-b border-slate-100 font-bold text-xs md:text-sm text-slate-800 transition-colors hover:bg-slate-100/60 cursor-pointer",children:[e.jsxs("span",{children:[t," (",a.length," รายการ)"]}),r?e.jsx(Y,{className:"w-4 h-4"}):e.jsx(Z,{className:"w-4 h-4"})]}),r&&e.jsx("div",{className:"divide-y divide-slate-100",children:a.map(l=>{const i=f[l.id]||{itemId:l.id,itemName:l.name,status:"พร้อมใช้",severity:l.severity},A=!["พร้อมใช้","ไม่มีประจำรถ","ไม่เกี่ยวข้องกับรถคันนี้"].includes(i.status);return e.jsxs("div",{className:`p-4 flex flex-col md:flex-row md:items-center justify-between gap-4 transition-colors ${A?"bg-red-50/10":""}`,children:[e.jsx("div",{className:"flex-1",children:e.jsxs("div",{className:"flex items-start gap-1.5",children:[e.jsx("span",{className:`text-[9px] font-black uppercase px-1.5 py-0.2 rounded border mt-0.5
|
|
${l.severity==="critical"?"bg-red-100 text-red-700 border-red-200":""}
|
|
${l.severity==="important"?"bg-amber-100 text-amber-700 border-amber-200":""}
|
|
${l.severity==="general"?"bg-slate-100 text-slate-600 border-slate-200":""}
|
|
`,children:l.severity==="critical"?"🔴 วิกฤต":l.severity==="important"?"🟡 สำคัญ":"⚪ ทั่วไป"}),e.jsx("span",{className:"text-xs md:text-sm font-bold text-slate-800",children:l.name})]})}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:["พร้อมใช้","ชำรุด","จำนวนไม่เพียงพอ","หมดอายุ","ไม่เกี่ยวข้องกับรถคันนี้"].map(o=>e.jsx("button",{type:"button",onClick:()=>G(l.id,o),className:`px-2.5 py-1 rounded-lg text-[10px] font-bold border transition-all cursor-pointer
|
|
${i.status===o?"bg-blue-600 text-white border-blue-600 shadow-sm":"bg-white hover:bg-slate-50 text-slate-600 border-slate-200"}
|
|
`,children:o},o))}),A&&e.jsxs("div",{className:"w-full md:w-auto flex flex-col sm:flex-row gap-2 mt-2 md:mt-0",children:[e.jsx("input",{type:"text",placeholder:"อธิบายรายละเอียดปัญหาชำรุด...",value:i.problemDetails||"",onChange:o=>T(l.id,"problemDetails",o.target.value),className:"px-2.5 py-1.5 border border-red-200 rounded-lg text-xs outline-none bg-red-50/20 focus:bg-white w-full md:w-48 font-semibold"}),i.status==="จำนวนไม่เพียงพอ"&&e.jsx("input",{type:"number",placeholder:"นับพบกี่ชิ้น",value:i.foundCount||"",onChange:o=>T(l.id,"foundCount",Number(o.target.value)),className:"px-2 py-1.5 border border-red-200 rounded-lg text-xs outline-none bg-red-50/20 focus:bg-white w-20 font-semibold"})]})]},l.id)})})]},`category_card_${s}`)})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-bold text-slate-500 mb-1",children:"หมายเหตุเพิ่มเติมภาพรวมการตรวจเช็ก"}),e.jsx("textarea",{rows:3,placeholder:"กรอกรายละเอียดความคืบหน้าการทำงาน อุปสรรคความร่วมมือ หรือปัญหาที่ต้องให้วิศวกรซ่อมบำรุงดำเนินการด่วน...",value:$,onChange:s=>O(s.target.value),className:"w-full px-3 py-2 border border-slate-200 rounded-xl text-xs font-medium outline-none focus:ring-1 focus:ring-blue-500 focus:border-blue-500"})]}),e.jsxs("div",{className:`p-4 rounded-2xl border flex flex-col md:flex-row md:items-center justify-between gap-4
|
|
${d.status==="พร้อมปฏิบัติการ"?"bg-emerald-50 border-emerald-200 text-emerald-800":""}
|
|
${d.status==="พร้อมใช้งานแบบมีข้อจำกัด"?"bg-amber-50 border-amber-200 text-amber-800":""}
|
|
${d.status==="ไม่พร้อมปฏิบัติการ"?"bg-red-50 border-red-200 text-red-800":""}
|
|
`,children:[e.jsxs("div",{children:[e.jsxs("div",{className:"text-xs font-black uppercase tracking-wider flex items-center gap-1.5",children:[d.status==="พร้อมปฏิบัติการ"&&e.jsx(U,{className:"w-4 h-4 text-emerald-600"}),d.status==="พร้อมใช้งานแบบมีข้อจำกัด"&&e.jsx(g,{className:"w-4 h-4 text-amber-600"}),d.status==="ไม่พร้อมปฏิบัติการ"&&e.jsx(R,{className:"w-4 h-4 text-red-600"}),"ผลการประมวลสถานะความพร้อมรถอัตโนมัติ: ",e.jsx("span",{className:"underline font-sans",children:d.status})]}),e.jsx("p",{className:"text-xs font-semibold mt-1 opacity-90",children:d.reason})]}),e.jsxs("button",{onClick:V,className:`w-full md:w-auto px-6 py-3 rounded-xl font-bold text-xs md:text-sm text-white shadow-md transition-all active:scale-95 cursor-pointer flex items-center justify-center gap-1.5
|
|
${d.status==="พร้อมปฏิบัติการ"?"bg-emerald-600 hover:bg-emerald-700 shadow-emerald-200":""}
|
|
${d.status==="พร้อมใช้งานแบบมีข้อจำกัด"?"bg-amber-600 hover:bg-amber-700 shadow-amber-200":""}
|
|
${d.status==="ไม่พร้อมปฏิบัติการ"?"bg-red-600 hover:bg-red-700 shadow-red-200":""}
|
|
`,id:"btn-submit-check",children:[e.jsx(ee,{className:"w-4 h-4"})," ยืนยันผลตรวจสอบและบันทึกข้อมูล"]})]})]}),x==="tickets"&&e.jsxs("div",{className:"space-y-4 animate-fadeIn",children:[e.jsxs("div",{className:"bg-white rounded-2xl p-4 md:p-5 shadow-sm border border-slate-100 flex flex-col md:flex-row md:items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-base font-bold text-slate-800",children:"รายการซ่อมบำรุงและงานติดตามแก้ไขปัญหา (Tickets)"}),e.jsx("p",{className:"text-xs text-slate-500 mt-0.5",children:"ติดตามการเติมเวชภัณฑ์และซ่อมแซมวิทยุ แบตเตอรี่ ประตูรถของทุกคัน"})]}),e.jsx("div",{className:"flex gap-2",children:e.jsxs("span",{className:"text-xs font-bold bg-red-100 text-red-700 px-3 py-1.5 rounded-lg border border-red-200 flex items-center gap-1",children:["🔴 ยังค้างอยู่: ",j.filter(s=>s.status!=="ปิดรายการ"&&s.status!=="ตรวจสอบผลแล้ว").length," งาน"]})})]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:j.map(s=>e.jsxs("div",{className:"bg-white rounded-2xl shadow-sm border border-slate-100 p-4 md:p-5 flex flex-col justify-between gap-4",children:[e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-[10px] bg-slate-100 font-mono text-slate-500 font-bold px-2 py-0.5 rounded border border-slate-200",children:s.id}),e.jsx("h4",{className:"font-bold text-slate-800 text-sm mt-1",children:s.itemName}),e.jsxs("p",{className:"text-[10px] text-slate-400 mt-0.5",children:["รถ: ",e.jsx("span",{className:"font-bold",children:s.ambulanceId})," | ทะเบียน: ",s.plateNo," (",s.unitName,")"]})]}),e.jsx("span",{className:`text-[10px] font-black px-2 py-0.5 rounded border uppercase tracking-wider
|
|
${s.severity==="critical"?"bg-red-100 text-red-700 border-red-200":""}
|
|
${s.severity==="important"?"bg-amber-100 text-amber-700 border-amber-200":""}
|
|
${s.severity==="general"?"bg-blue-100 text-blue-700 border-blue-200":""}
|
|
`,children:s.severity==="critical"?"วิกฤต":s.severity==="important"?"สำคัญ":"ทั่วไป"})]}),e.jsxs("div",{className:"bg-slate-50/60 p-3 rounded-xl border border-slate-100 text-xs font-medium text-slate-600 leading-relaxed",children:[e.jsx("span",{className:"font-bold text-slate-800 block mb-0.5",children:"ปัญหาที่พบ:"}),s.problemDetails,e.jsxs("div",{className:"text-[10px] text-slate-400 mt-2 font-semibold",children:["แจ้งโดย: ",s.reportedBy," | วันที่: ",s.reportedAt.replace("T"," ")]})]}),s.actionDetails&&e.jsxs("div",{className:"bg-emerald-50/40 p-3 rounded-xl border border-emerald-100 text-xs text-emerald-800 leading-relaxed",children:[e.jsx("span",{className:"font-bold block mb-0.5 text-emerald-900",children:"การดำเนินการแก้ไข:"}),s.actionDetails]}),e.jsxs("div",{className:"border-t border-slate-50 pt-3 flex flex-col sm:flex-row sm:items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-xs text-slate-400 font-bold",children:"สถานะตั๋ว:"}),e.jsx("span",{className:`text-xs font-bold px-2.5 py-1 rounded-full border
|
|
${s.status==="รอรับเรื่อง"?"bg-slate-50 text-slate-600 border-slate-200":""}
|
|
${s.status==="อยู่ระหว่างดำเนินการ"?"bg-amber-50 text-amber-700 border-amber-200":""}
|
|
${s.status==="รออะไหล่หรือรอเวชภัณฑ์"?"bg-purple-50 text-purple-700 border-purple-200":""}
|
|
${s.status==="ส่งซ่อม"?"bg-blue-50 text-blue-700 border-blue-200":""}
|
|
${s.status==="แก้ไขแล้ว"?"bg-cyan-50 text-cyan-700 border-cyan-200":""}
|
|
${s.status==="ตรวจสอบผลแล้ว"?"bg-emerald-50 text-emerald-700 border-emerald-200":""}
|
|
${s.status==="ปิดรายการ"?"bg-gray-100 text-gray-500 border-gray-200":""}
|
|
`,children:s.status})]}),e.jsx("div",{className:"flex gap-1",children:s.status!=="ปิดรายการ"&&e.jsxs("select",{onChange:t=>L(s.id,t.target.value,"อัปเดตงานบำรุงรักษาผ่านแดชบอร์ด"),defaultValue:s.status,className:"py-1.5 px-2.5 bg-slate-50 border border-slate-200 hover:border-slate-300 rounded-lg text-xs font-bold text-slate-700 outline-none transition-colors cursor-pointer",children:[e.jsx("option",{value:"รอรับเรื่อง",children:"รอรับเรื่อง"}),e.jsx("option",{value:"อยู่ระหว่างดำเนินการ",children:"อยู่ระหว่างดำเนินการ"}),e.jsx("option",{value:"ส่งซ่อม",children:"ส่งซ่อม"}),e.jsx("option",{value:"แก้ไขแล้ว",children:"แก้ไขแล้ว"}),e.jsx("option",{value:"ตรวจสอบผลแล้ว",children:"ตรวจสอบผลแล้ว"}),e.jsx("option",{value:"ปิดรายการ",children:"ปิดรายการ (ปิดถาวร)"})]})})]})]},s.id))})]})]})}export{de as default};
|