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 o,i,E as r,j as c,t as v,n as d,H as f,g as p,l as y,m as _,F as m,s as g,G as h,z as k,A as w,y as b,x,O as j,S as C}from"./index-DR4MYR5F.js";import{_ as A}from"./config-doctor.TgARj_nM.js";import{r as E,a as q}from"./cases.CqwTWi6x.js";import{c as S,a as T,b as O}from"./navigation.DbARx0MO.js";import{F as U,a as B,r as I}from"./session.EmQEGqqa.js";import{_ as D}from"./_plugin-vue_export-helper.BCo6x5W8.js";import"./auth.CseBt7py.js";function F(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=P(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=P(t,["value","key","option","option_key","id"])||l,n=P(t,["key","option","option_key"])||s,u=P(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:P(a,["correct_answer","correctAnswer","answer","right_answer"]),analysis:P(a,["analysis","explanation","解析"]),note:P(a,["note","hint","comment"]),videoTitle:P(l,["title","name"])||P(a,["video_title","videoTitle"]),videoDesc:P(l,["description","desc"])||P(a,["video_desc","videoDesc","video_description"]),videoUrl:P(l,["url"])||P(a,["video_url","videoUrl"])}:null}function P(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 $=D(e({__name:"teaching",props:{caseItem:{}},emits:["open-settings","open-profile","go-home"],setup(e,{emit:D}){const P=e,$=D,G=S($),K=T($),N=O($),z=a(0),H=a(""),J=a(!1),L=a(!1),M=a(null),Q=a([]),R=a({}),V=a(!1),W=a(!1),X=a(!1),Y=a(""),Z=a(!1);let ee=null;const ae=l((()=>P.caseItem||M.value)),le=l((()=>q(ae.value))),te=l((()=>{var e,a,l,t,s;return{name:(null==(e=ae.value)?void 0:e.patientName)||"未选择病例",gender:(null==(a=ae.value)?void 0:a.gender)||"-",age:(null==(l=ae.value)?void 0:l.age)||"-",department:(null==(t=ae.value)?void 0:t.department)||"-",chiefComplaint:(null==(s=ae.value)?void 0:s.title)||"暂无病例信息"}})),se=l((()=>te.value.chiefComplaint.includes("胸痛")?"胸痛":te.value.chiefComplaint.slice(0,6))),ne=l((()=>Q.value[z.value]||null)),ue=l((()=>{var e;return Boolean(null==(e=ne.value)?void 0:e.correctAnswer)})),oe=l((()=>{var e,a;return Boolean((null==(e=ne.value)?void 0:e.analysis)||(null==(a=ne.value)?void 0:a.note))})),ie=l((()=>{var e;return Boolean(null==(e=ne.value)?void 0:e.videoUrl)})),re=l((()=>z.value>=Q.value.length-1)),ce=l((()=>W.value?"提交中...":re.value?"提交评价":"下一题")),ve=l((()=>V.value?"题目加载中...":X.value?"题目加载失败,请稍后重试。":"暂无教学题目"));function de(){var e;(null==(e=ne.value)?void 0:e.videoUrl)?(J.value=!0,L.value=!1):me("当前题目暂无讲解视频")}async function fe(){if(!ne.value||W.value||V.value)return;if(!H.value)return void me("请先选择答案");if(re.value)return void(await async function(){if(!le.value)return void me("未找到当前教学病例");const e=Q.value.map((e=>({question_id:e.id,selected_answer:R.value[String(e.id)]||""}))).filter((e=>e.selected_answer));if(e.length!==Q.value.length)return void me("请完成全部题目后再提交");W.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||"教学评价生成失败");r
|