import{u as I,_ as B,d as E,e as h,w as t,g as a,c as M,h as D,b as _,i as g,t as v,j as T,F as A,a0 as P,k as U,J as V,m as H,o as F}from"./app-D7zH3Nl5.js";import{a as N,s as W}from"./apiAdmin-B6-2qm0d.js";import{F as q}from"./FormItemHeading-SJw_nlda.js";import{I as L}from"./index-Cu62pBdq.js";import{B as j}from"./useFlexGapSupport-CpBR-RD-.js";import{_ as J,F as R}from"./index-DZxk72Vu.js";import{S as z}from"./index-_ApNSgqk.js";import{S as G}from"./SaveOutlined-jkHaLNj1.js";import{M as K}from"./MinusCircleOutlined-X8B-rVd0.js";import{P as Q}from"./index-BUzTR6QN.js";import{f as X}from"./filter-BbCbC1s7.js";import{_ as Y,a as Z}from"./index-Cv7zOydE.js";import{_ as x}from"./index-BivgQiQE.js";const _e=()=>{const e="indicators?fields=id,xid,name,fields",o="indicators",{t:n}=I(),c={name:"",fields:[]},p=[{title:n("indicator.name"),dataIndex:"name"},{title:n("indicator.fields"),dataIndex:"fields"},{title:n("common.action"),dataIndex:"action"}],i=[{key:"name",value:n("indicator.name")}];return{url:e,addEditUrl:o,initData:c,columns:p,filterableColumns:i}},ee=E({props:["formData","data","visible","url","addEditType","pageTitle","successMessage"],components:{PlusOutlined:Q,MinusCircleOutlined:K,LoadingOutlined:P,SaveOutlined:G,FormItemHeading:q},setup(e,{emit:o}){const n=U([{name:"",id:""}]),{addEditRequestAdmin:c,loading:p,rules:i}=N(),f=s=>{let l=n.value.indexOf(s);l!==-1&&n.value.splice(l,1)},r=()=>{n.value.push({name:"",id:""})},d=()=>{const s=X(n.value,l=>l.name!="");c({url:e.url,data:{...e.formData,fields:s},successMessage:e.successMessage,success:l=>{o("addEditSuccess",l.xid)}})},m=()=>{i.value={},o("closed")},C=V(()=>n.value.length==0?!1:W(n.value,{name:""}));return H(()=>e.visible,(s,l)=>{n.value=[],e.addEditType=="edit"&&s?n.value=e.data.fields:n.value=[]}),{loading:p,rules:i,onClose:m,onSubmit:d,indicators:n,removeFormField:f,addFormField:r,addFormButtonStatus:C,drawerWidth:window.innerWidth<=991?"90%":"45%"}}});function ae(e,o,n,c,p,i){const f=L,r=J,d=Z,m=Y,C=_("FormItemHeading"),s=_("MinusCircleOutlined"),l=_("PlusOutlined"),k=j,y=R,S=_("SaveOutlined"),$=z,w=x;return F(),h(w,{title:e.pageTitle,width:e.drawerWidth,open:e.visible,"body-style":{paddingBottom:"80px"},"footer-style":{textAlign:"right"},maskClosable:!1,onClose:e.onClose},{footer:t(()=>[a($,null,{default:t(()=>[a(k,{key:"submit",type:"primary",loading:e.loading,onClick:e.onSubmit},{icon:t(()=>[a(S)]),default:t(()=>[g(" "+v(e.addEditType=="add"?e.$t("common.create"):e.$t("common.update")),1)]),_:1},8,["loading","onClick"]),a(k,{key:"back",onClick:e.onClose},{default:t(()=>[g(v(e.$t("common.cancel")),1)]),_:1},8,["onClick"])]),_:1})]),default:t(()=>[a(y,{layout:"vertical"},{default:t(()=>[a(m,{gutter:16},{default:t(()=>[a(d,{xs:24,sm:24,md:24,lg:24},{default:t(()=>[a(r,{label:e.$t("indicator.name"),name:"name",help:e.rules.name?e.rules.name.message:null,validateStatus:e.rules.name?"error":null,class:"required"},{default:t(()=>[a(f,{value:e.formData.name,"onUpdate:value":o[0]||(o[0]=u=>e.formData.name=u),placeholder:e.$t("common.placeholder_default_text",[e.$t("indicator.name")])},null,8,["value","placeholder"])]),_:1},8,["label","help","validateStatus"])]),_:1})]),_:1}),a(C,null,{default:t(()=>[g(v(e.$t("indicator.fields")),1)]),_:1}),e.indicators.length>0?(F(!0),M(A,{key:0},T(e.indicators,(u,O)=>(F(),h(m,{gutter:16,key:u.id},{default:t(()=>[a(d,{xs:24,sm:24,md:22,lg:22},{default:t(()=>[a(r,{name:["fields",O,"name"]},{default:t(()=>[a(f,{value:u.name,"onUpdate:value":b=>u.name=b,placeholder:e.$t("indicator.fields")},null,8,["value","onUpdate:value","placeholder"])]),_:2},1032,["name"])]),_:2},1024),a(d,{span:2},{default:t(()=>[a(s,{onClick:o[1]||(o[1]=b=>e.removeFormField(e.field))})]),_:1})]),_:2},1024))),128)):D("",!0),a(m,{gutter:16},{default:t(()=>[a(d,{xs:24,sm:24,md:24,lg:24},{default:t(()=>[a(r,null,{default:t(()=>[a(k,{type:"dashed",block:"",onClick:e.addFormField,disabled:e.addFormButtonStatus},{default:t(()=>[a(l),g(" "+v(e.$t("indicator.fields")),1)]),_:1},8,["onClick","disabled"])]),_:1})]),_:1})]),_:1})]),_:1})]),_:1},8,["title","width","open","onClose"])}const ge=B(ee,[["render",ae]]);export{ge as A,_e as f};
