import{d as x,h as m,ab as f,Y as U,r as s,o as V,f as v,w as u,b as l,H as L,a2 as P,l as g,E as w}from"./index.e3896b23.js";import{u as h,a as q}from"./catalogue.ebcb043b.js";const R=g("\u53D6\u6D88"),$=g("\u786E\u5B9A"),K=x({__name:"catalogue-add-or-update",emits:["refreshDataList"],setup(j,{expose:C,emit:E}){const i=m(!1),d=m(),b=f("editorValues"),D=f("editableTabs"),_=f("currentNodeData"),e=U({parentId:"",parentPath:"",path:"",name:"",taskType:"",orderNo:0,ifLeaf:1,description:""}),A=(n,t,r,o)=>{i.value=!0,d.value&&d.value.resetFields(),e.id="",d.value&&d.value.resetFields(),e.parentId=t,e.parentPath=r,e.ifLeaf=o,n&&k(n)},k=n=>{h(n).then(t=>{Object.assign(e,t.data)})},y=m({name:[{required:!0,message:"\u5FC5\u586B\u9879\u4E0D\u80FD\u4E3A\u7A7A",trigger:"blur"}],taskType:[{required:!0,message:"\u5FC5\u586B\u9879\u4E0D\u80FD\u4E3A\u7A7A",trigger:"blur"}],orderNo:[{required:!0,message:"\u5FC5\u586B\u9879\u4E0D\u80FD\u4E3A\u7A7A",trigger:"blur"}]}),c=()=>{d.value.validate(n=>{if(!n)return!1;q(e).then(()=>{if(e.id){let t=e.id+"";if(b[t]){b[t].nodeData=e,_.value.id==e.id&&(_.value=e);const r=D.value;for(let o in r){let p=r[o];if(p.name==t){p.title=e.name;break}}}}w.success({message:"\u64CD\u4F5C\u6210\u529F",duration:500,onClose:()=>{i.value=!1,E("refreshDataList")}})})})};return C({init:A}),(n,t)=>{const r=s("el-input"),o=s("el-form-item"),p=s("fast-select"),B=s("el-input-number"),N=s("el-form"),F=s("el-button"),T=s("el-dialog");return V(),v(T,{modelValue:i.value,"onUpdate:modelValue":t[8]||(t[8]=a=>i.value=a),title:e.id?"\u4FEE\u6539":"\u65B0\u589E","close-on-click-modal":!1},{footer:u(()=>[l(F,{onClick:t[6]||(t[6]=a=>i.value=!1)},{default:u(()=>[R]),_:1}),l(F,{type:"primary",onClick:t[7]||(t[7]=a=>c())},{default:u(()=>[$]),_:1})]),default:u(()=>[l(N,{ref_key:"dataFormRef",ref:d,model:e,rules:y.value,"label-width":"100px",onKeyup:t[5]||(t[5]=P(a=>c(),["enter"]))},{default:u(()=>[l(o,{label:"\u7236\u7EA7\u76EE\u5F55",prop:"parentPath"},{default:u(()=>[l(r,{disabled:"",modelValue:e.parentPath,"onUpdate:modelValue":t[0]||(t[0]=a=>e.parentPath=a),placeholder:""},null,8,["modelValue"])]),_:1}),l(o,{label:"\u540D\u79F0",prop:"name"},{default:u(()=>[l(r,{modelValue:e.name,"onUpdate:modelValue":t[1]||(t[1]=a=>e.name=a),placeholder:"\u540D\u79F0"},null,8,["modelValue"])]),_:1}),e.ifLeaf?L("",!0):(V(),v(o,{key:0,label:"\u4F5C\u4E1A\u7C7B\u578B",prop:"taskType"},{default:u(()=>[l(p,{disabled:!!e.id,modelValue:e.taskType,"onUpdate:modelValue":t[2]||(t[2]=a=>e.taskType=a),placeholder:"\u4F5C\u4E1A\u7C7B\u578B","dict-type":"production_task_type",clearable:""},null,8,["disabled","modelValue"])]),_:1})),l(o,{label:"\u5E8F\u53F7",prop:"orderNo"},{default:u(()=>[l(B,{modelValue:e.orderNo,"onUpdate:modelValue":t[3]||(t[3]=a=>e.orderNo=a),max:9999,placeholder:"\u5E8F\u53F7"},null,8,["modelValue"])]),_:1}),l(o,{label:"\u63CF\u8FF0",prop:"description"},{default:u(()=>[l(r,{type:"textarea",modelValue:e.description,"onUpdate:modelValue":t[4]||(t[4]=a=>e.description=a)},null,8,["modelValue"])]),_:1})]),_:1},8,["model","rules"])]),_:1},8,["modelValue","title"])}}});export{K as _};
