trainingResults.vue 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358
  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. >
  11. <el-row :type="'flex'" class="content">
  12. <el-col :span="12" class="pd-l-8">
  13. <div style="display: flex; flex-direction: row-reverse">
  14. <button class="btn" style="margin-top: 0px" @click="batch">
  15. 批量处理
  16. </button>
  17. </div>
  18. <div style="height: 70vh; overflow-y: auto">
  19. <div>
  20. <el-table
  21. highlight-current-row
  22. @current-change="handleClick"
  23. ref="multipleTable"
  24. empty-text="暂无数据"
  25. :data="allData"
  26. :header-cell-style="{
  27. height: '40px',
  28. background: 'rgba(83, 98, 104, 0.2)',
  29. color: '#b2bdc0',
  30. 'border-bottom': '0px solid red',
  31. }"
  32. :cell-style="{
  33. height: '40px',
  34. 'border-bottom': 'solid 0px #242424',
  35. }"
  36. stripe
  37. style="width: 100%; margin-bottom: 10px"
  38. >
  39. <el-table-column width="30">
  40.      
  41. <template #default="scope">
  42. <span
  43. class="mark"
  44. :style="{ 'background-color': scope.row.colors }"
  45. ></span>
  46. </template>
  47.    
  48. </el-table-column>
  49. <el-table-column
  50. prop="faultTime"
  51. label="FaultTime"
  52. width="150"
  53. align="center"
  54. ></el-table-column>
  55. <!-- <el-table-column
  56. prop="stationId"
  57. label="StationId"
  58. width="80"
  59. align="center"
  60. ></el-table-column> -->
  61. <el-table-column
  62. prop="stationName"
  63. label="StationName"
  64. width="120"
  65. align="center"
  66. ></el-table-column>
  67. <el-table-column
  68. prop="objectId"
  69. label="ObjectId"
  70. width="80"
  71. align="center"
  72. ></el-table-column>
  73. <el-table-column
  74. prop="modelId"
  75. label="ModelId"
  76. width="100"
  77. align="center"
  78. ></el-table-column>
  79. <el-table-column width="150">
  80. <template #default="scope">
  81. <span>
  82. <el-select
  83. v-model="scope.row.labels"
  84. @change="selectSearch(scope.row)"
  85. clearable
  86. placeholder="请选择"
  87. popper-class="select"
  88. style="width: 120px; margin-left: 20px"
  89. >
  90. <el-option
  91. v-for="item in moudleList"
  92. :key="item.faultcode"
  93. :label="item.faulttype"
  94. :value="item.faultcode"
  95. >
  96. </el-option>
  97. </el-select>
  98. </span>
  99. </template>
  100. </el-table-column>
  101. </el-table>
  102. </div>
  103. </div>
  104. </el-col>
  105. <el-col :span="12" class="pd-l-8">
  106. <MultipleYLineChartNormal
  107. height="35vh"
  108. ref="multiple"
  109. :list="Analysis"
  110. :yAxises="AnalysisYAxises"
  111. :showLegend="true"
  112. :default="!batchDisplay"
  113. ></MultipleYLineChartNormal>
  114. <button class="btn" @click="handleSearch()" style="margin-top: 20px">
  115. 查询
  116. </button>
  117. <div class="lables">
  118. <button
  119. v-for="(item, index) in lableList"
  120. :key="index"
  121. :class="item.isShow ? 'btn green' : 'btn'"
  122. @click="handleChange(item)"
  123. >
  124. {{ item.showName }}
  125. </button>
  126. </div>
  127. </el-col>
  128. <BatchData
  129. v-model="batchDisplay"
  130. :moudleList="moudleList"
  131. :allData="allData"
  132. @handleSave="saveData"
  133. ></BatchData>
  134. </el-row>
  135. </el-dialog>
  136. </template>
  137. <script>
  138. import BatchData from "./batchData.vue";
  139. import UniformCodes from "./UniformCodes.json";
  140. import MultipleYLineChartNormal from "../../NewPages/multiple-y-line-chart-normal.vue";
  141. import BASE from "@tools/basicTool.js";
  142. import axios from "axios";
  143. export default {
  144. components: { MultipleYLineChartNormal, BatchData },
  145. props: {
  146. allData: {
  147. type: Array,
  148. default: () => {
  149. return [];
  150. },
  151. },
  152. intervalValue: {
  153. type: Number,
  154. default: 1,
  155. },
  156. moudleList: {
  157. type: Array,
  158. default: () => {
  159. return [];
  160. },
  161. },
  162. },
  163. data() {
  164. return {
  165. chooseData: {},
  166. lableList: [],
  167. lineList: [],
  168. batchDisplay: false,
  169. Analysis: [
  170. {
  171. title: "",
  172. yAxisIndex: 0, // 使用单位
  173. value: [],
  174. },
  175. ],
  176. AnalysisYAxises: [
  177. {
  178. name: "",
  179. min: "",
  180. max: "",
  181. unit: "",
  182. position: "left",
  183. },
  184. {
  185. name: "",
  186. min: "",
  187. max: "",
  188. unit: "",
  189. position: "right",
  190. },
  191. ],
  192. };
  193. },
  194. mounted() {},
  195. methods: {
  196. opened() {
  197. (this.lableList = []),
  198. (this.lineList = []),
  199. (this.chooseData = this.allData[0]);
  200. // this.queryData();
  201. this.$refs.multipleTable.setCurrentRow(this.allData[0]);
  202. this.dataDeal(this.allData[0]);
  203. },
  204. queryData() {
  205. let param = [];
  206. this.allData.forEach((item) => {
  207. param.push(item.id);
  208. });
  209. let that = this;
  210. that.API.requestData({
  211. method: "GET",
  212. subUrl: "http://192.168.1.18:9002/case/fault/train/all",
  213. data: {
  214. ids: param.join(","),
  215. },
  216. success(res) {
  217. if (res) {
  218. res.data.forEach((item) => {
  219. that.allData.filter((items) => items.id === item.id)[0].labels =
  220. item.labels;
  221. });
  222. }
  223. },
  224. });
  225. },
  226. handleClick(val) {
  227. let valus = val ? val : this.allData[0];
  228. if (val) {
  229. this.dataDeal(valus);
  230. this.handleSearch();
  231. }
  232. },
  233. dataDeal(val) {
  234. this.chooseData = val;
  235. this.lableList = [];
  236. UniformCodes.forEach((code) => {
  237. if (val?.stationId === code.name) {
  238. code.values.forEach((item) => {
  239. if (val.modelId === item.modelId) {
  240. item.codes.forEach((values, index) => {
  241. if (values.name.length > 5) {
  242. values.showName = values.name.substring(0, 5) + "...";
  243. } else {
  244. values.showName = values.name;
  245. }
  246. if (index < 5) {
  247. values.isShow = true;
  248. } else {
  249. values.isShow = false;
  250. }
  251. });
  252. this.lableList = item.codes;
  253. }
  254. });
  255. }
  256. });
  257. },
  258. handleChange(val) {
  259. let index = this.lableList.filter((item) => item.isShow === true).length;
  260. if (index >= 5 && val.isShow === false) {
  261. this.BASE.showMsg({
  262. type: "warning",
  263. msg: "每次查询不可大于5个",
  264. });
  265. val.isShow = false;
  266. } else {
  267. val.isShow = !val.isShow;
  268. }
  269. },
  270. handleSearch() {
  271. this.lineList = [];
  272. let max = this.lableList.filter((item) => item.isShow === true).length;
  273. if (max > 0) {
  274. this.historyData(0, max);
  275. }
  276. },
  277. historyData(index, max) {
  278. let dataLsit = this.lableList.filter((item) => item.isShow === true);
  279. let that = this;
  280. that.API.requestData({
  281. method: "GET",
  282. baseURL: "http://192.168.10.18:8011/",
  283. subUrl: "ts/history/snap",
  284. data: {
  285. uniformCode: dataLsit[index].code,
  286. startTs:
  287. new Date(that.chooseData.faultTime).getTime() -
  288. that.intervalValue * 3600000,
  289. endTs: new Date(that.chooseData.faultTime).getTime() + 600000,
  290. thingType: "windturbine",
  291. thingId: that.chooseData.objectId,
  292. interval: 1,
  293. },
  294. success(res) {
  295. if (res) {
  296. let obj = {
  297. title: dataLsit[index].name,
  298. value: res,
  299. };
  300. that.lineList.push(obj);
  301. index++;
  302. if (index < max) {
  303. that.historyData(index, max);
  304. } else {
  305. that.Analysis = that.lineList;
  306. }
  307. }
  308. },
  309. });
  310. },
  311. selectSearch(val) {
  312. this.saveData(this.allData);
  313. },
  314. batch() {
  315. this.batchDisplay = true;
  316. },
  317. saveData(data) {
  318. this.$emit('save-date', data);
  319. },
  320. },
  321. };
  322. </script>
  323. <style lang="less" scoped>
  324. .templates {
  325. width: 100%;
  326. height: 100%;
  327. display: flex;
  328. align-items: center;
  329. justify-content: center;
  330. }
  331. .mark {
  332. display: flex;
  333. width: 15px;
  334. height: 15px;
  335. border-radius: 50%;
  336. }
  337. .lables {
  338. display: flex;
  339. flex-direction: row;
  340. flex-wrap: wrap;
  341. height: 28vh;
  342. overflow-y: auto;
  343. margin-top: 10px;
  344. }
  345. .btn green {
  346. width: 117px;
  347. margin-right: 7px;
  348. margin-top: 10px;
  349. }
  350. .btn {
  351. width: 117px;
  352. margin-right: 7px;
  353. margin-top: 10px;
  354. }
  355. .btn + button {
  356. margin-left: 0px;
  357. }
  358. </style>