index.vue 13 KB

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