mirror of
https://gitee.com/myxzgzs/boyue-kfcode-hasfj.git
synced 2025-06-21 17:09:37 +08:00
2 lines
9.7 KiB
JavaScript
2 lines
9.7 KiB
JavaScript
![]() |
import{s as ge,g as x,a as z,b as fe,c as ye,d as be,e as he}from"./messageSystem-ClP4fER0.js";import{_ as _e,d as Te,r as m,z as g,j as p,H as Ve,h as i,o as r,w as s,F as Ce,e as u,i as V,c,I as f,J as y,k as H,m as b,B as we,f as ke,a4 as C}from"./index-CrAWI0wi.js";const Me={key:0,style:{width:"100%"}},Re={key:1,style:{width:"100%"}},Ue={class:"dialog-footer"},Ie={__name:"addMessage",props:{title:{type:String,default:"发送消息界面"}},emits:["success","close"],setup(J,{expose:$,emit:G}){const{proxy:N}=Te(),{send_mode:K,message_type:P}=N.useDict("send_mode","message_type"),w=G,k=m([]),M=m([]),h=m([]),D=m([]),F=m(null),v=m(!1),l=m({messageTitle:null,messageContent:null,messageTemplate:null,messageRecipient:[],remark:null,sendMode:null,recipientType:null,code:null,contentType:null}),_=m(!1),q=g(()=>["1","2"].includes(l.value.sendMode)),B=g(()=>[{value:"user",label:"用户"},{value:"role",label:"角色"},{value:"dept",label:"部门"}]),Q=g(()=>{var t;return((t=B.value.find(e=>e.value===l.value.recipientType))==null?void 0:t.label)||""}),W=g(()=>l.value.recipientType&&(k.value.length||M.value.length||h.value.length)),X=m({messageTitle:[{required:!0,message:"请输入标题",trigger:"blur"}],sendMode:[{required:!0,message:"请选择发送方式",trigger:"change"}],messageRecipient:[{required:!0,message:"请选择收件人",trigger:"change"}],messageType:[{required:!0,message:"请选择消息类型",trigger:"change"}],recipientType:[{required:!0,message:"请选择收件人方式",trigger:"change"}],contentType:[{required:!0,message:"请选择内容类型",trigger:"change"}],messageContent:[{required:!0,message:"模版签名或消息内容不能为空",trigger:"blur"},{validator:ie,trigger:"blur"}],...q.value?{code:[{required:!0,message:"手机号或者邮箱",trigger:"blur"}]}:{}}),R=g(()=>l.value.recipientType?(l.value.recipientType==="user"?k.value:l.value.recipientType==="role"?M.value:h.value).map(e=>({id:e.userId||e.roleId||e.deptId,name:e.userName||e.roleName||e.deptName,phonenumber:e.phonenumber,email:e.email})):[]);async function U(){switch(l.value.messageRecipient=null,l.value.recipientType){case"user":await ae();break;case"role":await te();break;case"dept":await ne();break}}async function Y(t){try{let e=[];if(l.value.recipientType==="role")for(const o of t){const n=(await z(o)).data;e.push(...n.filter(d=>d.phonenumber||d.email||d.name))}else if(l.value.recipientType==="dept")for(const o of t){const n=(await x(o)).data;e.push(...n.filter(d=>d.phonenumber||d.email||d.name))}else e=R.value.filter(o=>t.includes(o.id)&&(o.phonenumber||o.email||o.name));S(e)}catch(e){console.error("未获取到用户信息",e)}}async function Z(t){try{const e=[];for(const o of t){const n=(await x(o)).data;e.push(...n.filter(d=>d.phonenumber||d.email||d.name))}S(e)}catch(e){console.error("未获取到部门成员信息",e)}}function S(t){l.value.code=t.map(e=>l.value.sendMode==="0"?e.name||"":l.value.sendMode==="1"?e.phonenumber||"":l.value.sendMode==="2"&&e.email||"").join(", "),l.value.code||C.warning("未找到该收件人有效联系方式!")}async function ee(){_.value=!0,await F.value.validate(async t=>{if(t)try{const o=(await le()).map(n=>({...l.value,messageRecipient:n.userName||n.name,code:l.value.sendMode==="1"?n.phonenumber:l.value.sendMode==="2"?n.email:n.name,sendMode:l.value.sendMode}));await fe(o),C.success("消息发送成功!"),w("success"),A()}catch(e){C.error("发送信息失败:",e)}else C.warning("请将信息输入完整!")}),_.value=!1}async function le(){if(l.value.recipientType==="dept"){const t=[];for(const e of l.value.messageRecipient)t.push(...(await x(e)).data.filter(o=>o.deptId));return t}else{if(l.value.recipientType==="role")return l.value.messageRecipient.flatMap(async t=>(await z(t)).data);if(l.value.recipientType==="user")return R.value.filter(t=>l.value.messageRecipient.includes(t.id))}return[]}async function ae(){try{k.value=(await he(l.value.sendMode)).data}catch(t){console.error("未获取到用户信息",t)}}async function te(){try{M.value=(await be()).data}catch(t){console.error("未<EFBFBD>
|