Files
vueapp/dist/assets/pages-scenario-scenario.BMKqvj1V.js
T

2 lines
8.7 KiB
JavaScript
Raw Normal View History

2026-06-11 12:12:55 +08:00
import{d as e,a,r as l,c as s,o as t,b as o,e as n,f as c,w as i,i as u,j as r,t as d,l as m,m as v,F as p,n as _,s as f,G as g,u as b,y,x as h,z as k,S as w}from"./index-CoO0Bu96.js";import{_ as C}from"./config-doctor.TgARj_nM.js";import{r as G}from"./cases.DfX6IxCO.js";import{F as j,a as x,r as I,c as T}from"./session.DpZWKT0-.js";import{_ as E}from"./_plugin-vue_export-helper.BCo6x5W8.js";const O=""+new URL("config-hospital-BKoUC35q.png",import.meta.url).href,F={environments:[{value:"outpatient",label:"门诊"},{value:"emergency",label:"急诊"},{value:"ward",label:"病房"}],ageGroups:[{value:"child",label:"儿童"},{value:"youth",label:"青年"},{value:"middle_aged",label:"中年"},{value:"elderly",label:"老年"}],educations:[{value:"primary_or_below",label:"小学及以下"},{value:"secondary",label:"中等教育"},{value:"higher",label:"高等教育"}],personalities:[{value:"calm",label:"平和"},{value:"anxious",label:"焦虑"},{value:"impatient",label:"急躁"},{value:"cooperative",label:"配合"},{value:"suspicious",label:"多疑"}]};function S(e,a,l){const s=null==e?void 0:e[a];return Array.isArray(s)?s:s&&"object"==typeof s?Object.entries(s).map((([e,a])=>({value:e,label:String(a)}))):l}async function $(e){var a;const l=await fetch(`${j}/training-config/options?case_id=${encodeURIComponent(e)}`,{method:"GET",headers:x()});if(!l.ok)throw new Error(await I(l));const s=await l.json();if("OK"!==s.code||!(null==(a=s.data)?void 0:a.recommended))throw new Error(s.message||"推荐配置加载失败");return{recommended:{environment:(t=s.data).recommended.visit_environment,ageGroup:t.recommended.age_group,education:t.recommended.education_level,personality:t.recommended.personality},recommendedLabels:{environment:t.recommended_labels.visit_environment,ageGroup:t.recommended_labels.age_group,education:t.recommended_labels.education_level,personality:t.recommended_labels.personality},options:{environments:S(t.options,"visit_environment",F.environments),ageGroups:S(t.options,"age_group",F.ageGroups),educations:S(t.options,"education_level",F.educations),personalities:S(t.options,"personality",F.personalities)}};var t}const A=E(e({__name:"scenario",props:{caseItem:{}},setup(e){const j=e,x=a({environment:"outpatient",ageGroup:"youth",education:"higher",personality:"calm"}),I=l([]),E=l(F),S=l(""),A=l(!1),N=l(""),U=l(!1),K=l(!1),L=l(null);let R=null;const q=s((()=>j.caseItem||L.value)),z=s((()=>q.value?`${q.value.title}${q.value.caseNo}`:"未选择病例"));async function B(){const e=await Promise.resolve({recommendations:[{id:"typical-outpatient",title:"典型门诊病例",desc:"门诊常规病例:针对初学者设计的标准化沟通流程。",tags:["中年","配合"],defaults:{environment:"outpatient",ageGroup:"middle_aged",education:"higher",personality:"calm"}},{id:"emergency-crisis",title:"急诊重症危机",desc:"急诊危重:急性心梗紧急入院。",tags:["老年","急躁"],defaults:{environment:"emergency",ageGroup:"elderly",education:"secondary",personality:"impatient"}}],options:F});I.value=e.recommendations,E.value=e.options;try{const e=await $(1);E.value=e.options,Object.assign(x,e.recommended)}catch(a){J(a instanceof Error?a.message:"推荐配置加载失败")}}function D(e,a){x[e]=a,S.value=""}function P(){K.value=!K.value}function H(){var e;q.value?(A.value=!0,(e={...x,caseId:q.value.id,caseNo:q.value.caseNo,mode:"teaching"===q.value.mode?"teaching":"practice",recommendationId:S.value||void 0},T({case_id:1,training_type:"diagnosis_treatment",mode:e.mode,score_type:"percentage",patient_config:{visit_environment:e.environment,age_group:e.ageGroup,education_level:e.education,personality:e.personality}}).then((a=>({id:a.session_code,...e,session:a,createdAt:(new Date).toISOString()})))).then((e=>{f("clinical-thinking-scenario",e),J("模拟场景已生成"),setTimeout((()=>{g({url:"/pages/chat/chat"})}),450)})).catch((e=>{J(e instanceof Error?e.message:"模拟场景生成失败")})).finally((()=>{setTimeout((()=>{A.value=!1}),600)}))):J("请先选择病例")}function J(e){R&&clearTimeout(R),N.va