outcome.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686
  1. <template>
  2. <div class="outcome" v-loading="saveLoading">
  3. <bar @cutPage="cutPage(1)" :tit="'分析结果'" :backPage="0"></bar>
  4. <div class="o_content">
  5. <van-tabs color="#409EFF" style="width:100%;height: 100%;display: flex;flex-direction: column;" v-model="showIndex" swipeable animated scrollspy @click="changeShowIndex" swipe-threshold="3">
  6. <van-tab v-for="(item,index) in dialogTagList" :name="item.value" :title="item.name" :key="item.value">
  7. <div class="o_c_item">
  8. <analysisItem
  9. ref="analysisItemRef"
  10. v-for="(item, index) in dataList"
  11. :key="item.id"
  12. :data="item"
  13. v-show="showIndex === item.Type"
  14. v-if="!(item.Type == 0 && item.tIndex == 2)"
  15. :analysisList="analysisList"
  16. :bmData="bmData"
  17. :fileId="fileId"
  18. :dataList="dataList"
  19. />
  20. </div>
  21. </van-tab>
  22. </van-tabs>
  23. </div>
  24. <!-- <div class="sortList">
  25. <div>
  26. <div :class="[showIndex == 0 ? 'sortActive' : '']" @click.stop="changeShowIndex(0)">通用</div>
  27. <div :class="[showIndex == 1 ? 'sortActive' : '']" @click.stop="changeShowIndex(1)">学科</div>
  28. <div :class="[showIndex == 2 ? 'sortActive' : '']" @click.stop="changeShowIndex(2)">扩展</div>
  29. </div>
  30. <span @click.stop="addAnalysis">+</span>
  31. </div>
  32. <div class="stencilList">
  33. <analysisItem
  34. ref="analysisItemRef"
  35. v-for="(item, index) in dataList"
  36. :key="item.id"
  37. :data="item"
  38. v-show="showIndex === item.Type"
  39. v-if="!(item.Type == 0 && item.tIndex == 2)"
  40. :analysisList="analysisList"
  41. :bmData="bmData"
  42. :fileId="fileId"
  43. :dataList="dataList"
  44. />
  45. </div> -->
  46. <div class="botBtn">
  47. <div class="shareBtn" @click.stop="share()">
  48. <img src="../../assets/images/classObserve/share.png" alt="" />
  49. <span>分享</span>
  50. </div>
  51. <div class="bb_box">
  52. <div class="btn" @click.stop="saveTemplate()">
  53. 保存模板
  54. </div>
  55. <!-- :class="['btn', fileId ? '' : 'btnDis']" -->
  56. <div class="btn" @click.stop="AllAnalysis()">
  57. 一键分析
  58. </div>
  59. <div class="btn" @click.stop="viewTheReport()">
  60. 查看报告
  61. </div>
  62. </div>
  63. </div>
  64. <van-popup v-model="showPopup">
  65. <div class="popupCon">
  66. <div class="tit">模板信息</div>
  67. <div class="bri">请根据提示补充模版信息</div>
  68. <div>
  69. <el-input v-model="form.name" placeholder="模版名称"></el-input>
  70. <el-input type="textarea" :rows="3" resize="none" v-model="form.brief" placeholder="模版简介"></el-input>
  71. <el-select v-model="form.subject" placeholder="所属学科" style="z-index: 2026;">
  72. <el-option
  73. v-for="item in subjectList"
  74. :key="item.value"
  75. :label="item.label"
  76. :value="item.value"
  77. ></el-option>
  78. </el-select>
  79. </div>
  80. <div class="switch">
  81. <span style="margin-right: 5px;">公开到社区</span
  82. ><el-switch v-model="form.per" active-color="rgba(54, 129, 252, 1)"> </el-switch>
  83. </div>
  84. </div>
  85. <div class="btnS">
  86. <div @click="cancelSaveTemplate">取消</div>
  87. <div style="color: rgba(54, 129, 252, 1);" @click="saveInfo">保存</div>
  88. </div>
  89. </van-popup>
  90. <van-popup v-model="sharePopup">
  91. <div class="saveBox">
  92. <div class="sb_imgArea">
  93. <span class="qrcodeUrl" ref="qrCodeUrl"></span>
  94. </div>
  95. <div class="sb_inputArea">
  96. <el-input class="sc_fu_input" style="color: black" disabled v-model="origin">
  97. <template slot="append"
  98. ><div class="sc_fu_copyBtn" @click.stop="copy(origin)">
  99. 复制链接
  100. </div></template
  101. >
  102. </el-input>
  103. </div>
  104. </div>
  105. <div class="btnS">
  106. <div @click="sharePopup = false">取消</div>
  107. <div style="color: rgba(54, 129, 252, 1);" @click="sharePopup = false">确定</div>
  108. </div>
  109. </van-popup>
  110. <div class="o_report" v-if="showReport">
  111. <div class="o_r_top">
  112. <span>查看报告</span>
  113. <div @click.stop="showReport = false">×</div>
  114. </div>
  115. <div class="o_r_box">
  116. <iframe v-if="origin" :src="origin" width="100%" height="100%"></iframe>
  117. </div>
  118. </div>
  119. <addTel ref="addTelRef" :data="analysisList" @success="addAnalysisByList" />
  120. </div>
  121. </template>
  122. <script>
  123. import bar from './components/bar.vue'
  124. import analysisItem from './components/analysisItem.vue'
  125. import { Dialog } from 'vant'
  126. import { insertClassroomTemplateRequest,insertNewObsRequest } from '@/api/classObserve'
  127. import QRCode from 'qrcodejs2'
  128. import addTel from './addTel.vue'
  129. let OpenCC = require("opencc-js");
  130. export default {
  131. components: {
  132. bar,
  133. analysisItem,
  134. addTel
  135. },
  136. props: {
  137. page: {
  138. type: Number,
  139. default: 1
  140. },
  141. dataList: {
  142. type: Array,
  143. default: () => []
  144. },
  145. dialogTagList:{
  146. type:Array,
  147. default:()=>[]
  148. },
  149. analysisList: {
  150. type: Array,
  151. default: () => []
  152. },
  153. bmData: {
  154. type: Object,
  155. default: () => {}
  156. },
  157. fileId: {
  158. type: String,
  159. default: ''
  160. },
  161. tid: {
  162. type: String,
  163. default: ''
  164. }
  165. },
  166. data() {
  167. return {
  168. userId: this.$store.state.user.id,
  169. abuShow: false,
  170. cellShow: false,
  171. showPopup: false,
  172. sharePopup: false,
  173. showIndex: 0,
  174. saveLoading: false,
  175. form: {
  176. name: '',
  177. brief: '',
  178. subject: '',
  179. pre: false
  180. },
  181. menuList:[],
  182. subjectList: [
  183. { value: '1', label: '语文' },
  184. { value: '2', label: '数学' },
  185. { value: '3', label: '英语' },
  186. { value: '4', label: '科学' },
  187. { value: '5', label: '物理' },
  188. { value: '6', label: '化学' },
  189. { value: '7', label: '生物' },
  190. { value: '8', label: '历史' },
  191. { value: '9', label: '地理' },
  192. { value: '10', label: '政治' }
  193. ],
  194. origin: '',
  195. showReport: false
  196. }
  197. },
  198. methods: {
  199. cutPage(page) {
  200. this.$emit('cutPage', page)
  201. },
  202. addAnalysis() {
  203. this.$refs.addTelRef.open(this.showIndex)
  204. },
  205. ctrlShow() {
  206. this.cellShow = !this.cellShow
  207. },
  208. showAbu() {
  209. this.abuShow = true
  210. },
  211. changeShowIndex(newIndex) {
  212. this.showIndex = newIndex
  213. },
  214. delItem(item) {
  215. Dialog.confirm({
  216. title: '删除分析',
  217. message: `确定删除 "${item.jsonData.name}" 这个分析?`
  218. })
  219. .then(() => {
  220. this.$parent.delAnalysis(item)
  221. })
  222. .catch(() => {
  223. console.log('不删除')
  224. // on cancel
  225. })
  226. },
  227. share() {
  228. // return;
  229. this.sharePopup = true
  230. this.$nextTick(() => {
  231. let url = `https://beta.cloud.cocorobo.cn/aigpt/#/classroom_observation_board?tid=${this.tid}`
  232. this.origin = url
  233. this.$refs.qrCodeUrl.innerHTML = ''
  234. var qrcode = new QRCode(this.$refs.qrCodeUrl, {
  235. text: url, // 需要转换为二维码的内容
  236. width: 250,
  237. height: 250,
  238. colorDark: '#000000',
  239. colorLight: '#ffffff',
  240. correctLevel: QRCode.CorrectLevel.H
  241. })
  242. })
  243. },
  244. copy(content) {
  245. // 创建临时textarea元素
  246. const tempInput = document.createElement('textarea')
  247. tempInput.value = content // 设置要复制的内容
  248. // 隐藏元素
  249. tempInput.style.position = 'absolute'
  250. tempInput.style.left = '-9999px'
  251. // 将元素添加到DOM中
  252. document.body.appendChild(tempInput)
  253. // 选中元素内容
  254. tempInput.select()
  255. // 执行复制操作
  256. document.execCommand('copy')
  257. // 移除临时元素
  258. document.body.removeChild(tempInput)
  259. this.$toast.success('复制成功')
  260. },
  261. viewTheReport() {
  262. this.showReport = true
  263. let url = `https://beta.cloud.cocorobo.cn/aigpt/#/classroom_observation_board?tid=${this.tid}`
  264. this.origin = url
  265. },
  266. AllAnalysis() {
  267. if (!this.fileId) return this.$toast('请先上传文件或者录音')
  268. this.$refs.analysisItemRef.forEach(i => {
  269. i.optimize()
  270. })
  271. this.$toast.success('一键分析成功')
  272. },
  273. saveTemplate() {
  274. this.showPopup = !this.showPopup
  275. },
  276. cancelSaveTemplate() {
  277. this.form = {
  278. name: '',
  279. brief: '',
  280. subject: '',
  281. per: false
  282. }
  283. this.showPopup = false
  284. },
  285. saveInfo() {
  286. if (!this.form.name.trim()) return this.$toast.fail('请填写模板名称')
  287. if (!this.form.subject.trim()) return this.$toast.fail('请选择科目')
  288. // if(!this.form.brief.trim())return this.$toast.fail("请填写模板简介");
  289. this.saveLoading = true
  290. let _data = JSON.parse(JSON.stringify(this.dataList))
  291. let _result = []
  292. _data.forEach(i => {
  293. if (i.Type == 0 && i.tIndex == 2) return
  294. i.jsonData.content = ''
  295. i.jsonData.dataFileList = []
  296. i.jsonData.fileList = []
  297. i.createtime = ''
  298. ;(i.id = ''), (i.tId = ''), (i.userid = '')
  299. _result.push(i)
  300. })
  301. let params = [
  302. {
  303. title: this.form.name,
  304. subject: this.form.subject,
  305. uid: this.userId,
  306. brief: this.form.brief,
  307. per: this.form.per ? 1 : 0,
  308. jsonData: JSON.stringify(_result)
  309. }
  310. ]
  311. insertClassroomTemplateRequest(params)
  312. .then(res => {
  313. this.$toast.success('保存为模板成功')
  314. this.cancelSaveTemplate()
  315. this.saveLoading = false
  316. })
  317. .catch(e => {
  318. this.$toast.fail('另存为模板失败')
  319. console.log(e)
  320. })
  321. },
  322. addAnalysisByList(list) {
  323. this.saveLoading = true;
  324. this.$refs.addTelRef.close()
  325. let promises = [];
  326. list.forEach((item,index)=>{
  327. promises.push(this.addAnalysisItem(item,index))
  328. })
  329. Promise.all(promises).then(()=>{
  330. this.saveLoading = false;
  331. this.$toast.success('添加成功')
  332. })
  333. },
  334. addAnalysisItem(id,index = 0) {
  335. return new Promise(resolve => {
  336. let converter = OpenCC.Converter({
  337. from:'hk',
  338. to:'cn'
  339. })
  340. let assistant = this.analysisList.find(i => i.id == id)
  341. let newIndexData = this.dataList
  342. .filter(i => i.Type == assistant.type)
  343. .sort((a, b) => new Date(a.createtime) - new Date(b.createtime))
  344. newIndexData = newIndexData.length ? newIndexData[newIndexData.length - 1] : null
  345. let newIndex = newIndexData ? newIndexData.tIndex + 1 : assistant.type == 0 ? 2 : 0
  346. let params = {
  347. index: newIndex+index,
  348. userid: this.userId,
  349. json_data: JSON.stringify({
  350. name: assistant.name,
  351. anotherName:assistant.name,
  352. result: assistant.detail,
  353. mId: assistant.id,
  354. echartsType: assistant.echartsType,
  355. fileList: [],
  356. dataFileList: [],
  357. content: ''
  358. }),
  359. tid: this.tid,
  360. type: assistant.type.toString()
  361. }
  362. insertNewObsRequest(params).then(res=>{
  363. let _data = res.FunctionResponse;
  364. if (_data.message && converter(_data.message) == converter("创建成功")) {
  365. let _result = JSON.parse(_data.result)[0];
  366. _result.jsonData = JSON.parse(_result.jsonData);
  367. this.$parent.dataList.push(_result)
  368. this.$nextTick(()=>{
  369. this.$refs.analysisItemRef.forEach(i=>{
  370. if(i.data.id===_result.id){
  371. i.optimize();
  372. }
  373. })
  374. })
  375. resolve();
  376. } else {
  377. this.$toast.fail(`"${assistant.title}"添加失败`);
  378. resolve();
  379. }
  380. })
  381. })
  382. },
  383. }
  384. }
  385. </script>
  386. <style lang="scss" scoped>
  387. .outcome {
  388. height: calc(100%);
  389. display: flex;
  390. flex-direction: column;
  391. justify-content: space-between;
  392. box-sizing: border-box;
  393. }
  394. /*
  395. .sortList {
  396. width: 100%;
  397. max-width: calc(100% - 15px);
  398. display: flex;
  399. box-sizing: border-box;
  400. justify-content: space-between;
  401. margin-top: 55px;
  402. height: auto;
  403. border-bottom: 0.5px rgba(231, 231, 231, 1) solid;
  404. background-color: red;
  405. span {
  406. display: flex;
  407. justify-content: center;
  408. align-items: center;
  409. width: 40px;
  410. height: auto;
  411. font-size: 20px;
  412. margin-right: 15px;
  413. }
  414. div {
  415. flex: 1;
  416. text-align: center;
  417. font-size: 16px;
  418. font-weight: 400;
  419. transition: 0.3s;
  420. position: relative;
  421. padding: 10px;
  422. }
  423. .sortImg {
  424. display: flex;
  425. align-items: center;
  426. justify-content: center;
  427. border-left: 0.5px rgba(231, 231, 231, 1) solid;
  428. }
  429. .sortActive {
  430. color: #3681fc;
  431. font-weight: bold;
  432. }
  433. }
  434. .stencilList {
  435. flex: 1;
  436. padding: 15px;
  437. box-sizing: border-box;
  438. overflow: auto;
  439. background-image: linear-gradient(to bottom, #fff 0%, #ebf1fd 100%);
  440. .tit {
  441. color: rgba(0, 0, 0, 0.9);
  442. font-size: 14px;
  443. font-weight: 600;
  444. margin-left: 5px;
  445. }
  446. .outcomeCon {
  447. // display: flex;
  448. min-height: 50px;
  449. border: 0.5px #ccc solid;
  450. align-items: center;
  451. border-radius: 5px;
  452. min-height: 40px;
  453. padding: 0 10px;
  454. }
  455. }
  456. */
  457. .o_content{
  458. width: 100%;
  459. flex:1;
  460. margin-top: 55px;
  461. height: auto;
  462. // background-color: red;
  463. .o_c_item{
  464. width: 100%;
  465. height: calc(100vh - 164px);
  466. flex: 1;
  467. overflow: auto;
  468. box-sizing: border-box;
  469. padding: 10px;
  470. // background:yellow;
  471. }
  472. }
  473. .botBtn {
  474. background-color: #fff;
  475. width: 100%;
  476. padding: 10px 10px;
  477. padding-left: 15px;
  478. box-sizing: border-box;
  479. display: flex;
  480. align-items: center;
  481. .shareBtn {
  482. display: flex;
  483. flex-direction: column;
  484. align-items: center;
  485. margin-right: 20px;
  486. justify-content: space-between;
  487. font-size: 12px;
  488. font-size: 400;
  489. color: rgba(4, 0, 0, 1);
  490. }
  491. .bb_box {
  492. flex: 1;
  493. display: flex;
  494. justify-content: center;
  495. align-items: center;
  496. justify-content: space-around;
  497. padding: 0;
  498. .btn {
  499. flex: 1;
  500. background-color: rgba(54, 129, 252, 1);
  501. color: #fff;
  502. height: 45px;
  503. border-radius: 10px;
  504. display: flex;
  505. font-size: 16px;
  506. margin: 0 5px;
  507. justify-content: center;
  508. align-items: center;
  509. }
  510. .btnDis {
  511. background-color: rgb(165, 165, 165);
  512. }
  513. }
  514. }
  515. .abu {
  516. background-color: #fff;
  517. width: 100px;
  518. border-radius: 6px;
  519. // padding: 10px 10px;
  520. box-shadow: 0px 8px 10px -5px rgba(0, 0, 0, 0.08);
  521. box-shadow: 0px 16px 24px 2px rgba(0, 0, 0, 0.04);
  522. box-shadow: 0px 6px 30px 5px rgba(0, 0, 0, 0.05);
  523. .abuBtn {
  524. display: flex;
  525. align-items: center;
  526. padding: 10px 15px;
  527. font-size: 12px;
  528. font-weight: 400;
  529. img {
  530. margin-right: 5px;
  531. }
  532. }
  533. }
  534. .outcomeBtn {
  535. display: flex;
  536. justify-content: space-around;
  537. padding: 10px 0;
  538. div {
  539. display: flex;
  540. img {
  541. width: 16px;
  542. height: 16px;
  543. }
  544. }
  545. }
  546. /deep/ .van-popup--center {
  547. border-radius: 10px;
  548. width: 280px;
  549. }
  550. /deep/.el-input__inner {
  551. border: 0;
  552. background-color: rgba(243, 243, 243, 1);
  553. }
  554. /deep/.el-select {
  555. width: 100%;
  556. }
  557. /deep/.el-textarea__inner {
  558. border: 0;
  559. background-color: rgba(243, 243, 243, 1);
  560. margin: 10px 0;
  561. }
  562. /deep/.van-overlay {
  563. z-index: 1999 !important;
  564. }
  565. /deep/.vant-tabs__content{
  566. flex: 1;
  567. }
  568. /deep/.van-popup {
  569. z-index: 2000 !important;
  570. }
  571. .popupCon {
  572. padding: 10px 15px;
  573. .tit {
  574. width: 100%;
  575. text-align: center;
  576. font-size: 18px;
  577. font-weight: 600;
  578. padding: 10px 0;
  579. }
  580. .bri {
  581. font-size: 16px;
  582. font-weight: 400;
  583. text-align: center;
  584. color: rgba(0, 0, 0, 0.6);
  585. padding-bottom: 10px;
  586. }
  587. .switch {
  588. margin: 10px 0;
  589. font-size: 14px;
  590. // font-weight: 600;
  591. color: rgba(0, 0, 0, 0.9);
  592. }
  593. }
  594. .btnS {
  595. display: flex;
  596. border-top: 0.5px solid rgba(231, 231, 231, 1);
  597. justify-content: space-between;
  598. div {
  599. flex: 1;
  600. text-align: center;
  601. padding: 17px 0;
  602. font-size: 14px;
  603. font-weight: 600;
  604. }
  605. }
  606. .saveBox {
  607. padding: 10px 15px;
  608. .sb_imgArea {
  609. width: 100%;
  610. height: auto;
  611. display: flex;
  612. justify-content: center;
  613. padding: 20px 0;
  614. }
  615. }
  616. .o_report {
  617. position: fixed;
  618. left: 0;
  619. top: 0;
  620. width: 100vw;
  621. height: 100vh;
  622. background-color: red;
  623. z-index: 999;
  624. .o_r_top {
  625. width: 100%;
  626. height: 40px;
  627. display: flex;
  628. justify-content: center;
  629. align-items: center;
  630. background-color: #15233e;
  631. position: relative;
  632. span {
  633. font-size: 16px;
  634. font-weight: bold;
  635. color: #fff;
  636. }
  637. div {
  638. position: absolute;
  639. right: 10px;
  640. color: #fff;
  641. font-size: 18px;
  642. height: auto;
  643. width: auto;
  644. padding: 2px 7px;
  645. border-radius: 5px;
  646. display: flex;
  647. box-sizing: border-box;
  648. // border: solid 1px #fff;
  649. justify-content: center;
  650. align-items: center;
  651. // background-color: #93b0eb;
  652. }
  653. }
  654. .o_r_box {
  655. width: 100%;
  656. height: calc(100% - 40px);
  657. display: flex;
  658. justify-content: center;
  659. align-items: center;
  660. background-color: #fff;
  661. }
  662. }
  663. </style>