import{r as s,m,v,X as r}from"./index.lP_uh0LI.js";import{a as i}from"./authFunction.z5AMEiSQ.js";import{a as x,J as D}from"./vue.BxlDVA1H.js";const u=`${m.system}column/`;function q(t){return s({url:u,method:"get",params:t})}function R(t){return s({url:u,method:"post",data:t})}function S(t){return s({url:u+t.id+"/",method:"put",data:t})}function _(t){return s({url:u+t+"/",method:"delete",data:{id:t}})}function M(t){return s({url:u+"multiple_delete/",method:"delete",data:{keys:t}})}function $(){return s({url:`${m.system}column/get_models/`,method:"get"})}const O=function({crudExpose:t,context:{props:k,modelDialog:p,selectOptions:c,allModelData:T}}){const f=async e=>{if(c.value.id)return await q({menu:c.value.id})},h=async({form:e,row:l})=>(e.id=l.id,await S(e)),g=async({row:e})=>await _(e.id),b=async({form:e})=>(e.menu=c.value.id,await R(e)),n=x([]),w=e=>{const o=t.getTableData().filter(a=>!e.includes(a));r.arrayEach(e,a=>{r.pluck(n.value,"id").includes(a.id)||(n.value=r.union(n.value,[a]))}),r.arrayEach(o,a=>{n.value=r.remove(n.value,d=>d.id!==a.id)})},y=()=>{const e=t.getBaseTableRef(),l=t.getTableData(),o=r.filter(l,a=>r.pluck(n.value,"id").includes(a.id));D(()=>{r.arrayEach(o,a=>{e.toggleRowSelection(a,!0)})})};return{selectedRows:n,crudOptions:{request:{pageRequest:f,addRequest:b,editRequest:h,delRequest:g},pagination:{show:!1},actionbar:{buttons:{add:{show:i("column:Create")},auto:{text:"自动匹配",type:"success",show:i("column:Match"),click:()=>p.value=!0}}},rowHandle:{fixed:"right",buttons:{view:{show:!1},edit:{show:i("column:Update")},remove:{show:i("column:Delete")}}},form:{col:{span:24},labelWidth:"110px",wrapper:{is:"el-dialog",width:"600px"}},table:{rowKey:"id",onSelectionChange:w,onRefreshed:()=>y()},columns:{$checked:{title:"选择",form:{show:!1},column:{type:"selection",align:"center",width:"70px",columnSetDisabled:!0}},_index:{title:"序号",form:{show:!1},column:{align:"center",width:"70px",columnSetDisabled:!0,formatter:e=>{let l=e.index??1,o=t.crudBinding.value.pagination;return((o.currentPage??1)-1)*o.pageSize+l+1}}},model:{title:"model",type:"dict-select",dict:v({url:`${m.system}system/column/get_models/`,label:"title",value:"key"}),column:{sortable:!0},form:{rules:[{required:!0,message:"必填项"}],component:{span:12,showSearch:!0,filterable:!0,filterOption(e,l){return l.label.indexOf(e)>=0||l.value.indexOf(e)>=0}}}},title:{title:"中文名",sortable:"custom",search:{show:!0},type:"text",form:{rules:[{required:!0,message:"必填项"}],component:{span:12,placeholder:"请输入中文名"}}},field_name:{title:"字段名",type:"text",search:{show:!0},column:{sortable:!0},form:{rules:[{required:!0,message:"必填项"}],component:{span:12,placeholder:"请输入字段名"}}}}}}},L=Object.freeze(Object.defineProperty({__proto__:null,createCrudOptions:O},Symbol.toStringTag,{value:"Module"}));export{M as B,L as a,O as c,$ as g};
