records.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467
  1. <template>
  2. <el-dialog
  3. width="70%"
  4. top="10vh"
  5. custom-class="modal"
  6. :close-on-click-modal="false"
  7. title="训练记录"
  8. v-model="dialogTableVisible"
  9. @opened="opened()"
  10. @closed="closed()"
  11. >
  12. <el-row :type="'flex'" class="content">
  13. <el-col :span="12" class="pd-l-8">
  14. <div style="font-size: 20px">历史记录</div>
  15. <div style="height: 60vh; overflow-y: auto; margin-top: 30px">
  16. <div v-if="supervisedFlag">
  17. <div
  18. class="body"
  19. v-for="(item, index) in recordList"
  20. :key="index"
  21. @click="chooses(index)"
  22. >
  23. <div class="left">
  24. <div :class="index === current ? 'round_on' : 'round'"></div>
  25. <div class="line"></div>
  26. </div>
  27. <div class="right">
  28. <div>{{ item.showTime }}</div>
  29. <div class="content">
  30. <div class="names">
  31. {{ item.showName || item.ducumentName }}
  32. </div>
  33. <button class="btn" @click="deleteDate(item.name)">
  34. 删除
  35. </button>
  36. </div>
  37. </div>
  38. </div>
  39. </div>
  40. <div v-else>
  41. <div
  42. class="body"
  43. v-for="(item, index) in showResultList"
  44. :key="index"
  45. @click="choose(index)"
  46. >
  47. <div class="left">
  48. <div :class="index === current ? 'round_on' : 'round'"></div>
  49. <div class="line"></div>
  50. </div>
  51. <div class="right">
  52. <div>{{ item.showTime }}</div>
  53. <div class="content">
  54. <div class="names">
  55. {{ item.showName || item.ducumentName }}
  56. </div>
  57. <button class="btn" @click="deleteDate(item.name)">
  58. 删除
  59. </button>
  60. </div>
  61. </div>
  62. </div>
  63. </div>
  64. </div>
  65. </el-col>
  66. <el-col :span="12" class="pd-l-8">
  67. <div style="margin-left: 30px; font-size: 20px">训练结果</div>
  68. <div v-if="supervisedFlag">
  69. <LineChart id="accuracyCharts" :dataList="accuracyList"></LineChart>
  70. <BarChart
  71. id="barCharts"
  72. @click="showDetials"
  73. height="350px"
  74. :barList="barList"
  75. :baseLine="recordList[current]?.coordinate?.BaseLine"
  76. ></BarChart>
  77. </div>
  78. <div v-else>
  79. <div
  80. class="scatterEchart"
  81. id="scatterEcharts"
  82. @click="showResults()"
  83. ></div>
  84. </div>
  85. </el-col>
  86. </el-row>
  87. <ChartDetails
  88. v-model="detialsDisplay"
  89. :barList="recordList[current]?.coordinate?.bar"
  90. :baseLine="recordList[current]?.coordinate?.BaseLine"
  91. ></ChartDetails>
  92. </el-dialog>
  93. </template>
  94. <script>
  95. import BarChart from ".//barChart.vue";
  96. import LineChart from "./lineChart.vue";
  97. import ChartDetails from "./chartDetails.vue";
  98. import * as echarts from "echarts";
  99. export default {
  100. components: {
  101. BarChart,
  102. LineChart,
  103. ChartDetails,
  104. },
  105. props: {
  106. supervisedFlag: {
  107. type: Boolean,
  108. default: false,
  109. },
  110. },
  111. data() {
  112. return {
  113. current: 0,
  114. accuracyList:{},
  115. barList: [],
  116. resultList: [],
  117. showResultList: [],
  118. recordList: [],
  119. detialsDisplay: false,
  120. colors: [
  121. "#FFFFFF",
  122. "#FF0000",
  123. "#820041",
  124. "#FF00FF",
  125. "#8600FF",
  126. "#0000C6",
  127. "#00FFFF",
  128. "#00DB00",
  129. "#F9F900",
  130. "#FF5809",
  131. "#984B4B",
  132. "#AFAF61",
  133. "#5151A2",
  134. "#FFAF60",
  135. "#B766AD",
  136. "#006030",
  137. "#2894FF",
  138. "#796400",
  139. ],
  140. series: [
  141. {
  142. name: "",
  143. symbolSize: 10,
  144. encode: { tooltip: [0, 1] },
  145. itemStyle: {
  146. color: "#ffffff",
  147. },
  148. data: [
  149. [11.0, 8.04],
  150. [8.07, 6.95],
  151. [13.0, 7.58],
  152. [9.05, 8.81],
  153. [11.0, 8.33],
  154. [14.0, 7.66],
  155. [13.4, 6.81],
  156. [10.0, 6.33],
  157. [14.0, 8.96],
  158. [12.5, 6.82],
  159. [9.15, 7.2],
  160. [11.5, 7.2],
  161. [3.03, 4.23],
  162. [12.2, 7.83],
  163. [2.02, 4.47],
  164. [1.05, 3.33],
  165. [4.05, 4.96],
  166. [6.03, 7.24],
  167. [12.0, 6.26],
  168. [12.0, 8.84],
  169. [7.08, 5.82],
  170. [5.02, 5.68],
  171. ],
  172. type: "scatter",
  173. },
  174. {
  175. name: "",
  176. encode: { tooltip: [0, 1] },
  177. symbolSize: 10,
  178. data: [
  179. [1.0, 8.04],
  180. [18.07, 6.95],
  181. [3.0, 7.58],
  182. [19.05, 8.81],
  183. [1.0, 8.33],
  184. [4.0, 7.66],
  185. [3.4, 6.81],
  186. [20.0, 6.33],
  187. [4.0, 8.96],
  188. [2.5, 6.82],
  189. [19.15, 7.2],
  190. [11.5, 7.2],
  191. [3.03, 4.23],
  192. [12.2, 7.83],
  193. [2.02, 4.47],
  194. [1.05, 3.33],
  195. [4.05, 4.96],
  196. [6.03, 7.24],
  197. [12.0, 6.26],
  198. [12.0, 8.84],
  199. [7.08, 5.82],
  200. [5.02, 5.68],
  201. ],
  202. type: "scatter",
  203. },
  204. ],
  205. };
  206. },
  207. methods: {
  208. opened() {
  209. if (!this.supervisedFlag) {
  210. this.getRecords();
  211. this.getScatter();
  212. } else {
  213. this.getSupervisedRecord();
  214. }
  215. },
  216. showDetials() {
  217. this.detialsDisplay = true;
  218. },
  219. choose(index) {
  220. this.current = index;
  221. },
  222. chooses(index) {
  223. this.current = index;
  224. this.accuracyList.accuracy =
  225. this.recordList[this.current]?.coordinate.accuracy;
  226. this.accuracyList.val_accuracy =
  227. this.recordList[this.current]?.coordinate.val_accuracy;
  228. this.recordList[this.current]?.coordinate.bar?.sort(
  229. this.Compare("value")
  230. );
  231. this.barList = this.recordList[this.current]?.coordinate.bar?.slice(0, 5);
  232. },
  233. getRecords() {
  234. let that = this;
  235. this.API.requestData({
  236. method: "GET",
  237. baseURL: "http://192.168.10.18:8080/",
  238. subUrl: "api/coordinate/history",
  239. success(res) {
  240. if (res) {
  241. res.forEach((item) => {
  242. let arr = item.name.split("-");
  243. item.coordinate = JSON.parse(item.coordinate);
  244. item.showName = arr[0];
  245. item.showTime = new Date(Number(arr[1])).formatDate(
  246. "yyyy-MM-dd hh:mm:ss"
  247. );
  248. });
  249. that.showResultList = res;
  250. that.dataDeal();
  251. }
  252. },
  253. });
  254. },
  255. getSupervisedRecord() {
  256. let that = this;
  257. this.API.requestData({
  258. method: "GET",
  259. baseURL: "http://192.168.10.18:8080/",
  260. subUrl: "api/supervised/history",
  261. success(res) {
  262. if (res) {
  263. res.forEach((item) => {
  264. let arr = item.name.split("-");
  265. item.coordinate = JSON.parse(item.coordinate);
  266. item.showName = arr[2];
  267. item.showTime = new Date(Number(arr[3])).formatDate(
  268. "yyyy-MM-dd hh:mm:ss"
  269. );
  270. item.coordinate.bar = JSON.parse(item.coordinate.bar);
  271. });
  272. that.accuracyList.accuracy = res[that.current]?.coordinate.accuracy;
  273. that.accuracyList.val_accuracy =
  274. res[that.current]?.coordinate.val_accuracy;
  275. res[that.current]?.coordinate.bar?.sort(that.Compare("value"));
  276. that.barList = res[that.current]?.coordinate.bar?.slice(0, 5);
  277. that.recordList = res;
  278. }
  279. },
  280. });
  281. },
  282. Compare(property) {
  283. return function (a, b) {
  284. var value1 = a[property];
  285. var value2 = b[property];
  286. return value2 - value1;
  287. };
  288. },
  289. dataDeal() {
  290. let that = this;
  291. that.resultList = [];
  292. let data = that.showResultList[that.current];
  293. let dataList = [];
  294. data?.coordinate.forEach((item, index) => {
  295. let idList = [];
  296. item.value.forEach((val) => {
  297. let datas = {};
  298. let arr = val[2].split("-");
  299. let dataArr = [];
  300. datas.name =
  301. arr[0] +
  302. "-" +
  303. new Date(Number(arr[1])).formatDate("yyyy-MM-dd hh:mm:ss");
  304. dataArr.push([Number(val[0]), Number(val[1])]);
  305. idList.push(arr[2]);
  306. datas.symbolSize = 10;
  307. datas.encode = { tooltip: [0, 1] };
  308. datas.data = dataArr;
  309. datas.type = "scatter";
  310. datas.itemStyle = { color: that.colors[index] };
  311. dataList.push(datas);
  312. });
  313. that.resultList.push(idList);
  314. });
  315. that.series = dataList;
  316. that.getScatter();
  317. },
  318. getScatter() {
  319. let chartDom = document.getElementById("scatterEcharts");
  320. let myChart = echarts.init(chartDom);
  321. let option;
  322. option = {
  323. legend: {
  324. show: true,
  325. data: ["测试", "测试1"],
  326. right: 56,
  327. icon: "circle",
  328. itemWidth: 6,
  329. inactiveColor: "#606769",
  330. textStyle: {
  331. color: "#B3BDC0",
  332. fontSize: 12,
  333. },
  334. },
  335. xAxis: {
  336. splitLine: { show: false },
  337. },
  338. yAxis: {
  339. splitLine: { show: false },
  340. },
  341. tooltip: {
  342. position: "top",
  343. },
  344. series: this.series,
  345. };
  346. option && myChart.setOption(option);
  347. },
  348. showResults() {
  349. this.showList = [];
  350. this.getFaultList(0);
  351. },
  352. deleteDate(val) {
  353. let that = this;
  354. this.API.requestData({
  355. method: "GET",
  356. baseURL: "http://192.168.10.18:8080/",
  357. subUrl: "api/coordinate/history/remove/",
  358. data: {
  359. names: val,
  360. },
  361. success(res) {
  362. if (res) {
  363. that.showResultList = [];
  364. that.barList = [];
  365. that.recordList = [];
  366. that.current = 0
  367. if (!that.supervisedFlag) {
  368. that.getRecords();
  369. that.getScatter();
  370. } else {
  371. that.getSupervisedRecord();
  372. }
  373. }
  374. },
  375. });
  376. },
  377. getFaultList(index) {
  378. let result = this.resultList[index];
  379. let that = this;
  380. this.API.requestData({
  381. method: "GET",
  382. baseURL: "http://192.168.11.18:8075/",
  383. subUrl: "fault/history/",
  384. data: {
  385. ids: result.join(","),
  386. },
  387. success(res) {
  388. if (res) {
  389. res.forEach((item) => {
  390. item.colors = that.colors[index];
  391. });
  392. that.showList =
  393. that.showList.length > 0 ? [that.showList, ...res] : res;
  394. index++;
  395. if (index < that.resultList.length) {
  396. that.getFaultList(index);
  397. } else {
  398. that.$emit("results", that.showList);
  399. }
  400. }
  401. },
  402. });
  403. },
  404. closed() {
  405. this.$emit("records-closed");
  406. },
  407. },
  408. };
  409. </script>
  410. <style lang="less" scoped>
  411. .body {
  412. display: flex;
  413. flex-direction: row;
  414. height: 75px;
  415. width: 100%;
  416. .left {
  417. display: flex;
  418. flex-direction: column;
  419. justify-content: center;
  420. align-items: center;
  421. width: 30px;
  422. margin-left: 30px;
  423. .round_on {
  424. width: 20px;
  425. height: 27px;
  426. border-radius: 50%;
  427. background-color: rgb(30, 209, 45);
  428. }
  429. .round {
  430. width: 20px;
  431. height: 27px;
  432. border-radius: 50%;
  433. background-color: crimson;
  434. }
  435. .line {
  436. width: 2px;
  437. height: 100%;
  438. background-color: #ffffff;
  439. }
  440. }
  441. .right {
  442. width: 100%;
  443. margin-left: 20px;
  444. .content {
  445. display: flex;
  446. flex-direction: row;
  447. justify-content: space-between;
  448. align-items: center;
  449. margin-top: 10px;
  450. .btn {
  451. margin-right: 20px;
  452. }
  453. }
  454. }
  455. }
  456. .scatterEchart {
  457. width: 600px;
  458. height: 500px;
  459. margin-top: -20px;
  460. }
  461. </style>