import{d as v,O as S,k as x,m as C,o as u,x as b,z as _,b as k,a as f,A as R,c as B,t as P,B as D}from"./vue.1703796278973.js";import{_ as I}from"./index.vue_vue_type_script_setup_true_name_PermissionButton_lang.1703796278973.js";import{M as y,ax as M}from"./index.17037962789732.js";import"./index.1703796278973300.js";import"./index.170379627897315.js";import"./index.170379627897317.js";import"./index.1703796278973301.js";import"./index.1703796278973302.js";import"./index.170379627897332.js";import"./index.1703796278973303.js";import"./index.170379627897339.js";import"./index.170379627897316.js";import"./index.170379627897314.js";import"./index.1703796278973304.js";import"./index.1703796278973305.js";import"./index.1703796278973306.js";import{d as N,e as O,u as h}from"./apiPage.1703796278973.js";import{u as T}from"./department.17037962789732.js";import{_ as V}from"./_plugin-vue_export-helper.1703796278973.js";import"./index.170379627897320.js";import"./index.170379627897321.js";import"./permission.1703796278973.js";import"./index.17037962789733.js";import"./dayjs.min.1703796278973.js";import"./isArray.1703796278973.js";import"./editor.api.1703796278973.js";import"./preload-helper.1703796278973.js";import"./monaco.contribution.1703796278973.js";import"./system.1703796278973.js";import"./comm.1703796278973.js";import"./index.170379627897333.js";import"./index.170379627897334.js";import"./default.1703796278973.js";import"./consts.1703796278973.js";import"./404.1703796278973.js";const E={class:"choose-api-container"},$={class:"table"},j=["onClick"],q=v({__name:"ChooseApi",props:{tableData:null,clickApi:null,selectedRowKeys:null,sourceKeys:null,mode:null,changedApis:null},emits:["refresh","update:clickApi","update:selectedRowKeys","update:changedApis"],setup(K,{emit:p}){const e=K,d=T(),m=S().query.code,g=[{title:"API",dataIndex:"url",key:"url",scopedSlots:!0},{title:"说明",dataIndex:"summary",key:"summary"}],l={onChange:a=>{const i=e.tableData.map(t=>t.id),c=i.filter(t=>e.sourceKeys.includes(t)),s=d.crossPageKeys.filter(t=>!i.includes(t)),n=c.filter(t=>!a.includes(t)),o=a.filter(t=>!c.includes(t));p("update:selectedRowKeys",[...s,...a]);const r={};[...o,...n].forEach(t=>{r[t]=e.tableData.find(w=>w.id===t)}),e.mode==="appManger"&&p("update:changedApis",{...d.changedApis,...r})},selectedRowKeys:x([])},A=async()=>{const a=e.selectedRowKeys,i=e.sourceKeys.filter(s=>!a.includes(s)),c=a.filter(s=>!e.sourceKeys.includes(s));if(e.mode==="api")i.length&&await N(i),(await O(c)).success&&(y.success("操作成功"),p("refresh"));else if(e.mode==="appManger"){const s=i.map(o=>{var r;return{id:o,permissions:(r=e.changedApis[o])==null?void 0:r.security}}),n=c.map(o=>{var r;return{id:o,permissions:(r=e.changedApis[o])==null?void 0:r.security}});Promise.all([h(m,"_delete",{operations:s}),h(m,"_add",{operations:n})]).then(o=>{o[0].status===200&&o[1].status===200&&(y.success("操作成功"),p("refresh"))})}};return C(()=>e.selectedRowKeys,a=>{l.selectedRowKeys.value=a}),(a,i)=>{const c=M,s=I;return u(),b("div",E,[_("div",$,[k(c,{columns:g,dataSource:e.tableData,rowSelection:e.mode!=="home"?l:void 0,noPagination:"",model:"TABLE"},{url:f(n=>[_("span",{style:{color:"#1d39c4",cursor:"pointer"},onClick:o=>p("update:clickApi",n)},R(n.url),9,j)]),_:1},8,["dataSource","rowSelection"])]),e.mode!=="home"?(u(),B(s,{key:0,type:"primary",hasPermission:"system/Platforms/Setting:update",onClick:A},{default:f(()=>[P(" 保存 ")]),_:1})):D("",!0)])}}});const Se=V(q,[["__scopeId","data-v-d82f67dd"]]);export{Se as default};
