import{C as P,g as j,a as q,d as M}from"./index.177f818c.js";import{O as w,P as I}from"./index.0d411246.js";import{E as O}from"./elementPlus.0e5067e4.js";import{d as $,Q as x,r as k,a9 as f,af as A,o as b,c as G,a as v,M as s,G as u,K as g,H,u as l,E as D,J,t as K,aq as Q,ar as R}from"./vue.3f733908.js";import{_ as L}from"./_plugin-vue_export-helper.c27b6911.js";import"./echarts.72dc8373.js";const W=m=>(Q("data-v-9ec74dbf"),m=m(),R(),m),X={class:"columns-table-com"},Y=W(()=>v("p",{class:"ctc-title"},"字段权限",-1)),Z={class:"ctc-head"},ee={class:"ctc-pagination"},te=$({__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=k(!1),C=k({});const p=async(t=r.currentInfo)=>{try{i.loading=!0;const e=await j({...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})=>{O.confirm("确定删除该字段吗？","提示",{type:"error",confirmButtonText:"确定",cancelButtonText:"取消"}).then(async()=>{const e=await M(t);(e==null?void 0:e.code)===2e3&&(w("删除成功"),p())}).catch(()=>{})},N=t=>{c.limit=t,p()},S=t=>{c.page=t,p()};return z({fetchData:p}),(t,e)=>{const a=f("el-button"),o=f("el-table-column"),_=f("el-table"),E=f("el-pagination"),F=f("el-drawer"),T=A("loading");return b(),G("div",X,[Y,v("div",Z,[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})]),H((b(),D(_,{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:U=>h("update",n.row)},{default:u(()=>[g("编辑")]),_:2},1032,["onClick"]),s(a,{type:"danger",onClick:U=>B(n.row)},{default:u(()=>[g("删除")]),_:2},1032,["onClick"])]),_:1})]),_:1},8,["data"])),[[T,l(i).loading]]),v("div",ee,[s(E,{"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:N,onCurrentChange:S},null,8,["current-page","page-size","total"])]),s(F,{modelValue:l(d),"onUpdate:modelValue":e[3]||(e[3]=n=>K(d)?d.value=n:d=n),title:"字段权限",direction:"rtl",size:"500px","close-on-click-modal":!1,"before-close":y},{default:u(()=>[l(d)?(b(),D(P,{key:0,currentInfo:r.currentInfo,initFormData:l(C),onDrawerClose:y},null,8,["currentInfo","initFormData"])):J("",!0)]),_:1},8,["modelValue"])])}}});const ce=L(te,[["__scopeId","data-v-9ec74dbf"]]);export{ce as default};
