import{p as b}from"./index-BuBKbyog.js";import{d as F,m as L,o as w,c as N,a as m,f as l,j as a,w as X,z as G,g as H,r as d,k as n,q as J,l as r,t as h,C as K,E as x,_ as O}from"./index-Bg3n6gLm.js";const Q={class:"passengers-page"},W={class:"header"},Y={class:"nav-links"},Z={class:"passengers-card card"},ee={class:"header-row"},le={key:0,class:"no-data"},ae=F({__name:"Passengers-Normal",setup(te){const v=d(!1),V=d([]),u=d(!1),c=d(!1),_=d(null),T=d(),s=d({name:"",idCard:"",passengerType:1,phone:""}),E={name:[{required:!0,message:"请输入姓名",trigger:"blur"}],idCard:[{required:!0,message:"请输入身份证号",trigger:"blur"},{pattern:/^[1-9]\d{5}(18|19|20)\d{2}(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])\d{3}[0-9Xx]$/,message:"身份证号格式不正确",trigger:"blur"}]};L(async()=>{await C()});const C=async()=>{v.value=!0;try{const o=await b.getList();V.value=o.data}catch{console.error("加载失败")}finally{v.value=!1}},B=()=>{c.value=!1,_.value=null,s.value={name:"",idCard:"",passengerType:1,phone:""},u.value=!0},D=o=>{c.value=!0,_.value=o.id,s.value={name:o.name,idCard:o.idCard,passengerType:o.passengerType,phone:o.phone||""},u.value=!0},U=async o=>{try{await K.confirm("确定要删除该旅客吗？","提示",{type:"warning"}),await b.delete(o.id),x.success("删除成功"),await C()}catch{console.error("删除失败")}},P=async()=>{var e;if(await((e=T.value)==null?void 0:e.validate()))try{c.value&&_.value?(await b.update(_.value,s.value),x.success("修改成功")):(await b.add(s.value),x.success("添加成功")),u.value=!1,await C()}catch{console.error("操作失败")}},$=o=>["","成人","儿童","学生","残军"][o]||"成人";return(o,e)=>{const f=n("router-link"),p=n("el-button"),i=n("el-table-column"),q=n("el-tag"),z=n("el-table"),M=n("el-empty"),k=n("el-input"),g=n("el-form-item"),y=n("el-option"),A=n("el-select"),I=n("el-form"),R=n("el-dialog"),S=J("loading");return w(),N("div",Q,[m("header",W,[l(f,{to:"/",class:"logo"},{default:a(()=>[...e[6]||(e[6]=[r("12306旅客管理系统",-1)])]),_:1}),m("nav",Y,[l(f,{to:"/ticket"},{default:a(()=>[...e[7]||(e[7]=[r("车票查询",-1)])]),_:1}),l(f,{to:"/orders"},{default:a(()=>[...e[8]||(e[8]=[r("订单管理",-1)])]),_:1})])]),m("div",Z,[m("div",ee,[e[10]||(e[10]=m("h2",null,"常用联系人",-1)),l(p,{type:"primary",onClick:B},{default:a(()=>[...e[9]||(e[9]=[r("添加旅客",-1)])]),_:1})]),X((w(),G(z,{data:V.value,stripe:""},{default:a(()=>[l(i,{prop:"name",label:"姓名"}),l(i,{prop:"idCard",label:"身份证号"}),l(i,{label:"旅客类型"},{default:a(({row:t})=>[r(h($(t.passengerType)),1)]),_:1}),l(i,{prop:"phone",label:"手机号"}),l(i,{label:"核验状态"},{default:a(({row:t})=>[l(q,{type:t.isVerified?"success":"warning"},{default:a(()=>[r(h(t.isVerified?"已核验":"待核验"),1)]),_:2},1032,["type"])]),_:1}),l(i,{label:"操作",width:"200"},{default:a(({row:t})=>[l(p,{size:"small",onClick:j=>D(t)},{default:a(()=>[...e[11]||(e[11]=[r("编辑",-1)])]),_:1},8,["onClick"]),l(p,{size:"small",type:"danger",onClick:j=>U(t)},{default:a(()=>[...e[12]||(e[12]=[r("删除",-1)])]),_:1},8,["onClick"])]),_:1})]),_:1},8,["data"])),[[S,v.value]]),V.value.length===0&&!v.value?(w(),N("div",le,[l(M,{description:"暂无旅客信息，请添加"})])):H("",!0)]),l(R,{modelValue:u.value,"onUpdate:modelValue":e[5]||(e[5]=t=>u.value=t),title:c.value?"编辑旅客":"添加旅客",width:"500px"},{footer:a(()=>[l(p,{onClick:e[4]||(e[4]=t=>u.value=!1)},{default:a(()=>[...e[13]||(e[13]=[r("取消",-1)])]),_:1}),l(p,{type:"primary",onClick:P},{default:a(()=>[...e[14]||(e[14]=[r("确定",-1)])]),_:1})]),default:a(()=>[l(I,{ref_key:"formRef",ref:T,model:s.value,rules:E,"label-width":"100px"},{default:a(()=>[l(g,{label:"姓名",prop:"name"},{default:a(()=>[l(k,{modelValue:s.value.name,"onUpdate:modelValue":e[0]||(e[0]=t=>s.value.name=t),placeholder:"请输入姓名"},null,8,["modelValue"])]),_:1}),l(g,{label:"身份证号",prop:"idCard"},{default:a(()=>[l(k,{modelValue:s.value.idCard,"onUpdate:modelValue":e[1]||(e[1]=t=>s.value.idCard=t),placeholder:"请输入身份证号",maxlength:"18"},null,8,["modelValue"])]),_:1}),l(g,{label:"旅客类型"},{default:a(()=>[l(A,{modelValue:s.value.passengerType,"onUpdate:modelValue":e[2]||(e[2]=t=>s.value.passengerType=t)},{default:a(()=>[l(y,{label:"成人",value:1}),l(y,{label:"儿童",value:2}),l(y,{label:"学生",value:3}),l(y,{label:"残疾军人",value:4})]),_:1},8,["modelValue"])]),_:1}),l(g,{label:"手机号"},{default:a(()=>[l(k,{modelValue:s.value.phone,"onUpdate:modelValue":e[3]||(e[3]=t=>s.value.phone=t),placeholder:"请输入手机号",maxlength:"11"},null,8,["modelValue"])]),_:1})]),_:1},8,["model"])]),_:1},8,["modelValue","title"])])}}}),ne=O(ae,[["__scopeId","data-v-0ab5e61f"]]);export{ne as default};
