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