import P from"./index.B_OetKUF.js";import{g as E,d as M,b as $}from"./api.Bo5_6aVX.js";import{an as w,F as q,ai as I}from"./index.CL7yl-Wb.js";import{a as A,_ as k,r as x,aj as m,at as J,c as K,o as _,b,L,S as s,K as u,P as g,u as l,J as D,M as O,y as R}from"./vue.D1BjjNmv.js";import{_ as G}from"./_plugin-vue_export-helper.DlAUqK2U.js";const H={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=k({page:1,limit:20}),c=k({loading:!1,data:[],total:0}),d=x(!1),C=x({});const p=async(t=r.currentInfo)=>{try{c.loading=!0;const e=await E({...i,...t});(e==null?void 0:e.code)===2e3&&(c.data=e.data,c.total=e.total)}finally{c.loading=!1}},B=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.currentInfo);(o==null?void 0:o.code)===2e3&&(I("匹配成功"),p());return}w("请选择角色和模型表！")},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&&(C.value=e),d.value=!0;return}w("请选择角色和模型表！")},y=t=>{t==="submit"&&p(),d.value=!1,C.value={}},h=({id:t})=>{q.confirm("确定删除该字段吗？","提示",{type:"error",confirmButtonText:"确定",cancelButtonText:"取消"}).then(async()=>{const e=await M(t);(e==null?void 0:e.code)===2e3&&(I("删除成功"),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"),S=m("el-pagination"),T=m("el-drawer"),U=J("loading");return _(),K("div",H,[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}),s(a,{type:"primary",onClick:B},{default:u(()=>e[5]||(e[5]=[g("自动匹配")])),_:1})]),L((_(),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:j=>v("update",n.row)},{default:u(()=>e[6]||(e[6]=[g("编辑")])),_:2},1032,["onClick"]),s(a,{type:"danger",onClick:j=>h(n.row)},{default:u(()=>e[7]||(e[7]=[g("删除")])),_:2},1032,["onClick"])]),_:1})]),_:1},8,["data"])),[[U,l(c).loading]]),b("div",W,[s(S,{"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(T,{modelValue:l(d),"onUpdate:modelValue":e[3]||(e[3]=n=>R(d)?d.value=n:d=n),title:"字段权限",direction:"rtl",size:"500px","close-on-click-modal":!1,"before-close":y},{default:u(()=>[l(d)?(_(),D(P,{key:0,currentInfo:r.currentInfo,initFormData:l(C),onDrawerClose:y},null,8,["currentInfo","initFormData"])):O("",!0)]),_:1},8,["modelValue"])])}}}),oe=G(X,[["__scopeId","data-v-9ec74dbf"]]);export{oe as default};
