2 lines
10 KiB
JavaScript
2 lines
10 KiB
JavaScript
|
|
import{d as e,r as a,c as l,o as t,b as s,e as n,f as u,w as i,i as o,E as r,j as c,t as v,n as d,H as f,g as y,l as p,m as _,F as m,s as g,G as h,y as k,z as w,x as b,u as x,T as C,S as j}from"./index-CoO0Bu96.js";import{_ as A}from"./config-doctor.TgARj_nM.js";import{r as E}from"./cases.DfX6IxCO.js";import{c as q,a as S,b as T}from"./navigation.C05E413Y.js";import{F as U,a as B,r as I}from"./session.DpZWKT0-.js";import{_ as O}from"./_plugin-vue_export-helper.BCo6x5W8.js";function D(e){if(!e||"object"!=typeof e)return null;const a=e,l=(t=a.video)&&"object"==typeof t&&!Array.isArray(t)?t:{};var t;const s=function(e){const a=e.question_id||e.id||e.item_id;return"number"==typeof a||"string"==typeof a?a:""}(a),n=F(a,["question","title","stem","content","text"]),u=function(e){if(Array.isArray(e))return e.map(((e,a)=>function(e,a){const l=String.fromCharCode(65+a);if("string"==typeof e)return{key:l,value:l,text:e};if(!e||"object"!=typeof e)return null;const t=e,s=F(t,["value","key","option","option_key","id"])||l,n=F(t,["key","option","option_key"])||s,u=F(t,["label","text","content","option_text","name"])||s;return{key:n,value:s,text:u}}(e,a))).filter((e=>Boolean(e)));if(e&&"object"==typeof e)return Object.entries(e).map((([e,a])=>({key:e,value:e,text:"string"==typeof a?a:String(a||"")}))).filter((e=>e.text));return[]}(a.options||a.choices||a.answers);return s&&n&&0!==u.length?{id:s,question:n,options:u,correctAnswer:F(a,["correct_answer","correctAnswer","answer","right_answer"]),analysis:F(a,["analysis","explanation","解析"]),note:F(a,["note","hint","comment"]),videoTitle:F(l,["title","name"])||F(a,["video_title","videoTitle"]),videoDesc:F(l,["description","desc"])||F(a,["video_desc","videoDesc","video_description"]),videoUrl:F(l,["url"])||F(a,["video_url","videoUrl"])}:null}function F(e,a){for(const l of a){const a=e[l];if("string"==typeof a&&a.trim())return a;if("number"==typeof a)return String(a)}return""}const P=O(e({__name:"teaching",props:{caseItem:{}},emits:["open-settings","open-profile","go-home"],setup(e,{emit:O}){const F=e,P=O,$=q(P),G=S(P),K=T(P),N=a(0),z=a(""),H=a(!1),J=a(!1),L=a(null),M=a([]),Q=a({}),R=a(!1),V=a(!1),W=a(!1),X=a(""),Y=a(!1);let Z=null;const ee=l((()=>F.caseItem||L.value)),ae=l((()=>1)),le=l((()=>{var e,a,l,t,s;return{name:(null==(e=ee.value)?void 0:e.patientName)||"未选择病例",gender:(null==(a=ee.value)?void 0:a.gender)||"-",age:(null==(l=ee.value)?void 0:l.age)||"-",department:(null==(t=ee.value)?void 0:t.department)||"-",chiefComplaint:(null==(s=ee.value)?void 0:s.title)||"暂无病例信息"}})),te=l((()=>le.value.chiefComplaint.includes("胸痛")?"胸痛":le.value.chiefComplaint.slice(0,6))),se=l((()=>M.value[N.value]||null)),ne=l((()=>{var e;return Boolean(null==(e=se.value)?void 0:e.correctAnswer)})),ue=l((()=>{var e,a;return Boolean((null==(e=se.value)?void 0:e.analysis)||(null==(a=se.value)?void 0:a.note))})),ie=l((()=>{var e;return Boolean(null==(e=se.value)?void 0:e.videoUrl)})),oe=l((()=>N.value>=M.value.length-1)),re=l((()=>V.value?"提交中...":oe.value?"提交评价":"下一题")),ce=l((()=>R.value?"题目加载中...":W.value?"题目加载失败,请稍后重试。":"暂无教学题目"));function ve(){var e;(null==(e=se.value)?void 0:e.videoUrl)?(H.value=!0,J.value=!1):_e("当前题目暂无讲解视频")}async function de(){if(!se.value||V.value||R.value)return;if(!z.value)return void _e("请先选择答案");if(oe.value)return void(await async function(){if(!ae.value)return void _e("未找到当前教学病例");const e=M.value.map((e=>({question_id:e.id,selected_answer:Q.value[String(e.id)]||""}))).filter((e=>e.selected_answer));if(e.length!==M.value.length)return void _e("请完成全部题目后再提交");V.value=!0;try{const a=await async function(e){var a;const l=await fetch(`${U}/teaching/evaluation`,{method:"POST",headers:B(),body:JSON.stringify(e)});if(!l.ok)throw new Error(await I(l));const t=await l.json();if("OK"!==t.code||!(null==(a=t.data)?void 0:a.evaluation_id))throw new Error(t.message||"教学评价生成失败");return t.data}({case_id:ae.value,ans
|