targetTrackingTrain.vue 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940
  1. <template>
  2. <div>
  3. <!-- <div style="width: 650px; margin: 20px auto; line-height: 2" v-if="!endFlag">
  4. <h2 style="margin-left:41%;margin-top:2%;">测试方法描述</h2>
  5. <p
  6. style="text-align: left; text-indent: 2em"
  7. >
  8. 圆点数目16个,跟踪物体数目为4或5,初始为红色,其余点为绿色。运动速度等级为两个,运动时长5秒或10秒,实验共有8个等级,每个等级测{{ tnumber }}次。
  9. 点击开始运动,所有点开始运动,运动结束后,点击选择你认为正确的点,选中状态的点为黄色,再次击即可取消选择,选择结束后,
  10. 保存,然后重复上述过程,直至测试结束。
  11. </p>
  12. <el-button type="primary" style="margin-left:47%;" @click="Init(parameters[0])">开始</el-button>
  13. </div> -->
  14. <!-- <div class="desc_wrap" v-if="!endFlag">
  15. <div
  16. style="
  17. width: 70%;
  18. height: 100%;
  19. background: rgb(248, 248, 248);
  20. opacity: 1;
  21. border-radius: 12px;
  22. margin: 0 auto;
  23. "
  24. >
  25. <div class="left_part">
  26. <div id="left_top">
  27. <div>
  28. <div id="setting">
  29. <img src="../../assets/9551.png" alt="" />
  30. </div>
  31. <div id="text">
  32. <span>操作提示:</span>
  33. </div>
  34. </div>
  35. </div>
  36. <div style="margin: 100px auto; width: 80%; text-align: left">
  37. <p>圆点数目16个,跟踪物体数目为4或5,初始为红色,其余点为绿色。运动速度等级为两个,运动时长5秒或10秒,实验共有8个等级,每个等级测{{ tnumber }}次。
  38. 点击开始运动,所有点开始运动,运动结束后,点击选择你认为正确的点,选中状态的点为黄色,再次击即可取消选择,选择结束后,
  39. 保存,然后重复上述过程,直至测试结束。</p>
  40. <p>{{subjectInfo.description}}</p>
  41. </div>
  42. </div>
  43. <div
  44. class="right_part"
  45. :style="{
  46. background:
  47. 'url(' + require('../../assets/page27.png') + ')',
  48. 'background-size': '100% 100%',
  49. }"
  50. >
  51. <div id="title">
  52. <span>目标追踪</span>
  53. </div>
  54. <div style="position: absolute; bottom: 30px; right: 42%">
  55. <el-button type="primary" class="start" @click="Init(parameters[0])">开始</el-button>
  56. </div>
  57. </div>
  58. </div>
  59. </div> -->
  60. <div
  61. v-if="testFlag"
  62. :class="{ testMainDiv: !testFlag, activeTask: testFlag }"
  63. >
  64. <div>
  65. <div
  66. style="width: 50%; margin-left: 15%; margin-top: 10px; float: left"
  67. >
  68. <el-progress
  69. class="main_progress"
  70. :text-inside="true"
  71. :format="format"
  72. :stroke-width="36"
  73. :percentage="(trainTime / 20) * 100"
  74. ></el-progress>
  75. </div>
  76. <div style="float: right; padding: 20px" @click.stop="screen()">
  77. <img src="../../assets/small-big.png" alt="" />
  78. </div>
  79. </div>
  80. <div id="main"></div>
  81. <el-button
  82. class="start"
  83. v-if="noclick"
  84. style="margin-left: 47%"
  85. @click="beginTest()"
  86. >开始运动</el-button
  87. >
  88. <el-button
  89. class="start"
  90. v-if="onsave"
  91. style="margin-left: 47%"
  92. @click="save()"
  93. >保存</el-button
  94. >
  95. <el-button
  96. class="start"
  97. style="margin-left: 47%"
  98. @click="submit()"
  99. >结束训练</el-button
  100. >
  101. <!-- <el-button @click="result()">跳转</el-button> -->
  102. </div>
  103. <div v-if="endFlag">
  104. <h2 style="margin-left: 45%; margin-top: 2%">测试结果</h2>
  105. <el-table
  106. :data="tableData"
  107. border
  108. :header-cell-style="{
  109. background: '#57acbb',
  110. color: '#ffffff',
  111. bordercolor: '#57acbb',
  112. }"
  113. style="width: 40%; margin-left: 30%; margin-top: 2%"
  114. >
  115. <el-table-column prop="level" label="难度等级" align="center">
  116. </el-table-column>
  117. <el-table-column prop="accary" align="center" label="正确率">
  118. </el-table-column>
  119. </el-table>
  120. </div>
  121. </div>
  122. </template>
  123. <script>
  124. import ecStat from "echarts-stat";
  125. import * as echarts from "echarts";
  126. import screenfull from "screenfull";
  127. export default {
  128. data() {
  129. return {
  130. sum: 0,
  131. tnumber: 1, //设置每个等级做几次
  132. endFlag: false,
  133. tableData: [],
  134. layer: 0,
  135. screen_flag: 0,
  136. a: 6,
  137. p: [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21],
  138. data: [],
  139. data_item: [],
  140. sumdata: [],
  141. myChart: "",
  142. option: "",
  143. info: [],
  144. flag1: 0,
  145. flag2: 0,
  146. flag3: 0,
  147. id_true: "",
  148. result1: new Set(),
  149. noclick: true,
  150. count: "",
  151. speed: "",
  152. end: false,
  153. number: "",
  154. userId: "",
  155. testFlag: false,
  156. onsave: false,
  157. pam: [
  158. [1, 0.0008, 1],
  159. [2, 0.0008, 1],
  160. [2, 0.001, 1],
  161. [1, 0.0008, 2],
  162. [2, 0.0008, 2],
  163. [2, 0.001, 2],
  164. [1, 0.0008, 3],
  165. [2, 0.0008, 3],
  166. [2, 0.001, 3],
  167. [1, 0.0008, 4],
  168. [2, 0.0008, 4],
  169. [2, 0.001, 4],
  170. [1, 0.0008, 5],
  171. [2, 0.0008, 5],
  172. [2, 0.001, 5],
  173. ],
  174. parameters: [],
  175. grade: [],
  176. RandomArray: [
  177. [0.1, -0.1],
  178. [0.2, -0.2],
  179. ],
  180. angle: [Math.PI / 2, Math.PI, (Math.PI * 3) / 2],
  181. raid: [1, 3, 5],
  182. angle_speed: [0.05, 0.07],
  183. continuation: 0,
  184. trainTime: 0,
  185. currentLevel: 0,
  186. userRecords: [],
  187. startTime: 0,
  188. };
  189. },
  190. mounted() {
  191. this.userId = sessionStorage.getItem("b80bb7740288fda1f201890375a60c8f");
  192. console.log(this.userId);
  193. for (let i = 0; i < 15; i++) {
  194. for (let j = 1; j <= this.tnumber; j++) {
  195. this.parameters.push(this.pam[i]);
  196. }
  197. }
  198. console.log(this.parameters);
  199. this.Init(this.parameters[0]);
  200. },
  201. methods: {
  202. result() {
  203. this.$router.push({
  204. name: "TestResult",
  205. params: {
  206. result: [
  207. { name: "1", value: "25%" },
  208. { name: "2", value: "25%" },
  209. ],
  210. },
  211. });
  212. },
  213. screen() {
  214. // 如果不允许进入全屏,发出不允许提示
  215. // if (!screenfull.isEnabled) {
  216. // this.$message("您的浏览器不能全屏");
  217. // return false;
  218. // }
  219. screenfull.toggle();
  220. },
  221. format(percentage) {
  222. return percentage === 100 ? "任务进度" : "任务进度";
  223. },
  224. //生成随机点
  225. Init(array) {
  226. if (this.screen_flag == 0) {
  227. this.screen();
  228. this.screen_flag++;
  229. }
  230. this.testFlag = true;
  231. this.speed = array[1];
  232. if (array[0] == 1) {
  233. this.count = 25;
  234. } else if (array[0] == 2) {
  235. this.count = 50;
  236. }
  237. this.number = array[2];
  238. this.drawponit();
  239. this.sumdata.push(this.data);
  240. this.creatLine(array);
  241. this.drawline();
  242. },
  243. drawponit() {
  244. for (var i = 0; i < 16; i++) {
  245. if (i >= 0 && i <= 12) {
  246. let obj = {};
  247. let a = [];
  248. var j = parseInt(Math.random() * 11);
  249. var s = Math.random() * 6;
  250. var f = Math.floor(Math.random() * 16) / 10;
  251. a.push(this.a * Math.sin(this.p[j] * s));
  252. a.push(this.a * Math.sin((this.p[j] + 1) * s + f));
  253. this.data.push(a);
  254. obj.p = j;
  255. obj.s = s;
  256. obj.f = f;
  257. this.info.push(obj);
  258. } else if (i >= 13 && i <= 15) {
  259. let a = [];
  260. let r = this.raid[i - 13];
  261. a.push(r * Math.sin(this.angle[i - 13]));
  262. a.push(r * Math.cos(this.angle[i - 13]));
  263. console.log(a);
  264. this.data.push(a);
  265. }
  266. }
  267. console.log(this.data);
  268. this.checkPoint();
  269. },
  270. //检查随机点的位置距离是否过近,若是过近,重新生成相关随机点
  271. checkPoint() {
  272. for (var i = 0; i < 16; i++) {
  273. for (var j = i + 1; j < 16; j++) {
  274. if (
  275. Math.pow(Math.abs(this.data[i][0]) - Math.abs(this.data[j][0]), 2) +
  276. Math.pow(
  277. Math.abs(this.data[i][1]) - Math.abs(this.data[j][1]),
  278. 2
  279. ) <
  280. 0.5
  281. ) {
  282. console.log("笑了" + i + " " + j);
  283. this.info = [];
  284. this.data = [];
  285. this.drawponit();
  286. return;
  287. }
  288. }
  289. }
  290. },
  291. //生成运动点轨迹
  292. creatLine(array) {
  293. let flag;
  294. if (array[1] == 0.0008) {
  295. flag = 0;
  296. } else if ((array[1] = 0.001)) {
  297. flag = 1;
  298. }
  299. //初始化this.speed
  300. let array_speed = [];
  301. if (array[1] == 0.0008) {
  302. for (let n = 0; n <= 9; n++) {
  303. array_speed.push(0.0008);
  304. }
  305. } else if ((array[1] = 0.001)) {
  306. for (let n = 0; n <= 9; n++) {
  307. array_speed.push(0.001);
  308. }
  309. }
  310. console.log(array_speed);
  311. let b = [];
  312. for (var q = 1; q < 70; q++) {
  313. this.data_item = [];
  314. this.flag1++;
  315. this.flag2++;
  316. for (let u = 0; u < 3; u++) {
  317. this.angle[u] += this.angle_speed[flag];
  318. }
  319. for (var j = 0; j < 16; j++) {
  320. if (j <= 9) {
  321. b = [];
  322. let x =
  323. this.a *
  324. Math.sin(
  325. this.p[this.info[j].p] *
  326. (this.info[j].s + array_speed[j] * this.flag1)
  327. );
  328. let y =
  329. this.a *
  330. Math.sin(
  331. (this.p[this.info[j].p] + 1) *
  332. (this.info[j].s + array_speed[j] * this.flag2) +
  333. this.info[j].f
  334. );
  335. //判断此时生成的x 和y 与上次生成的x 和y 的关系,若是太小,则改变速度
  336. let x1 = this.sumdata[this.sumdata.length - 1][j][0];
  337. let y1 = this.sumdata[this.sumdata.length - 1][j][1];
  338. if (
  339. Math.abs(Math.abs(x) - Math.abs(x1)) +
  340. Math.abs(Math.abs(y) - Math.abs(y1)) <
  341. 0.08
  342. ) {
  343. console.log(j);
  344. array_speed[j] += 0.0003;
  345. console.log("x1:" + x + " y1:" + y);
  346. x =
  347. this.a *
  348. Math.sin(
  349. this.p[this.info[j].p] *
  350. (this.info[j].s + array_speed[j] * this.flag1)
  351. );
  352. y =
  353. this.a *
  354. Math.sin(
  355. (this.p[this.info[j].p] + 1) *
  356. (this.info[j].s + array_speed[j] * this.flag2) +
  357. this.info[j].f
  358. );
  359. console.log("x2:" + x + " y2:" + y);
  360. }
  361. //x
  362. b.push(x);
  363. //y
  364. b.push(y);
  365. this.data_item.push(b);
  366. } else if (j >= 10 && j <= 12) {
  367. let x = [];
  368. x.push(
  369. this.sumdata[q - 1][j][0] +
  370. this.RandomArray[flag][parseInt(Math.random() * 2)]
  371. );
  372. x.push(
  373. this.sumdata[q - 1][j][1] +
  374. this.RandomArray[flag][parseInt(Math.random() * 2)]
  375. );
  376. this.data_item.push(x);
  377. } else if (j >= 13 && j <= 15) {
  378. b = [];
  379. let r = this.raid[j - 13];
  380. b.push(r * Math.sin(this.angle[j - 13]));
  381. b.push(r * Math.cos(this.angle[j - 13]));
  382. this.data_item.push(b);
  383. }
  384. }
  385. this.sumdata.push(this.data_item);
  386. }
  387. console.log(this.sumdata);
  388. this.checkLine();
  389. },
  390. checkLine() {
  391. for (let i = 0; i < 16; i++) {
  392. for (let j = i + 1; j < 16; j++) {
  393. if (
  394. Math.abs(
  395. this.sumdata[this.count][i][0] - this.sumdata[this.count][j][0]
  396. ) +
  397. Math.abs(
  398. this.sumdata[this.count][i][1] - this.sumdata[this.count][j][1]
  399. ) <
  400. 0.35
  401. ) {
  402. console.log(this.sumdata[this.count][i]);
  403. console.log(this.sumdata[this.count][j]);
  404. let sum =
  405. Math.abs(
  406. this.sumdata[this.count][i][0] - this.sumdata[this.count][j][0]
  407. ) +
  408. Math.abs(
  409. this.sumdata[this.count][i][1] - this.sumdata[this.count][j][1]
  410. );
  411. console.log(sum);
  412. this.count++;
  413. this.checkLine();
  414. return;
  415. }
  416. }
  417. }
  418. },
  419. drawline() {
  420. console.log(this.info);
  421. this.$nextTick(() => {
  422. this.myChart = echarts.init(document.getElementById("main"));
  423. echarts.registerTransform(ecStat.transform.clustering);
  424. const data = this.data;
  425. var CLUSTER_COUNT = 2;
  426. var DIENSIION_CLUSTER_INDEX = 2;
  427. var that = this;
  428. this.option = {
  429. backgroundColor: "transparent",
  430. dataset: [
  431. {
  432. source: data,
  433. },
  434. {
  435. transform: {
  436. type: "ecStat:clustering",
  437. config: {
  438. clusterCount: CLUSTER_COUNT,
  439. outputType: "single",
  440. outputClusterIndexDimension: DIENSIION_CLUSTER_INDEX,
  441. },
  442. },
  443. },
  444. ],
  445. tooltip: {
  446. show: false,
  447. },
  448. grid: {
  449. left: 60,
  450. },
  451. xAxis: {
  452. type: "value", // 坐标轴类型
  453. name: "", // 名称
  454. min: -7, // 最小值
  455. max: 7, // 最大值
  456. axisLine: {
  457. //y轴
  458. show: false,
  459. },
  460. axisTick: {
  461. //y轴刻度线
  462. show: false,
  463. },
  464. splitLine: {
  465. //网格线
  466. show: false,
  467. },
  468. axisLabel: {
  469. show: false,
  470. },
  471. },
  472. yAxis: {
  473. type: "value", // 坐标轴类型
  474. name: "", // 名称
  475. min: -7, // 最小值
  476. max: 7, // 最大值
  477. axisLine: {
  478. //y轴
  479. show: false,
  480. },
  481. axisTick: {
  482. //y轴刻度线
  483. show: false,
  484. },
  485. splitLine: {
  486. //网格线
  487. show: false,
  488. },
  489. axisLabel: {
  490. show: false,
  491. },
  492. },
  493. series: {
  494. type: "scatter",
  495. encode: { tooltip: [0, 1] },
  496. symbol: "circle",
  497. symbolSize: 30,
  498. itemStyle: {
  499. color: function (params) {
  500. if (that.end == false && that.result1.size != 0) {
  501. for (let x of that.result1) {
  502. if (
  503. params.data[0] == that.sumdata[that.count][x - 1][0] &&
  504. params.data[1] == that.sumdata[that.count][x - 1][1]
  505. )
  506. return "red";
  507. }
  508. return "#3F919F";
  509. } else {
  510. if (that.flag3 == 0) {
  511. if (that.number == 5) {
  512. if (params.data[0] == that.sumdata[0][0][0] && params.data[1] == that.sumdata[0][0][1]) {
  513. return '#EF6262';
  514. } else if (params.data[0] == that.sumdata[0][1][0] && params.data[1] == that.sumdata[0][1][1])
  515. return '#EF6262';
  516. else if (params.data[0] == that.sumdata[0][2][0] && params.data[1] == that.sumdata[0][2][1])
  517. return '#EF6262';
  518. else if (params.data[0] == that.sumdata[0][3][0] && params.data[1] == that.sumdata[0][3][1])
  519. return '#EF6262';
  520. else if (params.data[0] == that.sumdata[0][4][0] && params.data[1] == that.sumdata[0][4][1])
  521. return '#EF6262';
  522. else
  523. return '#3F919F';
  524. } else if (that.number == 4) {
  525. if (
  526. params.data[0] == that.sumdata[0][0][0] &&
  527. params.data[1] == that.sumdata[0][0][1]
  528. ) {
  529. return "#EF6262";
  530. } else if (
  531. params.data[0] == that.sumdata[0][1][0] &&
  532. params.data[1] == that.sumdata[0][1][1]
  533. )
  534. return "#EF6262";
  535. else if (
  536. params.data[0] == that.sumdata[0][2][0] &&
  537. params.data[1] == that.sumdata[0][2][1]
  538. )
  539. return "#EF6262";
  540. else if (
  541. params.data[0] == that.sumdata[0][3][0] &&
  542. params.data[1] == that.sumdata[0][3][1]
  543. )
  544. return "#EF6262";
  545. else return "#3F919F";
  546. } else if (that.number == 3) {
  547. if (
  548. params.data[0] == that.sumdata[0][0][0] &&
  549. params.data[1] == that.sumdata[0][0][1]
  550. ) {
  551. return "#EF6262";
  552. } else if (
  553. params.data[0] == that.sumdata[0][1][0] &&
  554. params.data[1] == that.sumdata[0][1][1]
  555. )
  556. return "#EF6262";
  557. else if (
  558. params.data[0] == that.sumdata[0][2][0] &&
  559. params.data[1] == that.sumdata[0][2][1]
  560. )
  561. return "#EF6262";
  562. else return "#3F919F";
  563. } else if (that.number == 2) {
  564. if (
  565. params.data[0] == that.sumdata[0][0][0] &&
  566. params.data[1] == that.sumdata[0][0][1]
  567. ) {
  568. return "#EF6262";
  569. } else if (
  570. params.data[0] == that.sumdata[0][1][0] &&
  571. params.data[1] == that.sumdata[0][1][1]
  572. )
  573. return "#EF6262";
  574. else return "#3F919F";
  575. } else if (that.number == 1) {
  576. if (
  577. params.data[0] == that.sumdata[0][0][0] &&
  578. params.data[1] == that.sumdata[0][0][1]
  579. ) {
  580. return "#EF6262";
  581. }
  582. else return "#3F919F";
  583. }
  584. } else if (that.flag3 == 1) {
  585. if (that.end == false) return "#3F919F";
  586. else {
  587. if (that.number == 5) {
  588. if (params.data[0] == that.sumdata[that.count][0][0] && params.data[1] == that.sumdata[that.count][0][1]) {
  589. return '#EF6262';
  590. } else if (params.data[0] == that.sumdata[that.count][1][0] && params.data[1] == that.sumdata[that.count][1][1])
  591. return '#EF6262';
  592. else if (params.data[0] == that.sumdata[that.count][2][0] && params.data[1] == that.sumdata[that.count][2][1])
  593. return '#EF6262';
  594. else if (params.data[0] == that.sumdata[that.count][3][0] && params.data[1] == that.sumdata[that.count][3][1])
  595. return '#EF6262';
  596. else if (params.data[0] == that.sumdata[that.count][4][0] && params.data[1] == that.sumdata[that.count][4][1])
  597. return '#EF6262';
  598. else
  599. return '#3F919F';
  600. } else if (that.number == 4) {
  601. if (
  602. params.data[0] == that.sumdata[that.count][0][0] &&
  603. params.data[1] == that.sumdata[that.count][0][1]
  604. ) {
  605. return "#EF6262";
  606. } else if (
  607. params.data[0] == that.sumdata[that.count][1][0] &&
  608. params.data[1] == that.sumdata[that.count][1][1]
  609. )
  610. return "#EF6262";
  611. else if (
  612. params.data[0] == that.sumdata[that.count][2][0] &&
  613. params.data[1] == that.sumdata[that.count][2][1]
  614. )
  615. return "#EF6262";
  616. else if (
  617. params.data[0] == that.sumdata[that.count][3][0] &&
  618. params.data[1] == that.sumdata[that.count][3][1]
  619. )
  620. return "#EF6262";
  621. else return "#3F919F";
  622. } else if (that.number == 3) {
  623. if (
  624. params.data[0] == that.sumdata[that.count][0][0] &&
  625. params.data[1] == that.sumdata[that.count][0][1]
  626. ) {
  627. return "#EF6262";
  628. } else if (
  629. params.data[0] == that.sumdata[that.count][1][0] &&
  630. params.data[1] == that.sumdata[that.count][1][1]
  631. )
  632. return "#EF6262";
  633. else if (
  634. params.data[0] == that.sumdata[that.count][2][0] &&
  635. params.data[1] == that.sumdata[that.count][2][1]
  636. )
  637. return "#EF6262";
  638. else return "#3F919F";
  639. } else if (that.number == 2) {
  640. if (
  641. params.data[0] == that.sumdata[that.count][0][0] &&
  642. params.data[1] == that.sumdata[that.count][0][1]
  643. ) {
  644. return "#EF6262";
  645. } else if (
  646. params.data[0] == that.sumdata[that.count][1][0] &&
  647. params.data[1] == that.sumdata[that.count][1][1]
  648. )
  649. return "#EF6262";
  650. else return "#3F919F";
  651. } else if (that.number == 1) {
  652. if (
  653. params.data[0] == that.sumdata[that.count][0][0] &&
  654. params.data[1] == that.sumdata[that.count][0][1]
  655. ) {
  656. return "#EF6262";
  657. }
  658. else return "#3F919F";
  659. }
  660. }
  661. }
  662. }
  663. },
  664. },
  665. datasetIndex: 1,
  666. },
  667. };
  668. this.option && this.myChart.setOption(this.option);
  669. });
  670. },
  671. beginTest() {
  672. this.startTime = new Date().getTime();
  673. this.sum++;
  674. var that = this;
  675. var flag = -1;
  676. this.flag3 = 1;
  677. this.noclick = false;
  678. this.option && this.myChart.setOption(this.option);
  679. setTimeout(function () {
  680. var id = setInterval(function () {
  681. flag++;
  682. console.log("flag:" + flag);
  683. if (flag > that.count) {
  684. clearInterval(id);
  685. that.myChart.on("click", function (params) {
  686. //点击事件
  687. that.scatterClick(params);
  688. });
  689. console.log(that.data);
  690. } else {
  691. for (var i = 0; i < 16; i++) {
  692. that.data[i][0] = that.sumdata[flag][i][0];
  693. that.data[i][1] = that.sumdata[flag][i][1];
  694. }
  695. that.myChart.setOption(that.option, true);
  696. }
  697. }, 300);
  698. }, 2000);
  699. },
  700. clearArray() {
  701. this.result1 = [];
  702. },
  703. scatterClick(params) {
  704. this.onsave = true;
  705. if (this.result1.size < this.number) {
  706. for (var i = 0; i < 16; i++) {
  707. if (
  708. this.sumdata[this.count][i][0] == params.data[0] &&
  709. this.sumdata[this.count][i][1] == params.data[1]
  710. ) {
  711. this.id_true = i + 1;
  712. }
  713. }
  714. //判断是否在set 数组中,如果在的话,移除,更新加载
  715. console.log("set集合:");
  716. console.log(this.result1);
  717. console.log("当前点击元素:" + this.id_true);
  718. if (this.result1.has(this.id_true)) {
  719. console.log("移除元素" + this.id_true);
  720. this.result1.delete(this.id_true);
  721. this.myChart.setOption(this.option, true);
  722. } else {
  723. console.log("加入元素:" + this.id_true);
  724. this.result1.add(this.id_true);
  725. this.myChart.setOption(this.option, true);
  726. }
  727. } else if (this.result1.size == this.number) {
  728. for (var i = 0; i < 16; i++) {
  729. if (
  730. this.sumdata[this.count][i][0] == params.data[0] &&
  731. this.sumdata[this.count][i][1] == params.data[1]
  732. ) {
  733. this.id_true = i + 1;
  734. }
  735. }
  736. if (this.result1.has(this.id_true)) {
  737. this.result1.delete(this.id_true);
  738. this.myChart.setOption(this.option, true);
  739. }
  740. }
  741. },
  742. save() {
  743. //正确率
  744. var count = 0;
  745. for (var x of this.result1) {
  746. if (x >= 1 && x <= this.number) {
  747. count++;
  748. }
  749. }
  750. var accary = count / this.number;
  751. this.grade.push(accary);
  752. this.userRecords.push({
  753. index: this.layer + 1,
  754. diff: this.pam[this.layer][2],
  755. velocity: this.pam[this.layer][1],
  756. duration: this.pam[this.layer][0] == 1 ? "5秒" : "10秒",
  757. targetNum: this.pam[this.layer][2],
  758. raghtRate: accary,
  759. responseTime: new Date().getTime() - this.startTime
  760. })
  761. // 计数连续正确次数
  762. if(accary >= 1) {
  763. this.continuation ++
  764. } else {
  765. this.continuation = 0
  766. }
  767. // 练习次数累计
  768. this.trainTime ++;
  769. //重置函数
  770. this.data = [];
  771. this.data_item = [];
  772. this.sumdata = [];
  773. this.myChart.dispose();
  774. this.option = "";
  775. this.info = [];
  776. this.flag1 = 0;
  777. this.flag2 = 0;
  778. this.flag3 = 0;
  779. this.id_true = "";
  780. this.result1.clear();
  781. console.log("mychart:" + this.myChart);
  782. console.log(this.result1);
  783. this.noclick = true;
  784. this.count = "";
  785. this.speed = "";
  786. this.end = false;
  787. this.number = "";
  788. if (this.layer >= 14) {
  789. this.testFlag = true;
  790. } else {
  791. this.testFlag = false;
  792. }
  793. this.onsave = false;
  794. this.RandomArray = [
  795. [0.1, -0.1],
  796. [0.2, -0.2],
  797. ];
  798. this.angle = [Math.PI / 2, Math.PI, (Math.PI * 3) / 2];
  799. this.raid = [1, 3, 5];
  800. this.angle_speed = [0.05, 0.07];
  801. if (this.layer >= 14 || this.trainTime >= 20) {
  802. this.submit();
  803. } else {
  804. // 开启下一级测试
  805. if(this.continuation == 3) {
  806. this.currentLevel ++;
  807. this.continuation = 0;
  808. this.layer = this.currentLevel * 3;
  809. } else {
  810. this.layer++;
  811. if(this.layer % 3 == 0) {
  812. this.layer = this.layer - 3;
  813. }
  814. }
  815. this.Init(this.parameters[this.layer]);
  816. }
  817. },
  818. submit() {
  819. // 退出全屏
  820. screenfull.exit();
  821. // 数据处理
  822. let indexList = [];
  823. let targetList = [];
  824. for(let i = 0; i < 5; i++) {
  825. targetList.push({
  826. targetCount: 0,
  827. rightRateCount: 0,
  828. responseTimeCount: 0
  829. })
  830. }
  831. this.userRecords.forEach((item, index) => {
  832. if(item.diff == 1) {
  833. targetList[0].targetCount += 1;
  834. targetList[0].rightRateCount += item.raghtRate;
  835. targetList[0].responseTimeCount += item.responseTime;
  836. }
  837. if(item.diff == 2) {
  838. targetList[1].targetCount += 1;
  839. targetList[1].rightRateCount += item.raghtRate;
  840. targetList[1].responseTimeCount += item.responseTime;
  841. }
  842. if(item.diff == 3) {
  843. targetList[2].targetCount += 1;
  844. targetList[2].rightRateCount += item.raghtRate;
  845. targetList[2].responseTimeCount += item.responseTime;
  846. }
  847. if(item.diff == 4) {
  848. targetList[3].targetCount += 1;
  849. targetList[3].rightRateCount += item.raghtRate;
  850. targetList[3].responseTimeCount += item.responseTime;
  851. }
  852. if(item.diff == 5) {
  853. targetList[4].targetCount += 1;
  854. targetList[4].rightRateCount += item.raghtRate;
  855. targetList[4].responseTimeCount += item.responseTime;
  856. }
  857. })
  858. for(let i = 0; i < 5; i++) {
  859. let temp = targetList[i]
  860. if(temp.targetCount != 0) {
  861. indexList.push({
  862. diff: i + 1,
  863. raghtRate: (temp.rightRateCount / temp.targetCount * 100).toFixed(2) + "%",
  864. averageTime: (temp.responseTimeCount / temp.targetCount).toFixed(2) + "ms",
  865. })
  866. }
  867. }
  868. this.$http.post(
  869. "cognize/MTT", //后台接口地址
  870. {
  871. userId: this.userId,
  872. userRecords: this.userRecords,
  873. indexList: indexList,
  874. testPlanId: this.$route.query.testPlanId || "",
  875. },
  876. (res) => {
  877. this.goTestResult(res.data);
  878. console.log(this.tableData);
  879. }
  880. );
  881. }
  882. },
  883. };
  884. </script>
  885. <style scoped>
  886. .el-button.start /deep/ {
  887. border: 2px solid rgb(255, 255, 255);
  888. box-shadow: 0 3px 6px rgba(0, 0, 0, 0.16);
  889. border-radius: 39px;
  890. }
  891. .testMainDiv {
  892. margin: 0 auto;
  893. margin-top: 10px;
  894. background: gray;
  895. background-size: cover;
  896. /* text-align:center; */
  897. /* object-fit:fill; */
  898. }
  899. .activeTask {
  900. background: url(../../assets/congnitiveAblitity/target_bg.png) no-repeat
  901. center;
  902. background-size: 100% 100%;
  903. position: fixed;
  904. top: 0;
  905. left: 0;
  906. right: 0;
  907. bottom: 0;
  908. }
  909. #main {
  910. width: 53%;
  911. height: 600px;
  912. margin-left: 23%;
  913. margin-top: 10vh;
  914. margin-bottom: 10px;
  915. border-radius: 12px;
  916. /* background: url(../../assets/5629.png) no-repeat;
  917. opacity: 0.8; */
  918. background: rgba(255, 255, 255, 0.41);
  919. }
  920. </style>