index.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623
  1. <template>
  2. <el-scrollbar height="92vh" v-if="gzCgd == 1">
  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">
  10. </el-option>
  11. </el-select>
  12. </div>
  13. </div>
  14. <div class="query-item">
  15. <div class="lable">样本类型:</div>
  16. <div class="search-input">
  17. <el-select v-model="tableTag" placeholder="请选择样本" popper-class="select">
  18. <el-option v-for="item in tableTagArr" :key="item.value" :value="item.value" :label="item.label">
  19. </el-option>
  20. </el-select>
  21. </div>
  22. </div>
  23. <div class="query-item">
  24. <div class="lable">故障分类:</div>
  25. <div class="search-input">
  26. <el-select v-model="widget" multiple collapse-tags clearable placeholder="请选择"
  27. popper-class="select">
  28. <el-option v-for="item in BuJian" :key="item.value" :value="item.value" :label="item.label">
  29. </el-option>
  30. </el-select>
  31. </div>
  32. </div>
  33. <div class="query-item">
  34. <div class="lable">风机型号:</div>
  35. <div class="search-input">
  36. <el-select v-model="model" multiple collapse-tags clearable placeholder="请选择"
  37. popper-class="select">
  38. <el-option v-for="item in fjxh" :key="item.value" :value="item.value" :label="item.label">
  39. </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="query()">查询</button>
  53. <button class="btn" @click="addEdit()">新增</button>
  54. </div>
  55. </div>
  56. </div>
  57. <el-row :type="'flex'" class="content">
  58. <el-col :span="24">
  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)"></ComTable>
  62. </el-col>
  63. </el-row>
  64. <el-dialog :title="isvisiableType == 1 ? '新增' : '编辑'" v-model="isvisiable" width="45%" top="15vh"
  65. custom-class="modal" :close-on-click-modal="false" :before-close="onClickDialogClose" class="isvisiable">
  66. <!-- 这里是新增或编辑 -->
  67. <el-row type="flex" class="mb10">
  68. <el-col :span="12">
  69. <div>样本类型:</div>
  70. <el-select v-model="tableTag" placeholder="请选择样本" popper-class="select" class="w">
  71. <el-option v-for="item in tableTagArr" :key="item.value" :value="item.value"
  72. :label="item.label">
  73. </el-option>
  74. </el-select>
  75. </el-col>
  76. <el-col :span="12">
  77. <div>风机型号:</div>
  78. <el-select v-model="tableModel" placeholder="请选择风机型号" popper-class="select" class="w">
  79. <el-option v-for="item in fjxh" :key="item.value" :value="item.value" :label="item.label">
  80. </el-option>
  81. </el-select>
  82. </el-col>
  83. </el-row>
  84. <el-row type="flex" class="mb10">
  85. <el-col :span="12">
  86. <div>故障分类:</div>
  87. <el-select v-model="tableFaulttype" placeholder="请选择故障" popper-class="select" class="w">
  88. <el-option v-for="item in BuJian" :key="item.value" :value="item.value" :label="item.label">
  89. </el-option>
  90. </el-select>
  91. </el-col>
  92. <el-col :span="12">
  93. <div>时间:</div>
  94. <el-date-picker v-model="tableTime" type="datetimerange" range-separator="至"
  95. start-placeholder="开始日期" end-placeholder="结束日期" class="w">
  96. </el-date-picker>
  97. </el-col>
  98. </el-row>
  99. <el-row type="flex" class="mb10">
  100. <el-col :span="12">
  101. <div>故障原因:</div>
  102. <el-input placeholder="请输入故障原因" v-model="tableSymptom" :value="tableSymptom">
  103. </el-input>
  104. </el-col>
  105. <el-col :span="12">
  106. <div>风机厂商:</div>
  107. <el-input placeholder="请输入风机厂商" v-model="tableManufacturer" :value="tableManufacturer">
  108. </el-input>
  109. </el-col>
  110. </el-row>
  111. <el-row type="flex" class="mb10">
  112. <el-col :span="12">
  113. <div>风机编号:</div>
  114. <el-input placeholder="请输入风机编号" v-model="tableWindturbineid" :value="tableWindturbineid">
  115. </el-input>
  116. </el-col>
  117. </el-row>
  118. <el-row type="flex" justify="end">
  119. <div class="query-actions" style="margin-top: 15px">
  120. <button class="btn" @click="onClickDialogClose">取消</button>
  121. <button class="btn" @click="dialogSave">保存</button>
  122. </div>
  123. </el-row>
  124. </el-dialog>
  125. </el-scrollbar>
  126. <el-scrollbar height="92vh" v-if="gzCgd == 2">
  127. <Point :data="gzCgdData" :st='st' @gzCgdClick="gzCgdClick" />
  128. </el-scrollbar>
  129. </template>
  130. <script>
  131. import ComTable from "@/components/coms/table/table.vue";
  132. import Point from "./point.vue";
  133. export default {
  134. components: {
  135. ComTable,
  136. Point,
  137. },
  138. data() {
  139. const that = this;
  140. return {
  141. tableTagArr: [{
  142. label: '正样本',
  143. value: 0
  144. },
  145. {
  146. label: '负样本',
  147. value: 1
  148. }
  149. ],
  150. queryType: false, //没有改变select时,点击查询无效
  151. pageIndex: 1,
  152. pageSize: 20,
  153. gzCgd: 1, //传感点组件隐藏或显示
  154. gzCgdData: [], //传感点参数
  155. st:'',
  156. BuJian: [],
  157. ChangZhan: [],
  158. fjxh: [],
  159. fjxhArr: [],
  160. widget: [],
  161. model: [],
  162. time: [],
  163. station: '',
  164. tableFaulttype: "",
  165. tableTag: "",
  166. tableModel: "",
  167. tableTime: "",
  168. tableSymptom: "",
  169. tableManufacturer: "",
  170. tableWindturbineid: "",
  171. tableCategory: "", //隐藏保存部分
  172. tableRemark: "",
  173. tableFaultcode: "",
  174. tableId: "",
  175. tableSymptomcode: "",
  176. tableStationen: "",
  177. isvisiable: false,
  178. isvisiableType: 1, //新增为1,编辑为2
  179. tableData: {
  180. column: [{
  181. name: "序号",
  182. field: "index",
  183. is_light: false,
  184. width: '50px',
  185. },
  186. {
  187. name: "样本类型",
  188. field: "tableTag",
  189. is_light: false,
  190. width: '100px',
  191. },
  192. {
  193. name: "风机编号",
  194. field: "tableWindturbineid",
  195. is_light: false,
  196. width: '150px',
  197. },
  198. {
  199. name: "故障分类",
  200. field: "tableFaulttype",
  201. is_light: false,
  202. width: '150px',
  203. },
  204. {
  205. name: "故障原因",
  206. field: "tableSymptom",
  207. is_light: false,
  208. width: '350px',
  209. },
  210. {
  211. name: "时间",
  212. field: "tableTime",
  213. is_light: false,
  214. width: '350px',
  215. },
  216. {
  217. name: "风机厂商",
  218. field: "tableManufacturer",
  219. is_light: false,
  220. width: '150px',
  221. },
  222. {
  223. name: "风机型号",
  224. field: "tableModel",
  225. is_light: false,
  226. width: '150px',
  227. },
  228. {
  229. name: "操作",
  230. is_light: false,
  231. width: '200px',
  232. template: () => {
  233. return (
  234. "<el-button type='text' style='cursor: pointer;' value='edit'>编辑</el-button>&nbsp" +
  235. "<el-button type='text' style='cursor: pointer;' value='delete'>删除</el-button>&nbsp" +
  236. "<el-button type='text' style='cursor: pointer;' value='config'>传感点</el-button>&nbsp"
  237. );
  238. },
  239. click(e, row) {
  240. that.onClickOption(e, row);
  241. },
  242. },
  243. ],
  244. data: [],
  245. }
  246. };
  247. },
  248. methods: {
  249. getTable() {
  250. let that = this;
  251. this.tableLoading = true;
  252. that.API.requestData({
  253. method: "GET",
  254. baseURL: "http://192.168.10.4:9002/",
  255. subUrl: "benchmarking/wplist",
  256. data: {
  257. wpId: that.stationId,
  258. startTs: that.startDate,
  259. endTs: that.endDate,
  260. pageNum: that.pageIndex,
  261. pageSize: that.pageSize,
  262. },
  263. success(res) {
  264. var dataTab = [];
  265. if (res.data) {
  266. res.data.list.forEach(item => {
  267. dataTab.push({ //表格
  268. recodedata: that.formatTime(item.recodedata),
  269. region: item.region,
  270. })
  271. })
  272. that.tableData.data = dataTab;
  273. that.tableData.total = res.data.total;
  274. } else {
  275. that.tableData.data = [];
  276. that.tableData.total = 0;
  277. }
  278. that.tableLoading = false;
  279. },
  280. });
  281. },
  282. onChangePage(params) {
  283. this.pageIndex = params.pageIndex;
  284. this.pageSize = params.pageSize;
  285. this.getTable();
  286. },
  287. startAjax() {
  288. var that = this;
  289. // that.time = [new Date((new Date() - 3600 * 1000 * 24 * 30)).formatDate("yyyy-MM-dd"), new Date().formatDate("yyyy-MM-dd")];
  290. that.time = [new Date((new Date() - 3600 * 1000 * 24 * 360)).formatDate("yyyy-MM-dd"), new Date()
  291. .formatDate("yyyy-MM-dd")
  292. ];
  293. that.API.requestData({
  294. method: "GET",
  295. baseURL: "http://10.155.32.4:9001/",
  296. subUrl: "benchmarking/wplist",
  297. success(res) {
  298. that.ChangZhan = res.data;
  299. // that.station = res.data[0].name
  300. that.station = res.data[1].name
  301. },
  302. });
  303. that.API.requestData({
  304. method: "GET",
  305. baseURL: "http://192.168.1.18:9002/",
  306. subUrl: "basic/widget/condition",
  307. success(res) {
  308. let keys = Object.keys(res.data[0]);
  309. let bujian = [],
  310. widget = [];
  311. keys.forEach((ele, index) => {
  312. bujian.push({
  313. label: res.data[0].ele,
  314. value: ele
  315. })
  316. widget.push(ele)
  317. })
  318. that.widget = widget;
  319. that.BuJian = bujian;
  320. },
  321. });
  322. that.API.requestData({
  323. method: "GET",
  324. baseURL: "http://192.168.1.18:9002/",
  325. subUrl: "basic/station/all",
  326. success(res) {
  327. let fjxhArr = [];
  328. let model = [],
  329. fjxh = [];
  330. res.data.forEach(ele => {
  331. fjxhArr.push({
  332. id: ele.id,
  333. value: ele.model.split("/")
  334. })
  335. if (ele.id == "MHS_FDC") {
  336. model = ele.model.split("/");
  337. model.forEach(ele => {
  338. fjxh.push({
  339. label: ele,
  340. value: ele
  341. })
  342. })
  343. }
  344. })
  345. that.fjxhArr = fjxhArr;
  346. that.model = model;
  347. that.fjxh = fjxh;
  348. },
  349. });
  350. },
  351. query() {
  352. if (this.queryType) {
  353. this.list();
  354. }
  355. },
  356. addEdit() {
  357. this.isvisiableType = 1;
  358. this.tableFaulttype = '';
  359. this.tableModel = '';
  360. this.tableTime = '';
  361. this.tableSymptom = '';
  362. this.tableManufacturer = '';
  363. this.tableWindturbineid = '';
  364. // this.tableCategory: data[i].category,
  365. // this.tableRemark: data[i].remark,
  366. // this.tableFaultcode: data[i].faultcode,
  367. // this.tableId: data[i].id,
  368. // this.tableSymptomcode:data[i].Symptomcode,
  369. // this.tableStationen:data[i].stationen
  370. this.isvisiable = true;
  371. },
  372. onClickOption(e, row) { // 操作按钮
  373. let that = this;
  374. if ("delete" == e.target.getAttribute("value")) {
  375. that
  376. .$confirm("确认删除此条样本数据?", "提示", {
  377. confirmButtonText: "删除",
  378. cancelButtonText: "取消"
  379. })
  380. .then((_) => {
  381. console.log('ok')
  382. // that.requestDelete(row);
  383. })
  384. .catch((_) => {});
  385. }
  386. if ("edit" == e.target.getAttribute("value")) {
  387. that.isvisiableType = 2;
  388. that.$nextTick(() => {
  389. let tableTime = row.tableTime.split(" - ");
  390. that.tableTag = row.tableTag;
  391. that.BuJian.forEach(ele => {
  392. if (ele.value == row.tableFaultcode) {
  393. that.tableFaulttype = ele.label
  394. }
  395. })
  396. that.tableModel = row.tableModel;
  397. that.tableTime = [Date.parse(new Date(tableTime[0])), Date.parse(new Date(tableTime[1]))];
  398. that.tableSymptom = row.tableSymptom;
  399. that.tableManufacturer = row.tableManufacturer;
  400. that.tableWindturbineid = row.tableWindturbineid;
  401. that.tableCategory = row.tableCategory;
  402. that.tableRemark = row.tableRemark;
  403. that.tableFaultcode = row.tableFaultcode;
  404. that.tableId = row.tableId;
  405. that.tableSymptomcode = row.tableSymptomcode;
  406. that.tableStationen = row.tableStationen;
  407. });
  408. that.isvisiable = true;
  409. }
  410. if ("config" == e.target.getAttribute("value")) { //传感点
  411. that.API.requestData({
  412. method: "GET",
  413. baseURL: "http://192.168.1.18:9002/",
  414. subUrl: "point/all",
  415. data: {
  416. wtId: row.tableWindturbineid,
  417. widget: row.tableFaultcode
  418. },
  419. success(res) {
  420. console.log(res)
  421. if (res.code == 200) {
  422. that.gzCgdData = res.data;
  423. that.st = Date.parse(new Date(row.tableTime.split(" - ")[0]));
  424. that.gzCgd = 2;
  425. }
  426. },
  427. });
  428. }
  429. },
  430. onClickDialogClose() { // 弹窗右上角关闭按钮
  431. this.isvisiable = false;
  432. this.isvisiableType = 1;
  433. },
  434. dialogSave() {
  435. let that = this;
  436. that.tableTime[0] = that.formatDate(that.tableTime[0].valueOf());
  437. that.tableTime[1] = that.formatDate(that.tableTime[1].valueOf());
  438. console.log(that.tableTime)
  439. that.API.requestData({
  440. method: "POST",
  441. baseURL: "http://192.168.1.18:9002/",
  442. headers: {
  443. 'Content-Type': 'application/json;charset=utf-8',
  444. },
  445. subUrl: "case/item/edit",
  446. body: {
  447. category: that.tableCategory,
  448. endtime: that.tableTime[1],
  449. faultcode: that.tableFaultcode,
  450. faulttype: that.tableFaulttype,
  451. id: that.tableId,
  452. manufacturer: that.tableManufacturer,
  453. model: that.tableModel,
  454. remark: that.tableRemark,
  455. starttime: that.tableTime[0],
  456. stationen: that.tableStationen,
  457. symptom: that.tableSymptom,
  458. symptomcode: that.tableSymptomcode,
  459. tag: that.tableTag == "正样本" ? 0 : 1,
  460. windturbineid: that.tableWindturbineid
  461. },
  462. success(res) {
  463. if (res.code == 200) {
  464. that.BASE.showMsg({
  465. type: "success",
  466. msg: "保存成功",
  467. });
  468. that.onClickDialogClose();
  469. that.list();
  470. }
  471. },
  472. });
  473. },
  474. gzCgdClick(data) {
  475. this.gzCgd = data;
  476. },
  477. formatDate(dates) {
  478. var date = new Date(dates);
  479. var YY = date.getFullYear() + '-';
  480. var MM = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
  481. var DD = (date.getDate() < 10 ? '0' + (date.getDate()) : date.getDate());
  482. var hh = (date.getHours() < 10 ? '0' + date.getHours() : date.getHours()) + ':';
  483. var mm = (date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes()) + ':';
  484. var ss = (date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds());
  485. return YY + MM + DD + " " + hh + mm + ss;
  486. },
  487. list() {
  488. var that = this;
  489. let station = '',
  490. widget = ''
  491. if (typeof that.time[0].valueOf() != 'string') {
  492. that.time[0] = that.formatDate(that.time[0].valueOf())
  493. }
  494. if (typeof that.time[1].valueOf() != 'string') {
  495. that.time[1] = that.formatDate(that.time[1].valueOf())
  496. }
  497. if (typeof that.station.valueOf() == 'string') {
  498. that.ChangZhan.forEach(ele => {
  499. if (ele.name == that.station) {
  500. station = ele.id
  501. }
  502. })
  503. }
  504. if (typeof that.widget.valueOf() == 'string') {
  505. that.BuJian.forEach(ele => {
  506. if (ele.label == that.widget) {
  507. widget = ele.value
  508. }
  509. })
  510. }
  511. if (that.model.length == 0) {
  512. that.BASE.showMsg({
  513. type: "warning",
  514. msg: "请选择风机型号",
  515. });
  516. return
  517. }
  518. if (that.widget.length == 0) {
  519. that.BASE.showMsg({
  520. type: "warning",
  521. msg: "请选择部件",
  522. });
  523. return
  524. }
  525. that.API.requestData({
  526. showLoading: true,
  527. method: "GET",
  528. baseURL: "http://192.168.1.18:9002/",
  529. subUrl: "case/fault/all",
  530. data: {
  531. widget: widget ? widget : that.widget,
  532. station: station ? station : that.station,
  533. model: that.model,
  534. st: that.time[0].valueOf(),
  535. et: that.time[1].valueOf()
  536. },
  537. success(res) {
  538. if (res.code == 200) {
  539. console.log(res)
  540. that.tableData.data = [];
  541. if (res.data.length) {
  542. let data = res.data;
  543. for (var i = 0; i < data.length; i++) {
  544. let obj = {
  545. index: i + 1,
  546. tableTag: data[i].tag == 0 ? '正样本' : '负样本',
  547. tableFaulttype: data[i].faulttype,
  548. tableModel: data[i].model,
  549. tableTime: data[i].starttime + ' - ' + data[i].endtime,
  550. tableSymptom: data[i].symptom,
  551. tableManufacturer: data[i].manufacturer,
  552. tableWindturbineid: data[i].windturbineid,
  553. tableCategory: data[i].category,
  554. tableRemark: data[i].remark,
  555. tableFaultcode: data[i].faultcode,
  556. tableId: data[i].id,
  557. tableSymptomcode: data[i].symptomcode,
  558. tableStationen: data[i].stationen
  559. };
  560. that.tableData.data.push(obj);
  561. }
  562. }
  563. }
  564. },
  565. });
  566. },
  567. },
  568. created() {
  569. let that = this;
  570. that.startAjax();
  571. setTimeout(function() {
  572. that.list()
  573. }, 500)
  574. },
  575. watch: {
  576. station(res) {
  577. let fjxh = [];
  578. this.fjxhArr.forEach(ele => {
  579. if (ele.id == res) {
  580. ele.value.forEach(ele2 => {
  581. fjxh.push({
  582. label: ele2,
  583. value: ele2
  584. })
  585. })
  586. this.model = ele.value;
  587. }
  588. })
  589. this.fjxh = fjxh;
  590. this.queryType = true;
  591. },
  592. widget() {
  593. this.queryType = true;
  594. },
  595. model() {
  596. this.queryType = true;
  597. },
  598. time() {
  599. this.queryType = true;
  600. },
  601. },
  602. };
  603. </script>
  604. <style lang="less" scoped>
  605. .mb10 {
  606. margin-bottom: 10px;
  607. }
  608. .el-select.w {
  609. width: 100%;
  610. }
  611. // .el-range-editor.w{width: 100%;}
  612. </style>