Files
wecom_it_smart_desk/frontend-agent/dist_old/assets/SessionWorkbench-BLisoDd-.js
T

2 lines
19 KiB
JavaScript
Raw Normal View History

import{v as pe,r as C,x as w,d as Z,i as _,b as u,n as $,w as o,f as t,t as r,g as p,h as g,c as h,e as k,m as G,z as H,F as O,u as P,Y as ve,Z as fe,o as _e,a as me,$ as ye,y as ge,E as M,B as le,j as we,q as ke}from"./index-CnIbBo4X.js";import{a as U}from"./index-ra8jRslb.js";import{u as he}from"./agent-Dxg35leS.js";import"./conversation-BQKKYvcD.js";async function be(a){return await U.post("/itportal/automation/sessions",a)}async function $e(a){return await U.get("/itportal/automation/sessions",{params:a})}async function Se(a){return await U.get(`/itportal/automation/sessions/${a}`)}async function Ie(a,c){return await U.post(`/itportal/automation/sessions/${a}/approve`,c)}async function xe(a,c){return await U.post(`/itportal/automation/sessions/${a}/takeover`,c)}async function Te(a){return await U.get("/itportal/automation/sessions/paused",{params:{employee_id:a}})}async function Ce(a,c){return await U.post(`/itportal/automation/sessions/${a}/agent-resume`,c)}async function Ae(a,c){return await U.post(`/itportal/automation/sessions/${a}/agent-close`,c)}async function ze(a){return await U.get(`/itportal/automation/sessions/${a}/info-items`)}function ie(){return localStorage.getItem("agent_token")||""}function Ve(a){const c=ie(),d=window.location.protocol==="https:"?"wss:":"ws:",x=window.location.host;return`${d}//${x}/ws/automation/${a}?token=${encodeURIComponent(c)}`}const Be=pe("automation",()=>{const a=C([]),c=C(null),d=C(!1),x=C(null),s=C(null),l=C(!1),i=C([]),z=C([]),y=w(()=>a.value.filter(f=>["created","running","paused"].includes(f.status)));async function m(){d.value=!0;try{a.value=await $e()}finally{d.value=!1}}async function S(f){d.value=!0;try{c.value=await Se(f)}finally{d.value=!1}}async function V(f){const T=await be(f);return c.value=T,await m(),T}async function N(f,T,J){const W={decision:T,note:J};c.value=await Ie(f,W)}async function I(f,T,J){const W={agent_id:T,note:J};c.value=await xe(f,W)}async function j(f){i.value=await Te(f)}async function D(f,T){c.value=await Ce(f,{note:T})}async function B(f,T){c.value=await Ae(f,{note:T})}async function v(f){z.value=await ze(f)}function b(f){E();const T=Ve(f),J=ie(),W=new WebSocket(T,[`bearer.${J}`]);x.value=W,s.value=f,W.onopen=()=>{l.value=!0},W.onmessage=Q=>{try{const q=JSON.parse(Q.data);K(q)}catch(q){console.error("[automation WS] 消息解析失败",q)}},W.onclose=()=>{l.value=!1},W.onerror=()=>{l.value=!1}}function E(){x.value&&(x.value.close(),x.value=null),l.value=!1,s.value=null}function K(f){if(!(f.session_id&&s.value&&f.session_id!==s.value))switch(f.type){case"automation.progress":case"automation.action_required":case"automation.resolved":case"automation.takeover":case"automation.error":s.value&&S(s.value);break;case"automation.paused":s.value&&S(s.value);break;case"automation.resumed":s.value&&(S(s.value),v(s.value));break;case"automation.info_corrected":s.value&&v(s.value);break;case"automation.info_supplemented":s.value&&v(s.value);break;case"automation.timeout_closed":s.value&&S(s.value);break}}return{sessions:a,currentSession:c,loading:d,wsConnected:l,pendingSessions:y,pausedSessions:i,infoItems:z,fetchSessions:m,fetchSession:S,createSession:V,approve:N,takeover:I,fetchPausedSessions:j,agentResume:D,agentClose:B,fetchInfoItems:v,connectWs:b,disconnectWs:E}}),We={class:"card-header"},je={class:"title-row"},De={class:"action-title"},Ne={class:"action-desc"},Le={key:0,class:"action-type"},Re={key:0,class:"payload-block"},Ue={class:"payload-pre"},Me={key:1,class:"ticket-block"},Pe={class:"ticket-status"},Ee={class:"action-buttons"},Je=Z({__name:"ActionApprovalCard",props:{action:{},ticket:{}},emits:["approve","reject"],setup(a,{emit:c}){const d=a,x=c,s=C(""),l=C(!1),i=w(()=>{switch(d.action.risk_level){case"read":return"只读";case"low":return"低风险";case"high":return"高危";default:return d.action.risk_level}}),z=w(()=>{switch(d.action.risk_level){case"read":return"info";case"low":return"success";case"high":return"danger";default:return"info"}}),y=w(()=>{if(!d.ticket)return"无";switch(d.ticket.status){case"pending":return"待审批";case"a