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