WxDrawer-BUO2tUK_.js 5.0 KB

1
  1. var N=Object.defineProperty;var C=Object.getOwnPropertySymbols;var Q=Object.prototype.hasOwnProperty,K=Object.prototype.propertyIsEnumerable;var D=(e,a,s)=>a in e?N(e,a,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[a]=s,I=(e,a)=>{for(var s in a||(a={}))Q.call(a,s)&&D(e,s,a[s]);if(C)for(var s of C(a))K.call(a,s)&&D(e,s,a[s]);return e};var m=(e,a,s)=>new Promise((d,l)=>{var w=t=>{try{n(s.next(t))}catch(i){l(i)}},c=t=>{try{n(s.throw(t))}catch(i){l(i)}},n=t=>t.done?d(t.value):Promise.resolve(t.value).then(w,c);n((s=s.apply(e,a)).next())});import{B as U,u as J}from"./useForm-DYTnyn58.js";import{g as X}from"./server-DUw7TuGO.js";import{B as Y,a as Z}from"./index-Bh1SitHa.js";import{B as ee,b as se}from"./index-5JuY20kX.js";import{a as k,v as ae,bm as oe,bn as te,bo as re,_ as ne}from"./entry/index-CP6zkLsN-1726190694502.js";import{g as le}from"./department-B6vcHhpB.js";import{d as ie,f as u,o as ce,c as ue,u as v,a6 as B,_ as de,$ as pe,k as f,a8 as g,G as S,aa as y,a1 as L,F as me}from"./vue-CmlY4eyV.js";const fe=(e,a="notice")=>k.post({url:"/wechat-api/wxhook/refreshLoginQR",params:e},{errorMessageMode:a,successMessageMode:a}),Se=(e,a="notice")=>k.post({url:"/wechat-api/wxhook/logout",params:e},{errorMessageMode:a,successMessageMode:a}),ye=(e,a="notice")=>k.post({url:"/wechat-api/wxhook/getFriendsAndGroups",params:e},{errorMessageMode:a,successMessageMode:a}),ge=ie({name:"WxDrawer",components:{BasicDrawer:Y,BasicForm:U,BasicModal:ee},emits:["success","register"],setup(e,{emit:a}){const s=u(!0),{t:d}=ae.useI18n();let l=u("");const w=u([]),c=u("");let n=u(void 0),t=u(void 0);const i=u([]),[$,{resetFields:A,setFieldsValue:R,validate:b}]=J({labelWidth:160,baseColProps:{span:24},layout:"vertical",schemas:i,showActionButtonGroup:!1});ce(()=>{i.value=[{field:"serverId",label:d("wechat.wx.serverId"),component:"ApiSelect",componentProps:{api:X,params:{page:1,pageSize:100},resultField:"data.data",labelField:"name",valueField:"id"},required:!0,ifShow:()=>s.value!==!0},{field:"port",label:d("wechat.wx.port"),component:"Input",required:!0,ifShow:()=>s.value!==!0},{field:"organizationId",label:"租户id",component:"ApiSelect",componentProps:{api:le,params:{page:1,pageSize:100},resultField:"data.data",labelField:"name",valueField:"id"},required:()=>!s.value},{field:"callback",label:d("wechat.wx.callback"),component:"Input",required:()=>!s.value},{field:"apiBase",label:"模型服务地址",component:"Input"},{field:"apiKey",label:"模型服务密钥",component:"Input"}]});const[x,{setDrawerProps:M,closeDrawer:F}]=Z(o=>m(this,null,function*(){var r,h;if(A(),M({confirmLoading:!1}),s.value=!!(o!=null&&o.isUpdate),v(s)){n.value=(r=o==null?void 0:o.record)==null?void 0:r.id,t.value=(h=o==null?void 0:o.record)==null?void 0:h.agentId;const _=I({},o.record);R(_)}})),O=ue(()=>v(s)?c.value="编辑微信":c.value="添加微信");function W(){return m(this,null,function*(){const o=yield b();let r=t.value;const{callback:h,apiBase:_,apiKey:j,organizationId:E}=o,H=n.value;v(s)?yield te({callback:h,apiBase:_,apiKey:j,organizationId:E,agentId:r,id:H}):yield oe(o),F(),a("success")})}function P(){F()}const[T,{openModal:q,setModalProps:p,closeModal:z}]=se();function V(){return m(this,null,function*(){const o=yield b();p({confirmLoading:!0}),M({confirmLoading:!0}),(yield re(o)).code===0&&(F(),z(),a("success")),p({confirmLoading:!1}),M({confirmLoading:!1})})}function G(){return m(this,null,function*(){const o=yield b();let r=yield fe(o);r.code===0&&(r.data.status==="0"||r.data.status==="5"?(p({showOkBtn:!0}),l.value=`<img src="${r.data.qRCode}" />`):r.data.status==="3"&&v(s)?(p({showOkBtn:!1}),l.value=`<p><b>${r.data.statusDesc}</b></p><p>如果需要更换账号,您需要先退出登陆~</p>`):(p({showOkBtn:!1}),l.value=`<p><b>${r.data.statusDesc}</b></p>`),q(!0))})}return{registerDrawer:x,registerForm:$,getTitle:O,handleSubmit:V,registerModal:T,showQRCode:G,modalContent:l,drawerTitle:c,handleSuccess:W,handleCancel:P,modeList:w,recordId:n,recordAgentId:t}}}),we={style:{"text-align":"center"}},he=["innerHTML"];function ve(e,a,s,d,l,w){const c=B("BasicForm"),n=B("a-button"),t=B("BasicDrawer"),i=B("BasicModal");return de(),pe(me,null,[f(t,y(e.$attrs,{onRegister:e.registerDrawer,showFooter:"",showCancelBtn:!1,showOkBtn:!1,title:e.getTitle,width:"500px"}),{appendFooter:g(()=>[f(n,{onClick:e.handleCancel},{default:g(()=>[S("取消")]),_:1},8,["onClick"]),f(n,{type:"primary",onClick:e.handleSuccess},{default:g(()=>[S("确认")]),_:1},8,["onClick"])]),default:g(()=>[f(c,{onRegister:e.registerForm},null,8,["onRegister"])]),_:1},16,["onRegister","title"]),f(i,y({onRegister:e.registerModal},e.$attrs,{visible:!0,title:"扫码登陆",helpMessage:["扫码完成后请等待页面刷新"],destroyOnClose:!0,maskClosable:!1,onOk:e.handleSubmit}),{default:g(()=>[L("div",we,[L("div",{innerHTML:e.modalContent},null,8,he)])]),_:1},16,["onRegister","onOk"])],64)}const Be=ne(ge,[["render",ve]]),Le=Object.freeze(Object.defineProperty({__proto__:null,default:Be},Symbol.toStringTag,{value:"Module"}));export{Be as W,Le as a,ye as g,Se as l,fe as r};