import{d as b,k as O,v as C,o as c,c as f,a as l,b as h,u as i,x as j,F as B,h as N,t as D,A as y,X as U,z as _,a0 as V}from"./vue.1703796278973.js";import{M as u,a9 as A,a5 as F,aL as J,W as z}from"./index.17037962789732.js";import"./index.170379627897337.js";import"./index.170379627897315.js";import"./index.1703796278973304.js";import"./index.170379627897316.js";import"./index.170379627897317.js";import{c as E,d as G,s as I,e as P,f as W}from"./apply.1703796278973.js";import{h as X,G as q}from"./system.1703796278973.js";const H={style:{margin:"20px 0 0 0"}},se=b({__name:"MenuDialog",props:{mode:null,visible:{type:Boolean},id:null,provider:null},emits:["update:visible"],setup(v,{emit:p}){const r=v,k=X(),d=O(!1),g=()=>{const n=m(e.menuTree,[...e.checkedMenu,...e.half]);e.checkedSystem?n&&n.length!==0?(d.value=!0,I("iot",e.id,n).then(t=>{t.status===200&&(u.success("操作成功"),p("update:visible",!1))}).finally(()=>d.value=!1)):u.warning("请勾选配置菜单"):u.warning("请选择所属系统")},x=()=>{r.mode==="add"&&k.jumpPage("system/Apply/Save",{},{id:e.id}),p("update:visible",!1)},e=C({id:r.id,checkedSystem:void 0,checkedMenu:[],expandedKeys:[],half:[],provider:r.provider,systemList:[],menuTree:[]});r.id&&(T(),S());function M(n){(e.provider==="internal-standalone"?P(e.id,n):W(n)).then(a=>{e.menuTree=a.result,e.expandedKeys=a.result.map(o=>o.id)})}function S(){const n={terms:[{column:"appId",value:e.id}]};q(n).then(t=>{if(t.status===200){e.menuTree=t.result;const a=t.result.map(o=>o.id);e.expandedKeys=a,e.checkedMenu=a}})}function T(){(e.provider==="internal-standalone"?E(e.id,["iot"]):G(["iot"])).then(t=>{t.status===200&&(e.systemList=t.result.map(a=>({label:a,value:a})))})}function w(n,t){e.checkedMenu=n,e.half=t.halfCheckedKeys}function m(n,t){return n!=null&&n.length?n.filter(a=>t.indexOf(a.id)<=-1?!1:(a.children=m(a.children,t),!0)):n}return(n,t)=>{const a=A,o=F,K=J,L=z;return c(),f(L,{visible:"",title:"集成菜单",width:"600px",onOk:g,onCancel:x,class:"edit-dialog-container",confirmLoading:i(d)},{default:l(()=>[h(o,{value:i(e).checkedSystem,"onUpdate:value":t[0]||(t[0]=s=>i(e).checkedSystem=s),onChange:t[1]||(t[1]=s=>s&&M(s)),style:{width:"200px"},placeholder:"请选择集成系统"},{default:l(()=>[(c(!0),j(B,null,N(i(e).systemList,s=>(c(),f(a,{value:s.value},{default:l(()=>[D(y(s.label),1)]),_:2},1032,["value"]))),256))]),_:1},8,["value"]),U(_("p",H," 当前集成菜单 ",512),[[V,i(e).menuTree.length>0]]),h(K,{checkedKeys:i(e).checkedMenu,"onUpdate:checkedKeys":t[2]||(t[2]=s=>i(e).checkedMenu=s),expandedKeys:i(e).expandedKeys,"onUpdate:expandedKeys":t[3]||(t[3]=s=>i(e).expandedKeys=s),checkable:"","tree-data":i(e).menuTree,fieldNames:{key:"id",title:"name"},onCheck:w},{title:l(({name:s})=>[_("span",null,y(s),1)]),_:1},8,["checkedKeys","expandedKeys","tree-data"])]),_:1},8,["confirmLoading"])}}});export{se as _};
