import{r as s,m as v,v as D,e as E,R as O,X as l}from"./index.lP_uh0LI.js";import{a as d}from"./authFunction.z5AMEiSQ.js";import{a as R,g as h,b as m,J as A}from"./vue.BxlDVA1H.js";const o=`${v.system}menu_button/`;function q(e){return s({url:o,method:"get",params:e})}function S(e){return s({url:o,method:"post",data:e})}function T(e){return s({url:o+e.id+"/",method:"put",data:e})}function x(e){return s({url:o+e+"/",method:"delete",data:{id:e}})}function _(e){return s({url:o+"batch_create/",method:"post",data:e})}function j(e){return s({url:o+"multiple_delete/",method:"delete",data:{keys:e}})}const C=function({crudExpose:e,context:n}){const p=async()=>{if(n.selectOptions.value.id)return await q({menu:n.selectOptions.value.id})},f=async({form:t,row:i})=>await T({...t,menu:i.menu}),w=async({row:t})=>await x(t.id),b=async({form:t})=>await S({...t,menu:n.selectOptions.value.id}),u=R([]),g=t=>{const r=e.getTableData().filter(a=>!t.includes(a));l.arrayEach(t,a=>{l.pluck(u.value,"id").includes(a.id)||(u.value=l.union(u.value,[a]))}),l.arrayEach(r,a=>{u.value=l.remove(u.value,c=>c.id!==a.id)})},y=()=>{const t=e.getBaseTableRef(),i=e.getTableData(),r=l.filter(i,a=>l.pluck(u.value,"id").includes(a.id));A(()=>{l.arrayEach(r,a=>{t.toggleRowSelection(a,!0)})})};return{selectedRows:u,crudOptions:{pagination:{show:!1},search:{container:{action:{col:{span:8}}}},actionbar:{buttons:{add:{show:d("btn:Create")},batchAdd:{show:!0,type:"primary",text:"批量生成",click:async()=>{if(n.selectOptions.value.id==null){E.error("请选择菜单");return}const t=await _({menu:n.selectOptions.value.id});t.code==2e3&&(O(t.msg),e.doRefresh())}}}},rowHandle:{fixed:"right",width:200,buttons:{view:{show:!1},edit:{icon:"",type:"primary",show:d("btn:Update")},remove:{show:d("btn:Delete")}}},request:{pageRequest:p,addRequest:b,editRequest:f,delRequest:w,transformRes:({res:t,query:i})=>{const r=t,a={records:[],total:r.data.length||0};return r&&r.code===2e4&&(a.records=r.data.map(c=>({...c}))),a}},table:{rowKey:"id",onSelectionChange:g,onRefreshed:()=>y()},form:{col:{span:24},labelWidth:"100px",wrapper:{is:"el-dialog",width:"600px"}},columns:{$checked:{title:"选择",form:{show:!1},column:{type:"selection",align:"center",width:"70px",columnSetDisabled:!0}},_index:{title:"序号",form:{show:!1},column:{type:"index",align:"center",width:"70px",columnSetDisabled:!0}},search:{title:"关键词",column:{show:!1},type:"text",search:{show:!0},form:{show:!1,component:{placeholder:"输入关键词搜索"}}},id:{title:"ID",type:"text",column:{show:!1},search:{show:!1},form:{show:!1}},name:{title:"权限名称",type:"text",search:{show:!0},column:{minWidth:120,sortable:!0},form:{rules:[{required:!0,message:"权限名称必填"}],component:{placeholder:"输入权限名称搜索",props:{clearable:!0,allowCreate:!0,filterable:!0}},helper:{render(){return h(m("el-alert"),{title:"手动输入",type:"warning",description:"页面中按钮的名称或者自定义一个名称"},null)}}}},value:{title:"权限值",type:"text",search:{show:!1},column:{width:200,sortable:!0},form:{rules:[{required:!0,message:"权限标识必填"}],placeholder:"输入权限标识",helper:{render(){return h(m("el-alert"),{title:"唯一值",type:"warning",description:"用于判断前端按钮权限或接口权限"},null)}}}},method:{title:"请求方式",search:{show:!1},type:"dict-select",column:{width:120,sortable:!0},dict:D({data:[{label:"GET",value:0},{label:"POST",value:1,color:"success"},{label:"PUT",value:2,color:"warning"},{label:"DELETE",value:3,color:"danger"}]}),form:{rules:[{required:!0,message:"必填项"}]}}}}}},P=Object.freeze(Object.defineProperty({__proto__:null,createCrudOptions:C},Symbol.toStringTag,{value:"Module"}));export{j as B,P as a,C as c};
