var B=Object.defineProperty,P=Object.defineProperties;var z=Object.getOwnPropertyDescriptors;var F=Object.getOwnPropertySymbols;var j=Object.prototype.hasOwnProperty,M=Object.prototype.propertyIsEnumerable;var D=(s,n,e)=>n in s?B(s,n,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[n]=e,I=(s,n)=>{for(var e in n||(n={}))j.call(n,e)&&D(s,e,n[e]);if(F)for(var e of F(n))M.call(n,e)&&D(s,e,n[e]);return s},k=(s,n)=>P(s,z(n));var u=(s,n,e)=>new Promise((g,l)=>{var r=i=>{try{t(e.next(i))}catch(o){l(o)}},m=i=>{try{t(e.throw(i))}catch(o){l(o)}},t=i=>i.done?g(i.value):Promise.resolve(i.value).then(r,m);t((e=e.apply(s,n)).next())});import{P as G}from"./index.87b9fa4d.js";import{c as T,e as O,f as V,g as H}from"./api.761a0b6b.js";import{d as C,a as E,r as L,u as q,B as S,i as a,q as $,l as h,a8 as R,a9 as w,a7 as N,k as d,_ as x,p as b,ai as J,H as K,cg as Q,aa as W,ch as U,bC as _}from"./index.0d3a6da1.js";import{N as X}from"./TreeSelect.f1593ba3.js";import"./searchs.b637f0d6.js";const Y=C({name:"city-operation",props:{type:{type:String,default:"add"},parentId:{type:Number,default:0},data:{type:Object,default:()=>{}}},emits:["close","getList"],setup(s,{slots:n,attrs:e,emit:g}){const l=E({applyType:s.parentId==0?0:1,parentId:s.parentId,appName:null,appKey:null,clientIds:null,permissionFlag:!0,remark:null}),r=L([]),m=L(!1),t=L();L([]);const i=q(),o=p=>u(this,null,function*(){try{console.log(p);const{data:c}=yield T({page:1,rows:999,parentId:p.key}),y=[];(c.rows||[]).forEach(f=>{y.push({key:f.id,label:f.appName,isLeaf:!(f.number>0)})}),p.children=[...y]}catch(c){}}),v=(p=0)=>u(this,null,function*(){try{const{data:c}=yield T({page:1,rows:999,parentId:p}),y=[];return(c.rows||[]).forEach(f=>{y.push({key:f.id,label:f.appName,isLeaf:!(f.number>0)})}),y}catch(c){}}),A=()=>u(this,null,function*(){t.value.validate(p=>u(this,null,function*(){if(p)return!1;try{m.value=!0,s.type==="add"?(yield O({appName:l.appName,clientIds:l.clientIds,parentId:l.parentId,appKey:l.appKey,permissionFlag:l.permissionFlag,remark:l.remark}),i.success("\u6DFB\u52A0\u6210\u529F")):s.type==="edit"&&(yield V(k(I({},l),{id:s.data.id})),i.success("\u4FEE\u6539\u6210\u529F")),g("close"),g("getList")}catch(c){}m.value=!1}))});return S(()=>u(this,null,function*(){if(r.value=yield v(),console.log(s.parentId),s.type==="edit"){const p=s.data,c=yield v(s.parentId);r.value.forEach(y=>{y.key==s.parentId&&(y.children=[...c])}),l.appName=p.appName,l.clientIds=p.clientIds,l.permissionFlag=p.permissionFlag,l.remark=p.remark,l.appKey=p.appKey}})),()=>a("div",{style:"background: #fff; padding-top: 12px"},[a($,{model:l,ref:t,"label-placement":"left","label-width":"100"},{default:()=>[s.type==="add"&&a(h,{label:"\u5E94\u7528\u7C7B\u578B",path:"applyType",rule:[{required:!0,message:"\u8BF7\u9009\u62E9\u5E94\u7528\u7C7B\u578B"}]},{default:()=>[a(R,{value:l.applyType,"onUpdate:value":p=>l.applyType=p},{default:()=>[a(w,null,{default:()=>[a(N,{value:0},{default:()=>[d("\u9876\u7EA7\u5E94\u7528")]}),a(N,{value:1},{default:()=>[d("\u5B50\u7EA7\u5E94\u7528")]})]})]})]}),l.applyType>0&&s.type==="add"&&a(h,{label:"\u5E94\u7528\u5206\u7C7B",path:"parentId",rule:[{required:!0,message:"\u8BF7\u9009\u62E9\u5E94\u7528\u5206\u7C7B"}]},{default:()=>[a(X,{value:l.parentId,"onUpdate:value":p=>l.parentId=p,options:r.value,showPath:!0,allowCheckingNotLoaded:!1,onLoad:o,placeholder:"\u8BF7\u9009\u62E9\u5E94\u7528\u5206\u7C7B",clearable:!0},null)]}),a(h,{label:"\u5E94\u7528\u540D\u79F0",path:"appName",rule:[{required:!0,message:"\u8BF7\u8F93\u5165\u5E94\u7528\u540D\u79F0"}]},{default:()=>[a(x,{value:l.appName,"onUpdate:value":p=>l.appName=p,placeholder:"\u8BF7\u8F93\u5165\u5E94\u7528\u540D\u79F0",clearable:!0,maxlength:100},null)]}),l.applyType==0&&a(h,{label:"\u5E94\u7528\u7F16\u7801",path:"appKey",rule:[{required:!1,message:"\u8BF7\u8F93\u5165\u5E94\u7528\u7F16\u7801"}]},{default:()=>[a(x,{value:l.appKey,"onUpdate:value":p=>l.appKey=p,placeholder:"\u8BF7\u8F93\u5165\u5E94\u7528\u7F16\u7801",clearable:!0,maxlength:100},null)]}),a(h,{label:"\u6743\u9650\u5BA2\u6237\u7AEF",path:"clientIds",rule:[{required:!0,message:"\u8BF7\u8F93\u5165\u6743\u9650\u5BA2\u6237\u7AEF"}]},{default:()=>[a(x,{value:l.clientIds,"onUpdate:value":p=>l.clientIds=p,maxlength:200,placeholder:"\u8BF7\u8F93\u5165\u6743\u9650\u5BA2\u6237\u7AEF",clearable:!0},null)]}),a(h,{label:"\u6743\u9650\u8BA4\u8BC1",path:"permissionFlag",rule:[{required:!0,message:"\u8BF7\u9009\u62E9\u6743\u9650\u8BA4\u8BC1"}]},{default:()=>[a(R,{value:l.permissionFlag,"onUpdate:value":p=>l.permissionFlag=p},{default:()=>[a(w,null,{default:()=>[a(N,{value:!0},{default:()=>[d("\u662F")]}),a(N,{value:!1},{default:()=>[d("\u5426")]})]})]})]}),a(h,{label:"\u5907\u6CE8",path:"remark",rule:[{required:!0,message:"\u5907\u6CE8"}]},{default:()=>[a(x,{value:l.remark,"onUpdate:value":p=>l.remark=p,maxlength:180,type:"textarea",rows:3,placeholder:"\u8BF7\u8F93\u5165\u5907\u6CE8"},null)]})]}),a(w,{justify:"end"},{default:()=>[a(b,{type:"default",onClick:()=>g("close")},{default:()=>[d("\u53D6\u6D88")]}),a(b,{type:"primary",onClick:()=>A(),loading:m.value},{default:()=>[d("\u4FDD\u5B58")]})]})])}}),se=C({name:"system-apply",setup(){const s=J(),n=q(),e=E({loading:!1,pagination:{page:1,rows:10,pageTotal:0},dataList:[],visiableApply:!1,applyType:"add",parentId:0,applyData:{},expandedRowKeys:[]}),g=()=>[{title:"\u7F16\u53F7",key:"id"},{title:"\u5E94\u7528\u540D\u79F0",key:"appName"},{title:"\u5E94\u7528\u7F16\u7801",key:"appKey"},{title:"\u6388\u6743\u5BA2\u6237\u7AEF",key:"clientIds"},{title:"\u6388\u6743\u8BA4\u8BC1",key:"permissionFlag",render(t){return t.permissionFlag?a(U,{type:"primary"},{default:()=>[d("\u662F")]}):a(U,{type:"default"},{default:()=>[d("\u5426")]})}},{title:"\u5907\u6CE8",key:"remark"},{title:"\u64CD\u4F5C",key:"operation",render(t){return a(w,null,{default:()=>[K(a(b,{type:"primary",text:!0,size:"small",onClick:()=>{e.visiableApply=!0,e.applyType="edit",e.parentId=t.parentId,e.applyData=t}},{default:()=>[d("\u7F16\u8F91")]}),[[_("auth"),"sysApplication/update1674670570951729154"]]),K(a(b,{type:"primary",text:!0,size:"small",onClick:()=>l(t)},{default:()=>[d("\u5220\u9664")]}),[[_("auth"),"sysApplication/remove1674670676950179841"]])]})}}],l=t=>{console.log(t,"row"),s.warning({title:"\u8B66\u544A",content:`\u5220\u9664"${t.appName}"\uFF0C\u662F\u5426\u7EE7\u7EED\uFF1F`,positiveText:"\u786E\u5B9A",negativeText:"\u53D6\u6D88",onPositiveClick:()=>u(this,null,function*(){try{yield H({id:t.id}),e.pagination.page=1,r(),n.success("\u5220\u9664\u6210\u529F")}catch(i){}})})},r=()=>u(this,null,function*(){try{e.loading=!0,console.log(e.expandedRowKeys,"expandedRowKeys"),e.expandedRowKeys=[];const{data:t}=yield T(k(I({},e.pagination),{parentId:0}));e.loading=!1,e.pagination.pageTotal=Number(t.total);const i=[];(t.rows||[]).forEach(o=>{o.isLeaf=!(o.number>0),i.push(o)}),e.dataList=i}catch(t){}}),m=t=>u(this,null,function*(){try{const o=(yield T({page:1,rows:999,parentId:t.id})).data.rows||[],v=[];o.forEach(A=>{v.push(k(I({},A),{isLeaf:!0}))}),t.children=v}catch(i){}});return S(()=>{r()}),()=>a("div",{class:"system-menu-container"},[a("div",{class:["section-container"]},[a(w,{style:{paddingBottom:"12px"},justify:"space-between"},{default:()=>[K(a(b,{type:"primary",onClick:()=>{e.applyType="add",e.parentId=0,e.applyData={},e.visiableApply=!0}},{default:()=>[d("\u6DFB\u52A0\u5E94\u7528")]}),[[_("auth"),"sysApplication/save1674670435916111873"]])]}),a(Q,{loading:e.loading,columns:g(),data:e.dataList,allowCheckingNotLoaded:!0,cascade:!1,expandedRowKeys:e.expandedRowKeys,onUpdateExpandedRowKeys:t=>{e.expandedRowKeys=t},rowKey:t=>t.id,onLoad:m},null),a(G,{page:e.pagination.page,"onUpdate:page":t=>e.pagination.page=t,pageSize:e.pagination.rows,"onUpdate:pageSize":t=>e.pagination.rows=t,pageTotal:e.pagination.pageTotal,"onUpdate:pageTotal":t=>e.pagination.pageTotal=t,onList:r,sync:!0},null)]),a(W,{show:e.visiableApply,"onUpdate:show":t=>e.visiableApply=t,preset:"dialog",showIcon:!1,title:e.applyType==="add"?"\u6DFB\u52A0\u5E94\u7528":"\u4FEE\u6539\u5E94\u7528",style:{width:"500px"}},{default:()=>[a(Y,{type:e.applyType,parentId:e.parentId,data:e.applyData,onClose:()=>e.visiableApply=!1,onGetList:r},null)]})])}});export{se as default};