import{a as Q,r,_ as X,f as M,q as j,aj as s,c as b,o as w,S as l,b as g,K as o,L as z,T as G,P as p,Q as x,R as K,a9 as J,u as y,H as W}from"./vue.YrNK8sx4.js";import{k as Y,a5 as Z,O as ee,F as te,G as le,H as oe,X as R,E as ae}from"./index.BKEMpsLA.js";import{g as ne,B as se,c as ie}from"./crud.9ZZ-VNyV.js";import{b as ce}from"./api.BUJM_Ai1.js";import{_ as de}from"./_plugin-vue_export-helper.DlAUqK2U.js";import"./authFunction.DqglRaEG.js";const ue={class:"model-card"},re=["value"],pe={class:"dialog-footer"},me={style:{height:"72vh"}},fe=Q({__name:"index",setup(_e,{expose:V}){let m=r({name:null});const n=X({model:"",app:"",menu:""}),d=r(!1),f=r([]),B=r(null),T=(e,t)=>{B.value=t,n.model=e.key,n.app=e.app},_=r(""),L=M(()=>{if(!_.value)return f.value;const e=_.value.toLowerCase();return f.value.filter(t=>t.app.toLowerCase().includes(e)||t.title.toLowerCase().includes(e)||t.key.toLowerCase().includes(e))}),E=e=>{!e.is_catalog&&e.id?(m.value=e,c.doRefresh()):c.setTableData([])},S=async()=>{if(n.menu=m.value.id,d.value=!1,n.menu&&n.model){const e=await ce(n);(e==null?void 0:e.code)===2e3&&te("匹配成功"),c.doSearch({form:{menu:n.menu,model:n.model}})}else le("请选择角色和模型表！")},h=M(()=>i.value.length),N=async()=>{await oe.confirm(`确定要批量删除这${i.value.length}条记录吗`,"确认",{distinguishCancelAndClose:!0,confirmButtonText:"确定",cancelButtonText:"取消",closeOnClickModal:!1}),await se(R.pluck(i.value,"id")),ae.info("删除成功"),i.value=[],await c.doRefresh()},O=e=>{const t=c.getBaseTableRef(),k=c.getTableData();R.pluck(k,"id").includes(e.id)?t.toggleRowSelection(e,!1):i.value=R.remove(i.value,C=>C.id!==e.id)},{crudBinding:$,crudRef:F,crudExpose:c,selectedRows:i}=Y({createCrudOptions:ie,props:n,modelDialog:d,selectOptions:m,allModelData:f});return j(async()=>{const e=await ne();f.value=e.data}),V({selectOptions:m,handleRefreshTable:E}),(e,t)=>{const k=s("el-tag"),C=s("el-input"),U=s("el-text"),u=s("el-button"),q=s("el-dialog"),A=s("el-tooltip"),D=s("el-table-column"),H=s("el-table"),I=s("el-popover"),P=s("fs-crud");return w(),b("div",null,[l(q,{ref:"modelRef",modelValue:d.value,"onUpdate:modelValue":t[2]||(t[2]=a=>d.value=a),title:"选择model"},{footer:o(()=>[g("span",pe,[l(u,{onClick:t[1]||(t[1]=a=>d.value=!1)},{default:o(()=>t[3]||(t[3]=[p("取消")])),_:1}),l(u,{type:"primary",onClick:S},{default:o(()=>t[4]||(t[4]=[p(" 确定 ")])),_:1})])]),default:o(()=>[z(g("div",null,[l(k,null,{default:o(()=>[p("已选择:"+x(n.model),1)]),_:1})],512),[[G,n.model]]),l(C,{modelValue:_.value,"onUpdate:modelValue":t[0]||(t[0]=a=>_.value=a),placeholder:"搜索模型...",style:{"margin-bottom":"10px"}},null,8,["modelValue"]),g("div",ue,[(w(!0),b(K,null,J(L.value,(a,v)=>(w(),b("div",{value:a.key,key:v},[l(U,{type:B.value===v?"primary":"",onClick:ve=>T(a,v)},{default:o(()=>[p(x(a.app+"--"+a.title+"("+a.key+")"),1)]),_:2},1032,["type","onClick"])],8,re))),128))])]),_:1},8,["modelValue"]),g("div",me,[l(P,W({ref_key:"crudRef",ref:F},y($)),{"pagination-left":o(()=>[l(A,{content:"批量删除"},{default:o(()=>[l(u,{text:"",type:"danger",disabled:h.value===0,icon:y(ee),circle:"",onClick:N},null,8,["disabled","icon"])]),_:1})]),"pagination-right":o(()=>[l(I,{placement:"top",width:400,trigger:"click"},{reference:o(()=>[l(u,{text:"",type:h.value>0?"primary":""},{default:o(()=>[p("已选中"+x(h.value)+"条数据",1)]),_:1},8,["type"])]),default:o(()=>[l(H,{data:y(i),size:"small"},{default:o(()=>[l(D,{width:"150",property:"id",label:"id"}),l(D,{fixed:"right",label:"操作","min-width":"60"},{default:o(a=>[l(u,{text:"",type:"info",icon:y(Z),onClick:v=>O(a.row),circle:""},null,8,["icon","onClick"])]),_:1})]),_:1},8,["data"])]),_:1})]),_:1},16)])])}}}),we=de(fe,[["__scopeId","data-v-390f83fc"]]);export{we as default};
