index.vue 37 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313
  1. <template>
  2. <div class="classroomObservation" v-loading="loading">
  3. <!-- <div class="co-header1">
  4. <div class="co-h1-left">
  5. <span class="co-h1-l-icon el-icon-s-home"></span>
  6. <div class="co-h1-l-router">
  7. <span class="co-h1-l-r-up" @click="goTo('ai助手')">AI助手</span>
  8. <span class="co-h1-l-r-rightIcon el-icon-arrow-right"></span>
  9. <span class="co-j1-l-r-down">课堂观察</span>
  10. </div>
  11. </div>
  12. </div> -->
  13. <div class="co-header2">
  14. <div class="co-h2-left">
  15. <!-- <span
  16. class="co-h2-l-icon"
  17. @click="$refs.addNewCourseDialogRef.open()"
  18. ></span> -->
  19. <span class="co-h2-l-icon"></span>
  20. <!-- @click="addNewCourse()" -->
  21. <!--<span class="co-h2-l-hr"></span>-->
  22. <span class="co-h2-l-text">
  23. <el-select
  24. class="co_h2_l_t_select"
  25. v-model="tid"
  26. placeholder="查看历史课堂"
  27. @change="changeTid"
  28. >
  29. <el-option
  30. v-for="item in optionData"
  31. :key="item.value"
  32. :label="item.label"
  33. :value="item.value"
  34. >
  35. <div class="selectBox">
  36. <span>{{ item.label }}</span>
  37. <div class="controlsBox">
  38. <span
  39. class="changeSelect"
  40. @click.stop="changeCourse(item)"
  41. ></span>
  42. <span
  43. class="delSelect"
  44. @click.stop="delCourse(item.id)"
  45. ></span>
  46. </div>
  47. </div>
  48. </el-option>
  49. </el-select>
  50. </span>
  51. <!-- <div
  52. class="co_h2_l_del"
  53. @click.stop="delCourse()"
  54. v-if="optionData.length > 0"
  55. >
  56. <span></span>
  57. </div> -->
  58. </div>
  59. <div class="co-h2-right">
  60. <div
  61. :class="['co-h2-r-btn', fileId && tid ? '' : 'ca-h2-r-noActive']"
  62. style="background: rgba(54, 129, 252, 1)"
  63. @click.stop="getReport()"
  64. >
  65. <span class="co-h2-r-b-icon1"></span>
  66. <div style="color: white">一键分析</div>
  67. </div>
  68. <div
  69. :class="['co-h2-r-btn', fileId && tid ? '' : 'ca-h2-r-noActive']"
  70. style="background: #ffffff"
  71. @click.stop="preview()"
  72. >
  73. <span class="co-h2-r-b-icon2"></span>
  74. <div style="color: black">查看报告</div>
  75. </div>
  76. <!-- <div class="co-h2-r-btn2" @click.stop="preview()">
  77. <el-tooltip class="item" effect="light" content="预览" placement="top">
  78. <img
  79. src="../../../assets/icon/classroomObservation/Syan.png"
  80. alt=""
  81. />
  82. </el-tooltip>
  83. </div> -->
  84. <div :class="['co-h2-r-btn2']" @click.stop="shareBtn">
  85. <!-- <span class="co-h2-r-b-icon3"></span> -->
  86. <el-tooltip
  87. class="item"
  88. effect="light"
  89. content="分享"
  90. placement="top"
  91. >
  92. <img
  93. src="../../../assets/icon/classroomObservation/daoChu.svg"
  94. alt=""
  95. />
  96. </el-tooltip>
  97. </div>
  98. <div :class="['co-h2-r-btn2']" @click.stop="derive">
  99. <!-- <span class="co-h2-r-b-icon3"></span> -->
  100. <el-tooltip
  101. class="item"
  102. effect="light"
  103. content="导出"
  104. placement="top"
  105. >
  106. <img
  107. src="../../../assets/icon/classroomObservation/derive.svg"
  108. alt=""
  109. />
  110. </el-tooltip>
  111. </div>
  112. <div :class="['co-h2-r-btn2']" @click.stop="examine">
  113. <!-- <span class="co-h2-r-b-icon3"></span> -->
  114. <el-tooltip
  115. class="item"
  116. effect="light"
  117. content="审核"
  118. placement="top"
  119. >
  120. <img
  121. src="../../../assets/icon/classroomObservation/examine.svg"
  122. alt=""
  123. />
  124. </el-tooltip>
  125. </div>
  126. <!-- <div :class="['co-h2-r-btn2']" @click.stop="home">
  127. <el-tooltip
  128. class="item"
  129. effect="light"
  130. content="主页"
  131. placement="top"
  132. >
  133. <img
  134. src="../../../assets/icon/classroomObservation/home.svg"
  135. alt=""
  136. />
  137. </el-tooltip>
  138. </div> -->
  139. </div>
  140. </div>
  141. <div class="co-main">
  142. <div class="co-m-left">
  143. <chatArea
  144. ref="chatAreaRef"
  145. :tid="tid"
  146. @updateFileId="updateFileId"
  147. @changeAudioUrl="changeAudioUrl"
  148. @updateTranscription="updateTranscription"
  149. :fileId="fileId"
  150. :createTime="createTime"
  151. :fileIdId="fileIdId"
  152. />
  153. </div>
  154. <div class="co-m-right">
  155. <messageArea
  156. :tid="tid"
  157. :fileId="fileId"
  158. ref="messageAreaRef"
  159. @changeAudioUrl="changeAudioUrl"
  160. @changeChatAreaAudioUrl="changeChatAreaAudioUrl"
  161. @changeTranscription="changeTranscription"
  162. @changeOptionData="changeOptionData"
  163. @updateTime="updateTime"
  164. />
  165. </div>
  166. </div>
  167. <sharePdf :tid="tid" ref="sharePdfRef" @shareBtn="shareBtn"></sharePdf>
  168. <changeCourseNameDialog
  169. :tid="tid"
  170. ref="changeCourseNameDialogRef"
  171. @success="changeCourseSuccess"
  172. />
  173. <!-- <addNewCourseDialog
  174. :courseList="optionData"
  175. ref="addNewCourseDialogRef"
  176. @success="addNewCourse"
  177. /> -->
  178. </div>
  179. </template>
  180. <script>
  181. // 聊天区域
  182. import chatArea from "./components/chatArea.vue";
  183. // 信息区域
  184. import messageArea from "./components/messageArea.vue";
  185. import sharePdf from "./components/sharePdf.vue";
  186. import { v4 as uuidv4 } from "uuid";
  187. // 添加课堂弹窗
  188. // import addNewCourseDialog from "./components/addNewCourseDialog.vue";
  189. //修改课程名称弹窗
  190. import changeCourseNameDialog from "./components/changeCourseNameDialog";
  191. //保存模板弹窗
  192. import QRCode from "qrcodejs2";
  193. import * as echarts from "echarts";
  194. import "echarts-wordcloud";
  195. // word
  196. import htmlDocx from "html-docx-js/dist/html-docx";
  197. import saveAs from "file-saver";
  198. import MarkdownIt from "markdown-it";
  199. export default {
  200. components: {
  201. chatArea,
  202. messageArea,
  203. sharePdf,
  204. changeCourseNameDialog
  205. // addNewCourseDialog,
  206. },
  207. data() {
  208. return {
  209. loading: false,
  210. createTime: new Date().toLocaleString().replaceAll("/", "-"),
  211. tid: "",
  212. fileId: "",
  213. fileIdId: "",
  214. optionData: [],
  215. userId: this.$route.query["userid"],
  216. tag: {
  217. 0: "一",
  218. 1: "二",
  219. 2: "三"
  220. }
  221. };
  222. },
  223. methods: {
  224. //切换了课堂
  225. changeTid(newValue) {
  226. this.$nextTick(() => {
  227. this.$refs.messageAreaRef.getData();
  228. this.$refs.chatAreaRef.getData();
  229. this.getFileIdId();
  230. // setTimeout(()=>{
  231. // this.$refs.messageAreaRef.init();
  232. // this.$refs.chatAreaRef.init();
  233. // this.tid = "";
  234. // this.fileId = "";
  235. // this.fileIdId = "";
  236. // },6000)
  237. });
  238. },
  239. addNewCourse() {
  240. return new Promise((resolve, reject) => {
  241. this.addNewCourseByDefault().then(_ => {
  242. resolve();
  243. });
  244. });
  245. // var OpenCC = require("opencc-js");
  246. // let converter = OpenCC.Converter({
  247. // from: "hk",
  248. // to: "cn",
  249. // });
  250. // return new Promise((resolve, reject) => {
  251. // if (this.loading) return this.$message.info("请稍等");
  252. // this.loading = true;
  253. // let date = new Date();
  254. // let month = date.getMonth() + 1;
  255. // let day = date.getDate();
  256. // let classroomName = `${month < 10 ? "0" + month : month}${
  257. // day < 10 ? "0" + day : day
  258. // }新建课堂`;
  259. // let sum = this.optionData.filter(
  260. // (i) => i.label.indexOf(classroomName) != -1
  261. // ).length;
  262. // if (!sum == 0) {
  263. // classroomName += sum;
  264. // }
  265. // let params = {
  266. // tid: uuidv4(),
  267. // name: classroomName,
  268. // userid: this.userId,
  269. // };
  270. // this.ajax
  271. // .post(
  272. // "https://gpt4.cocorobo.cn/insert_classroom_observation_tid",
  273. // params
  274. // )
  275. // .then((res) => {
  276. // let _data = res.data.FunctionResponse;
  277. // if (converter(_data.message) == converter("创建成功")) {
  278. // // 设置该课堂的tid
  279. // this.tid = params.tid;
  280. // this.ajax
  281. // .post("https://gpt4.cocorobo.cn/insert_classroom_observation", {
  282. // tid: params.tid,
  283. // type: 10,
  284. // index: 0,
  285. // json_data: JSON.stringify({ file_ids: "" }),
  286. // userid: this.userId,
  287. // })
  288. // .then((res2) => {
  289. // let _data2 = res2.data.FunctionResponse;
  290. // if (converter(_data2.message) == converter("创建成功")) {
  291. // this.loading = false;
  292. // this.$nextTick(() => {
  293. // this.getCourseList().then((_) => {
  294. // this.getFileIdId();
  295. // this.$refs.messageAreaRef.getData();
  296. // this.$refs.chatAreaRef.getData();
  297. // resolve();
  298. // });
  299. // });
  300. // } else {
  301. // this.$message.error("创建fileIds失败");
  302. // }
  303. // });
  304. // } else if (converter(_data.message) == converter("tid重复")) {
  305. // this.$message.error("该课堂已存在");
  306. // this.loading = false;
  307. // } else {
  308. // this.$message.error("创建失败");
  309. // this.loading = false;
  310. // }
  311. // });
  312. // });
  313. },
  314. addNewCourseByDefault() {
  315. // 通过用户ID获取默认的模板
  316. var OpenCC = require("opencc-js");
  317. let converter = OpenCC.Converter({
  318. from: "hk",
  319. to: "cn"
  320. });
  321. return new Promise((resolve, reject) => {
  322. let params = {
  323. uid: this.userId
  324. };
  325. this.loading = true;
  326. this.ajax
  327. .get(this.$store.state.api + "selectClassroomDefault", params)
  328. .then(res => {
  329. let _data = res.data[0][0];
  330. if (_data) {
  331. this.loading = true;
  332. _data.tips = JSON.parse(_data.tips);
  333. let _result = [];
  334. _data.tips.forEach(i => {
  335. if (i.isOtherData) return _result.push(i);
  336. if (converter("词频词汇分析") == converter(i.jsonData.name))
  337. return;
  338. let _obj = {
  339. jsonData: i.jsonData,
  340. type: i.Type,
  341. index: i.tIndex
  342. };
  343. _result.push(_obj);
  344. });
  345. this.loading = false;
  346. // console.log('👇要生成的模板')
  347. // console.log(_result)
  348. this.addNewCourseByTemplate(_result).then(_ => {
  349. resolve();
  350. });
  351. } else {
  352. this.loading = false;
  353. this.$message.error("获取模板详细为空");
  354. }
  355. });
  356. });
  357. },
  358. addNewCourseByTemplate(json = []) {
  359. if (json.length <= 0) return;
  360. var OpenCC = require("opencc-js");
  361. let converter = OpenCC.Converter({
  362. from: "hk",
  363. to: "cn"
  364. });
  365. let tagList = json.find(i => i.isOtherData);
  366. json = json.filter(
  367. i =>
  368. !i.isOtherData &&
  369. converter(i.jsonData.name) != converter("词频词汇分析")
  370. );
  371. return new Promise((resolve, reject) => {
  372. this.loading = true;
  373. const _newTid = uuidv4();
  374. let params = {
  375. tid: _newTid,
  376. userid: this.userId,
  377. template: json
  378. };
  379. this.ajax
  380. .post(
  381. "https://gpt4.cocorobo.cn/insert_classroom_observation_template",
  382. params
  383. )
  384. .then(res => {
  385. let _data = res.data.FunctionResponse;
  386. if (converter(_data.message) == converter("创建成功")) {
  387. // 设置该课堂的tid
  388. this.tid = params.tid;
  389. this.ajax
  390. .post("https://gpt4.cocorobo.cn/insert_classroom_observation", {
  391. tid: params.tid,
  392. type: 10,
  393. index: 0,
  394. json_data: JSON.stringify({ file_ids: "" }),
  395. userid: this.userId
  396. })
  397. .then(res2 => {
  398. let _data2 = res2.data.FunctionResponse;
  399. if (converter(_data2.message) == converter("创建成功")) {
  400. this.loading = false;
  401. this.$nextTick(() => {
  402. this.getCourseList().then(_ => {
  403. this.getFileIdId();
  404. this.$refs.messageAreaRef.getData().then(res => {
  405. if (tagList) {
  406. this.$refs.messageAreaRef.changeAnalysisName(
  407. tagList.dialogTagList,
  408. 1
  409. );
  410. }
  411. });
  412. this.$refs.chatAreaRef.getData();
  413. resolve();
  414. });
  415. });
  416. } else {
  417. this.$message.error("创建fileIds失败");
  418. }
  419. });
  420. } else if (converter(_data.message) == converter("tid重复")) {
  421. this.$message.error("该课堂已存在");
  422. this.loading = false;
  423. } else {
  424. this.$message.error("创建失败");
  425. this.loading = false;
  426. }
  427. });
  428. });
  429. },
  430. updateFileId(newValue) {
  431. this.fileId = newValue;
  432. },
  433. // 生成报告
  434. getReport() {
  435. if (!this.fileId) return;
  436. // this.$confirm("操作将覆盖原有内容,是否继续?", "提示", {
  437. // confirmButtonText: "确定",
  438. // cancelButtonText: "取消",
  439. // type: "warning",
  440. // })
  441. // .then(() => {
  442. this.$refs.messageAreaRef.getReport();
  443. // })
  444. // .catch((e) => {
  445. // console.log(e)
  446. // console.log("取消生成报告");
  447. // });
  448. },
  449. //预览
  450. preview() {
  451. if (!this.fileId) return;
  452. window.parent.postMessage(
  453. {
  454. tools: "classroom_observation_board",
  455. type: this.tid
  456. },
  457. "*"
  458. );
  459. },
  460. async derive() {
  461. if (!this.tid) return this.$message.error("请先选择课堂");
  462. try {
  463. this.loading = true;
  464. let bmData = this.$refs.messageAreaRef.bmData
  465. ? this.$refs.messageAreaRef.bmData.jsonData
  466. : "";
  467. const md = new MarkdownIt();
  468. let dataList = this.$refs.messageAreaRef.dataList;
  469. let tagList = this.$refs.messageAreaRef.dialogTagList;
  470. let showBrief = this.$refs.messageAreaRef.showBrief;
  471. tagList.forEach(i => (i.dataList = []));
  472. let url = `https://beta.cloud.cocorobo.cn/aigpt/#/classroom_observation_board?tid=${this.tid}`;
  473. const qRCodeSrc = await this.getQrCodeImageSrc(url);
  474. dataList.forEach(i1 => {
  475. tagList.forEach(i2 => {
  476. if (i2.value == i1.Type) {
  477. i2.dataList.push(i1);
  478. }
  479. });
  480. });
  481. let directoryHtml = `<div style="margin-bottom:1in"><div style="text-align:center;font-size:20pt;margin-bottom:0.5in">目录</div>`;
  482. let analysisHtml = ``;
  483. // tagList.forEach(i => {
  484. // let dire = `<div>`;
  485. // let tagHtml = `<div style="margin-bottom:100px">`;
  486. // if (i.value == 0) {
  487. // i.dataList = i.dataList.filter(i2 => i2.tIndex != 2);
  488. // }
  489. // i.dataList.sort((a, b) => a.tIndex - b.tIndex);
  490. // tagHtml += `<h1 style="font-size:16pt;margin-bottom:30px">${
  491. // this.tag[i.value]
  492. // }、${i.name}</h1>`;
  493. // dire += `<div style="font-size:14pt;margin:15px 0">${
  494. // this.tag[i.value]
  495. // }、${i.name}</div>`;
  496. // i.dataList.forEach(async (i2, i2Index) => {
  497. // tagHtml += `<h2 style="font-size:14pt;margin-bottom:20px">${i2Index +
  498. // 1}、${
  499. // i2.jsonData.anotherName
  500. // ? i2.jsonData.anotherName
  501. // : i2.jsonData.name
  502. // }</h2>`;
  503. // dire += `<div style="font-size:11pt;margin:10px 0;margin-left:50px">${i2Index +
  504. // 1}、${
  505. // i2.jsonData.anotherName
  506. // ? i2.jsonData.anotherName
  507. // : i2.jsonData.name
  508. // }</div>`;
  509. // if (showBrief) {
  510. // tagHtml += `<div style="font-size:10.5pt;font-style:italic;margin-bottom:10px;color:#6b798e">${i2.jsonData.result}</div>`;
  511. // }
  512. // if (i2.jsonData.eChartData) {
  513. // console.log(
  514. // await this.getEChartsImageSrc(i2.jsonData.eChartData)
  515. // );
  516. // // tagHtml += `<div>${await this.getEChartsImageSrc(
  517. // // i2.jsonData.eChartData
  518. // // )}</div>`;
  519. // // tagHtml+=`<img src="${await this.getEChartsImageSrc(i2.jsonData.eChartData)}" style="width:400px;height:400px;"/>`
  520. // }
  521. // let _content = md.render(i2.jsonData.content);
  522. // tagHtml += `<div style="font-size:10.5pt;margin-bottom:10px">${_content}</div>`;
  523. // });
  524. // tagHtml += "</div>";
  525. // dire += "</div>";
  526. // analysisHtml += tagHtml;
  527. // directoryHtml += dire;
  528. // });
  529. for (let c = 0; c < tagList.length; c++) {
  530. let i = tagList[c];
  531. let dire = `<div>`;
  532. let tagHtml = `<div style="margin-bottom:0.5in">`;
  533. if (i.value == 0) {
  534. i.dataList = i.dataList.filter(i2 => i2.tIndex != 2);
  535. }
  536. i.dataList.sort((a, b) => a.tIndex - b.tIndex);
  537. tagHtml += `<h1 style="font-size:16pt;margin-bottom:-1in">${
  538. this.tag[i.value]
  539. }、${i.name}</h1>`;
  540. dire += `<p style="font-size:14pt;margin-bottom:-0.8in">${
  541. this.tag[i.value]
  542. }、${i.name}</p>`;
  543. for (let d = 0; d < i.dataList.length; d++) {
  544. let i2 = i.dataList[d];
  545. let i2Index = d;
  546. tagHtml += `<h2 style="font-size:14pt;margin-bottom:-1in">${i2Index +
  547. 1}、${
  548. i2.jsonData.anotherName
  549. ? i2.jsonData.anotherName
  550. : i2.jsonData.name
  551. }</h2>`;
  552. dire += `<p style="font-size:11pt;margin-bottom:-0.8in;margin-left:0.1in">${i2Index +
  553. 1}、${
  554. i2.jsonData.anotherName
  555. ? i2.jsonData.anotherName
  556. : i2.jsonData.name
  557. }</p>`;
  558. if (showBrief) {
  559. tagHtml += `<p style="font-size:10.5pt;font-style:italic;margin-bottom:-0.7in;color:#6b798e">${i2.jsonData.result}</p>`;
  560. }
  561. if (i2.jsonData.eChartData) {
  562. tagHtml += `<img src="${await this.getEChartsImageSrc(
  563. i2.jsonData.eChartData
  564. )}"/>`;
  565. }
  566. if (i2.jsonData.CH && i2.jsonData.RT) {
  567. tagHtml += `<div>
  568. <img src=''>
  569. </div>`;
  570. }
  571. let _content = md.render(i2.jsonData.content);
  572. tagHtml += `<p style="font-size:10.5pt;margin-bottom:-0.5in">${_content}</p>`;
  573. }
  574. tagHtml += "</div>";
  575. dire += "</div>";
  576. analysisHtml += tagHtml;
  577. directoryHtml += dire;
  578. }
  579. directoryHtml += "</div>";
  580. // this.loading = false;
  581. // return console.log(analysisHtml);
  582. // return console.log(analysisHtml);
  583. let _html = `
  584. <div>
  585. <p style="width:100vw;margin-bottom:1.5in">*分析结果仅供参考</p>
  586. <p style="font-size:28pt;width:100vw;text-align:center;">课堂观察报告</p>
  587. <p style="font-size:10pt;width:100vw;text-align:center;margin-bottom:0.6in">报告生成时间:${new Date().toLocaleString()}</p>
  588. <div style="font-size:16pt;width:100vw;text-align:center;margin-bottom:1in">
  589. <p style="font-size:20pt;margin-bottom:0.7in">《${bmData.courseName}》</p>
  590. <p style="margin-bottom:-1in">授课老师:${bmData.teacherName ? bmData.teacherName : "未填写"}</p>
  591. <p style="margin-bottom:-1in">授课年级:${bmData.grade ? bmData.grade : "未填写"}</p>
  592. <p style="margin-bottom:-1in">授课科目:${bmData.subject ? bmData.subject : "未填写"}</p>
  593. <p style="margin-bottom:-1in">授课时间:${bmData.time ? bmData.time : "未填写"}</p>
  594. </div>
  595. <div style="font-size:16pt;width:100vw;text-align:center;margin-bottom:0.5in">
  596. <img src="${qRCodeSrc}" style="width:150px;height:150px;margin:auto;"/>
  597. <p>扫码查看网页版</p>
  598. </div>
  599. </div>
  600. ${directoryHtml}
  601. <div>
  602. ${analysisHtml}
  603. </div>
  604. `;
  605. this.generateDocx(`《${bmData.courseName}》课堂观察报告`, _html);
  606. this.loading = false;
  607. } catch (e) {
  608. console.log(e);
  609. this.$message.error("导出失败");
  610. this.loading = false;
  611. }
  612. },
  613. getQrCodeImageSrc(url) {
  614. return new Promise((resolve, reject) => {
  615. let qrcode = new QRCode(document.createElement("div"), {
  616. text: url, // 需要转换为二维码的内容
  617. width: 150,
  618. height: 150,
  619. colorDark: "#000000",
  620. colorLight: "#ffffff",
  621. correctLevel: QRCode.CorrectLevel.H
  622. });
  623. let img = qrcode._el.getElementsByTagName("img")[0];
  624. img.onload = () => {
  625. resolve(img.src);
  626. };
  627. });
  628. },
  629. getEChartsImageSrc(option) {
  630. return new Promise(resolve => {
  631. let hiddenDiv = document.createElement("div");
  632. hiddenDiv.style.width = "600px";
  633. hiddenDiv.style.height = "500px";
  634. hiddenDiv.style.position = "absolute";
  635. hiddenDiv.style.left = "-9999px"; // 隐藏div
  636. document.body.appendChild(hiddenDiv);
  637. // 初始化图表
  638. let myChart = echarts.init(hiddenDiv);
  639. // 设置图标配置
  640. myChart.setOption(option);
  641. myChart.on("finished", () => {
  642. // 获取图表的图片
  643. let base64Image = myChart.getDataURL({
  644. type: "png", // 图片格式
  645. pixelRatio: 1, // 图像清晰度
  646. backgroundColor: "#fff" // 背景颜色
  647. });
  648. resolve(base64Image);
  649. // 清除隐藏的div和图表实例
  650. document.body.removeChild(hiddenDiv);
  651. myChart.dispose();
  652. });
  653. });
  654. },
  655. // 导出docx
  656. async generateDocx(name, html) {
  657. // 将html文件中需要用到的数据挂载到store上
  658. const content = `<!DOCTYPE html>
  659. <html xmlns:v='urn:schemas-microsoft-com
  660. :vml'xmlns:o='urn:schemas-microsoft-com:office
  661. :office'xmlns:w='urn:schemas-microsoft-com:office
  662. :word'xmlns:m='http://schemas.microsoft.com/office/2004/12/omml'
  663. xmlns='http://www.w3.org/TR/REC-html40'
  664. xmlns='http://www.w3.org/1999/xhtml'>
  665. <head>
  666. <meta charset="UTF-8">
  667. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  668. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  669. <title>${name}</title>
  670. <style>
  671. *{
  672. font-family: '宋体';
  673. margin:0;
  674. padding:0;
  675. line-height:1;
  676. }
  677. table {
  678. border-collapse: collapse; /* 折叠边框 */
  679. width: 100%;
  680. font-size:10.5pt;
  681. }
  682. th, td {
  683. border: 1px solid black; /* 线条样式 */
  684. padding: 8px;
  685. text-align: left;
  686. font-size:10.5pt;
  687. }
  688. ol,ul{
  689. margin:0;
  690. padding:0;
  691. margin-right:-1in;
  692. }
  693. li{
  694. margin-bottom:0.1in
  695. margin-right:-1in;
  696. }
  697. p{
  698. line-height:1;
  699. margin:0;
  700. padding:0
  701. }
  702. </style>
  703. </head>
  704. <body>
  705. ${html}
  706. </body>
  707. </html>`;
  708. // console.log(content)
  709. // return console.log(content)
  710. // debugger
  711. let blob = htmlDocx.asBlob(content);
  712. // const uploadFile = new File([blob], `${name}.docx`, {
  713. // type:
  714. // "application/vnd.openxmlformats-officedocument.wordprocessingml.document"
  715. // });
  716. saveAs(blob, `${name}.docx`);
  717. return true;
  718. // this.beforeUploadHtml(uploadFile);
  719. },
  720. beforeUploadHtml(event) {
  721. var file = event;
  722. var credentials = {
  723. accessKeyId: "AKIATLPEDU37QV5CHLMH",
  724. secretAccessKey: "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"
  725. }; //秘钥形式的登录上传
  726. window.AWS.config.update(credentials);
  727. window.AWS.config.region = "cn-northwest-1"; //设置区域
  728. var bucket = new window.AWS.S3({ params: { Bucket: "ccrb" } }); //选择桶
  729. var _this = this;
  730. if (file) {
  731. var params = {
  732. Key:
  733. file.name.split(".")[0] +
  734. new Date().getTime() +
  735. "." +
  736. file.name.split(".")[file.name.split(".").length - 1],
  737. ContentType: file.type,
  738. Body: file,
  739. "Access-Control-Allow-Credentials": "*",
  740. ACL: "public-read"
  741. }; //key可以设置为桶的相抵路径,Body为文件, ACL最好要设置
  742. var options = {
  743. partSize: 2048 * 1024 * 1024,
  744. queueSize: 2,
  745. leavePartsOnError: true
  746. };
  747. bucket
  748. .upload(params, options)
  749. .on("httpUploadProgress", function(evt) {
  750. //这里可以写进度条
  751. // console.log("Uploaded : " + parseInt((evt.loaded * 80) / evt.total) + '%');
  752. })
  753. .send(function(err, data) {
  754. if (err) {
  755. _this.$message.error("上传失败");
  756. } else {
  757. console.log(data.Location);
  758. }
  759. });
  760. }
  761. },
  762. // 分享
  763. shareBtn() {
  764. // if(!this.fileId)return;
  765. // this.dialogVisibleShare = !this.dialogVisibleShare;
  766. this.$refs.sharePdfRef.open();
  767. },
  768. // 审核
  769. examine() {
  770. if (!this.tid) return;
  771. window.parent.postMessage(
  772. {
  773. tools: "classroom_observation_ob_comment",
  774. type: this.tid
  775. },
  776. "*"
  777. );
  778. },
  779. // 主页
  780. home() {
  781. this.$message.info("主页");
  782. },
  783. delCourse(_value) {
  784. this.$confirm("此操作将永久删除该课堂, 是否继续?", "提示", {
  785. confirmButtonText: "确定",
  786. cancelButtonText: "取消",
  787. type: "warning"
  788. })
  789. .then(() => {
  790. // this.optionData.splice(
  791. // this.optionData.findIndex((item) => item.value == _value),
  792. // 1
  793. // );
  794. // this.tid = this.optionData[0] ? this.optionData[0].value : "";
  795. // this.changeTid(this.tid);
  796. // this.$message({
  797. // type: "success",
  798. // message: "删除成功!",
  799. // });
  800. let params = {
  801. tid: _value
  802. };
  803. this.ajax
  804. .post(
  805. "https://gpt4.cocorobo.cn/update_classroom_observation_isdel",
  806. params
  807. )
  808. .then(res => {
  809. this.$message({
  810. type: "success",
  811. message: "删除成功!"
  812. });
  813. this.tid = "";
  814. // 清空tid
  815. this.tid = "";
  816. this.fileIdId = "";
  817. this.fileId = "";
  818. this.getCourseList().then(_ => {
  819. if (!this.tid) {
  820. this.$refs.messageAreaRef.init();
  821. this.$refs.chatAreaRef.init();
  822. } else {
  823. this.getFileIdId();
  824. this.$refs.messageAreaRef.getData();
  825. this.$refs.chatAreaRef.getData();
  826. }
  827. });
  828. });
  829. })
  830. .catch(() => {});
  831. },
  832. // 获取修改fileId的ID
  833. getFileIdId() {
  834. if (!this.tid) return;
  835. let pram = {
  836. tid: this.tid,
  837. type: "10"
  838. };
  839. this.fileIdId = "";
  840. this.fileId = "";
  841. this.ajax
  842. .post("https://gpt4.cocorobo.cn/get_classroom_observation_new", pram)
  843. .then(res => {
  844. let _data = res.data.FunctionResponse.result.length
  845. ? JSON.parse(res.data.FunctionResponse.result)
  846. : [];
  847. if (_data.length <= 0) return;
  848. this.fileIdId = _data[0].id;
  849. if (_data[0].jsonData != "") {
  850. this.fileId = JSON.parse(_data[0].jsonData).file_ids;
  851. } else {
  852. this.fileId = "";
  853. }
  854. });
  855. },
  856. // 切换录音文件
  857. changeAudioUrl(data) {
  858. this.$refs.messageAreaRef.changeAudioUrl(data);
  859. },
  860. changeChatAreaAudioUrl(data) {
  861. this.$refs.chatAreaRef.changeAudioUrl(data.url);
  862. },
  863. getCourseList() {
  864. this.loading = true;
  865. return new Promise((resolve, reject) => {
  866. this.ajax
  867. .post("https://gpt4.cocorobo.cn/get_classroom_observation_all", {
  868. userid: this.userId
  869. })
  870. .then(res => {
  871. let _data = res.data.FunctionResponse.result;
  872. let _result = [];
  873. try {
  874. _result = _data ? JSON.parse(_data) : [];
  875. } catch (error) {
  876. _result = [];
  877. }
  878. if (_result.length <= 0) {
  879. this.loading = false;
  880. resolve();
  881. return;
  882. }
  883. let _optionData = _result.map(item => {
  884. item.jsonData = item.jsonData ? JSON.parse(item.jsonData) : {};
  885. return {
  886. label: item.jsonData.courseName
  887. ? item.jsonData.courseName
  888. : `${item.tId}课堂`,
  889. value: item.tId,
  890. id: item.id
  891. };
  892. });
  893. _optionData = _optionData.filter(i => i.label != "" && i.tId != "");
  894. this.optionData = _optionData;
  895. if (this.optionData.length > 0) {
  896. this.$refs.chatAreaRef.$refs.startPageRef.showIntroduce = false;
  897. }
  898. this.loading = false;
  899. resolve();
  900. })
  901. .catch(e => {
  902. console.log(e);
  903. resolve();
  904. this.$message.error("获取课堂列表失败");
  905. });
  906. });
  907. },
  908. updateTranscription({ transcriptionData, editorBarData }, fn) {
  909. this.$refs.messageAreaRef.updateMessageTranscription(
  910. {
  911. transcriptionData,
  912. editorBarData
  913. },
  914. fn
  915. );
  916. },
  917. changeTranscription({ transcriptionData, editorBarData }) {
  918. this.$refs.chatAreaRef.changeEditorBar({
  919. transcriptionData,
  920. editorBarData
  921. });
  922. },
  923. changeOptionData(_tid, _newObj) {
  924. let _index = this.optionData.findIndex(i => i.value == _tid);
  925. if (_index != -1) {
  926. this.optionData[_index] = { ...this.optionData[_index], ..._newObj };
  927. this.$forceUpdate();
  928. }
  929. },
  930. updateTime(time) {
  931. this.createTime = time;
  932. },
  933. // 修改课程名称
  934. changeCourse(item) {
  935. this.$refs.changeCourseNameDialogRef.open(item);
  936. // console.log(item);
  937. },
  938. // 修改课程名称确定
  939. changeCourseSuccess(data) {
  940. this.loading = true;
  941. if (this.tid == data.tid) {
  942. this.$refs.messageAreaRef.bmData.jsonData.courseName = data.name;
  943. this.$refs.messageAreaRef
  944. .saveData(this.$refs.messageAreaRef.bmData)
  945. .then(res => {
  946. this.loading = false;
  947. this.optionData.find(i => i.id == data.id).label = data.name;
  948. this.$message.success("修改成功");
  949. });
  950. } else {
  951. this.ajax
  952. .post("https://gpt4.cocorobo.cn/get_classroom_observation_new", {
  953. tid: data.tid,
  954. type: 0
  955. })
  956. .then(res => {
  957. let _data = res.data.FunctionResponse.result;
  958. _data = JSON.parse(_data);
  959. let _bmData = _data.find(i => i.tIndex == 0);
  960. _bmData.jsonData = JSON.parse(_bmData.jsonData);
  961. _bmData.jsonData.courseName = data.name;
  962. this.$refs.messageAreaRef.saveData(_bmData).then(res => {
  963. this.loading = false;
  964. this.optionData.find(i => i.id == data.id).label = data.name;
  965. this.$message.success("修改成功");
  966. });
  967. })
  968. .catch(e => {
  969. console.log(e);
  970. this.$message.error("修改失败");
  971. this.loading = false;
  972. });
  973. }
  974. },
  975. //保存词频词汇分析
  976. saveWordFrequency({ _sentence = 0, _words = 0 }) {
  977. this.$refs.messageAreaRef.saveWordFrequency({ _sentence, _words });
  978. }
  979. },
  980. mounted() {
  981. this.getCourseList().then(_ => {
  982. if (!this.tid) {
  983. return this.$refs.messageAreaRef.getDefaultData();
  984. }
  985. this.getFileIdId();
  986. this.$refs.messageAreaRef.getData();
  987. this.$refs.chatAreaRef.getData();
  988. });
  989. }
  990. };
  991. </script>
  992. <style scoped>
  993. .classroomObservation {
  994. min-width: 1500px;
  995. width: 100%;
  996. height: 100%;
  997. display: flex;
  998. flex-direction: column;
  999. background-color: #f0f2f5;
  1000. }
  1001. .co-header1 {
  1002. width: 100%;
  1003. height: 46px;
  1004. background-color: #060e17;
  1005. display: flex;
  1006. align-items: center;
  1007. justify-content: space-between;
  1008. box-sizing: border-box;
  1009. padding: 0 20px;
  1010. }
  1011. .co-h1-left {
  1012. width: auto;
  1013. height: 22px;
  1014. display: flex;
  1015. align-items: center;
  1016. box-sizing: border-box;
  1017. padding: 0 20px;
  1018. }
  1019. .co-h1-l-icon {
  1020. color: #5d6268;
  1021. width: 16px;
  1022. height: 16px;
  1023. margin-right: 10px;
  1024. }
  1025. .co-h1-l-router {
  1026. display: flex;
  1027. align-items: center;
  1028. color: white;
  1029. font-size: 14px;
  1030. }
  1031. .co-h1-l-router > span {
  1032. margin: 0 5px;
  1033. }
  1034. .co-h1-l-r-up {
  1035. color: #5d6268;
  1036. cursor: pointer;
  1037. }
  1038. .co-h1-l-r-up:hover {
  1039. color: white;
  1040. }
  1041. .co-j1-l-r-down {
  1042. cursor: pointer;
  1043. }
  1044. .co-h1-l-r-rightIcon {
  1045. font-size: 16px;
  1046. color: #5d6268;
  1047. }
  1048. .co-header2 {
  1049. width: 100%;
  1050. height: 42px;
  1051. min-height: 42px;
  1052. max-height: 42px;
  1053. background-color: white;
  1054. display: flex;
  1055. align-items: center;
  1056. justify-content: space-between;
  1057. box-sizing: border-box;
  1058. padding: 0 20px;
  1059. }
  1060. .co-h2-left {
  1061. width: auto;
  1062. height: 22px;
  1063. display: flex;
  1064. align-items: center;
  1065. font-size: 14px;
  1066. }
  1067. .co-h2-l-icon {
  1068. width: 20px;
  1069. height: 20px;
  1070. position: relative;
  1071. background: url("../../../assets/icon/classroomObservation/courseIcon.svg")
  1072. no-repeat;
  1073. /* transform: rotate(45deg); */
  1074. cursor: pointer;
  1075. background-size: 100% 100%;
  1076. }
  1077. .co-h2-l-hr {
  1078. width: 2px;
  1079. height: 20px;
  1080. background-color: #e7e7e7;
  1081. border-radius: 10px;
  1082. margin: 0 10px;
  1083. }
  1084. .co-h2-right {
  1085. width: auto;
  1086. height: 100%;
  1087. display: flex;
  1088. align-items: center;
  1089. }
  1090. .co-h2-r-btn {
  1091. width: auto;
  1092. box-sizing: border-box;
  1093. padding: 0 10px;
  1094. height: 30px;
  1095. display: flex;
  1096. align-items: center;
  1097. cursor: pointer;
  1098. font-size: 14px;
  1099. margin: 0 10px;
  1100. box-sizing: border-box;
  1101. border: 1px solid rgba(134, 179, 253, 1);
  1102. /* border: solid 1px #3681FC; */
  1103. border-radius: 5px;
  1104. }
  1105. .ca-h2-r-noActive {
  1106. opacity: 0.5 !important;
  1107. cursor: not-allowed !important;
  1108. }
  1109. .co-h2-r-btn2 {
  1110. width: auto;
  1111. box-sizing: border-box;
  1112. padding: 10px;
  1113. height: 30px;
  1114. display: flex;
  1115. align-items: center;
  1116. cursor: pointer;
  1117. margin: 0 10px;
  1118. box-sizing: border-box;
  1119. border-radius: 5px;
  1120. box-shadow: 0px 4px 10px 0px rgba(29, 57, 131, 0.08);
  1121. /* box-shadow: 1px 1px 20px 4px rgba(29, 57, 131, 0.05); */
  1122. }
  1123. .co-h2-r-btn2 > img {
  1124. width: 20px;
  1125. height: 20px;
  1126. }
  1127. .co-h2-r-btn > span:nth-child(1) {
  1128. width: 20px;
  1129. height: 20px;
  1130. margin-right: 8px;
  1131. }
  1132. .co-h2-r-b-icon1 {
  1133. background: url("../../../assets/icon/classroomObservation/six.svg") no-repeat;
  1134. background-size: 100% 100%;
  1135. }
  1136. .co-h2-r-b-icon2 {
  1137. background: url("../../../assets/icon/classroomObservation/Syan.svg")
  1138. no-repeat;
  1139. background-size: 100% 100%;
  1140. }
  1141. /* .co-h2-r-b-icon2 {
  1142. background: url("../../../assets/icon/classroomObservation/daoChu.png")
  1143. no-repeat;
  1144. background-size: 100% 100%;
  1145. }
  1146. .co-h2-r-b-icon3 {
  1147. background: url("../../../assets/icon/classroomObservation/Syan.png")
  1148. no-repeat;
  1149. background-size: 100% 100%;
  1150. } */
  1151. /* .co-h2-r-blueBtn {
  1152. background: rgba(134, 179, 253, 1);
  1153. color: white;
  1154. } */
  1155. .co-main {
  1156. width: 100%;
  1157. flex: 1;
  1158. display: flex;
  1159. /* align-items: center; */
  1160. /* justify-content: center; */
  1161. }
  1162. .co-m-left {
  1163. box-sizing: border-box;
  1164. flex: 1;
  1165. min-width: 650px;
  1166. }
  1167. .co-m-right {
  1168. height: 100%;
  1169. flex: 1;
  1170. box-sizing: border-box;
  1171. min-width: 450px;
  1172. overflow: auto;
  1173. }
  1174. .co_h2_l_t_select >>> .el-input__inner {
  1175. border: none;
  1176. }
  1177. /* .co_h2_l_t_select >>> .el-input__suffix {
  1178. display: none;
  1179. } */
  1180. .co_h2_l_del {
  1181. width: 35px;
  1182. height: 35px;
  1183. margin-left: 10px;
  1184. border-radius: 5px;
  1185. display: flex;
  1186. justify-content: center;
  1187. align-items: center;
  1188. cursor: pointer;
  1189. }
  1190. .co_h2_l_del > span {
  1191. width: 20px;
  1192. height: 20px;
  1193. display: flex;
  1194. justify-content: center;
  1195. align-items: center;
  1196. background: url("../../../assets/icon/classroomObservation/del.svg") no-repeat;
  1197. background-size: 100% 100%;
  1198. }
  1199. .co_h2_l_del:hover {
  1200. background-color: #eaeef1;
  1201. }
  1202. .selectBox {
  1203. width: 100%;
  1204. height: 100%;
  1205. display: flex;
  1206. align-items: center;
  1207. justify-content: space-between;
  1208. }
  1209. .controlsBox {
  1210. display: flex;
  1211. align-items: center;
  1212. width: auto;
  1213. height: 100%;
  1214. display: none;
  1215. }
  1216. .selectBox:hover > .controlsBox {
  1217. display: flex;
  1218. }
  1219. .changeSelect {
  1220. width: 16px;
  1221. height: 16px;
  1222. /* display: none; */
  1223. align-items: center;
  1224. justify-content: center;
  1225. background: url("../../../assets/icon/classroomObservation/editIcon.svg")
  1226. no-repeat;
  1227. background-size: 100% 100%;
  1228. box-sizing: border-box;
  1229. margin-right: 10px;
  1230. }
  1231. .delSelect {
  1232. width: 16px;
  1233. height: 16px;
  1234. /* display: none; */
  1235. align-items: center;
  1236. justify-content: center;
  1237. background: url("../../../assets/icon/classroomObservation/del.svg") no-repeat;
  1238. background-size: 100% 100%;
  1239. box-sizing: border-box;
  1240. /* transform: translateY(7px); */
  1241. }
  1242. </style>