import{r as u,n as b,P as p}from"./index.DoJnwA7v.js";import{h as y}from"./elementPlus.CqHltQSO.js";import{a as o}from"./authFunction.DSpD5R8m.js";import{U as n,ai as i}from"./vue.1RczIYhx.js";const a="/api/system/menu_button/";function E(e){return u({url:a,method:"get",params:e})}function g(e){return u({url:a,method:"post",data:e})}function v(e){return u({url:a+e.id+"/",method:"put",data:e})}function A(e){return u({url:a+e+"/",method:"delete",data:{id:e}})}function F(e){return u({url:a+"batch_create/",method:"post",data:e})}const q=function({crudExpose:e,context:r}){const h=async()=>{if(r.selectOptions.value.id)return await E({menu:r.selectOptions.value.id})},m=async({form:t,row:s})=>await v({...t,menu:s.menu}),f=async({row:t})=>await A(t.id),w=async({form:t})=>await g({...t,menu:r.selectOptions.value.id});return{crudOptions:{pagination:{show:!1},search:{container:{action:{col:{span:8}}}},actionbar:{buttons:{add:{show:o("btn:Create")},batchAdd:{show:!0,type:"primary",text:"批量生成",click:async()=>{if(r.selectOptions.value.id==null){y.error("请选择菜单");return}const t=await F({menu:r.selectOptions.value.id});t.code==2e3&&(b(t.msg),e.doRefresh())}}}},rowHandle:{fixed:"right",width:200,buttons:{view:{show:!1},edit:{icon:"",type:"primary",show:o("btn:Update")},remove:{show:o("btn:Delete")}}},request:{pageRequest:h,addRequest:w,editRequest:m,delRequest:f},form:{col:{span:24},labelWidth:"100px",wrapper:{is:"el-dialog",width:"600px"}},columns:{_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 n(i("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 n(i("el-alert"),{title:"唯一值",type:"warning",description:"用于判断前端按钮权限或接口权限"},null)}}}},method:{title:"请求方式",search:{show:!1},type:"dict-select",column:{width:120,sortable:!0},dict:p({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:"必填项"}]}},api:{title:"接口地址",search:{show:!1},type:"dict-select",dict:p({getData(){return u({url:"/swagger.json"}).then(t=>{const s=Object.keys(t.paths),c=[];for(const d of s){const l={};l.label=d,l.value=d,c.push(l)}return c})}}),column:{minWidth:250,sortable:!0},form:{rules:[{required:!0,message:"必填项"}],component:{props:{allowCreate:!0,filterable:!0,clearable:!0}},helper:{render(){return n(i("el-alert"),{title:"请正确填写，以免请求时被拦截。匹配单例使用正则,例如:/api/xx/.*?/",type:"warning"},null)}}}}}}}};export{q as createCrudOptions};
