index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489
  1. <template>
  2. <el-scrollbar height="92vh">
  3. <div class="query mg-b-8">
  4. <div class="query-items">
  5. <div class="query-item" style="width: 200px;">
  6. <div class="lable">场站:</div>
  7. <div class="search-input">
  8. <el-select v-model="station" placeholder="请选择" popper-class="select">
  9. <el-option v-for="item in ChangZhan" :key="item.id" :value="item.id" :label="item.name"> </el-option>
  10. </el-select>
  11. </div>
  12. </div>
  13. <div class="query-item" style="width: 230px;">
  14. <div class="lable">故障类型:</div>
  15. <div class="search-input">
  16. <el-select v-model="widget" multiple collapse-tags clearable placeholder="请选择" popper-class="select">
  17. <el-option @click="checkAll" :class="active?'green':''">
  18. 全选
  19. </el-option>
  20. <el-option v-for="item in widgetArr" :key="item.value" :value="item.value" :label="item.label">
  21. </el-option>
  22. </el-select>
  23. </div>
  24. </div>
  25. <div class="query-item" style="width: 230px;">
  26. <div class="lable">风机型号:</div>
  27. <div class="search-input">
  28. <el-select v-model="model" multiple collapse-tags clearable placeholder="请选择" popper-class="select">
  29. <el-option v-for="item in fjxh" :key="item.value" :value="item.value" :label="item.label">
  30. </el-option>
  31. </el-select>
  32. </div>
  33. </div>
  34. <div class="query-item" style="width: 180px;">
  35. <div class="lable">模型:</div>
  36. <div class="search-input">
  37. <el-select v-model="mx" collapse-tags clearable placeholder="请选择" popper-class="select">
  38. <el-option key="1" value="list" label="原数据"></el-option>
  39. <el-option key="2" value="alg" label="DB-SCAN"></el-option>
  40. </el-select>
  41. </div>
  42. </div>
  43. <div class="query-item">
  44. <div class="lable">时间:</div>
  45. <div class="search-input">
  46. <el-date-picker v-model="time" type="datetimerange" range-separator="至" start-placeholder="开始日期"
  47. end-placeholder="结束日期">
  48. </el-date-picker>
  49. </div>
  50. </div>
  51. <div class="query-actions">
  52. <button class="btn" @click="list">查询</button>
  53. <button class="btn" @click="query()">导入</button>
  54. <button class="btn" @click="export">导出</button>
  55. </div>
  56. </div>
  57. </div>
  58. <el-row :type="'flex'" class="content">
  59. <ComTable :data="tableData" :pageSize="pageSize" @onPagging="onChangePage" height="84vh"
  60. v-loading="tableLoading" element-loading-text="拼命加载中"
  61. element-loading-background="rgba(0, 0, 0, 0.8)" v-if="mx=='list'"></ComTable>
  62. <ComTable :data="tableData2" :pageSize="pageSize" @onPagging="onChangePage" height="84vh"
  63. v-loading="tableLoading" element-loading-text="拼命加载中"
  64. element-loading-background="rgba(0, 0, 0, 0.8)" v-else></ComTable>
  65. </el-row>
  66. <el-dialog title="原始数据对比" v-model="gzCgd" width="80%" top="5vh" custom-class="modal" :close-on-click-modal="false" :before-close="onClickDialogClose" class="isvisiable">
  67. <Point :data="gzCgdData" :st='st' v-if='gzCgd'/>
  68. </el-dialog>
  69. </el-scrollbar>
  70. </template>
  71. <script>
  72. import ComTable from "@/components/coms/table/table.vue";
  73. import Point from "./point.vue";
  74. export default {
  75. components: {
  76. ComTable,
  77. Point,
  78. },
  79. data() {
  80. const that = this;
  81. return {
  82. active: true,
  83. selectAll: true,
  84. pageIndex: 1,
  85. pageSize: 20,
  86. gzCgd: false, //传感点组件隐藏或显示
  87. gzCgdData: [], //传感点参数
  88. st:'',
  89. widgetArr: [],
  90. ChangZhan: [],
  91. fjxh: [],
  92. fjxhArr: [],
  93. widget: [],
  94. model: [],
  95. mx:'list',
  96. time: [],
  97. station: '',
  98. tableData: {
  99. column: [{
  100. name: "序号",
  101. field: "index",
  102. is_light: false,
  103. width: '50px',
  104. },
  105. {
  106. name: "风机编号",
  107. field: "wtId",
  108. is_light: false,
  109. width: '150px',
  110. },
  111. {
  112. name: "故障类型",
  113. field: "tableTag",
  114. is_light: false,
  115. width: '150px',
  116. },
  117. {
  118. name: "故障现象",
  119. field: "symptom",
  120. is_light: false,
  121. width: '300px',
  122. },
  123. {
  124. name: "时间",
  125. field: "tableTime",
  126. is_light: false,
  127. width: '350px',
  128. },
  129. {
  130. name: "风机型号",
  131. field: "tableModel",
  132. is_light: false,
  133. width: '150px',
  134. },
  135. {
  136. name: "厂商",
  137. field: "tableManufacturer",
  138. is_light: false,
  139. width: '150px',
  140. },
  141. {
  142. name: "操作",
  143. field: "cz",
  144. is_light: false,
  145. width: '200px',
  146. template: () => {
  147. return (
  148. "<el-button type='text' style='cursor: pointer;' value='config'>传感点</el-button>&nbsp"
  149. );
  150. },
  151. click(e, row) {
  152. that.onClickOption(e, row);
  153. },
  154. },
  155. ],
  156. data: [],
  157. },
  158. tableData2: {
  159. column: [{
  160. name: "序号",
  161. field: "index",
  162. is_light: false,
  163. width: '50px',
  164. },
  165. {
  166. name: "风机编号",
  167. field: "wtId",
  168. is_light: false,
  169. width: '200px',
  170. },
  171. {
  172. name: "故障类型",
  173. field: "faulttype",
  174. is_light: false,
  175. width: '200px',
  176. },
  177. {
  178. name: "故障时间",
  179. field: "faultTime",
  180. is_light: false,
  181. width: '200px',
  182. },
  183. {
  184. name: "风机型号",
  185. field: "modelId",
  186. is_light: false,
  187. width: '200px',
  188. },
  189. {
  190. name: "操作",
  191. field: "cz",
  192. is_light: false,
  193. width: '200px',
  194. template: () => {
  195. return (
  196. "<el-button type='text' style='cursor: pointer;' value='config'>传感点</el-button>&nbsp"
  197. );
  198. },
  199. click(e, row) {
  200. that.onClickOption(e, row);
  201. },
  202. },
  203. ],
  204. data: [],
  205. },
  206. };
  207. },
  208. methods: {
  209. checkAll() {
  210. this.selectAll = !this.selectAll
  211. if (this.selectAll) {
  212. let widget = [];
  213. this.widgetArr.forEach(ele=>{
  214. widget.push(ele.value)
  215. })
  216. this.widget = widget;
  217. this.active = true;
  218. } else {
  219. this.active = false;
  220. this.widget = [];
  221. }
  222. },
  223. onChangePage(params) {
  224. this.pageIndex = params.pageIndex;
  225. this.pageSize = params.pageSize;
  226. this.list();
  227. },
  228. async startAjax() {
  229. var that = this;
  230. that.time = [new Date((new Date() - 3600 * 1000 * 24 * 360)).formatDate("yyyy-MM-dd hh:mm:ss"), new Date()
  231. .formatDate("yyyy-MM-dd hh:mm:ss")
  232. ];
  233. await that.API.requestData({
  234. method: "GET",
  235. baseURL: "http://10.155.32.4:9001/",
  236. subUrl: "benchmarking/wplist",
  237. success(res) {
  238. that.ChangZhan = res.data;
  239. that.station = res.data[1].name
  240. },
  241. });
  242. await that.API.requestData({
  243. method: "GET",
  244. baseURL: "http://192.168.1.18:9002/",
  245. subUrl: "basic/widget/condition",
  246. success(res) {
  247. let widgetArr = [],
  248. widget = [];
  249. res.data.forEach((ele, index) => {
  250. widgetArr.push({
  251. label: ele.faulttype,
  252. value: ele.faultcode
  253. })
  254. widget.push(ele.faultcode)
  255. })
  256. that.widget = widget;
  257. that.widgetArr = widgetArr;
  258. },
  259. });
  260. await that.API.requestData({
  261. method: "GET",
  262. baseURL: "http://192.168.1.18:9002/",
  263. subUrl: "basic/station/all",
  264. success(res) {
  265. let fjxhArr = [];
  266. let model = [],
  267. fjxh = [];
  268. res.data.forEach(ele => {
  269. fjxhArr.push({
  270. id: ele.id,
  271. value: ele.model.split("/")
  272. })
  273. if (ele.id == "MHS_FDC") {
  274. model = ele.model.split("/");
  275. model.forEach(ele => {
  276. fjxh.push({
  277. label: ele,
  278. value: ele
  279. })
  280. })
  281. }
  282. })
  283. that.fjxhArr = fjxhArr;
  284. that.model = model;
  285. that.fjxh = fjxh;
  286. },
  287. });
  288. that.list()
  289. },
  290. onClickOption(e, row) { // 操作按钮
  291. let that = this;
  292. if ("config" == e.target.getAttribute("value")) { //传感点
  293. that.API.requestData({
  294. method: "GET",
  295. baseURL: "http://192.168.1.18:9002/",
  296. subUrl: "point/list",
  297. data: {
  298. wtId: row.wtId,
  299. widget: row.widget
  300. },
  301. success(res) {
  302. if (res.code == 200) {
  303. if(res.data.length){
  304. that.gzCgdData = res.data;
  305. if(that.mx == 'list'){
  306. that.st = Date.parse(new Date(row.tableTime.split(" - ")[0]));
  307. }else{
  308. that.st = Date.parse(new Date(row.faultTime));
  309. }
  310. that.gzCgd = true;
  311. }else{
  312. that.BASE.showMsg({
  313. msg: "暂无数据"
  314. });
  315. }
  316. }
  317. },
  318. });
  319. }
  320. },
  321. onClickDialogClose() { // 弹窗右上角关闭按钮
  322. this.gzCgd = false;
  323. },
  324. formatDate(dates) {
  325. var date = new Date(dates);
  326. var YY = date.getFullYear() + '-';
  327. var MM = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
  328. var DD = (date.getDate() < 10 ? '0' + (date.getDate()) : date.getDate());
  329. var hh = (date.getHours() < 10 ? '0' + date.getHours() : date.getHours()) + ':';
  330. var mm = (date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes()) + ':';
  331. var ss = (date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds());
  332. return YY + MM + DD + " " + hh + mm + ss;
  333. },
  334. list() {
  335. var that = this;
  336. let station = '',
  337. widget = ''
  338. if (typeof that.time[0].valueOf() != 'string') {
  339. that.time[0] = that.formatDate(that.time[0].valueOf())
  340. }
  341. if (typeof that.time[1].valueOf() != 'string') {
  342. that.time[1] = that.formatDate(that.time[1].valueOf())
  343. }
  344. if (typeof that.station.valueOf() == 'string') {
  345. that.ChangZhan.forEach(ele => {
  346. if (ele.name == that.station) {
  347. station = ele.id
  348. }
  349. })
  350. }
  351. if (typeof that.widget.valueOf() == 'string') {
  352. that.widgetArr.forEach(ele => {
  353. if (ele.label == that.widget) {
  354. widget = ele.value
  355. }
  356. })
  357. }
  358. if (that.model.length== 0) {
  359. that.BASE.showMsg({
  360. type: "warning",
  361. msg: "请选择风机型号",
  362. });
  363. return
  364. }
  365. if (that.widget.length == 0) {
  366. that.BASE.showMsg({
  367. type: "warning",
  368. msg: "请选择部件",
  369. });
  370. return
  371. }
  372. that.API.requestData({
  373. showLoading: true,
  374. method: "GET",
  375. baseURL: "http://192.168.1.18:9002/",
  376. subUrl: "case/fault/list",
  377. data: {
  378. widget: widget ? widget : that.widget,
  379. station: station ? station : that.station,
  380. model: that.model,
  381. st: that.time[0].valueOf(),
  382. et: that.time[1].valueOf()
  383. },
  384. success(res) {
  385. if (res.code == 200) {
  386. if (res.data.length) {
  387. let data = res.data;
  388. if(that.mx == 'list'){
  389. that.tableData.data = [];
  390. let k = 0;
  391. for (var i = 0; i < data.length; i++) {
  392. if(data[i].endtime != undefined){
  393. k ++;
  394. let obj = {
  395. index: k,
  396. tableTag: data[i].faulttype,
  397. symptom: data[i].symptom,
  398. tableModel: data[i].model,
  399. tableTime: data[i].starttime + ' - ' + data[i].endtime,
  400. tableManufacturer: data[i].manufacturer,
  401. wtId: data[i].windturbineid,
  402. widget:data[i].faultcode
  403. };
  404. that.tableData.data.push(obj);
  405. }
  406. }
  407. }else{
  408. that.tableData2.data = [];
  409. let k = 0;
  410. for (var i = 0; i < data.length; i++) {
  411. if(data[i].endtime == undefined){
  412. k ++;
  413. let obj = {
  414. index: k,
  415. wtId: data[i].windturbineid,
  416. faulttype: data[i].faulttype,
  417. modelId: data[i].model,
  418. faultTime: data[i].starttime,
  419. widget:data[i].faultcode
  420. };
  421. that.tableData2.data.push(obj);
  422. }
  423. }
  424. }
  425. }
  426. }
  427. },
  428. });
  429. },
  430. formatJson(filterVal, jsonData) {
  431. return jsonData.map(v => filterVal.map(j => v[j]));
  432. },
  433. export() {
  434. let that = this;
  435. const {export_json_to_excel} = require('@tools/excel/Export2Excel.js'); // 注意这个Export2Excel路径
  436. let tHeader = []; // 上面设置Excel的表格第一行的标题
  437. let filterVal = []; // 上面的index、nickName、name是tableData里对象的属性key值
  438. that.tableData.column.forEach(ele => {
  439. if(ele.field != 'cz'){
  440. tHeader.push(ele.name);
  441. filterVal.push(ele.field);
  442. }
  443. });
  444. const data = that.formatJson(filterVal, that.tableData.data);
  445. export_json_to_excel(tHeader, data, '故障样本库'); // 最后一个是表名字
  446. },
  447. },
  448. created() {
  449. this.startAjax();
  450. },
  451. watch: {
  452. station(res) {
  453. let fjxh = [];
  454. this.fjxhArr.forEach(ele => {
  455. if (ele.id == res) {
  456. ele.value.forEach(ele2 => {
  457. fjxh.push({
  458. label: ele2,
  459. value: ele2
  460. })
  461. })
  462. this.model = ele.value;
  463. }
  464. })
  465. this.fjxh = fjxh;
  466. },
  467. mx(){
  468. this.list();
  469. }
  470. },
  471. };
  472. </script>
  473. <style lang="less" scoped>
  474. .mb10 {
  475. margin-bottom: 10px;
  476. }
  477. .el-select.w {
  478. width: 100%;
  479. }
  480. // .el-range-editor.w{width: 100%;}
  481. </style>