index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660
  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-hr"></span>
  20. <span class="co-h2-l-text">
  21. <el-select
  22. class="co_h2_l_t_select"
  23. v-model="tid"
  24. placeholder="请选择"
  25. @change="changeTid"
  26. >
  27. <el-option
  28. v-for="item in optionData"
  29. :key="item.value"
  30. :label="item.label"
  31. :value="item.value"
  32. >
  33. <div class="selectBox">
  34. <span style="float: left">{{ item.label }}</span>
  35. <span
  36. class="delSelect"
  37. @click.stop="delCourse(item.value)"
  38. style="float: right"
  39. ></span>
  40. </div>
  41. </el-option>
  42. </el-select>
  43. </span>
  44. <!-- <div
  45. class="co_h2_l_del"
  46. @click.stop="delCourse()"
  47. v-if="optionData.length > 0"
  48. >
  49. <span></span>
  50. </div> -->
  51. </div>
  52. <div class="co-h2-right">
  53. <div
  54. :class="['co-h2-r-btn', fileId ? '' : 'ca-h2-r-noActive']"
  55. style="background: rgba(54, 129, 252, 1)"
  56. @click.stop="getReport()"
  57. >
  58. <span class="co-h2-r-b-icon1"></span>
  59. <div style="color: white">一键分析</div>
  60. </div>
  61. <div
  62. :class="['co-h2-r-btn', fileId ? '' : 'ca-h2-r-noActive']"
  63. style="background: #ffffff"
  64. @click.stop="preview()"
  65. >
  66. <span class="co-h2-r-b-icon2"></span>
  67. <div style="color: black">查看报告</div>
  68. </div>
  69. <!-- <div class="co-h2-r-btn2" @click.stop="preview()">
  70. <el-tooltip class="item" effect="light" content="预览" placement="top">
  71. <img
  72. src="../../../assets/icon/classroomObservation/Syan.png"
  73. alt=""
  74. />
  75. </el-tooltip>
  76. </div> -->
  77. <div :class="['co-h2-r-btn2']" @click.stop="shareBtn">
  78. <!-- <span class="co-h2-r-b-icon3"></span> -->
  79. <el-tooltip
  80. class="item"
  81. effect="light"
  82. content="分享"
  83. placement="top"
  84. >
  85. <img
  86. src="../../../assets/icon/classroomObservation/daoChu.svg"
  87. alt=""
  88. />
  89. </el-tooltip>
  90. </div>
  91. <div :class="['co-h2-r-btn2']" @click.stop="examine">
  92. <!-- <span class="co-h2-r-b-icon3"></span> -->
  93. <el-tooltip
  94. class="item"
  95. effect="light"
  96. content="审核"
  97. placement="top"
  98. >
  99. <img
  100. src="../../../assets/icon/classroomObservation/examine.svg"
  101. alt=""
  102. />
  103. </el-tooltip>
  104. </div>
  105. <!-- <div :class="['co-h2-r-btn2']" @click.stop="home">
  106. <el-tooltip
  107. class="item"
  108. effect="light"
  109. content="主页"
  110. placement="top"
  111. >
  112. <img
  113. src="../../../assets/icon/classroomObservation/home.svg"
  114. alt=""
  115. />
  116. </el-tooltip>
  117. </div> -->
  118. </div>
  119. </div>
  120. <div class="co-main">
  121. <div class="co-m-left">
  122. <chatArea
  123. ref="chatAreaRef"
  124. :tid="tid"
  125. @updateFileId="updateFileId"
  126. @changeAudioUrl="changeAudioUrl"
  127. @updateTranscription="updateTranscription"
  128. :fileId="fileId"
  129. :fileIdId="fileIdId"
  130. />
  131. </div>
  132. <div class="co-m-right">
  133. <messageArea
  134. :tid="tid"
  135. :fileId="fileId"
  136. ref="messageAreaRef"
  137. @changeAudioUrl="changeAudioUrl"
  138. @changeChatAreaAudioUrl="changeChatAreaAudioUrl"
  139. @changeTranscription="changeTranscription"
  140. @changeOptionData="changeOptionData"
  141. />
  142. </div>
  143. </div>
  144. <sharePdf
  145. :dialogVisibleShare="dialogVisibleShare"
  146. :tid="tid"
  147. @shareBtn="shareBtn"
  148. ></sharePdf>
  149. <addNewCourseDialog
  150. :courseList="optionData"
  151. ref="addNewCourseDialogRef"
  152. @success="addNewCourse"
  153. />
  154. </div>
  155. </template>
  156. <script>
  157. // 聊天区域
  158. import chatArea from "./components/chatArea.vue";
  159. // 信息区域
  160. import messageArea from "./components/messageArea.vue";
  161. import sharePdf from "./components/sharePdf.vue";
  162. // 添加课程弹窗
  163. import addNewCourseDialog from "./components/addNewCourseDialog.vue";
  164. export default {
  165. components: {
  166. chatArea,
  167. messageArea,
  168. sharePdf,
  169. addNewCourseDialog,
  170. },
  171. data() {
  172. return {
  173. title: "12月19日会议录音",
  174. loading: false,
  175. dialogVisibleShare: false,
  176. tid: "",
  177. fileId: "",
  178. fileIdId: "",
  179. optionData: [],
  180. };
  181. },
  182. methods: {
  183. //切换了课堂
  184. changeTid(newValue) {
  185. this.$nextTick(() => {
  186. this.$refs.messageAreaRef.getData();
  187. this.$refs.chatAreaRef.getData();
  188. this.getFileIdId();
  189. });
  190. },
  191. addNewCourse(form) {
  192. if (this.loading) return this.$message.info("请稍等");
  193. this.loading = true;
  194. let params = {
  195. tid: form.no,
  196. name: form.name,
  197. };
  198. this.ajax
  199. .post(
  200. "https://gpt4.cocorobo.cn/insert_classroom_observation_tid",
  201. params
  202. )
  203. .then((res) => {
  204. let _data = res.data.FunctionResponse;
  205. if (_data.message == "创建成功") {
  206. this.tid = form.no;
  207. // 设置该课程的tid
  208. this.ajax
  209. .post("https://gpt4.cocorobo.cn/insert_classroom_observation", {
  210. tid: this.tid,
  211. type: 10,
  212. index: 0,
  213. json_data: JSON.stringify({ file_ids: "" }),
  214. })
  215. .then((res2) => {
  216. let _data2 = res2.data.FunctionResponse;
  217. if (_data2.message == "创建成功") {
  218. this.loading = false;
  219. this.$nextTick(() => {
  220. this.getCourseList().then((_) => {
  221. this.getFileIdId();
  222. this.$refs.messageAreaRef.getData();
  223. this.$refs.chatAreaRef.getData();
  224. });
  225. });
  226. } else {
  227. this.$message.error("创建fileIds失败");
  228. }
  229. });
  230. } else if (_data.message == "tid重复") {
  231. this.$message.error("该课程已存在");
  232. this.loading = false;
  233. } else {
  234. this.$message.error("创建失败");
  235. this.loading = false;
  236. }
  237. });
  238. },
  239. updateFileId(newValue) {
  240. this.fileId = newValue;
  241. },
  242. // 生成报告
  243. getReport() {
  244. if (!this.fileId) return;
  245. this.$refs.messageAreaRef.getReport();
  246. },
  247. //预览
  248. preview() {
  249. if (!this.fileId) return;
  250. window.parent.postMessage(
  251. {
  252. tools: "classroom_observation_board",
  253. type: this.tid,
  254. },
  255. "*"
  256. );
  257. },
  258. // 分享
  259. shareBtn() {
  260. // if(!this.fileId)return;
  261. this.dialogVisibleShare = !this.dialogVisibleShare;
  262. },
  263. // 审核
  264. examine() {
  265. if (!this.tid) return;
  266. window.parent.postMessage(
  267. {
  268. tools: "classroom_observation_ob_comment",
  269. type: this.tid,
  270. },
  271. "*"
  272. );
  273. },
  274. // 主页
  275. home() {
  276. this.$message.info("主页");
  277. },
  278. delCourse(_value = this.tid) {
  279. this.$confirm("此操作将永久删除该课程, 是否继续?", "提示", {
  280. confirmButtonText: "确定",
  281. cancelButtonText: "取消",
  282. type: "warning",
  283. })
  284. .then(() => {
  285. this.optionData.splice(
  286. this.optionData.findIndex((item) => item.value == _value),
  287. 1
  288. );
  289. this.tid = this.optionData[0] ? this.optionData[0].value : "";
  290. this.changeTid(this.tid);
  291. this.$message({
  292. type: "success",
  293. message: "删除成功!",
  294. });
  295. })
  296. .catch(() => {});
  297. },
  298. // 获取修改fileId的ID
  299. getFileIdId() {
  300. if (!this.tid) return;
  301. let pram = {
  302. tid: this.tid,
  303. type: "10",
  304. };
  305. this.fileIdId = "";
  306. this.fileId = "";
  307. this.ajax
  308. .post("https://gpt4.cocorobo.cn/get_classroom_observation_new", pram)
  309. .then((res) => {
  310. console.log(res);
  311. let _data = res.data.FunctionResponse.result.length
  312. ? JSON.parse(res.data.FunctionResponse.result)
  313. : [];
  314. if (_data.length <= 0) return;
  315. this.fileIdId = _data[0].id;
  316. if (_data[0].jsonData != "") {
  317. this.fileId = JSON.parse(_data[0].jsonData).file_ids;
  318. } else {
  319. this.fileId = "";
  320. }
  321. });
  322. },
  323. // 切换录音文件
  324. changeAudioUrl(data) {
  325. this.$refs.messageAreaRef.changeAudioUrl(data);
  326. },
  327. changeChatAreaAudioUrl(data) {
  328. this.$refs.chatAreaRef.changeAudioUrl(data.url);
  329. },
  330. getCourseList() {
  331. this.loading = true;
  332. return new Promise((resolve, reject) => {
  333. this.ajax
  334. .post("https://gpt4.cocorobo.cn/get_classroom_observation_all")
  335. .then((res) => {
  336. let _data = res.data.FunctionResponse.result;
  337. let _result = _data ? JSON.parse(_data) : [];
  338. if (_result.length <= 0) return;
  339. let _optionData = _result.map((item) => {
  340. item.jsonData = item.jsonData ? JSON.parse(item.jsonData) : {};
  341. return {
  342. label: item.jsonData.courseName
  343. ? item.jsonData.courseName
  344. : `${item.tId}课程`,
  345. value: item.tId,
  346. };
  347. });
  348. _optionData = _optionData.filter(
  349. (i) => i.label != "" && i.tId != ""
  350. );
  351. this.optionData = _optionData;
  352. if (this.optionData.length > 0) {
  353. if (!this.tid) this.tid = this.optionData[0].value;
  354. }
  355. this.loading = false;
  356. resolve();
  357. });
  358. });
  359. },
  360. updateTranscription({ transcriptionData, editorBarData }, fn) {
  361. this.$refs.messageAreaRef.updateMessageTranscription(
  362. {
  363. transcriptionData,
  364. editorBarData,
  365. },
  366. fn
  367. );
  368. },
  369. changeTranscription({ transcriptionData, editorBarData }) {
  370. this.$refs.chatAreaRef.changeEditorBar({
  371. transcriptionData,
  372. editorBarData,
  373. });
  374. },
  375. changeOptionData(_tid, _newObj) {
  376. let _index = this.optionData.findIndex((i) => i.value == _tid);
  377. if (_index != -1) {
  378. this.optionData[_index] = { ...this.optionData[_index], ..._newObj };
  379. this.$forceUpdate();
  380. }
  381. console.log(this.optionData);
  382. },
  383. },
  384. mounted() {
  385. this.getCourseList().then((_) => {
  386. if (!this.tid) return;
  387. this.getFileIdId();
  388. this.$refs.messageAreaRef.getData();
  389. this.$refs.chatAreaRef.getData();
  390. });
  391. },
  392. };
  393. </script>
  394. <style scoped>
  395. .classroomObservation {
  396. min-width: 1500px;
  397. width: 100%;
  398. height: 100%;
  399. display: flex;
  400. flex-direction: column;
  401. background-color: #f0f2f5;
  402. }
  403. .co-header1 {
  404. width: 100%;
  405. height: 46px;
  406. background-color: #060e17;
  407. display: flex;
  408. align-items: center;
  409. justify-content: space-between;
  410. box-sizing: border-box;
  411. padding: 0 20px;
  412. }
  413. .co-h1-left {
  414. width: auto;
  415. height: 22px;
  416. display: flex;
  417. align-items: center;
  418. box-sizing: border-box;
  419. padding: 0 20px;
  420. }
  421. .co-h1-l-icon {
  422. color: #5d6268;
  423. width: 16px;
  424. height: 16px;
  425. margin-right: 10px;
  426. }
  427. .co-h1-l-router {
  428. display: flex;
  429. align-items: center;
  430. color: white;
  431. font-size: 14px;
  432. }
  433. .co-h1-l-router > span {
  434. margin: 0 5px;
  435. }
  436. .co-h1-l-r-up {
  437. color: #5d6268;
  438. cursor: pointer;
  439. }
  440. .co-h1-l-r-up:hover {
  441. color: white;
  442. }
  443. .co-j1-l-r-down {
  444. cursor: pointer;
  445. }
  446. .co-h1-l-r-rightIcon {
  447. font-size: 16px;
  448. color: #5d6268;
  449. }
  450. .co-header2 {
  451. width: 100%;
  452. height: 42px;
  453. min-height: 42px;
  454. max-height: 42px;
  455. background-color: white;
  456. display: flex;
  457. align-items: center;
  458. justify-content: space-between;
  459. box-sizing: border-box;
  460. padding: 0 20px;
  461. }
  462. .co-h2-left {
  463. width: auto;
  464. height: 22px;
  465. display: flex;
  466. align-items: center;
  467. font-size: 14px;
  468. }
  469. .co-h2-l-icon {
  470. width: 20px;
  471. height: 20px;
  472. position: relative;
  473. background: url("../../../assets/icon/classroomObservation/close.png")
  474. no-repeat;
  475. transform: rotate(45deg);
  476. cursor: pointer;
  477. background-size: 100% 100%;
  478. }
  479. .co-h2-l-hr {
  480. width: 2px;
  481. height: 20px;
  482. background-color: #e7e7e7;
  483. border-radius: 10px;
  484. margin: 0 10px;
  485. }
  486. .co-h2-right {
  487. width: auto;
  488. height: 100%;
  489. display: flex;
  490. align-items: center;
  491. }
  492. .co-h2-r-btn {
  493. width: auto;
  494. box-sizing: border-box;
  495. padding: 0 10px;
  496. height: 30px;
  497. display: flex;
  498. align-items: center;
  499. cursor: pointer;
  500. font-size: 14px;
  501. margin: 0 10px;
  502. box-sizing: border-box;
  503. border: 1px solid rgba(134, 179, 253, 1);
  504. /* border: solid 1px #3681FC; */
  505. border-radius: 5px;
  506. }
  507. .ca-h2-r-noActive {
  508. opacity: 0.5 !important;
  509. cursor: not-allowed !important;
  510. }
  511. .co-h2-r-btn2 {
  512. width: auto;
  513. box-sizing: border-box;
  514. padding: 10px;
  515. height: 30px;
  516. display: flex;
  517. align-items: center;
  518. cursor: pointer;
  519. margin: 0 10px;
  520. box-sizing: border-box;
  521. border-radius: 5px;
  522. box-shadow: 0px 4px 10px 0px rgba(29, 57, 131, 0.08);
  523. /* box-shadow: 1px 1px 20px 4px rgba(29, 57, 131, 0.05); */
  524. }
  525. .co-h2-r-btn > span:nth-child(1) {
  526. width: 20px;
  527. height: 20px;
  528. margin-right: 8px;
  529. }
  530. .co-h2-r-b-icon1 {
  531. background: url("../../../assets/icon/classroomObservation/six.svg") no-repeat;
  532. background-size: 100% 100%;
  533. }
  534. .co-h2-r-b-icon2 {
  535. background: url("../../../assets/icon/classroomObservation/Syan.svg")
  536. no-repeat;
  537. background-size: 100% 100%;
  538. }
  539. /* .co-h2-r-b-icon2 {
  540. background: url("../../../assets/icon/classroomObservation/daoChu.png")
  541. no-repeat;
  542. background-size: 100% 100%;
  543. }
  544. .co-h2-r-b-icon3 {
  545. background: url("../../../assets/icon/classroomObservation/Syan.png")
  546. no-repeat;
  547. background-size: 100% 100%;
  548. } */
  549. /* .co-h2-r-blueBtn {
  550. background: rgba(134, 179, 253, 1);
  551. color: white;
  552. } */
  553. .co-main {
  554. width: 100%;
  555. flex: 1;
  556. display: flex;
  557. /* align-items: center; */
  558. /* justify-content: center; */
  559. }
  560. .co-m-left {
  561. box-sizing: border-box;
  562. flex: 1;
  563. min-width: 650px;
  564. }
  565. .co-m-right {
  566. height: 100%;
  567. flex: 1;
  568. box-sizing: border-box;
  569. min-width: 450px;
  570. overflow: auto;
  571. }
  572. .co_h2_l_t_select >>> .el-input__inner {
  573. border: none;
  574. }
  575. /* .co_h2_l_t_select >>> .el-input__suffix {
  576. display: none;
  577. } */
  578. .co_h2_l_del {
  579. width: 35px;
  580. height: 35px;
  581. margin-left: 10px;
  582. border-radius: 5px;
  583. display: flex;
  584. justify-content: center;
  585. align-items: center;
  586. cursor: pointer;
  587. }
  588. .co_h2_l_del > span {
  589. width: 20px;
  590. height: 20px;
  591. display: flex;
  592. justify-content: center;
  593. align-items: center;
  594. background: url("../../../assets/icon/classroomObservation/del.svg") no-repeat;
  595. background-size: 100% 100%;
  596. }
  597. .co_h2_l_del:hover {
  598. background-color: #eaeef1;
  599. }
  600. .selectBox {
  601. width: 100%;
  602. height: 100%;
  603. }
  604. .selectBox:hover .delSelect {
  605. display: flex;
  606. }
  607. .delSelect {
  608. width: 16px;
  609. height: 16px;
  610. display: none;
  611. align-items: center;
  612. justify-content: center;
  613. background: url("../../../assets/icon/classroomObservation/del.svg") no-repeat;
  614. background-size: 100% 100%;
  615. box-sizing: border-box;
  616. transform: translateY(7px);
  617. }
  618. </style>