trainChapter.vue 46 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297
  1. <template>
  2. <div class="chapter-container">
  3. <div v-if="!state.hasRead" class="chapter-describe">
  4. <div class="describe-cnt" v-html="state.readHtml"></div>
  5. <div class="describe-readed">
  6. <a class="readed-btn" :class="{ reading: state.readingTime > 0 }" @click="hasReadClick">知道了{{ state.readingTime > 0 ? ` (${state.readingTime}s)` : '' }}</a>
  7. </div>
  8. </div>
  9. <div v-if="state.hasRead && state.showCnt" class="chapter-box">
  10. <NavMenus :back-confirm="state.lastChapterNum != maxChapterNum"></NavMenus>
  11. <div class="chapter-content">
  12. <!-- 原本的左侧菜单 -->
  13. <!-- <div class="menu-box" :class="{ fold: state.menuFold }">
  14. <div class="menu-title">{{ state.chapterTree[state.currentStep]?.name ?? '' }}</div>
  15. <div class="menu-list">
  16. <el-scrollbar :max-height="state.menuListHeight">
  17. <el-steps direction="vertical" space="3rem" :active="state.currentStep">
  18. <el-step v-for="(item, idx) in state.chapterTree" :title="item.name" @click="menuClick($event, idx)">
  19. <template #icon>
  20. <div class="step-icon">
  21. <div class="step-icon-inner"></div>
  22. </div>
  23. </template>
  24. <template #description v-if="item.children?.length > 0">
  25. <el-steps
  26. direction="vertical"
  27. space="1.8rem"
  28. :active="idx < state.currentStep ? item.children.length : idx > state.currentStep ? -1 : state.activeSecondMenu"
  29. >
  30. <el-step v-for="item1 in item.children" :title="item1.name" @click="menuClick($event, idx, item1.id)">
  31. <template #icon><div class="step-icon-second"></div></template>
  32. </el-step>
  33. </el-steps>
  34. </template>
  35. </el-step>
  36. </el-steps>
  37. </el-scrollbar>
  38. <div class="menu-switch" @click="menuSwitch"></div>
  39. </div>
  40. </div> -->
  41. <!-- 新的左侧菜单 -->
  42. <div :class="'menuLeft ' + (menuLeftLook == true ? 'menuLeftOpenEvent' : 'menuLeftExitEvent')" >
  43. <div class="menuTitle" >
  44. <div class="logoLeft"></div>
  45. <div class="txtRight">知识学习</div>
  46. </div>
  47. <div class="menuList" >
  48. <div class="menuListBorder commonsScrollbarNew" >
  49. <div class="menuListMain" v-for="(item, index) of state.chapterTree" :key="index" >
  50. <div :class="'menuListpParent ' + ( (index < state.currentStep) ? 'menuListpParentYes' : (index == state.currentStep) ? 'menuListpParentSelect' : '' ) "
  51. @click="menuClickNew(item, index)" >
  52. <div class="menuListpParentLeft">
  53. <div v-if="index == state.currentStep" class="logoTime" ></div>
  54. <div v-if="index != state.currentStep" :class="'' + ( (index <= state.currentStep) ? 'logoMenu' : 'logoNo' )" ></div>
  55. </div>
  56. <div class="menuListpParentCenter">{{ item.name }}</div>
  57. <!-- <div class="menuListpParentRight" v-if="item.children != null && item.children != undefined && item.children.length > 0" >
  58. +
  59. </div> -->
  60. </div>
  61. <div :class="'menuListpChildren ' + ( (index < state.currentStep || ( index == state.currentStep && index_1 + 1 < state.currentNode ) ) ? 'menuListpChildrenYes' : (index_1 + 1 == state.currentNode) ? 'menuListpChildrenSelect' : '' ) "
  62. @click="menuClickNew(item_1, index, item_1.id)"
  63. v-if="item.children?.length > 0" v-for="(item_1, index_1) of item.children" :key="index_1" >
  64. <div class="menuListpChildrenKong" ></div>
  65. <div class="menuListpChildrenLeft" >
  66. <div v-if="(index_1 + 1 == state.currentNode)" class="logoTime" ></div>
  67. <div v-if="(index_1 + 1 != state.currentNode)" :class="'' + ( (index < state.currentStep || ( index == state.currentStep && index_1 < state.currentNode ) ) ? 'logoMenu' : 'logoNo' )" ></div>
  68. </div>
  69. <div class="menuListpChildrenRight">
  70. {{ item_1.name }}
  71. </div>
  72. </div>
  73. </div>
  74. </div>
  75. </div>
  76. </div>
  77. <div :class="'menuLook ' + (menuLeftLook == true ? 'menuLookOpenEvent ' : 'menuLookExit menuLookExitEvent')"
  78. @click="(menuLeftLook = menuLeftLook == true ? false : true)" ></div>
  79. <div v-if="state.currentChapter.type != 30" class="chapter-detail">
  80. <div class="detail-title">{{ state.currentChapter.name }}</div>
  81. <div class="detail-cnt" v-html="htmlContent"></div>
  82. </div>
  83. <!-- <div v-else class="chapter-3d">
  84. <CourseChapter3d :config="state.chapterTree[state.currentStep]?.threeDimensionalConfig ?? ''"></CourseChapter3d>
  85. <CourseChapter3dView></CourseChapter3dView>
  86. </div> -->
  87. </div>
  88. <!-- 后台交互,显示,上一步下一步逻辑UI -->
  89. <StepTips
  90. v-if="
  91. stepTipsLook == true
  92. && (
  93. (
  94. courseChapter3dShow().show.showToastViewBool == false
  95. && courseChapter3dShow().show.showLinkOkNextBool == false
  96. )
  97. || (
  98. courseChapter3dShow().show.showToastViewBool == true
  99. && courseChapter3dShow().show.showToastState == ''
  100. && courseChapter3dShow().show.showLinkOkNextBool == false
  101. )
  102. )
  103. "
  104. :msg="state.tipsMsg"
  105. :btns="state.tipsBtns"
  106. :countdown="tipsCountdown"
  107. :key="state.tipsKey"
  108. ></StepTips>
  109. </div>
  110. <!-- 3d组件放在这里,让它可以隐藏起来,提前加载好场景。要不然后续切换3d场景每次要重新加载,比较麻烦 -->
  111. <!-- <div v-show="state.hasRead && state.showCnt && state.currentChapter.type == 30" class="chapter-3d"> -->
  112. <div v-if="courseChapter3dViewBool == true" class="chapter-3d">
  113. <div v-show="state.hasRead && state.showCnt && state.currentChapter.type == 30">
  114. <!-- 老版本的三维逻辑了,用不到了 -->
  115. <!-- <CourseChapter3d
  116. :config="state?.currentChapter ?? ''"
  117. :studentTaskIdList="studentTaskIdList"
  118. @tipsBtnsUpOpen="tipsBtnsUpOpenEvent"
  119. @tipsBtnsDownOpen="tipsBtnsDownOpenEvent"
  120. ></CourseChapter3d>
  121. <CourseChapter3dView
  122. @showOperationHelpExitEvent="showOperationHelpExitEvent"
  123. @carCameraScreenshot="carCameraScreenshotEvent"
  124. @carShutDown="carShutDownEvent"
  125. ></CourseChapter3dView> -->
  126. <QingXiCheAndQvMain :initTime="initTimeQingXiCarAndQv" :processUiOpen="(stepTipsLook == true ? false : true)"
  127. @callbackProgress="callbackProgressQingXiCheAndQv" ></QingXiCheAndQvMain>
  128. </div>
  129. </div>
  130. </div>
  131. </template>
  132. <script setup lang="ts">
  133. import { onMounted, reactive, computed, watch, onUnmounted, nextTick, ref } from 'vue';
  134. import NavMenus from '../components/navMenus.vue';
  135. import StepTips from '../components/stepTips.vue';
  136. import { useRoute } from 'vue-router';
  137. import { getCourseInfo, getCourseChapterTree, studyReport, getCurrentChapter, updateProgress } from '@/api/student/trainChapter';
  138. import { studentTaskOptionPipDefectListByStudentId } from '@/api/student/studentTaskOptionPipDefect';
  139. import CourseChapter3d from '@/components/student/CourseChapter3d.vue';
  140. import CourseChapter3dView from '@/components/student/courseChapter3d/view.vue';
  141. import QingXiCheAndQvMain from '@/components/ThreeWorldEventQingXiCheAndQv/QingXiCheAndQvMain.vue';
  142. import { getTrainDetail } from '@/api/student/trainList';
  143. import router from '@/router/index';
  144. import { courseChapter3dShow } from '@/stores/courseChapter3dShow.ts';
  145. import { threeWorld } from '@/stores/threeWorld.ts';
  146. import { uploadFileOss, getLiteMeta } from '../../../util/fileUtils';
  147. import { ElMessage, ElMessageBox, ElNotification } from 'element-plus';
  148. import { studentTaskPhoto } from '@/api/techer/taskStudentScore';
  149. import { ModelHtml5Audio } from "../../../components/student/event/ModelHtml5Audio.ts";
  150. const route = useRoute();
  151. const taskId = route.params.taskId as string;
  152. const studentTaskId = route.params.studentTaskId as string;
  153. const state: anyObj = reactive({
  154. hasRead: true,
  155. readingTime: 10,
  156. readHtml: '',
  157. showCnt: false,
  158. menuFold: false,
  159. menuListHeight: ``,
  160. tipsKey: 0,
  161. tipsMsg: '',
  162. tipsBtns: [],
  163. chapterTree: [],
  164. currentStep: 0,
  165. currentNode: 0,
  166. currentChapter: { type: 10 },
  167. activeSecondMenu: -1,
  168. lastChapterNum: -1,
  169. });
  170. // 控制左侧菜单是否展示
  171. let menuLeftLook = ref(true)
  172. // 播放声音
  173. let objAudio = new ModelHtml5Audio();
  174. let chapterQueue: Array<Array<anyObj>> = [];
  175. let maxChapterNum = 0;
  176. // 获取当前学生任务ID缺陷列表
  177. let studentTaskIdList: any = ref([]);
  178. // 用于控制3d场景什么时候加载显示
  179. let courseChapter3dViewBool = ref(false);
  180. /**
  181. * 因为引入了其他三维场景
  182. * 三维场景里,自带了上一步,下一步的逻辑UI
  183. * 所以控制,原先前端UI的 上一步,下一步的UI逻辑是否显示还是隐藏
  184. */
  185. let stepTipsLook = ref(true);
  186. // 控制清洗车回到第一个流程逻辑
  187. let initTimeQingXiCarAndQv = ref("0");
  188. const buildChapterQueue = (data: anyObj[], optionChapters: anyObj[], root = true): anyObj[] => {
  189. let chapters: anyObj[] = [];
  190. data?.forEach((item, idx) => {
  191. const children = item.children;
  192. //delete item.children;
  193. const opt = optionChapters.find((x) => x.chapterId == item.id);
  194. if (opt) item.durationStudyMin = opt.durationStudyMin;
  195. chapters.push(item);
  196. if (children && children.length > 0) {
  197. const childs = buildChapterQueue(children, optionChapters, false);
  198. chapters = chapters.concat(childs);
  199. }
  200. if (root) {
  201. chapterQueue[idx] = [...chapters];
  202. chapters = [];
  203. }
  204. });
  205. if (root) maxChapterNum = (chapterQueue.length - 1) * 100 + chapterQueue[chapterQueue.length - 1].length - 1;
  206. return chapters;
  207. };
  208. const menuSwitch = () => {
  209. state.menuFold = !state.menuFold;
  210. };
  211. const menuClick = (evt: Event, step: number, nodeId?: string) => {
  212. if ((evt.target as HTMLElement).classList.contains('el-step__title')) {
  213. let chapterNum = step * 100,
  214. node = 0;
  215. if (nodeId) {
  216. node = chapterQueue[step].findIndex((x) => x.id == nodeId);
  217. if (node > -1) chapterNum += node;
  218. }
  219. if (chapterNum <= state.lastChapterNum) {
  220. state.currentStep = step;
  221. state.currentNode = node;
  222. state.currentChapter = chapterQueue[step][node];
  223. } else {
  224. ElMessage({
  225. message: '该章节还未完成学习,请先按顺序完成学习!',
  226. type: 'warning',
  227. });
  228. }
  229. }
  230. evt.stopPropagation();
  231. };
  232. /**
  233. * 新的左侧菜单点击的逻辑
  234. * @param item
  235. * @param step
  236. * @param nodeId
  237. */
  238. const menuClickNew = (item: any, step: number, nodeId?: string) => {
  239. console.log("menuClickNew ---", item, step, nodeId)
  240. let chapterNum = step * 100,
  241. node = 0;
  242. if (nodeId) {
  243. node = chapterQueue[step].findIndex((x) => x.id == nodeId);
  244. if (node > -1) chapterNum += node;
  245. }
  246. if (chapterNum <= state.lastChapterNum) {
  247. state.currentStep = step;
  248. state.currentNode = node;
  249. state.currentChapter = chapterQueue[step][node];
  250. console.log(
  251. 'menuClickNew --- 1111111111 ',
  252. state.currentStep,
  253. state.currentNode,
  254. state.currentChapter
  255. );
  256. } else {
  257. ElMessage({
  258. message: '该章节还未完成学习,请先按顺序完成学习!',
  259. type: 'warning',
  260. });
  261. }
  262. };
  263. const hasReadClick = () => {
  264. state.hasRead = true;
  265. state.showCnt = true;
  266. setMenuListHeight();
  267. };
  268. const setMenuListHeight = () => {
  269. nextTick(() => {
  270. let height = document.querySelector('.menu-box')?.clientHeight ?? 0;
  271. if (height) state.menuListHeight = `calc(${height}px - 12rem)`;
  272. });
  273. };
  274. const countdown = (name: string, callback?: Function) => {
  275. if (state[name]) {
  276. const interval = setInterval(() => {
  277. state[name]--;
  278. if (state[name] == 0) {
  279. clearInterval(interval);
  280. if (callback) callback();
  281. }
  282. }, 1000);
  283. }
  284. };
  285. const tipsCountdown = computed(() => {
  286. let countdown = state.currentChapter.durationStudyMin ?? 0;
  287. const chapterNum = state.currentStep * 100 + state.currentNode;
  288. if (chapterNum <= state.lastChapterNum) countdown = 0;
  289. return countdown;
  290. });
  291. const htmlContent = computed(() => {
  292. if (state.currentChapter.type == 10) {
  293. return state.currentChapter.richText;
  294. } else if (state.currentChapter.type == 20) {
  295. return `<iframe src='${state.currentChapter.videoUrl}' width='100%' height='99%' scrolling='no' frameborder='0'><iframe>`;
  296. } else return '';
  297. });
  298. const prevStep = () => {
  299. if (state.currentNode == 0) {
  300. state.currentStep--;
  301. state.currentNode = chapterQueue[state.currentStep].length - 1;
  302. } else state.currentNode--;
  303. state.currentChapter = chapterQueue[state.currentStep][state.currentNode];
  304. };
  305. const nextStep = () => {
  306. updateStudyProgress();
  307. state.currentNode++;
  308. if (state.currentNode >= chapterQueue[state.currentStep].length) {
  309. state.currentStep++;
  310. state.currentNode = 0;
  311. }
  312. state.currentChapter = chapterQueue[state.currentStep][state.currentNode];
  313. };
  314. const completeStudy = () => {
  315. updateStudyProgress();
  316. router.push({ path: `/train/main/${taskId}` });
  317. };
  318. const updateStudyProgress = () => {
  319. //更新学习进度
  320. const num = state.currentStep * 100 + state.currentNode;
  321. if (num > state.lastChapterNum) {
  322. state.lastChapterNum = num;
  323. updateProgress(studentTaskId, state.currentChapter.id);
  324. }
  325. };
  326. const initTips = () => {
  327. state.tipsKey++;
  328. state.tipsMsg = state.currentChapter.tips;
  329. // 得到三维的参数
  330. let threeDimensionalConfig = state.currentChapter.threeDimensionalConfig;
  331. console.log("获取课程树 ---", state.chapterTree)
  332. console.log(
  333. "initTips ===> 每次进入不同流程后,进行处理的逻辑",
  334. state.tipsMsg, state.currentChapter, threeDimensionalConfig
  335. );
  336. // /**
  337. // * 因为加入了其他三维场景
  338. // * 他们有自带的上一步,下一步的UI控制
  339. // * 所以这里进行特殊处理
  340. // */
  341. // if (typeof threeDimensionalConfig == "string" && threeDimensionalConfig == "仿真模拟_清洗车") {
  342. // var thisTime = new Date().getTime();
  343. // initTimeQingXiCarAndQv.value = "" + thisTime;
  344. // // 此时进入三维场景,就默认进入到最后一个步骤
  345. // state.tipsBtns = [
  346. // {
  347. // name: '上一步',
  348. // click: prevStep,
  349. // attr: { type: 'primary', plain: 'plain' },
  350. // },
  351. // {
  352. // name: '完成并前往编制报告',
  353. // click: completeStudy,
  354. // attr: { type: 'primary' },
  355. // },
  356. // ];
  357. // // 同时先隐藏UI
  358. // stepTipsLook.value = false;
  359. // return;
  360. // }
  361. // 显示UI
  362. stepTipsLook.value = true;
  363. if (state.currentStep == 0 && state.currentNode == 0) {
  364. state.tipsBtns = [
  365. {
  366. name: '下一步',
  367. click: nextStep,
  368. attr: { type: 'primary' },
  369. },
  370. ];
  371. } else if (state.currentStep == chapterQueue.length - 1 && state.currentNode == chapterQueue[state.currentStep].length - 1) {
  372. state.tipsBtns = [
  373. {
  374. name: '上一步',
  375. click: prevStep,
  376. attr: { type: 'primary', plain: 'plain' },
  377. },
  378. {
  379. name: '完成并前往编制报告',
  380. click: completeStudy,
  381. attr: { type: 'primary' },
  382. },
  383. ];
  384. } else {
  385. state.tipsBtns = [
  386. {
  387. name: '上一步',
  388. click: prevStep,
  389. attr: { type: 'primary', plain: 'plain' },
  390. },
  391. {
  392. name: '下一步',
  393. click: nextStep,
  394. attr: { type: 'primary' },
  395. },
  396. ];
  397. }
  398. /**
  399. * 因为加入了其他三维场景
  400. * 他们有自带的上一步,下一步的UI控制
  401. * 所以这里进行特殊处理
  402. */
  403. if (typeof threeDimensionalConfig == "string" && threeDimensionalConfig == "仿真模拟_清洗车") {
  404. var thisTime = new Date().getTime();
  405. initTimeQingXiCarAndQv.value = "" + thisTime;
  406. // 隐藏 上一步,下一步 UI
  407. stepTipsLook.value = false;
  408. }
  409. };
  410. let studyInterval: NodeJS.Timeout;
  411. // 开场音乐
  412. let musicIndex = new URL("./../../../assets/music/index.mp3", import.meta.url).href;
  413. onMounted(() => {
  414. // // 第一次进来播放指定的声音基本上
  415. // objAudio.pause();
  416. // // 设置播放音乐的文件,或者地址
  417. // objAudio.setUrl(musicIndex);
  418. // // 不需要循环播放
  419. // objAudio.loopClose();
  420. // // 继续播放音乐
  421. // objAudio.start();
  422. threeWorld().loadSuccess = false;
  423. courseChapter3dViewBool.value = false;
  424. //学习时间上报
  425. studyInterval = setInterval(() => {
  426. const type = state.currentChapter.type != 30 ? 1 : 2;
  427. studyReport(studentTaskId, type);
  428. }, 1000 * 100);
  429. //获取任务信息
  430. getTrainDetail(taskId).then((res) => {
  431. //获取课程信息
  432. getCourseInfo(res.data.data.courseId).then((res1) => {
  433. if (res1.data.data.description) {
  434. state.hasRead = false;
  435. state.readHtml = res1.data.data.description;
  436. countdown('readingTime');
  437. } else {
  438. state.hasRead = true;
  439. state.showCnt = true;
  440. setMenuListHeight();
  441. }
  442. window.addEventListener('resize', () => {
  443. setMenuListHeight();
  444. });
  445. });
  446. //获取课程树
  447. getCourseChapterTree(res.data.data.courseId).then((res2) => {
  448. state.chapterTree = res2.data.data;
  449. buildChapterQueue(res2.data.data, res.data.data.optionChapters);
  450. //需先根据学习进度确定开始章节:currentStep和currentNode,默认第一章第一节
  451. //获取学习到的章节
  452. getCurrentChapter(studentTaskId).then((res3) => {
  453. const chapterId = res3.data.data;
  454. if (chapterId) {
  455. for (let i = 0; i < chapterQueue.length; i++) {
  456. const idx = chapterQueue[i].findIndex((x) => x.id == chapterId);
  457. if (idx > -1) {
  458. state.currentStep = i;
  459. state.currentNode = idx;
  460. break;
  461. }
  462. }
  463. state.lastChapterNum = state.currentStep * 100 + state.currentNode;
  464. }
  465. state.currentChapter = chapterQueue[state.currentStep][state.currentNode];
  466. initTips();
  467. });
  468. });
  469. // 根据学生id任务获取缺陷数据
  470. studentTaskOptionPipDefectListByStudentId(studentTaskId)
  471. .then((studentTaskOptionPipDefectListByStudentIdRes) => {
  472. studentTaskIdList.value = studentTaskOptionPipDefectListByStudentIdRes?.data?.data;
  473. courseChapter3dViewBool.value = true;
  474. // console.log(
  475. // "根据学生id任务获取缺陷数据",
  476. // studentTaskIdList.value,
  477. // studentTaskId
  478. // );
  479. })
  480. .catch((error) => {
  481. courseChapter3dViewBool.value = true;
  482. });
  483. });
  484. });
  485. onUnmounted(() => {
  486. if (studyInterval) clearInterval(studyInterval);
  487. });
  488. watch(
  489. () => state.currentChapter,
  490. (newVal) => {
  491. initTips();
  492. //滚动当前课程菜单至可视区域
  493. nextTick(() => {
  494. const target = document.querySelector('.el-step__description .is-process') as HTMLElement;
  495. target?.scrollIntoView({ behavior: 'smooth', block: 'center' });
  496. });
  497. //课程菜单默认显示二级,兼容课程树层级大于二级的情况
  498. if (state.currentNode == 0) state.activeSecondMenu = -1;
  499. else {
  500. const idx = (state.chapterTree[state.currentStep].children as anyObj[])?.findIndex((x) => x.id == newVal.id);
  501. if (idx > -1) state.activeSecondMenu = idx;
  502. }
  503. }
  504. );
  505. /**
  506. * 检测实训注意事项 知道了点击回调
  507. */
  508. courseChapter3dShow().show.showMatterGotItCallback = function () {
  509. // console.log(
  510. // "检测实训注意事项 知道了点击回调", res
  511. // );
  512. // 触发下一步逻辑
  513. nextStep();
  514. };
  515. /**
  516. * 监听弹出提示隐藏后来触发不同的逻辑
  517. */
  518. watch(
  519. () => courseChapter3dShow().show.showToastViewBool,
  520. (newVal, oldVal) => {
  521. if (courseChapter3dShow().show.showToastViewBool == true) {
  522. return;
  523. }
  524. // console.log(
  525. // " () => courseChapter3dShow().show.showToastState 1111111111 ",
  526. // courseChapter3dShow().show.showToastState
  527. // );
  528. switch (courseChapter3dShow().show.showToastState) {
  529. case '立即穿戴':
  530. // // 触发下一步逻辑
  531. // nextStep();
  532. break;
  533. }
  534. }
  535. );
  536. // 记录 tipsBtnsUpOpenEvent 事件是否显示上一步按钮
  537. let tipsBtnsUpOpenEventBool: Boolean = true;
  538. /**
  539. * 上一步是否显示
  540. * open true - 显示, false - 隐藏
  541. */
  542. const tipsBtnsUpOpenEvent = (open: Boolean) => {
  543. // console.log("上一步是否显示", open);
  544. tipsBtnsUpOpenEventBool = open;
  545. tipsBtnsUpAndDownOpenEvent();
  546. };
  547. // 记录 tipsBtnsUpOpenEvent 事件是否显示下一步按钮
  548. let tipsBtnsDownOpenEventBool: Boolean = true;
  549. /**
  550. * 下一步是否显示
  551. * open true - 显示, false - 隐藏
  552. */
  553. const tipsBtnsDownOpenEvent = (open: Boolean) => {
  554. // console.log("下一步是否显示", open);
  555. tipsBtnsDownOpenEventBool = open;
  556. tipsBtnsUpAndDownOpenEvent();
  557. };
  558. /**
  559. * 通过3d传来的事件来控制上一步下一步是否显示逻辑
  560. */
  561. const tipsBtnsUpAndDownOpenEvent = () => {
  562. let newArray = [];
  563. if (tipsBtnsUpOpenEventBool == true) {
  564. // newArray.push({
  565. // name: '上一步',
  566. // click: prevStep,
  567. // attr: { type: 'primary', plain: 'plain' },
  568. // });
  569. }
  570. if (tipsBtnsDownOpenEventBool == true) {
  571. newArray.push({
  572. name: '下一步',
  573. click: nextStep,
  574. attr: { type: 'primary' },
  575. });
  576. }
  577. // console.log(
  578. // " ========= state.tipsBtns ========= ",
  579. // state.tipsBtns
  580. // );
  581. // 如果出现 完成并前往编制报告 则不替换
  582. try {
  583. for (let i = 0; i < state.tipsBtns.length; i++) {
  584. let thisTipsBtns = state.tipsBtns[i];
  585. if (thisTipsBtns.name.indexOf('完成') >= 0) {
  586. return;
  587. }
  588. }
  589. } catch (e) {}
  590. state.tipsBtns = newArray;
  591. };
  592. // 操作帮助点击退出
  593. const showOperationHelpExitEvent = () => {
  594. // 触发下一步逻辑
  595. nextStep();
  596. };
  597. /**
  598. * 车的完成下井实验
  599. */
  600. const carShutDownEvent = () => {
  601. // 触发下一步逻辑
  602. nextStep();
  603. };
  604. /**
  605. * 车的相机截图
  606. * img base64位图片
  607. */
  608. const carCameraScreenshotEvent = (img: any) => {
  609. // console.log(
  610. // "车的相机截图", img
  611. // );
  612. // 将 base64为转换成,Blob格式
  613. let objBlob = dataURLtoBlob(img);
  614. // blob 转换成 file对象
  615. const file = new File([objBlob], 'example.png', { type: 'text/plain' });
  616. // 优先上传文件
  617. // @ts-ignore
  618. uploadFileOss(file, 'course/cover', null)
  619. .then(function (e: any) {
  620. // console.log(
  621. // "上传文件", e
  622. // );
  623. studentTaskPhoto({
  624. studentTaskId: studentTaskId,
  625. imageUrl: e,
  626. remark: '',
  627. })
  628. .then(function (studentTaskPhotoRes: any) {
  629. // console.log(
  630. // "上传文件成功", studentTaskPhotoRes
  631. // );
  632. // ElMessage({
  633. // message: '截图上传完成',
  634. // type: 'success',
  635. // });
  636. courseChapter3dShow().show.showToastViewBool = false;
  637. courseChapter3dShow().show.showPromptEvent('截图上传完成', null, function (res: any) {
  638. // console.log("yes", res);
  639. });
  640. })
  641. .catch(function (studentTaskPhotoResError: any) {
  642. // ElMessage({
  643. // message: '上传失败',
  644. // type: 'warning',
  645. // });
  646. courseChapter3dShow().show.showToastViewBool = false;
  647. courseChapter3dShow().show.showPromptEvent('上传失败', null, function (res: any) {
  648. // console.log("yes", res);
  649. });
  650. });
  651. })
  652. .catch(function (e: any) {
  653. // ElMessage({
  654. // message: e || '上传失败',
  655. // type: 'warning',
  656. // });
  657. courseChapter3dShow().show.showToastViewBool = false;
  658. courseChapter3dShow().show.showPromptEvent('上传失败', null, function (res: any) {
  659. // console.log("yes", res);
  660. });
  661. });
  662. };
  663. /**
  664. * 将base64转换为blob
  665. * @param dataurl base64位图片
  666. */
  667. const dataURLtoBlob = (dataurl: any) => {
  668. let arr = dataurl.split(','),
  669. mime = arr[0].match(/:(.*?);/)[1],
  670. bstr = atob(arr[1]),
  671. n = bstr.length,
  672. u8arr = new Uint8Array(n);
  673. while (n--) {
  674. u8arr[n] = bstr.charCodeAt(n);
  675. }
  676. return new Blob([u8arr], { type: mime });
  677. };
  678. /**
  679. * 清洗车自定义回调步骤
  680. */
  681. const callbackProgressQingXiCheAndQv = (json : any) => {
  682. console.log("callbackProgressQingXiCheAndQv ===>", json);
  683. // 完成所有步骤
  684. if (json.name == "equipmentRepositioningWork") {
  685. stepTipsLook.value = true;
  686. }
  687. }
  688. </script>
  689. <style lang="scss" scoped>
  690. @use './css/animationEvent.scss';
  691. @use './css/commonsScrollbarNew.scss';
  692. .chapter-container {
  693. position: absolute;
  694. width: 100%;
  695. height: 100%;
  696. display: flex;
  697. justify-content: center;
  698. align-items: center;
  699. z-index: 1;
  700. .chapter-describe {
  701. position: relative;
  702. width: 70%;
  703. height: 90%;
  704. background-image: url(/src/assets/student/bg_describe.png);
  705. background-size: 100% 100%;
  706. &:before {
  707. content: '';
  708. position: absolute;
  709. top: 3%;
  710. left: 28%;
  711. height: 6%;
  712. width: 70%;
  713. background-image: url(/src/assets/student/training.png);
  714. background-size: auto 100%;
  715. background-repeat: no-repeat;
  716. }
  717. .describe-cnt {
  718. overflow: auto;
  719. box-sizing: border-box;
  720. position: absolute;
  721. inset: 10rem 0 10rem 6rem;
  722. padding-right: 4rem;
  723. }
  724. .describe-readed {
  725. position: absolute;
  726. bottom: 3rem;
  727. width: 100%;
  728. display: flex;
  729. justify-content: center;
  730. .readed-btn {
  731. width: 20rem;
  732. height: 5.4rem;
  733. line-height: 5.4rem;
  734. text-align: center;
  735. color: white;
  736. font-size: 2rem;
  737. border-radius: 0.8rem;
  738. background: linear-gradient(90deg, #6cd9e9 0%, #4b90dd 100%);
  739. cursor: pointer;
  740. &.reading {
  741. pointer-events: none;
  742. }
  743. }
  744. }
  745. }
  746. .chapter-box {
  747. width: 100%;
  748. height: 100%;
  749. }
  750. .chapter-content {
  751. position: absolute;
  752. width: 100%;
  753. height: 100%;
  754. .menu-box {
  755. position: absolute;
  756. top: 3.2rem;
  757. left: 2rem;
  758. width: 20rem;
  759. height: calc(100% - 18rem);
  760. transition-property: left;
  761. transition-duration: 0.6s;
  762. z-index: 2;
  763. &.fold {
  764. left: -20rem;
  765. .menu-switch {
  766. background-image: url(/src/assets/student/training/menu_switch1.png);
  767. }
  768. }
  769. .menu-switch {
  770. position: absolute;
  771. width: 2rem;
  772. height: 5rem;
  773. background-image: url(/src/assets/student/training/menu_switch.png);
  774. background-size: 100% 100%;
  775. right: -2rem;
  776. top: 50%;
  777. margin-top: -2.5rem;
  778. cursor: pointer;
  779. }
  780. .menu-title {
  781. height: 5rem;
  782. background-image: url(/src/assets/student/training/menu_title.png);
  783. background-size: 100% 100%;
  784. color: white;
  785. // font-size: 2rem;
  786. font-size: 1.8rem;
  787. overflow: hidden;
  788. &:before {
  789. content: '';
  790. display: inline-block;
  791. vertical-align: middle;
  792. height: 5rem;
  793. width: 8rem;
  794. background-image: url(/src/assets/student/training/menu_icon.png);
  795. background-size: auto 50%;
  796. background-repeat: no-repeat;
  797. background-position: center center;
  798. }
  799. }
  800. .menu-list {
  801. position: relative;
  802. min-height: 20rem;
  803. max-height: calc(100% - 6rem);
  804. margin-top: 1rem;
  805. padding: 3rem 0 3rem 2rem;
  806. background-image: url(/src/assets/student/training/menu_list.png);
  807. // background-image: url(/src/assets/menuLeft/menuBottom.webp);
  808. background-size: 100% 100%;
  809. box-sizing: border-box;
  810. --step-item-size: 2rem;
  811. --step-icon-size: 1.2rem;
  812. --step-line-left: 0.9rem;
  813. --step-border-width: 0.2rem;
  814. .step-icon {
  815. width: var(--step-item-size);
  816. height: var(--step-item-size);
  817. border-radius: 50%;
  818. border: var(--step-border-width) solid #5faaf4;
  819. box-sizing: border-box;
  820. transition: 0.15s ease-out;
  821. display: flex;
  822. justify-content: center;
  823. align-items: center;
  824. .step-icon-inner {
  825. width: var(--step-icon-size);
  826. height: var(--step-icon-size);
  827. background-size: 100% 100%;
  828. }
  829. }
  830. :deep(.el-step__head) {
  831. width: var(--step-item-size);
  832. .el-step__line {
  833. width: var(--step-border-width);
  834. top: var(--step-item-size);
  835. left: var(--step-line-left);
  836. background-color: #5faaf4;
  837. }
  838. .el-step__icon {
  839. width: unset;
  840. height: unset;
  841. background: transparent;
  842. display: flex;
  843. }
  844. &.is-process .step-icon-inner {
  845. background-image: url(/src/assets/student/training/step_process.png);
  846. }
  847. &.is-finish .step-icon-inner {
  848. background-image: url(/src/assets/student/training/step_finish.png);
  849. }
  850. }
  851. :deep(.el-step__main) {
  852. padding-left: 2rem;
  853. padding-right: 2rem;
  854. .el-step__title {
  855. // font-size: var(--step-item-size);
  856. font-size: 1.5rem;
  857. color: white;
  858. font-weight: unset;
  859. line-height: var(--step-item-size);
  860. cursor: pointer;
  861. &.is-process,
  862. &.is-finish {
  863. text-shadow: 0px 1px 1px rgba(0, 0, 0, 0.2);
  864. background: linear-gradient(180deg, #82ccdd 0%, #589cf2 100%);
  865. background-clip: text;
  866. -webkit-background-clip: text;
  867. -webkit-text-fill-color: transparent;
  868. }
  869. }
  870. .el-step__description {
  871. margin-left: -1.1rem;
  872. // --step-item-size: 0.9rem;
  873. --step-item-size: 1.1rem;
  874. --step-icon-size: 0.6rem;
  875. .el-steps {
  876. margin: 0.8rem 0;
  877. }
  878. .el-step__head {
  879. width: var(--step-icon-size);
  880. &.is-process .step-icon-second {
  881. background-color: #5ff49b;
  882. }
  883. &.is-finish .step-icon-second {
  884. background-color: #5fa9f4;
  885. }
  886. }
  887. .el-step__icon {
  888. height: var(--step-item-size);
  889. line-height: var(--step-item-size);
  890. }
  891. .step-icon-second {
  892. width: var(--step-icon-size);
  893. height: var(--step-icon-size);
  894. border-radius: 50%;
  895. box-sizing: border-box;
  896. background-color: #ccc;
  897. }
  898. .el-step__line {
  899. width: 0.1rem;
  900. left: 0.25rem;
  901. top: 0.6rem;
  902. bottom: -0.4rem;
  903. margin-bottom: unset !important;
  904. &:after {
  905. display: none;
  906. }
  907. }
  908. .el-step:last-of-type .el-step__line {
  909. display: none;
  910. }
  911. .el-step__main {
  912. padding-left: 0.6rem;
  913. }
  914. .el-step__title {
  915. font-size: var(--step-item-size);
  916. &.is-process {
  917. color: #5ff49b;
  918. -webkit-text-fill-color: unset;
  919. }
  920. &.is-finish {
  921. color: #5fa9f4;
  922. -webkit-text-fill-color: unset;
  923. }
  924. }
  925. }
  926. }
  927. :deep(.el-step:last-of-type) {
  928. .el-step__line {
  929. display: block;
  930. margin-bottom: 1rem;
  931. &:after {
  932. content: '';
  933. position: absolute;
  934. border: 0.8rem solid transparent;
  935. border-top-color: #5faaf4;
  936. bottom: -1rem;
  937. left: -0.7rem;
  938. }
  939. .el-step__line-inner {
  940. transition-delay: 150ms;
  941. border-width: 0px;
  942. height: 0%;
  943. }
  944. }
  945. }
  946. }
  947. }
  948. .chapter-detail {
  949. position: absolute;
  950. top: 3.2rem;
  951. left: 28rem;
  952. width: 88rem;
  953. height: 56rem;
  954. max-height: calc(100% - 12rem);
  955. background-image: url(/src/assets/student/training/window_bg.png);
  956. background-size: 100% 100%;
  957. .detail-title {
  958. height: 18%;
  959. font-size: 3rem;
  960. text-align: center;
  961. color: white;
  962. display: flex;
  963. justify-content: center;
  964. align-items: center;
  965. }
  966. .detail-cnt {
  967. height: 76%;
  968. padding: 0 5rem;
  969. box-sizing: border-box;
  970. overflow: auto;
  971. :deep(img) {
  972. max-width: 100%;
  973. }
  974. }
  975. }
  976. // 左侧菜单
  977. .menuLeft {
  978. position: fixed;
  979. top: 10.92rem;
  980. bottom: 18rem;
  981. left: 2.28rem;
  982. width: 21.64rem;
  983. z-index: 2;
  984. opacity: 0.9;
  985. .menuTitle {
  986. position: absolute;
  987. width: 100%;
  988. top: 0px;
  989. left: 0px;
  990. height: 5.71rem;
  991. background-image: url(/src/assets/menuLeft/title.webp);
  992. background-size: 100% 100%;
  993. .logoLeft, .txtRight {
  994. position: absolute;
  995. }
  996. .logoLeft {
  997. width: 2.28rem;
  998. height: 2.92rem;
  999. background-image: url(/src/assets/menuLeft/gps.webp);
  1000. background-size: 100% 100%;
  1001. top: 1.6rem;
  1002. left: 2.07rem;
  1003. }
  1004. .txtRight {
  1005. top: 0px;
  1006. height: 5.71rem;
  1007. line-height: 5.71rem;
  1008. left: 5.64rem;
  1009. right: 3rem;
  1010. font-weight: 400;
  1011. font-size: 2.5rem;
  1012. color: #FFFFFF;
  1013. white-space: nowrap; /* 不换行 */
  1014. overflow: hidden; /* 隐藏超出部分 */
  1015. text-overflow: ellipsis; /* 显示省略号 */
  1016. }
  1017. }
  1018. .menuList {
  1019. position: absolute;
  1020. width: 100%;
  1021. top: 7rem;
  1022. bottom: 0px;
  1023. background-image: url(/src/assets/menuLeft/menuBottom.webp);
  1024. background-size: 100% 100%;
  1025. padding: 1rem 0.5rem 1rem 0.5rem;
  1026. .menuListBorder {
  1027. position: absolute;
  1028. top: 1rem;
  1029. left: 1rem;
  1030. bottom: 1rem;
  1031. right: 1rem;
  1032. .menuListMain {
  1033. position: relative;
  1034. width: 100%;
  1035. height: auto;
  1036. .menuListpParent, .menuListpChildren {
  1037. position: relative;
  1038. width: 90%;
  1039. left: 5%;
  1040. margin: 0.35rem 0rem 0.35rem 0rem;
  1041. padding: 0.35rem 0rem 0.35rem 0rem;
  1042. // 手势
  1043. cursor:pointer;
  1044. }
  1045. .logoMenu {
  1046. width: 1rem;
  1047. height: 1rem;
  1048. background-image: url(/src/assets/menuLeft/yes.webp);
  1049. background-size: 100% 100%;
  1050. }
  1051. .logoTime {
  1052. width: 1rem;
  1053. height: 1rem;
  1054. background-image: url(/src/assets/menuLeft/time.webp);
  1055. background-size: 100% 100%;
  1056. }
  1057. .logoNo {
  1058. width: 1rem;
  1059. height: 1rem;
  1060. background-image: url(/src/assets/menuLeft/no.webp);
  1061. background-size: 100% 100%;
  1062. }
  1063. .menuListpParent {
  1064. font-weight: 400;
  1065. font-size: 1.28rem;
  1066. color: #C8C8C8;
  1067. background: #386064;
  1068. height: 2.5rem;
  1069. .menuListpParentLeft, .menuListpParentCenter, .menuListpParentRight {
  1070. position: absolute;
  1071. height: 100%;
  1072. top: 0px;
  1073. }
  1074. .menuListpParentLeft {
  1075. left: 0px;
  1076. width: 2.5rem;
  1077. /* 水平垂直居中,支持文字自动换行 */
  1078. display: flex;
  1079. flex-direction: column;
  1080. justify-content: center;
  1081. align-items: center;
  1082. }
  1083. .menuListpParentCenter {
  1084. left: 2.5rem;
  1085. right: 2.5rem;
  1086. line-height: 2.5rem;
  1087. white-space: nowrap; /* 不换行 */
  1088. overflow: hidden; /* 隐藏超出部分 */
  1089. text-overflow: ellipsis; /* 显示省略号 */
  1090. }
  1091. .menuListpParentRight {
  1092. width: 2.5rem;
  1093. right: 0px;
  1094. background: #2BA987;
  1095. color: #FFFFFF;
  1096. font-size: 2rem;
  1097. /* 水平垂直居中,支持文字自动换行 */
  1098. display: flex;
  1099. flex-direction: column;
  1100. justify-content: center;
  1101. align-items: center;
  1102. }
  1103. }
  1104. .menuListpParentYes {
  1105. color: #ffffff;
  1106. }
  1107. .menuListpParentSelect {
  1108. color: #ffffff;
  1109. }
  1110. .menuListpChildren {
  1111. font-weight: 400;
  1112. font-size: 1.14rem;
  1113. color: #C8C8C8;
  1114. .menuListpChildrenKong, .menuListpChildrenLeft, .menuListpChildrenRight {
  1115. display: inline-flex;
  1116. }
  1117. .menuListpChildrenKong {
  1118. width: 1%;
  1119. }
  1120. .menuListpChildrenLeft {
  1121. width: 16%;
  1122. /* 水平垂直居中,支持文字自动换行 */
  1123. flex-direction: column;
  1124. justify-content: center;
  1125. align-items: center;
  1126. }
  1127. .menuListpChildrenRight {
  1128. width: 83%;
  1129. }
  1130. }
  1131. .menuListpChildrenYes {
  1132. color: #2CD36B;
  1133. }
  1134. .menuListpChildrenSelect {
  1135. color: #FFFFFF;
  1136. background: linear-gradient( 90deg, rgba(39,171,151,0.6) 0%, rgba(39,171,151,0.2) 100%);
  1137. }
  1138. }
  1139. }
  1140. }
  1141. }
  1142. .menuLook {
  1143. position: fixed;
  1144. width: 2rem;
  1145. height: 5.71rem;
  1146. left: 23.5rem;
  1147. top: 50%;
  1148. margin: -2.855rem 0px 0px 0px;
  1149. z-index: 2;
  1150. background-image: url(/src/assets/menuLeft/menuOpen.webp);
  1151. background-size: 100% 100%;
  1152. // 手势
  1153. cursor:pointer;
  1154. }
  1155. .menuLookExit {
  1156. background-image: url(/src/assets/menuLeft/menuExit.webp);
  1157. background-size: 100% 100%;
  1158. }
  1159. }
  1160. }
  1161. </style>