import{c as S,u as U}from"./group-DxznlajQ.js";import{g as V}from"./gitDictData-jrP3nJ1a.js";import{d as D,V as B,r as p,u as N,ay as M,aw as O,c as A,o as L,t as z,w as r,j as l,c8 as H,c9 as K,p as m,l as n,_ as $,k as G,D as J,aA as W}from"./index-9PRMimni.js";const Q=D({__name:"ItemForm",props:{permissionList:{type:Array},isEdit:{type:Boolean,defalut:!1},resultList:{type:Array},isShowSubmit:{type:Boolean,defalut:!1}},emits:["change"],setup(k,{expose:E,emit:I}){const{t}=B(),h=I,c=k,w=p([{label:"Dry Bulk OIL",value:"248"},{label:"CHEMICALS TANKER",value:"250"}]),j=p([]),x=p([]),g=N(),v=p(null),i=p(!1),C=()=>({id:null,projectChinese:"",projectEnglish:"",exercisetype:"",exercisevesseltype:"",peroid:"",remark:"",status:"Active",aaa:""}),a=p(C()),f={status:{required:!0,message:t("drill.addPlan.rulesForStatus"),trigger:"change"},projectEnglish:{required:!0,message:t("drill.addPlan.rulesForEProject"),trigger:"blur"},projectChinese:{required:!0,message:t("drill.addPlan.rulesForCProject"),trigger:"blur"},peroid:{required:!0,message:t("drill.addPlan.rulesForPeriod"),trigger:"change"},exercisetype:{required:!0,message:t("drill.addPlan.rulesForShipType"),trigger:"change"},exercisevesseltype:{required:!0,message:t("drill.addPlan.rulesForDrillCategory"),trigger:"change"}};function T(u){u==="Temporary"?(f.peroid.required=!1,a.value.peroid=""):f.peroid.required=!0}function q(u){a.value=u,v.value?.restoreValidation()}function F(u){i.value=!0,v.value.validate(e=>{if(e)i.value=!1,g.error(t("drill.addPlan.rulesForEmpty"));else{let d=Object.assign({groupName:u.name,groupId:u.id},a.value);c.isEdit?U(a.value).then(()=>{i.value=!1,g.success(t("drill.manage.editSuccess")),_(),h("change")}).catch(()=>{i.value=!1}):S(d).then(()=>{i.value=!1,g.success(t("drill.manage.addSuccess")),_(),h("change")}).catch(()=>{i.value=!1})}})}function _(){v.value.restoreValidation(),a.value=Object.assign(a.value,C())}return M(()=>c.resultList,(u,e)=>{console.log("resultList 发生变化:",u,e)},{deep:!0}),O(async()=>{const{projectTypeList:u,getPeriodList:e}=await V();x.value=e.list,j.value=u.list,a.value={...c.resultList}}),E({submit:F,handleReset:_,setData:q}),(u,e)=>{const d=K,P=H,o=$,y=G,b=W,R=z;return L(),A(R,{model:a.value,rules:f,ref_key:"formRef",ref:v,"label-placement":"left","label-width":180,"require-mark-placement":"left"},{default:r(()=>[l(o,{label:n(t)("drill.manage.formStatus"),path:"status"},{default:r(()=>[l(P,{value:a.value.status,"onUpdate:value":e[0]||(e[0]=s=>a.value.status=s)},{default:r(()=>[l(d,{label:"Active",value:"Active"},{default:r(()=>e[8]||(e[8]=[m(" Active")])),_:1}),l(d,{label:"Inactive",value:"Inactive"},{default:r(()=>e[9]||(e[9]=[m(" Inactive")])),_:1})]),_:1},8,["value"])]),_:1},8,["label"]),l(o,{label:n(t)("drill.manage.formItemEnglish"),path:"projectEnglish"},{default:r(()=>[l(y,{placeholder:"",value:a.value.projectEnglish,"onUpdate:value":e[1]||(e[1]=s=>a.value.projectEnglish=s)},null,8,["value"])]),_:1},8,["label"]),l(o,{label:n(t)("drill.manage.formItemChinese"),path:"projectChinese"},{default:r(()=>[l(y,{placeholder:"",value:a.value.projectChinese,"onUpdate:value":e[2]||(e[2]=s=>a.value.projectChinese=s)},null,8,["value"])]),_:1},8,["label"]),l(o,{label:n(t)("drill.manage.tablePeroid"),path:"peroid"},{default:r(()=>[l(P,{value:a.value.aaa,"onUpdate:value":[e[3]||(e[3]=s=>a.value.aaa=s),T],style:{width:"40%"}},{default:r(()=>[l(d,{label:"Temporary",value:"Temporary"},{default:r(()=>e[10]||(e[10]=[m(" Temporary")])),_:1}),l(d,{label:"Annual",value:"Annual"},{default:r(()=>e[11]||(e[11]=[m(" Annual")])),_:1})]),_:1},8,["value"]),a.value.aaa==="Annual"?(L(),A(b,{key:0,style:{width:"60%"},"label-field":"value","value-field":"value",value:a.value.peroid,"onUpdate:value":e[4]||(e[4]=s=>a.value.peroid=s),options:x.value},null,8,["value","options"])):J("",!0)]),_:1},8,["label"]),l(o,{label:n(t)("drill.manage.formType"),path:"exercisevesseltype"},{default:r(()=>[l(b,{value:a.value.exercisevesseltype,"onUpdate:value":e[5]||(e[5]=s=>a.value.exercisevesseltype=s),options:w.value},null,8,["value","options"])]),_:1},8,["label"]),l(o,{label:n(t)("drill.manage.formCategory"),path:"exercisetype"},{default:r(()=>[l(b,{value:a.value.exercisetype,"onUpdate:value":e[6]||(e[6]=s=>a.value.exercisetype=s),options:j.value},null,8,["value","options"])]),_:1},8,["label"]),l(o,{label:n(t)("drill.manage.formRemark"),path:"remark"},{default:r(()=>[l(y,{value:a.value.remark,"onUpdate:value":e[7]||(e[7]=s=>a.value.remark=s),placeholder:"Textarea",type:"textarea",autosize:{minRows:3,maxRows:5}},null,8,["value"])]),_:1},8,["label"])]),_:1},8,["model"])}}});export{Q as _};
