import S from"./index.BxXbAEbc.js";import{g as $,d as P,a as R}from"./api.yjAhi7Po.js";import{a1 as y,E as q,R as x}from"./index.lP_uh0LI.js";import{d as A,r as I,a as k,b as m,x as M,e as O,f as C,s as b,z as G,g as s,w as u,l as g,u as l,h as D,j as H,$ as J}from"./vue.BxlDVA1H.js";import{_ as K}from"./_plugin-vue_export-helper.DlAUqK2U.js";const L={class:"columns-table-com"},Q={class:"ctc-head"},W={class:"ctc-pagination"},X=A({__name:"index",props:{currentInfo:{type:Object,required:!0,default:()=>{}}},setup(z,{expose:V}){const r=z;let i=I({page:1,limit:20}),c=I({loading:!1,data:[],total:0}),d=k(!1),_=k({});const p=async(t=r.currentInfo)=>{try{c.loading=!0;const e=await $({...i,...t});(e==null?void 0:e.code)===2e4&&(c.data=e.data,c.total=e.total)}finally{c.loading=!1}},h=async()=>{var t,e,a;if((t=r.currentInfo)!=null&&t.role&&((e=r.currentInfo)!=null&&e.model)&&((a=r.currentInfo)!=null&&a.app)){const o=await R(r.currentInfo);(o==null?void 0:o.code)===2e4&&(x("匹配成功"),p());return}y("请选择角色和模型表！")},v=(t,e)=>{var a,o,f;if((a=r.currentInfo)!=null&&a.role&&((o=r.currentInfo)!=null&&o.model)&&((f=r.currentInfo)!=null&&f.app)){t==="update"&&e&&(_.value=e),d.value=!0;return}y("请选择角色和模型表！")},w=t=>{t==="submit"&&p(),d.value=!1,_.value={}},B=({id:t})=>{q.confirm("确定删除该字段吗？","提示",{type:"error",confirmButtonText:"确定",cancelButtonText:"取消"}).then(async()=>{const e=await P(t);(e==null?void 0:e.code)===2e4&&(x("删除成功"),p())}).catch(()=>{})},N=t=>{i.limit=t,p()},F=t=>{i.page=t,p()};return V({fetchData:p}),(t,e)=>{const a=m("el-button"),o=m("el-table-column"),f=m("el-table"),T=m("el-pagination"),U=m("el-drawer"),j=M("loading");return C(),O("div",L,[e[8]||(e[8]=b("p",{class:"ctc-title"},"字段权限",-1)),b("div",Q,[s(a,{type:"primary",onClick:e[0]||(e[0]=n=>v("create"))},{default:u(()=>e[4]||(e[4]=[g("新增")])),_:1,__:[4]}),s(a,{type:"primary",onClick:h},{default:u(()=>e[5]||(e[5]=[g("自动匹配")])),_:1,__:[5]})]),G((C(),D(f,{data:l(c).data,border:"",class:"ctc-table"},{default:u(()=>[s(o,{prop:"field_name",label:"字段名"}),s(o,{prop:"title",label:"列名"}),s(o,{label:"操作",width:"180",align:"center"},{default:u(n=>[s(a,{type:"primary",onClick:E=>v("update",n.row)},{default:u(()=>e[6]||(e[6]=[g("编辑")])),_:2,__:[6]},1032,["onClick"]),s(a,{type:"danger",onClick:E=>B(n.row)},{default:u(()=>e[7]||(e[7]=[g("删除")])),_:2,__:[7]},1032,["onClick"])]),_:1})]),_:1},8,["data"])),[[j,l(c).loading]]),b("div",W,[s(T,{"current-page":l(i).page,"onUpdate:currentPage":e[1]||(e[1]=n=>l(i).page=n),"page-size":l(i).limit,"onUpdate:pageSize":e[2]||(e[2]=n=>l(i).limit=n),"page-sizes":[5,10,20,50],total:l(c).total,background:"",layout:"total, sizes, prev, pager, next, jumper",onSizeChange:N,onCurrentChange:F},null,8,["current-page","page-size","total"])]),s(U,{modelValue:l(d),"onUpdate:modelValue":e[3]||(e[3]=n=>J(d)?d.value=n:d=n),title:"字段权限",direction:"rtl",size:"500px","close-on-click-modal":!1,"before-close":w},{default:u(()=>[l(d)?(C(),D(S,{key:0,currentInfo:r.currentInfo,initFormData:l(_),onDrawerClose:w},null,8,["currentInfo","initFormData"])):H("",!0)]),_:1},8,["modelValue"])])}}}),oe=K(X,[["__scopeId","data-v-73db435b"]]);export{oe as default};
