import{a as V,E as q,b as te}from"./element-plus-53a783a7.js";import"./vue-20eed888.js";import{u as ae}from"./index-03a63030.js";import{u as le}from"./vue-i18n-d6e8419a.js";import{d as re,G as ie,r as m,k as r,ah as v,ai as I,o as w,c as se,e as F,P as x,b as L,u as b,L as A,a as C,U as E,S as R,i as oe,F as ne}from"./@vue-e95c845e.js";import{_ as pe}from"./y9plugin-components-412bad23.js";const ue=re({__name:"parameterTable",props:{parameterStatus:{type:String,default:()=>"3"},data:{type:Array,default:()=>[]},isView:{type:Boolean,default:()=>!1}},setup(z,{expose:O}){const S=ie("sizeObjInfo"),M=ae(),{t:a}=le(),N=m({}),P=m(),g=m(!1),T=m([]),c=z;let h=1e4,d=m({rowKey:"id",headerBackground:!0,pageConfig:!1,border:!0,defaultExpandAll:!0,height:"200px",columns:[{type:"selection",width:60},{type:"index",title:r(()=>a("序号")),width:80,fixed:"left"},{title:r(()=>a("参数key")),width:180,key:"parameterKey",render:e=>JSON.parse(e.isItems)?v("span",{class:"isItems"},e.parameterKey):e.parameterKey},{title:r(()=>a("层级")),key:"level",render:e=>v("span",X(e.level)+"级")},{title:r(()=>a("参数类型")),key:"parameterType"},{title:r(()=>a("是否必填")),key:"required"},{title:r(()=>a("参数描述")),key:"notes"},{title:r(()=>a("操作")),width:150,fixed:"right",render:e=>v("div",j(e))}],tableData:c.data});function j(e){let t=[],l=v("span",{onClick:()=>{H(e)}},a("详情")),o=v("span",{class:"leftMargin",onClick:()=>{G(e)}},a("添加")),i=v("span",{class:"leftMargin",onClick:()=>{W(e)}},a("编辑")),f=v("span",{class:"leftMargin",onClick:()=>{Q(e.id)}},a("删除"));return c.isView?(t.push(l),t.push(i),e.parameterType=="map"&&t.push(o),e.isItems!=null&&e.isItems||t.push(f)):t.push(l),t}const U=m({filtersValueCallBack:e=>{N.value=e},itemList:[{type:"slot",slotName:"slotBtns",span:(M.device==="mobile",24),justify:"flex-end"}],showBorder:!0}),B=m();let u=m({show:!1,title:r(()=>a("新增参数")),showFooter:!0,onOkLoading:!0,onOk:e=>new Promise(async(t,l)=>{var i;await((i=B.value)==null?void 0:i.elFormRef).validate(async f=>{let s=B.value.model;if(f){if(s.pid!="0"){let y=[];for(let p of d.value.tableData)p.children instanceof Array&&k(p.children,y),y.push(p);for(let p of y)if(g.value){if(p.id==s.id){K(p,s);break}}else if(p.id==s.pid){p.children||(p.children=[]),s.parameterType=="array"&&(s.children=[{id:h++,pid:s.id,parameterType:"String",parameterStatus:c.parameterStatus,parameterKey:"items",required:"否",isItems:!0,level:s.level+1}]),p.children.push(s);break}t()}else if(g.value){let y=[];for(let p of d.value.tableData)p.children instanceof Array&&k(p.children,y),y.push(p);for(let p of y)if(p.id==s.id){K(p,s);break}t()}else s.parameterType=="array"&&(s.children=[{id:h++,pid:s.id,parameterType:"String",parameterStatus:c.parameterStatus,parameterKey:"items",required:"否",isItems:!0,level:s.level+1}]),d.value.tableData.push(s),t();l()}else l()})})}),n=m({model:{},rules:{parameterKey:[{required:!0,message:r(()=>a("参数key不能为空")),trigger:"blur"}],parameterType:[{required:!0,message:r(()=>a("字段类型不能为空")),trigger:"blur"}],required:[{required:!0,message:r(()=>a("是否必填不能为空")),trigger:"blur"}],pid:[{required:!0,message:r(()=>a("父级不能不选择")),trigger:"blur"}]},itemList:[{type:"input",label:r(()=>a("参数key")),prop:"parameterKey"},{type:"select",label:r(()=>a("字段类型")),prop:"parameterType",props:{options:[{label:r(()=>a("String")),value:"String"},{label:r(()=>a("integer")),value:"integer"},{label:r(()=>a("boolean")),value:"boolean"},{label:r(()=>a("double")),value:"double"},{label:r(()=>a("array")),value:"array"},{label:r(()=>a("map")),value:"map"},{label:r(()=>a("number")),value:"number"}],events:{change:e=>{n.value.model.parameterType!=null&&(n.value.model.parameterType=="map"||n.value.model.parameterType=="array")&&V.alert('参数类型由"'+n.value.model.parameterType+'"变更为"'+e+'"将会覆盖子级节点数据',"参数类型变更确认",{confirmButtonText:"确认"})}}}},{type:"select",label:r(()=>a("是否必填")),prop:"required",props:{options:[{label:r(()=>a("是")),value:"是"},{label:r(()=>a("否")),value:"否"}]}},{type:"input",label:r(()=>a("参数描述")),prop:"notes"}],descriptionsFormConfig:{labelWidth:"200px",labelAlign:"center"}});function D(e,t){let l={type:"select",label:r(()=>a("选择父级")),prop:"pid",props:{options:[{label:r(()=>a("本级")),value:"0"}],disabled:!0}},o=[];for(let i of d.value.tableData)i.children instanceof Array&&k(i.children,o),o.push(i);for(let i of o)if(i.id!=n.value.model.id){let f={label:r(()=>a(i.parameterKey)),value:i.id};l.props.options.push(f)}if(n.value.itemList[0].prop=="pid"?n.value.itemList[0].props.options=l.props.options:n.value.itemList.unshift(l),e=="")for(let i of n.value.itemList)i.prop!="pid"&&(i.props==null?i.props={disabled:!1}:i.props.disabled=!1);else for(let i of n.value.itemList)i.props==null?i.props={disabled:!0}:i.props.disabled=!0}function k(e,t){if(e!=null){let l=1;for(let o of e)o.children instanceof Array&&k(o.children,t),o.sort=l,l++,t.push(o)}}let J=0;function $(){g.value=!1,u.value.show=!0,n.value.model={pid:"0",id:h++,isItems:!1,parameterStatus:c.parameterStatus,level:1,sort:++J},D("");for(let e of n.value.itemList)e.prop!="pid"&&(e.props==null?e.props={disabled:!1}:e.props.disabled=!1),e.prop=="pid"&&(e.props==null?e.props={disabled:!0}:e.props.disabled=!0);u.value.okText="保存",u.value.title=r(()=>a("新增参数信息"))}const G=e=>{g.value=!1,u.value.show=!0,n.value.model={pid:e.id,id:h++,isItems:!1,parameterStatus:c.parameterStatus,level:e.level+1},u.value.okText="保存",u.value.title=r(()=>a("新增参数信息")),D("")};function W(e){if(g.value=!0,n.value.model=e,D(""),u.value.okText="保存",u.value.title=r(()=>a("编辑权限信息")),e.isItems)for(let t of n.value.itemList)t.prop=="parameterKey"&&(t.props==null?t.props={disabled:!0}:t.props.disabled=!0);u.value.show=!0}async function H(e){n.value.model=e,D(e.id),u.value.okText=!1,u.value.title=r(()=>a("查看权限信息")),u.value.show=!0}async function Q(e){V.confirm("是否确认删除这条数据,删除会同步删除该节点下的所有数据","删除数据确认",{confirmButtonText:"确定",cancelButtonText:"取消",type:"info",draggable:!0}).then(()=>{let t=0;for(let l of d.value.tableData){if(l.id==e){d.value.tableData.splice(t,1);break}l.children&&_(l.children,e),t++}}).catch(()=>{q({type:"info",message:"删除取消"})})}const _=(e,t)=>{let l=0;for(let o of e){if(o.id==t){e.splice(l,1);break}o.children&&_(o.children,t),l++}},K=(e,t)=>{let l=!1,o=!1,i=!1,f=!1;e.parameterType=="array"&&(i=!0),t.parameterType=="array"&&(f=!0),e.parameterType=="map"&&(l=!0),l&&t.parameterType!="map"&&(o=!0);for(let s in e)e[s]=t[s];o&&(e.children=[]),i?f||(e.children=[]):f&&(e.children=[{id:h++,pid:t.id,parameterType:"String",parameterStatus:c.parameterStatus,parameterKey:"items",required:"否",isItems:!0,level:e.level+1}])};function X(e){switch(e){case 1:return"一";case 2:return"二";case 3:return"三";case 4:return"四";case 5:return"五";case 6:return"六";case 7:return"七";case 8:return"八";case 9:return"九";case 10:return"十";default:return"十一"}}const Y=()=>{d.value.tableData=[]},Z=()=>{let e=[],t=1;for(let l of d.value.tableData)l.children instanceof Array&&k(l.children,e),l.sort=t,t++;return d.value.tableData},ee=()=>{if(T.value.length==0){q({type:"warning",message:"未选择数据,无法删除"});return}for(let e of T.value){let t=0;for(let l of d.value.tableData){if(l.id==e.id){d.value.tableData.splice(t,1);break}l.children&&_(l.children,e.id),t++}}};return O({resetTable:Y,getTableData:Z}),(e,t)=>{const l=te,o=I("y9Table"),i=I("y9Form"),f=I("y9Dialog");return w(),se(ne,null,[F(o,{config:b(d),filterConfig:U.value,selectedVal:T.value,"onUpdate:selectedVal":t[1]||(t[1]=s=>T.value=s),ref_key:"filterRef",ref:P},{slotBtns:x(()=>[c.isView?(w(),L(l,{key:0,size:b(S).buttonSize,style:A({fontSize:b(S).baseFontSize}),class:"global-btn-main",type:"primary",onClick:$},{default:x(()=>[t[3]||(t[3]=C("i",{class:"ri-add-line"},null,-1)),C("span",null,E(e.$t("新增")),1)]),_:1},8,["size","style"])):R("",!0),z.isView?(w(),L(l,{key:1,size:b(S).buttonSize,style:A({fontSize:b(S).baseFontSize}),class:"el-button el-button--default global-btn-third",onClick:t[0]||(t[0]=s=>ee())},{default:x(()=>[t[4]||(t[4]=C("i",{class:"ri-delete-bin-line"},null,-1)),C("span",null,E(e.$t("删除")),1)]),_:1},8,["size","style"])):R("",!0)]),_:1},8,["config","filterConfig","selectedVal"]),F(f,{config:b(u),"onUpdate:config":t[2]||(t[2]=s=>oe(u)?u.value=s:u=s)},{default:x(()=>[F(i,{ref_key:"ruleFormRef",ref:B,config:b(n)},null,8,["config"])]),_:1},8,["config"])],64)}}});const be=pe(ue,[["__file","E:/workSpaceJDK11/y9-interface-platform/y9vue-interfacePlatform/src/views/parameter/parameterTable.vue"]]);export{be as p};