import{u as S}from"./useInstance.233fbdde.js";import{A as q}from"./index.1d26a072.js";import{az as i,aa as g,d as z,a6 as P,r as B,b as j,p as E,c as d,e as c,k as x,i as s,h as o,u,A as v,f as I,j as O,F as R,a2 as T,m as C,E as _}from"./index.0308b213.js";const le=e=>i.get("addon/mealbox.meal_box/list",{params:e}),G=e=>i.get(`addon/mealbox.meal_box/detail?id=${e}`),H=e=>i.post("addon/mealbox.meal_box/add",e),J=e=>i.post("addon/mealbox.meal_box/edit",e),ue=e=>i.post("addon/mealbox.meal_box/delete",{id:e}),K=e=>i.get("addon/mealbox.meal_box/selectArea",{params:e}),oe=e=>i.post("addon/mealbox.meal_box/submit",{boxs:e}),ne=e=>g.get("agent/plugin.mealbox.meal_box/list",{params:e}),Q=e=>g.get(`agent/plugin.mealbox.meal_box/detail?id=${e}`),W=e=>g.post("agent/plugin.mealbox.meal_box/add",e),X=e=>g.post("agent/plugin.mealbox.meal_box/edit",e),se=e=>g.post("agent/plugin.mealbox.meal_box/delete",{id:e}),Y=C("\u63D0\u4EA4"),Z=C("\u53D6\u6D88"),de=z({props:{modelValue:{type:Boolean,default:!1},id:{default:0},isBatchSubmit:{type:Boolean,default:!1},areas:{default:[]}},emits:["update:modelValue","onClose"],setup(e,{emit:V}){const f=e,{global:h}=S(),{OpPlatform:b}=P(),A=B(!1),y=B();let a=j({id:0,name:"",agentid:"",status:0,area_ids:[],num:0});const F=B([]),M=n=>{b.value==="agent"?Q(n).then(t=>{a.name=t.data.name,a.agentid=t.data.agentid,a.status=t.data.status,a.area_ids=t.data.area_ids.map(p=>Number(p))}):G(n).then(t=>{a.name=t.data.name,a.agentid=t.data.agentid,a.status=t.data.status,a.area_ids=t.data.area_ids.map(p=>Number(p))})};E(()=>f.modelValue,n=>{A.value=n});const k=n=>{K({agentid:n}).then(t=>{F.value=t.areas})},w=()=>{a.id>0?b.value==="agent"?X(a).then(()=>{_({message:"\u4FEE\u6539\u9910\u76D2\u6570\u636E\u6210\u529F",type:"success"}),m()}):J(a).then(()=>{_({message:"\u4FEE\u6539\u9910\u76D2\u6570\u636E\u6210\u529F",type:"success"}),m()}):b.value==="agent"?W(a).then(()=>{_({message:"\u65B0\u589E\u9910\u76D2\u6570\u636E\u6210\u529F",type:"success"}),m()}):H(a).then(()=>{_({message:"\u65B0\u589E\u9910\u76D2\u6570\u636E\u6210\u529F",type:"success"}),m()})};E(()=>f.id,n=>{a.id=n,F.value=f.areas,n&&M(n)},{immediate:!0});const m=()=>{V("update:modelValue",!1),V("onClose"),h.$resetForm(y.value,a)};return(n,t)=>{const p=d("el-input"),r=d("el-form-item"),U=d("el-switch"),N=d("el-option"),L=d("el-select"),D=d("el-button"),$=d("el-dialog");return c(),x($,{modelValue:A.value,"onUpdate:modelValue":t[5]||(t[5]=l=>A.value=l),title:e.id?"\u7F16\u8F91\u9910\u76D2":"\u65B0\u589E\u9910\u76D2",width:"50%",onClose:m},{default:s(()=>[o(u(T),{model:u(a),"label-width":"120px"},{default:s(()=>[e.isBatchSubmit?(c(),x(r,{key:0,label:"\u6279\u91CF\u6DFB\u52A0\u6570\u91CF"},{default:s(()=>[o(p,{modelValue:u(a).num,"onUpdate:modelValue":t[0]||(t[0]=l=>u(a).num=l),placeholder:"\u8BF7\u8F93\u5165\u6279\u91CF\u6DFB\u52A0\u6570\u91CF"},null,8,["modelValue"])]),_:1})):v("",!0),u(b)==="shangpu"?(c(),x(r,{key:1,class:"tn-el-form-item",label:"\u4EE3\u7406\u533A\u57DF"},{default:s(()=>[o(u(q),{modelValue:u(a).agentid,"onUpdate:modelValue":t[1]||(t[1]=l=>u(a).agentid=l),onChange:k},null,8,["modelValue"])]),_:1})):v("",!0),o(r,{label:"\u9910\u76D2\u540D\u79F0"},{default:s(()=>[o(p,{modelValue:u(a).name,"onUpdate:modelValue":t[2]||(t[2]=l=>u(a).name=l),placeholder:"\u8BF7\u8F93\u5165\u533A\u57DF\u540D\u79F0"},null,8,["modelValue"])]),_:1}),o(r,{label:"\u72B6\u6001"},{default:s(()=>[o(U,{modelValue:u(a).status,"onUpdate:modelValue":t[3]||(t[3]=l=>u(a).status=l),size:"large",width:60,"inline-prompt":"","active-text":"\u5F00\u542F","inactive-text":"\u5173\u95ED","active-color":"#00C5A1","active-value":1,"inactive-value":0},null,8,["modelValue"])]),_:1}),o(r,{label:"\u533A\u57DF"},{default:s(()=>[o(L,{modelValue:u(a).area_ids,"onUpdate:modelValue":t[4]||(t[4]=l=>u(a).area_ids=l),multiple:"",placeholder:"\u8BF7\u9009\u62E9\u533A\u57DF",clearable:"",filterable:""},{default:s(()=>[(c(!0),I(R,null,O(F.value,l=>(c(),x(N,{key:l.id,label:l.name,value:l.id},null,8,["label","value"]))),128))]),_:1},8,["modelValue"])]),_:1}),o(r,null,{default:s(()=>[o(D,{type:"primary",onClick:w},{default:s(()=>[Y]),_:1}),o(D,{onClick:m},{default:s(()=>[Z]),_:1})]),_:1})]),_:1},8,["model"])]),_:1},8,["modelValue","title"])}}});export{de as _,le as a,ue as b,se as d,ne as g,oe as s};
