index.vue 13 KB

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