import{d as F,i as S,D as O,o as l,a as U,w as n,c as t,f as x,M as j,G as R,H as k,E as B,J as u,n as w,m as q,L as G,T as H,B as L,U as J,V as K,q as P,j as r,k as y,b as z,x as Q,F as g,t as W,e as N,at as X,au as Y,a4 as Z,av as ee}from"./index.29cf2edd.js";/* empty css              *//* empty css              *//* empty css              *//* empty css              *//* empty css              *//* empty css              *//* empty css              *//* empty css              *//* empty css              *//* empty css              */const te=x("Cancel"),ne=x("Save"),ae=F({__name:"VisaTypeForm",props:{visible:{type:Boolean,required:!0}},emits:["change"],setup(D,{emit:v}){const c=S(),o=O({name:""}),a={name:{required:!0,message:"Please enter VISA Type Name"}},m=()=>{c.value.validateFields().then(h=>{j.confirm({title:"\u0E97\u0EC8\u0EB2\u0E99\u0E95\u0EC9\u0EAD\u0E87\u0E81\u0EB2\u0E99\u0E9A\u0EB1\u0E99\u0E97\u0EB6\u0E81\u0EC1\u0E97\u0EC9\u0E9A\u0ECD\u0EC8?",icon:t(R),content:t("div",{style:"color:red;"},"\u0E81\u0EBB\u0E94\u0E9B\u0EB8\u0EC8\u0EA1 'OK' \u0EC0\u0E9E\u0EB7\u0EC8\u0EAD\u0EA2\u0EB7\u0E99\u0EA2\u0EB1\u0E99"),onOk(){k(),B.addVisaType(o).then(async _=>{u(),b(),w.success("Successful"),v("change",!0)}).catch(_=>{u()})},onCancel(){},class:""})}).catch(h=>{})},f=()=>{v("change",!1)},b=()=>{o.name=""};return(h,_)=>{const A=q,T=G,e=H,s=L,p=J,d=K;return l(),U(d,{title:"Add New VISA Type",width:540,visible:D.visible,"body-style":{paddingBottom:"80px"},"footer-style":{textAlign:"right"},onClose:f},{extra:n(()=>[t(p,null,{default:n(()=>[t(s,{onClick:f},{default:n(()=>[te]),_:1}),t(s,{type:"primary",onClick:m},{default:n(()=>[ne]),_:1})]),_:1})]),default:n(()=>[t(e,{ref_key:"formRef",ref:c,model:o,rules:a,layout:"vertical"},{default:n(()=>[t(T,{label:"VISA Type Name",name:"name"},{default:n(()=>[t(A,{value:o.name,"onUpdate:value":_[0]||(_[0]=V=>o.name=V)},null,8,["value"])]),_:1})]),_:1},8,["model"])]),_:1},8,["visible"])}}}),oe={class:"text-right",style:{"margin-bottom":"10px"}},se=x("Add New"),ie={key:1},le=x("Save"),ue=y("a",null,"Cancel",-1),ce=["onClick"],_e=y("a",null,"Delete",-1),Be=F({__name:"VisaType",setup(D){const v=[{title:"ID",dataIndex:"id",key:"id"},{title:"Type",dataIndex:"name",key:"name"},{title:"Action",key:"action"}];let c=S();const o=S(!1),a=O({});P(()=>{m()});const m=()=>{k(),B.getVisaTypes().then(e=>{u(),c.value=e.data}).catch(e=>{u(),w.error(e.message)})},f=e=>{a[e]=X(c.value.filter(s=>e===s.id)[0])},b=async e=>{const s={id:e,name:a[e].name};k(),await B.updateVisaType(s).then(p=>{u(),w.success("Saved"),Object.assign(c.value.filter(d=>e===d.id)[0],a[e]),delete a[e]}).catch(p=>{u()})},h=e=>{delete a[e]},_=async e=>{k(),await B.deleteVisaType(e).then(s=>{u(),m()}).catch(s=>{u()})},A=()=>{o.value=!0},T=e=>{o.value=!1,e&&m()};return(e,s)=>{const p=L,d=q,V=Y,$=Z,I=ee,M=Q;return l(),r("div",null,[y("div",oe,[t(p,{type:"primary",onClick:A},{default:n(()=>[se]),_:1})]),t(M,{columns:v,"data-source":z(c)},{bodyCell:n(({column:C,text:re,record:i})=>[C.key==="name"?(l(),r(g,{key:0},[a[i.id]?(l(),U(d,{key:0,value:a[i.id][C.dataIndex],"onUpdate:value":E=>a[i.id][C.dataIndex]=E,style:{margin:"-5px 0"}},null,8,["value","onUpdate:value"])):(l(),r("span",ie,W(i.name),1))],64)):N("",!0),C.key==="action"?(l(),r(g,{key:1},[a[i.id]?(l(),r(g,{key:0},[t(V,{onClick:E=>b(i.id)},{default:n(()=>[le]),_:2},1032,["onClick"]),t($,{type:"vertical"}),t(I,{title:"Sure to cancel?",onConfirm:E=>h(i.id)},{default:n(()=>[ue]),_:2},1032,["onConfirm"])],64)):(l(),r(g,{key:1},[y("span",null,[y("a",{onClick:E=>f(i.id)},"Edit",8,ce)]),t($,{type:"vertical"}),t(I,{title:"Sure to delete?",onConfirm:E=>_(i.id)},{default:n(()=>[_e]),_:2},1032,["onConfirm"])],64))],64)):N("",!0)]),_:1},8,["data-source"]),t(ae,{visible:o.value,onChange:T},null,8,["visible"])])}}});export{Be as default};
