var H=Object.defineProperty;var z=Object.getOwnPropertySymbols;var J=Object.prototype.hasOwnProperty,K=Object.prototype.propertyIsEnumerable;var L=(n,i,o)=>i in n?H(n,i,{enumerable:!0,configurable:!0,writable:!0,value:o}):n[i]=o,N=(n,i)=>{for(var o in i||(i={}))J.call(i,o)&&L(n,o,i[o]);if(z)for(var o of z(i))K.call(i,o)&&L(n,o,i[o]);return n};var g=(n,i,o)=>new Promise((_,b)=>{var S=r=>{try{y(o.next(r))}catch(c){b(c)}},k=r=>{try{y(o.throw(r))}catch(c){b(c)}},y=r=>r.done?_(r.value):Promise.resolve(r.value).then(S,k);y((o=o.apply(n,i)).next())});import{u as Q,a as W,b as X,_ as Y}from"./useCrudSchemas-f5-cIgli.js";import{_ as ee}from"./Dialog.vue_vue_type_style_index_0_lang-Crgw5i7b.js";import{e as v,c as te}from"./index-D4Ne4xf-.js";import{_ as ae}from"./Write.vue_vue_type_script_setup_true_lang-CnraElVh.js";import{b as le,e as oe,f as ie,h as ne,i as re}from"./index-C2dtKDaF.js";import{n as P,f as se}from"./element-plus-DNKe9-lk.js";import{l as ue,r as u,Z as ce,U as s,F as j,u as a,n as de,m as A,p as me,O as m,q as fe,S as x,T as R,B as E,M as U,R as M,y as pe}from"./vue-chunks-DyZSmvoe.js";import"./tsxHelper-DOqx_mcA.js";import"./tree-Dgaev6Pi.js";import"./useForm-kq1sxERw.js";import"./wang-editor-C7jwA1hA.js";import"./useValidator-BN3tPovt.js";const ge={class:"mb-10px"};function O(n){return typeof n=="function"||Object.prototype.toString.call(n)==="[object Object]"&&!pe(n)}const Ae=ue({__name:"index",setup(n){const i=u([]),{tableRegister:o,tableState:_,tableMethods:b}=Q({fetchDataApi:()=>g(this,null,function*(){const{currentPage:e,pageSize:t}=_,l=yield ie({current:a(e),pageSize:a(t)});return{list:l.list,total:l.count}}),fetchDelApi:()=>g(this,null,function*(){})}),{loading:S,dataList:k,total:y,currentPage:r,pageSize:c}=_,{getList:T,getElTableExpose:F}=b,{t:d}=te(),q=ce([{field:"selection",search:{hidden:!0},form:{hidden:!0},detail:{hidden:!0},table:{type:"selection"}},{field:"name",label:"预设角色",search:{hidden:!0},detail:{span:24}},{field:"tag",label:"标签",search:{hidden:!0},colProps:{span:8},formatter:e=>e.tag&&s(P,{type:"primary"},{default:()=>[e.tag]})},{field:"promot",label:"提示词",search:{hidden:!0},formatter:e=>e.promot&&s(P,{type:"primary"},{default:()=>[e.promot]})},{field:"desc",label:"备注",search:{hidden:!0},formatter:e=>e.desc&&s(P,{type:"primary"},{default:()=>[e.desc]})},{field:"action",width:"260px",label:d("tableDemo.action"),search:{hidden:!0},form:{hidden:!0},detail:{hidden:!0},table:{slots:{default:e=>{let t,l;return s(j,null,[s(v,{type:"primary",onClick:()=>Z(e.row,"edit")},O(t=d("exampleDemo.edit"))?t:{default:()=>[t]}),s(v,{type:"danger",onClick:()=>$(e.row)},O(l=d("exampleDemo.del"))?l:{default:()=>[l]})])}}}}]),{allSchemas:V}=W(q),f=u(!1),B=u(""),h=u(null),p=u(""),I=()=>{B.value=d("exampleDemo.add"),h.value=null,f.value=!0,p.value=""},D=u(!1),$=e=>g(this,null,function*(){const t=yield F();i.value=e?[e.id]:(t==null?void 0:t.getSelectionRows().map(l=>l.id))||[],D.value=!0,yield se.confirm("确定删除?","提示",{confirmButtonText:"确定",cancelButtonText:"取消",type:"warning"}),yield le(a(i).join(",")).finally(()=>{D.value=!1,T()})}),Z=(e,t)=>g(this,null,function*(){B.value="编辑",yield oe(e.id),p.value=t,h.value=e,e.type!="contact"?h.value.roomList=e.groups:h.value.friendList=e.groups,de(()=>{a(C).change(e.type)}),p.value=t,f.value=!0}),C=u(),w=u(!1),G=()=>g(this,null,function*(){const e=a(C),t=yield e==null?void 0:e.submit();if(t){w.value=!0;let l=null;p.value=="edit"?l=yield ne(t).catch(()=>{}).finally(()=>{w.value=!1}):l=yield re(N({},t)).catch(()=>{}).finally(()=>{w.value=!1}),l&&(f.value=!1,r.value=1,T())}});return(e,t)=>(A(),me(j,null,[s(a(Y),{title:"预设角色",message:"添加自定义角色(promot)"},{default:m(()=>[fe("div",ge,[s(a(v),{type:"primary",onClick:I},{default:m(()=>[x(R(a(d)("exampleDemo.add")),1)]),_:1}),s(a(v),{loading:D.value,type:"danger",onClick:t[0]||(t[0]=l=>$(null))},{default:m(()=>[x(R(a(d)("exampleDemo.del")),1)]),_:1},8,["loading"])]),s(a(X),{pageSize:a(c),"onUpdate:pageSize":t[1]||(t[1]=l=>E(c)?c.value=l:null),currentPage:a(r),"onUpdate:currentPage":t[2]||(t[2]=l=>E(r)?r.value=l:null),columns:a(V).tableColumns,data:a(k),"show-overflow-tooltip":!1,loading:a(S),pagination:{total:a(y)},"image-preview":["url"],onRegister:a(o)},null,8,["pageSize","currentPage","columns","data","loading","pagination","onRegister"])]),_:1}),s(a(ee),{modelValue:f.value,"onUpdate:modelValue":t[4]||(t[4]=l=>f.value=l),title:B.value},{footer:m(()=>[p.value!="copy"?(A(),U(a(v),{key:0,type:"primary",loading:w.value,onClick:G},{default:m(()=>[x(" 保存 ")]),_:1},8,["loading"])):M("",!0),s(a(v),{onClick:t[3]||(t[3]=l=>f.value=!1)},{default:m(()=>[x(R(a(d)("dialogDemo.close")),1)]),_:1})]),default:m(()=>[p.value!="copy"?(A(),U(ae,{key:0,ref_key:"writeRef",ref:C,"form-schema":a(V).formSchema,"current-row":h.value},null,8,["form-schema","current-row"])):M("",!0)]),_:1},8,["modelValue","title"])],64))}});export{Ae as default};
