import{t as a,z as e,l as s,bo as t,x as r,cN as l}from"./utils-lib.js?v=20260328163632";import{n as i}from"./useMethod2.js?v=20260328163632";import{t as o}from"./database.js?v=20260328163632";import{u}from"./store.js?v=20260328163632";import{k as c,a9 as p,c as n,r as d,o as m,V as v,_ as b,Y as f}from"./base-lib.js?v=20260328163632";import"./naive-ui.js?v=20260328163632";import"./__commonjsHelpers__.js?v=20260328163632";import"./env-lib.js?v=20260328163632";import"./index85.js?v=20260328163632";import"./service.vue_vue_type_style_index_0_scoped_073b5b46_lang.js?v=20260328163632";const y=c({__name:"index",props:{compData:{default:()=>({rowData:{}})}},setup(c,{expose:y}){const j=c,{refreshTableList:_}=u(),{rowData:w}=p(j.compData),h=n((()=>Array.isArray(w.value))),x=d(!1),g={labelStyle:"min-width: 100px"},I=n((()=>{let a=[{type:"select",key:"access",attrs:{class:"!w-220px",options:i,placeholder:s("请选择"),"onUpdate:value":a=>{x.value="ip"===a}}}];return x.value&&a.push({type:"input",key:"address",attrs:{type:"textarea",rows:4,class:"!w-220px mt-20px",placeholder:s("如需填写多个IP，请换行填写，每行一个IP")}}),{label:s("访问权限"),attrs:g,ruleKey:"address",rules:[{validator:(a,e,t)=>"ip"!==A.value.access||(""===e?new Error(s("请输入IP地址")):(e.split("\n").forEach((a=>{if(""!==a&&!l(a))return new Error(s("请输入正确的IP地址"))})),!0)),trigger:["blur","change"]}],style:{display:"block"},children:a}})),P=d({formAttrs:{labelWidth:"auto"},formItems:[]}),k=n((()=>(P.value.formItems=[I.value],P.value))),[D,A,E]=a(k);return m((()=>{var a,e;h.value?Object.assign(A.value,{access:"127.0.0.1",address:""}):(x.value=!["127.0.0.1","%"].includes(w.value.accept),Object.assign(A.value,{access:x.value?"ip":w.value.accept,address:x.value?null==(e=null==(a=w.value)?void 0:a.accept)?void 0:e.split(",").join("\n"):""}))})),y({onConfirm:async()=>{await E.value.validate();const{access:a,address:l}=A.value;if("%"===a&&await e({title:s("提示"),content:s("设置权限为所有人后，将会导致数据库安全性降低，他人可以随意访问数据库，是否继续操作？")}),h.value){let e=[];return await Promise.all(w.value.map((async s=>{try{const t=await o({id:s.id,access:"ip"===a?l:a});e.push({name:null==s?void 0:s.name,msg:t.msg,status:t.status})}catch(t){}}))),t(e,{title:s("修改权限")}),!0}if(0===(await r({loading:s("正在设置访问权限，请稍后..."),request:o({id:w.value.id,access:"ip"===a?l.split("\n").join(","):a}),message:!0,data:{status:Number}})).status)return _(),!0}}),(a,e)=>(v(),b(f(D),{class:"p-20px"}))}});export{y as default};
