gpsren.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599
  1. <template>
  2. <div>
  3. <el-form :model="form" ref="form" label-width="100px" class="demo-ruleForm" label-position="top">
  4. <el-col :span="24">
  5. <el-form-item label="G(目标导向):" class="cust-label">
  6. <div v-html="question.gOriented" style="font-weight: 700;font-size: 16px;"></div>
  7. </el-form-item>
  8. </el-col>
  9. <el-steps :active="active" finish-status="success" simple style="margin-top: 20px">
  10. <el-step>
  11. <div slot="title" style="border-radius: 10px;">
  12. <div style="display: flex;flex-direction: row;justify-content: center;align-items: center;">
  13. <span>P</span>
  14. <span>(问题定义)</span>
  15. </div>
  16. </div>
  17. </el-step>
  18. <el-step>
  19. <div slot="title" style="border-radius: 10px;">
  20. <div style="display: flex;flex-direction: row;justify-content: center;align-items: center;">
  21. <span>S</span>
  22. <span>(系统拆解)</span>
  23. </div>
  24. </div>
  25. </el-step>
  26. <el-step>
  27. <div slot="title" style="border-radius: 10px;">
  28. <div style="display: flex;flex-direction: row;justify-content: center;align-items: center;">
  29. <span>R</span>
  30. <span>(结果整合)</span>
  31. </div>
  32. </div>
  33. </el-step>
  34. <el-step>
  35. <div slot="title" style="border-radius: 10px;">
  36. <div style="display: flex;flex-direction: row;justify-content: center;align-items: center;">
  37. <span>E</span>
  38. <span>(结果评估)</span>
  39. </div>
  40. </div>
  41. </el-step>
  42. <el-step>
  43. <div slot="title" style="border-radius: 10px;">
  44. <div style="display: flex;flex-direction: row;justify-content: center;align-items: center;">
  45. <span>N</span>
  46. <span>(总结新知识)</span>
  47. </div>
  48. </div>
  49. </el-step>
  50. </el-steps>
  51. <!-- <div>
  52. <el-button icon="el-icon-discover" size="small" type="success">AI助手</el-button>
  53. </div> -->
  54. <br />
  55. <el-col :span="24" >
  56. <div class="test-area" v-if="active==0">
  57. <el-form-item class="test-form cust-label">
  58. <el-input type="textarea" class="custom-height" v-model="form.p" :placeholder="stepmodel.P"></el-input>
  59. </el-form-item>
  60. <div class="test-form ai-evaluate">
  61. <div v-if="showAIEvaluate"><i class="el-icon-loading"></i></div>
  62. <div v-else >
  63. <p v-html="resp"></p>
  64. </div>
  65. </div>
  66. </div>
  67. <div class="test-area" v-if="active==1">
  68. <el-form-item class="test-form cust-label">
  69. <el-input type="textarea" class="custom-height" v-model="form.s" :placeholder="stepmodel.S"></el-input>
  70. </el-form-item>
  71. <div class="test-form ai-evaluate">
  72. <div v-if="showAIEvaluate"><i class="el-icon-loading"></i></div>
  73. <div v-else >
  74. <p v-html="resp"></p>
  75. </div>
  76. </div>
  77. </div>
  78. <div class="test-area" v-if="active==2">
  79. <el-form-item class="test-form cust-label">
  80. <el-input type="textarea" class="custom-height" v-model="form.r" :placeholder="stepmodel.R"></el-input>
  81. </el-form-item>
  82. <div class="test-form ai-evaluate">
  83. <div v-if="showAIEvaluate"><i class="el-icon-loading"></i></div>
  84. <div v-else >
  85. <p v-html="resp"></p>
  86. </div>
  87. </div>
  88. </div>
  89. <div class="test-area" v-if="active==3">
  90. <el-form-item class="test-form cust-label">
  91. <el-input type="textarea" class="custom-height" v-model="form.e" :placeholder="stepmodel.E"></el-input>
  92. </el-form-item>
  93. <div class="test-form ai-evaluate">
  94. <div v-if="showAIEvaluate"><i class="el-icon-loading"></i></div>
  95. <div v-else >
  96. <p v-html="resp"></p>
  97. </div>
  98. </div>
  99. </div>
  100. <div class="test-area" v-if="active==4">
  101. <el-form-item class="test-form cust-label" style="width:100%;">
  102. <el-input type="textarea" class="custom-height" v-model="form.n" :placeholder="stepmodel.N"></el-input>
  103. </el-form-item>
  104. <!-- <div class="test-form ai-evaluate">
  105. <div v-if="showAIEvaluate"><i class="el-icon-loading"></i></div>
  106. <div v-else >
  107. <p v-html="resp"></p>
  108. </div>
  109. </div> -->
  110. </div>
  111. <div class="opt-area" v-if="active <4">
  112. <div class="opt-left">
  113. <el-button :disabled="showAIEvaluate" :icon="showAIEvaluate?'el-icon-loading':'el-icon-arrow-right'" style="width: 100%;" size="small" type="primary" plain @click="onAIEvaluate">提交AI测评</el-button>
  114. </div>
  115. <div class="opt-left">
  116. <el-button :disabled="showAIEvaluate" icon="el-icon-check" v-if="active<4" style="width: 100%;" size="small" type="success" plain @click="onNext">下一步</el-button>
  117. </div>
  118. </div>
  119. <div v-else class="opt-area" >
  120. <el-button :disabled="showAIEvaluate" icon="el-icon-check" style="width: 100%;" size="small" type="success" plain @click="onFinish">完成</el-button>
  121. </div>
  122. </el-col>
  123. </el-form>
  124. <!-- <template>
  125. <el-dialog :visible.sync="dialogResultVisible" width="50%" top="0" custom-class="GPSREN" :modal="false"
  126. :modal-append-to-body="false">
  127. <div slot="title" class="cust-title">
  128. AI评价 <i :class="aiTestClass"></i>
  129. </div>
  130. <div class="block">
  131. <div v-html="resp"></div>
  132. </div>
  133. <span slot="footer" class="dialog-footer" v-if="aiTestClass=='el-icon-reading'">
  134. <el-button icon="el-icon-arrow-right" size="small" type="primary" plain v-if="active<4"
  135. @click="()=>{active++;dialogResultVisible = false;}">AI评测</el-button>
  136. <el-button type="primary" @click="()=>{dialogResultVisible = false;dialogVisible = false}"
  137. size="small" v-else-if="active==4">提交</el-button>
  138. <el-button @click="dialogResultVisible = false" size="small">修改</el-button>
  139. <el-button @click="()=>{dialogResultVisible = false; active=0;}" size="small">重新答题</el-button>
  140. </span>
  141. </el-dialog>
  142. </template> -->
  143. </div>
  144. </template>
  145. <script>
  146. import Axios from 'axios';
  147. import { getDictValueByType } from '../api/dict'
  148. import { mockAI, steps ,tips} from '../mock/gpsren';
  149. import {askAI,postGPSREN,getStepModel} from '../api/ai'
  150. let thisPage = null
  151. let stepMapToCnt = {}
  152. export default {
  153. name: 'gpsren-info',
  154. props: {
  155. question:Object,
  156. finish:Function
  157. },
  158. data() {
  159. return {
  160. headers: {
  161. Authorization: this.$store.state.user.token,
  162. Platform: 'educationStudent'
  163. },
  164. id: '',
  165. showAIEvaluate:false,
  166. openAnswerFlag: false,
  167. sumSource: 0,
  168. score:0,
  169. dialogImageUrl: '',
  170. questionTypeList: [],
  171. fileUrl: this.$store.state.common.fileHost,
  172. dialogAnswerImgVisible: false,
  173. uploadAction: this.$httpApi.httpUrl('/api/upload/2'),
  174. dialogVisible: false,
  175. form: {},
  176. saveForm:{},
  177. config: {
  178. zIndex: 0
  179. },
  180. active: 0,
  181. dialogResultVisible: false,
  182. aiTestItem: [],
  183. aiTestClass: "el-icon-reading",
  184. resp:'',
  185. stepmodel: {
  186. "P": "",
  187. "S":"",
  188. "R":"",
  189. "E":""
  190. },
  191. stepscore: {
  192. "P": 0,
  193. "S":0,
  194. "R":0,
  195. "E":0
  196. },
  197. }
  198. },
  199. beforeCreate() {
  200. thisPage = this
  201. },
  202. mounted() {
  203. const loading = this.$loading({
  204. lock: true,
  205. text: 'Loading',
  206. spinner: 'el-icon-loading',
  207. background: 'rgba(0, 0, 0, 0.7)'
  208. });
  209. this.$nextTick(()=>{
  210. this.stepmodel = {
  211. "P":"",
  212. "S":"",
  213. "R":"",
  214. "E":""
  215. }
  216. console.log("this.stepmodel===> ",this.stepmodel)
  217. //todo
  218. getStepModel().then(resp=>{
  219. console.log(resp)
  220. if(resp.status == 200) {
  221. let res = resp.data
  222. if(res.code == 1) {
  223. let stepModels = res.data.dataList
  224. for(let n =0 ;n<stepModels.length;n++) {
  225. let m = stepModels[n]
  226. this.stepmodel[m.name] = m.requires
  227. this.stepscore[m.name] = m.score
  228. }
  229. }
  230. }
  231. }).finally(d=>{
  232. console.log("this.stepmodel",this.stepmodel)
  233. loading.close()
  234. })
  235. })
  236. },
  237. methods: {
  238. //提交测评
  239. onAIEvaluate() {
  240. let step = steps[this.active]
  241. if(!!!this.form[`${step.toLowerCase()}`]) {
  242. //没有学生答案
  243. this.$message({
  244. type: 'warning',
  245. message: '请输入答案',
  246. duration: 1000
  247. })
  248. return
  249. }
  250. this.showAIEvaluate = true
  251. let run = () => {
  252. return this.remoteAskAI(this.$props.question.courseName ,
  253. step,
  254. this.$props.question.gOriented,
  255. this.$props.question[`${step.toLowerCase()}ScoreStd`] + ' '+ this.stepmodel[step],
  256. this.form[`${step.toLowerCase()}`],
  257. this.stepscore[step]
  258. )
  259. }
  260. run().finally(f=>{ this.showAIEvaluate = false; })
  261. },
  262. //
  263. remoteAskAI(cn, sn, g,sa,ssa,_s) {
  264. console.log(cn,sn,g,sa,ssa)
  265. this.resp = ''
  266. return askAI({
  267. memoryId:1,
  268. courseName:cn,
  269. stepName:sn,
  270. goal:g,
  271. standardAnswer:sa,
  272. studentAnswer:ssa,
  273. score:_s
  274. }).then(r=>{
  275. if(r.status == 200) {
  276. let res = r.data
  277. if(res.code == 1) {
  278. console.log(res.data)
  279. try{
  280. let jData = JSON.parse(res.data)
  281. this.resp = jData.text
  282. this.score = jData.score
  283. }catch(e){
  284. console.log(e)
  285. this.resp = "AI返回值不符合格式要求"
  286. }
  287. } else {
  288. this.resp = res.message
  289. }
  290. } else {
  291. this.resp = "AI超时"
  292. }
  293. return this.resp
  294. }).catch(c=>{
  295. this.resp = "服务故障,请重试"
  296. }).finally(()=>{
  297. //记录本地
  298. this.saveForm[`${sn.toLowerCase()}Answer`] = ssa
  299. this.saveForm[`${sn.toLowerCase()}Score`] = this.score
  300. })
  301. },
  302. onNext() {
  303. //保存答案
  304. let step = steps[this.active]
  305. let a = this.saveForm[`${step.toLowerCase()}Answer`]
  306. if(!!!a) {
  307. this.$message({
  308. type:"error",
  309. message:`请填写${step}部分,并先经过AI测评`,
  310. duration:1000
  311. })
  312. return
  313. }
  314. //进入到下一个步骤
  315. this.active ++
  316. this.resp = ''
  317. this.showAIEvaluate = false
  318. this.score = 0
  319. },
  320. onFinish() {
  321. //保存
  322. let params = {
  323. goalInfoId: this.$props.question.id,
  324. nAnswer:this.form.n
  325. }
  326. let p = Object.assign(params,this.saveForm)
  327. postGPSREN(p).then(d=>{
  328. console.log("postGPSREN",d)
  329. if(d.status == 200) {
  330. let dt = d.data || {}
  331. if(dt.code == 1) {
  332. this.$props.finish && this.$props.finish()
  333. }
  334. }
  335. })
  336. },
  337. },
  338. filters: {
  339. getStepModelTips(s) {
  340. let cs = this.stepmodel[s]
  341. console.log("dddd==>",cs)
  342. if(!!cs) {
  343. return cs['requires'] || ""
  344. }
  345. return ""
  346. },
  347. },
  348. }
  349. </script>
  350. <style lang="scss">
  351. .el-dialog__header {
  352. background-color: #477efa !important;
  353. color: aliceblue !important;
  354. }
  355. .el-dialog__close {
  356. color: aliceblue !important;
  357. }
  358. .GPSREN {
  359. margin-bottom: 0px !important;
  360. .cust-title {
  361. text-align: center;
  362. font-size: 20px;
  363. }
  364. .test-area{
  365. display: flex;
  366. align-items:flex-start;
  367. justify-content: space-between;
  368. gap: 10px;
  369. height: 350px;
  370. .test-form{
  371. width:50%;
  372. }
  373. .ai-evaluate{
  374. color:#333;
  375. background-color: #eee;
  376. border: solid 1px #eee;
  377. height: calc(100%);
  378. overflow: auto;
  379. }
  380. }
  381. .cust-label {
  382. font-weight: bold;
  383. .el-form-item__label {
  384. color: #67C23A !important;
  385. }
  386. }
  387. .custom-height .el-textarea__inner {
  388. height: 350px;
  389. /* 设置你想要的高度 */
  390. }
  391. .opt-area{
  392. // background-color: #67C23A;
  393. color:#eee;
  394. display: flex;
  395. align-items:center;
  396. justify-content: space-between;
  397. gap: 10px;
  398. .opt-left{
  399. width: 50%;
  400. height: 100%;
  401. }
  402. }
  403. }
  404. .testbox p {
  405. display: inline-block;
  406. }
  407. /*.el-upload--picture-card {*/
  408. /* width: 100px !important;*/
  409. /* height: 90px !important;*/
  410. /* line-height: 100px !important;*/
  411. /* vertical-align: top;*/
  412. /*}*/
  413. .tops {
  414. display: inline-block;
  415. text-align: center;
  416. width: 100px;
  417. height: 40px;
  418. line-height: 40px;
  419. border-radius: 40px;
  420. background-color: #FAD303;
  421. box-shadow: 3px 2px 0 0 rgba(250, 213, 3, 0.445);
  422. }
  423. .el-pagination {
  424. margin-top: 15px;
  425. text-align: center;
  426. }
  427. .title3 .count {
  428. position: relative;
  429. overflow: overlay;
  430. display: inline-block;
  431. font-weight: bolder;
  432. left: 86px;
  433. color: red;
  434. font-size: 45px;
  435. }
  436. .title3 .mark {
  437. width: 205px;
  438. top: 85px;
  439. left: 57%;
  440. height: 64px;
  441. position: absolute;
  442. }
  443. .el-radio-button__inner,
  444. .el-radio-group {
  445. padding-top: 20px !important;
  446. display: block !important;
  447. }
  448. .testinfo {
  449. padding-left: 30px;
  450. padding-top: 22px;
  451. }
  452. .title3 {
  453. width: 100%;
  454. height: 30px;
  455. text-align: center;
  456. }
  457. .subbtnbox {
  458. width: 100%;
  459. text-align: center;
  460. padding: 20px;
  461. .btn {
  462. width: 100px;
  463. background-color: red;
  464. }
  465. }
  466. .testbox {
  467. display: inline-block;
  468. margin-top: 20px
  469. }
  470. .btnbox {
  471. display: flex;
  472. display: -webkit-flex;
  473. justify-content: space-around;
  474. padding-left: 100px;
  475. margin-top: 30px;
  476. padding-right: 100px;
  477. }
  478. .play {
  479. display: inline-block;
  480. height: 30px;
  481. line-height: 30px;
  482. padding-left: 10px;
  483. color: red;
  484. cursor: pointer;
  485. .cp {
  486. font-size: 20px;
  487. vertical-align: middle;
  488. }
  489. .ai-ana {
  490. color: skyblue;
  491. }
  492. }
  493. .typing-effect {
  494. overflow: hidden;
  495. /* 确保超出部分的内容不显示 */
  496. border-right: .15em solid orange;
  497. /* 光标效果 */
  498. white-space: nowrap;
  499. /* 防止文本换行 */
  500. animation: typing 3s steps(20, end), blink-caret .75s step-end infinite;
  501. }
  502. @keyframes typing {
  503. from {
  504. width: 0
  505. }
  506. to {
  507. width: 100%
  508. }
  509. }
  510. @keyframes blink-caret {
  511. from,
  512. to {
  513. border-color: transparent
  514. }
  515. 50% {
  516. border-color: orange
  517. }
  518. }
  519. </style>