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