import{d as A,gF as G,gG as X,V as Y,b as H,r as n,ay as J,c as _,o as i,X as K,w as c,j as u,h as b,a9 as w,M as Q,i as P,A as V,F as D,aG as M,D as Z,p as ee,U as te,N as se,l as ae,h3 as le,E as oe,dg as ne,ac as re}from"./index-9PRMimni.js";import{U as E}from"./util-CWVrglD_.js";import{b as ie}from"./plan-n8bSdRD5.js";const ce={class:"bg-sky-50 h-9 leading-9 border-solid border border-sky-100 text-center"},de=["type","onClick","onContextmenu"],ge=A({__name:"vesselDasbord",props:{modelValue:{type:Object,default:()=>({shipId:"",years:[]})},modelModifiers:{}},emits:G(["itemClicked","rightClickSelect","getButtonPermissions"],["update:modelValue"]),setup(F,{expose:B,emit:O}){const N=X(F,"modelValue");B({initData:x});const f=O,{t:h}=Y(),g=H(),o=n([{label:h("hsqe.planner.assignedReport"),key:"assignedReport",disabled:!1},{label:h("hsqe.planner.edit"),key:"edit",disabled:!1},{label:"Delete",key:"delete",disabled:!1},{label:"Log",key:"auditLog",disabled:!1}]),k=new Date().getMonth(),p=n(!1),y=n(0),m=n(0),v=n([]),R=n([]),C=n({id:null,name:"",status:"",exerciseMonth:"",exerciseCycle:"",exerciseYears:null,exerciseType:null});J(()=>N,t=>{x(t.value)},{deep:!0});function I(t){if(t){const s=E.getPlannerStateWithValue(t).backgroundColor,l=E.getPlannerStateWithValue(t).color;return{"background-color":s,"font-family":"PingFang SC, PingFang SC","border-color":`${l} !important`,color:l}}else return{"background-color":"#4C6DDE","font-family":"PingFang SC, PingFang SC",color:"red"}}function L(){return{"background-color":"rgba(239, 242, 251, 1)"}}async function x(t){try{const s=await ie(t);R.value=s.data,f("getButtonPermissions",s.buttonPermissions,s.singleVesselId,s.singleVesselStatus||""),v.value=s.data.map((e,a)=>({...e,value:a+1,isPastOrCurrent:a+1<=k,isCurrentMonth:a+1===k+1}));let l=g.info.roles;o[0].disabled=s.singleVesselStatus!=="1003"||l.indexOf("captain")===-1,console.log("人:",g.info.roles)}catch(s){console.error("获取计划列表失败:",s)}}function U(t){f("itemClicked",t)}function $(t){f("rightClickSelect",t,C.value)}function T(t,s){C.value=s;let l=g.info.roles;switch(s.status){case"1001":o.value.forEach((e,a)=>{e.key==="delete"?e.disabled=!1:e.disabled=!0});break;case"1002":o.value.forEach((e,a)=>{e.disabled=!0});break;case"1003":o.value.forEach((e,a)=>{e.key==="delete"?e.disabled=!0:e.key==="assignedReport"||e.key==="edit"?l.indexOf("captain")!==-1||l.indexOf("chief_officer")!==-1?e.disabled=!1:e.disabled=!0:e.disabled=!1});break;case"1005":o.value.forEach((e,a)=>{e.key==="delete"||e.key==="edit"?e.disabled=!0:e.disabled=!1});break;case"1004":o.value.forEach((e,a)=>{e.key==="delete"||e.key==="edit"?e.disabled=!0:e.disabled=!1})}t.preventDefault(),p.value=!1,re().then(()=>{p.value=!0,y.value=t.clientX,m.value=t.clientY})}function W(){p.value=!1}return(t,s)=>{const l=se,e=Q,a=te,j=ne,q=K;return i(),_(q,null,{default:c(()=>[u(a,{cols:"12","x-gap":12,class:"tableCenter h-[60vh] overflow-y-auto scrollbar-hide"},{default:c(()=>[(i(!0),b(D,null,w(v.value,d=>(i(),_(e,{key:d.value,span:"1"},{default:c(()=>[P("div",{style:M(L()),class:oe([d.isCurrentMonth?"bg-sky-100":"","h-full cursor-pointer"])},[P("div",ce,V(d.month),1),(i(!0),b(D,null,w(d.list,(r,z)=>(i(),b("div",{key:`${d.value}-${z}`,type:r.type,onClick:S=>U(r),class:"mt-4 border-t-2 border-solid border-inherit px-2 py-2",style:M(I(r.status)),onContextmenu:S=>T(S,r)},[r.status===5?(i(),_(a,{key:0,"x-gap":"12",cols:1},{default:c(()=>[u(e,{span:"1"},{default:c(()=>[u(l,{class:"text-center ml-6"},{default:c(()=>[u(ae(le))]),_:1})]),_:1})]),_:1})):Z("",!0),ee(" "+V(r.name),1)],44,de))),128))],6)]),_:2},1024))),128))]),_:1}),u(j,{placement:"bottom-start",onSelect:$,trigger:"manual",x:y.value,y:m.value,options:o.value,show:p.value,"on-clickoutside":W},null,8,["x","y","options","show"])]),_:1})}}});export{ge as _};
