import{r as o,m as d,v as p,x as m,s as h}from"./index.lP_uh0LI.js";import{a as i}from"./authFunction.z5AMEiSQ.js";import{d as f}from"./dictionary.D0i47SYU.js";import{g as w,b as y,J as g}from"./vue.BxlDVA1H.js";const n=`${d.system}dictionary/`;function b(t){return o({url:n,method:"get",params:t})}function R(t){return o({url:n,method:"post",data:t})}function c(t){return o({url:n+t.id+"/",method:"put",data:t})}function v(t){return o({url:n+t+"/",method:"delete",data:{id:t}})}const W=function({crudExpose:t,context:s}){return{crudOptions:{request:{pageRequest:async e=>await b(e),addRequest:async({form:e})=>await R(e),editRequest:async({form:e,row:r})=>(e.id=r.id,await c(e)),delRequest:async({row:e})=>await v(e.id),transformRes:({res:e,query:r})=>{const a=e,u={records:[],currentPage:r.page,pageSize:r.limit,total:a.data.count||0};return a&&a.code===2e4&&(u.records=(a.data.results||[]).map(l=>({...l}))),u}},rowHandle:{fixed:"right",width:200,buttons:{view:{show:!1},edit:{iconRight:"Edit",type:"primary",link:!0,show:i("dictionary:Update")},remove:{iconRight:"Delete",type:"primary",link:!0,show:i("dictionary:Delete")},custom:{text:"字典配置",type:"primary",link:!0,show:i("dictionary:Update"),tooltip:{placement:"top",content:"字典配置"},click:e=>{const{row:r}=e;s.subDictRef.value.drawer=!0,g(()=>{s.subDictRef.value.setSearchFormData({form:{parent:r.id}}),s.subDictRef.value.doRefresh()})}}}},columns:{_index:{title:"序号",form:{show:!1},column:{align:"center",width:"70px",columnSetDisabled:!0,formatter:e=>{let r=e.index??1,a=t.crudBinding.value.pagination;return((a.currentPage??1)-1)*a.pageSize+r+1}}},search:{title:"关键词",column:{show:!1},search:{show:!0,component:{props:{clearable:!0},placeholder:"请输入关键词"}},form:{show:!1,component:{props:{clearable:!0}}}},label:{title:"字典名称",search:{show:!0,component:{props:{clearable:!0}}},type:"input",column:{minWidth:120},form:{rules:[{required:!0,message:"字典名称必填项"}],component:{props:{clearable:!0},placeholder:"请输入字典名称"}}},value:{title:"字典编号",search:{disabled:!0,component:{props:{clearable:!0}}},type:"input",column:{minWidth:120},form:{rules:[{required:!0,message:"字典编号必填项"}],component:{props:{clearable:!0},placeholder:"请输入字典编号"},helper:{render(e){return w(y("el-alert"),{title:"使用方法：dictionary('字典编号')",type:"warning"},null)}}}},status:{title:"状态",search:{show:!0},type:"dict-radio",column:{minWidth:90,component:{name:"fs-dict-switch",activeText:"",inactiveText:"",style:"--el-switch-on-color: var(--el-color-primary); --el-switch-off-color: #dcdfe6",onChange:m(e=>()=>{c(e.row).then(r=>{h(r.msg)})})}},dict:p({data:f("button_status_bool")})},sort:{title:"排序",type:"number",column:{minWidth:80},form:{value:1}}},search:{autoSearch:!1}}}};export{W as createCrudOptions};
