index.vue 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993
  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
  9. v-model="station"
  10. placeholder="请选择"
  11. popper-class="select"
  12. @change="stationChange"
  13. >
  14. <el-option
  15. v-for="item in ChangZhan"
  16. :key="item.id"
  17. :value="item.id"
  18. :label="item.name"
  19. >
  20. </el-option>
  21. </el-select>
  22. </div>
  23. </div>
  24. <div class="query-item" style="width: 230px">
  25. <div class="lable">故障类型:</div>
  26. <div class="search-input">
  27. <el-select
  28. v-model="widget"
  29. multiple
  30. collapse-tags
  31. clearable
  32. placeholder="请选择"
  33. popper-class="select"
  34. >
  35. <el-option @click="checkAll" :class="active ? 'green' : ''">
  36. 全选
  37. </el-option>
  38. <el-option
  39. v-for="item in widgetArr"
  40. :key="item.value"
  41. :value="item.value"
  42. :label="item.label"
  43. >
  44. </el-option>
  45. </el-select>
  46. </div>
  47. </div>
  48. <div class="query-item" style="width: 230px">
  49. <div class="lable">风机型号:</div>
  50. <div class="search-input">
  51. <el-select
  52. v-model="model"
  53. multiple
  54. collapse-tags
  55. clearable
  56. placeholder="请选择"
  57. popper-class="select"
  58. >
  59. <el-option
  60. v-for="item in fjxh"
  61. :key="item.value"
  62. :value="item.value"
  63. :label="item.label"
  64. >
  65. </el-option>
  66. </el-select>
  67. </div>
  68. </div>
  69. <div class="query-item" style="width: 230px">
  70. <div class="lable">样本类型:</div>
  71. <div class="search-input">
  72. <el-select
  73. v-model="category"
  74. collapse-tags
  75. clearable
  76. placeholder="请选择"
  77. popper-class="select"
  78. >
  79. <el-option
  80. v-for="item in categorys"
  81. :key="item.value"
  82. :value="item.value"
  83. :label="item.label"
  84. />
  85. </el-select>
  86. </div>
  87. </div>
  88. <div class="query-item">
  89. <div class="lable">时间:</div>
  90. <div class="search-input">
  91. <el-date-picker
  92. v-model="time"
  93. type="datetimerange"
  94. range-separator="至"
  95. start-placeholder="开始日期"
  96. end-placeholder="结束日期"
  97. >
  98. </el-date-picker>
  99. </div>
  100. </div>
  101. <div class="query-actions">
  102. <button class="btn" @click="list">查询</button>
  103. <button class="btn" @click="add">新增</button>
  104. <button class="btn" @click="query()">导入</button>
  105. <button class="btn" @click="exportData()">导出</button>
  106. </div>
  107. </div>
  108. </div>
  109. <el-row :type="'flex'" class="content">
  110. <ComTable
  111. :data="tableData"
  112. :pageSize="pageSize"
  113. @onPagging="onChangePage"
  114. height="84vh"
  115. v-loading="tableLoading"
  116. element-loading-text="拼命加载中"
  117. element-loading-background="rgba(0, 0, 0, 0.8)"
  118. v-if="category == '0'"
  119. ></ComTable>
  120. <ComTable
  121. :data="tableData2"
  122. :pageSize="pageSize"
  123. @onPagging="onChangePage"
  124. height="84vh"
  125. v-loading="tableLoading"
  126. element-loading-text="拼命加载中"
  127. element-loading-background="rgba(0, 0, 0, 0.8)"
  128. v-else
  129. ></ComTable>
  130. </el-row>
  131. <el-dialog
  132. title="原始数据对比"
  133. v-model="gzCgd"
  134. width="80%"
  135. top="5vh"
  136. custom-class="modal"
  137. :close-on-click-modal="false"
  138. :before-close="onClickDialogClose"
  139. class="isvisiable"
  140. >
  141. <Point :data="gzCgdData" :st="st" v-if="gzCgd" />
  142. </el-dialog>
  143. <el-dialog
  144. :title="'故障样本库' + addDialogTitle"
  145. v-model="addDialogShow"
  146. width="50%"
  147. custom-class="modal currentAddDialog"
  148. :close-on-click-modal="false"
  149. class="isvisiable"
  150. @closed="
  151. (res) => {
  152. addDialogTitle = '';
  153. addDialogShow = false;
  154. list()
  155. }
  156. "
  157. >
  158. <el-form
  159. ref="addDialogRef"
  160. :model="addDialogForm"
  161. :rules="addDialogRules"
  162. label-width="120px"
  163. >
  164. <div class="inlineItem">
  165. <el-form-item label="场站:" prop="stationen">
  166. <el-select
  167. v-model="addDialogForm.stationen"
  168. placeholder="请选择"
  169. popper-class="select"
  170. @change="addDialogStationChange"
  171. >
  172. <el-option
  173. v-for="item in ChangZhan"
  174. :key="item.id"
  175. :value="item.id"
  176. :label="item.name"
  177. >
  178. </el-option>
  179. </el-select>
  180. </el-form-item>
  181. <el-form-item label="风机:" prop="windturbineid">
  182. <el-select
  183. v-model="addDialogForm.windturbineid"
  184. placeholder="请选择"
  185. popper-class="select"
  186. >
  187. <el-option
  188. v-for="item in fengjiArray"
  189. :key="item.id"
  190. :value="item.id"
  191. :label="item.name"
  192. >
  193. </el-option>
  194. </el-select>
  195. </el-form-item>
  196. </div>
  197. <div class="inlineItem">
  198. <el-form-item label="故障类型:" prop="faulttype">
  199. <el-select
  200. v-model="addDialogForm.faulttype"
  201. placeholder="请选择"
  202. popper-class="select"
  203. @change="addDialogFaulttypeChange"
  204. >
  205. <el-option
  206. v-for="item in widgetArr"
  207. :key="item.value"
  208. :value="item.value"
  209. :label="item.label"
  210. >
  211. </el-option>
  212. </el-select>
  213. </el-form-item>
  214. <el-form-item label="风机型号:" prop="model">
  215. <el-select
  216. v-model="addDialogForm.model"
  217. placeholder="请选择"
  218. popper-class="select"
  219. >
  220. <el-option
  221. v-for="item in addDialogFjxh"
  222. :key="item.value"
  223. :value="item.value"
  224. :label="item.label"
  225. >
  226. </el-option>
  227. </el-select>
  228. </el-form-item>
  229. </div>
  230. <div class="inlineItem">
  231. <el-form-item label="故障时间:" prop="time">
  232. <el-date-picker
  233. v-model="addDialogForm.time"
  234. type="datetimerange"
  235. range-separator="至"
  236. start-placeholder="开始时间"
  237. end-placeholder="结束时间"
  238. value-format="YYYY-MM-DD hh:mm:ss"
  239. >
  240. </el-date-picker>
  241. </el-form-item>
  242. </div>
  243. <div class="inlineItem">
  244. <el-form-item label="风机厂商:" prop="manufacturer">
  245. <el-select
  246. style="width: 100%"
  247. v-model="addDialogForm.manufacturer"
  248. placeholder="请选择"
  249. popper-class="select"
  250. >
  251. <el-option
  252. v-for="item in manufacturerArray"
  253. :key="item.value"
  254. :value="item.value"
  255. :label="item.label"
  256. >
  257. </el-option>
  258. </el-select>
  259. </el-form-item>
  260. </div>
  261. <div class="inlineItem" style="width: 100%">
  262. <el-form-item style="width: 100%" label="故障现象:" prop="symptom">
  263. <el-input
  264. type="textarea"
  265. v-model="addDialogForm.symptom"
  266. placeholder="请输入"
  267. clearable
  268. resize="none"
  269. :maxlength="200"
  270. :autosize="{ minRows: 2, maxRows: 6 }"
  271. :rows="2"
  272. show-word-limit
  273. />
  274. </el-form-item>
  275. </div>
  276. </el-form>
  277. <template #footer>
  278. <span class="dialog-footer">
  279. <el-button
  280. class="btn red"
  281. type="danger"
  282. @click="cancelAdd('addDialogRef')"
  283. >
  284. 取消
  285. </el-button>
  286. <el-button
  287. class="btn green"
  288. type="success"
  289. style="margin-left: 12px"
  290. @click="submitForm('addDialogRef')"
  291. >
  292. 保存
  293. </el-button>
  294. </span>
  295. </template>
  296. </el-dialog>
  297. </el-scrollbar>
  298. </template>
  299. <script>
  300. import ComTable from "@/components/coms/table/table.vue";
  301. import Point from "./point.vue";
  302. import { ElMessageBox, ElMessage, Action } from "element-plus";
  303. import axios from "axios";
  304. export default {
  305. components: {
  306. ComTable,
  307. Point,
  308. },
  309. data() {
  310. const that = this;
  311. return {
  312. addDialogTitle: "",
  313. addDialogShow: false,
  314. addDialogForm: {
  315. tag: 0,
  316. category: 0,
  317. stationcn: "",
  318. stationen: "",
  319. windturbineid: "",
  320. faulttype: "",
  321. faultcode: "",
  322. time: [],
  323. symptom: "",
  324. manufacturer: "",
  325. },
  326. addDialogRules: {
  327. stationen: [
  328. {
  329. required: true,
  330. message: "场站不可为空",
  331. trigger: "change",
  332. },
  333. ],
  334. windturbineid: [
  335. {
  336. required: true,
  337. message: "风机不可为空",
  338. trigger: "change",
  339. },
  340. ],
  341. faulttype: [
  342. {
  343. required: true,
  344. message: "故障类型不可为空",
  345. trigger: "change",
  346. },
  347. ],
  348. model: [
  349. {
  350. required: true,
  351. message: "风机型号不可为空",
  352. trigger: "change",
  353. },
  354. ],
  355. time: [
  356. {
  357. required: true,
  358. message: "故障时间区间不可为空",
  359. trigger: "blur",
  360. },
  361. ],
  362. manufacturer: [
  363. {
  364. required: true,
  365. message: "风机厂商不可为空",
  366. trigger: "change",
  367. },
  368. ],
  369. symptom: [
  370. {
  371. required: true,
  372. message: "故障现象不可为空",
  373. trigger: "change",
  374. },
  375. ],
  376. },
  377. fengjiArray: [],
  378. addDialogFjxh: [],
  379. manufacturerArray: [
  380. { label: "联合动力", value: "联合动力" },
  381. { label: "华创", value: "华创" },
  382. ],
  383. sourceTableData: [],
  384. active: true,
  385. selectAll: true,
  386. pageIndex: 1,
  387. pageSize: 20,
  388. gzCgd: false, //传感点组件隐藏或显示
  389. gzCgdData: [], //传感点参数
  390. category: "0", //模型分类
  391. categorys: [
  392. { label: "检修样本", value: "0" },
  393. { label: "DBSCAN样本", value: "1" },
  394. ],
  395. st: "",
  396. widgetArr: [],
  397. ChangZhan: [],
  398. fjxh: [],
  399. fjxhArr: [],
  400. widget: [],
  401. model: [],
  402. time: [],
  403. station: "",
  404. tableData: {
  405. column: [
  406. {
  407. name: "序号",
  408. field: "index",
  409. is_light: false,
  410. width: "50px",
  411. },
  412. {
  413. name: "风机编号",
  414. field: "wtId",
  415. is_light: false,
  416. width: "150px",
  417. },
  418. {
  419. name: "故障类型",
  420. field: "tableTag",
  421. is_light: false,
  422. width: "150px",
  423. },
  424. {
  425. name: "故障现象",
  426. field: "symptom",
  427. is_light: false,
  428. width: "300px",
  429. },
  430. {
  431. name: "时间",
  432. field: "tableTime",
  433. is_light: false,
  434. width: "350px",
  435. },
  436. {
  437. name: "风机型号",
  438. field: "tableModel",
  439. is_light: false,
  440. width: "150px",
  441. },
  442. {
  443. name: "厂商",
  444. field: "tableManufacturer",
  445. is_light: false,
  446. width: "150px",
  447. },
  448. {
  449. name: "操作",
  450. field: "cz",
  451. is_light: false,
  452. width: "200px",
  453. template: () => {
  454. return "<el-button type='text' style='cursor: pointer;' value='config' data-callback='onClickOption'>传感点</el-button><el-button type='text' style='cursor: pointer;margin:0 10px;' value='config' data-callback='edit'>编辑</el-button><el-button type='text' style='cursor: pointer;' value='config' data-callback='delete'>删除</el-button>";
  455. },
  456. click(e, row) {
  457. const fnName = e.target.getAttribute("data-callback");
  458. fnName && that[fnName](e, row);
  459. },
  460. },
  461. ],
  462. data: [],
  463. },
  464. tableData2: {
  465. column: [
  466. {
  467. name: "序号",
  468. field: "index",
  469. is_light: false,
  470. width: "50px",
  471. },
  472. {
  473. name: "风机编号",
  474. field: "wtId",
  475. is_light: false,
  476. width: "200px",
  477. },
  478. {
  479. name: "故障类型",
  480. field: "faulttype",
  481. is_light: false,
  482. width: "200px",
  483. },
  484. {
  485. name: "故障时间",
  486. field: "faultTime",
  487. is_light: false,
  488. width: "200px",
  489. },
  490. {
  491. name: "风机型号",
  492. field: "modelId",
  493. is_light: false,
  494. width: "200px",
  495. },
  496. {
  497. name: "操作",
  498. field: "cz",
  499. is_light: false,
  500. width: "200px",
  501. template: () => {
  502. return "<el-button type='text' style='cursor: pointer;' value='config' data-callback='onClickOption'>传感点</el-button><el-button type='text' style='cursor: pointer;margin:0 10px;' value='config' data-callback='edit'>编辑</el-button><el-button type='text' style='cursor: pointer;' value='config' data-callback='delete'>删除</el-button>";
  503. },
  504. click(e, row) {
  505. const fnName = e.target.getAttribute("data-callback");
  506. fnName && that[fnName](e, row);
  507. },
  508. },
  509. ],
  510. data: [],
  511. },
  512. };
  513. },
  514. methods: {
  515. stationChange() {
  516. let fjxh = [];
  517. this.fjxhArr.forEach((ele) => {
  518. if (ele.id == this.station) {
  519. ele.value.forEach((ele2) => {
  520. fjxh.push({
  521. label: ele2,
  522. value: ele2,
  523. });
  524. });
  525. this.model = ele.value;
  526. }
  527. });
  528. this.fjxh = fjxh;
  529. },
  530. checkAll() {
  531. this.selectAll = !this.selectAll;
  532. if (this.selectAll) {
  533. let widget = [];
  534. this.widgetArr.forEach((ele) => {
  535. widget.push(ele.value);
  536. });
  537. this.widget = widget;
  538. this.active = true;
  539. } else {
  540. this.active = false;
  541. this.widget = [];
  542. }
  543. },
  544. onChangePage(params) {
  545. this.pageIndex = params.pageIndex;
  546. this.pageSize = params.pageSize;
  547. this.list();
  548. },
  549. async startAjax() {
  550. var that = this;
  551. that.time = [
  552. new Date(new Date() - 3600 * 1000 * 24 * 360).formatDate(
  553. "yyyy-MM-dd hh:mm:ss"
  554. ),
  555. new Date().formatDate("yyyy-MM-dd hh:mm:ss"),
  556. ];
  557. await that.API.requestData({
  558. method: "GET",
  559. baseURL: "http://192.168.1.18:9002/",
  560. subUrl: "basic/widget/condition",
  561. success(res) {
  562. let widgetArr = [],
  563. widget = [];
  564. res.data.forEach((ele, index) => {
  565. widgetArr.push({
  566. label: ele.faulttype,
  567. value: ele.faultcode,
  568. });
  569. widget.push(ele.faultcode);
  570. });
  571. that.widget = widget;
  572. that.widgetArr = widgetArr;
  573. },
  574. });
  575. await that.API.requestData({
  576. method: "GET",
  577. baseURL: "http://192.168.1.18:9002/",
  578. subUrl: "basic/station/all",
  579. success(res) {
  580. that.ChangZhan = res.data;
  581. that.station = res.data[1].name;
  582. let fjxhArr = [];
  583. let model = [],
  584. fjxh = [];
  585. res.data.forEach((ele) => {
  586. fjxhArr.push({
  587. id: ele.id,
  588. value: ele.model.split("/"),
  589. });
  590. if (ele.id == "NSS_FDC") {
  591. model = ["UP82"];
  592. fjxh.push({
  593. label: "UP82",
  594. value: "UP82",
  595. });
  596. }
  597. });
  598. that.fjxhArr = fjxhArr;
  599. that.model = model;
  600. that.fjxh = fjxh;
  601. },
  602. });
  603. that.list();
  604. },
  605. onClickOption(e, row) {
  606. // 操作按钮
  607. let that = this;
  608. if ("config" == e.target.getAttribute("value")) {
  609. //传感点
  610. that.API.requestData({
  611. method: "GET",
  612. baseURL: "http://192.168.1.18:9002/",
  613. subUrl: "point/list",
  614. data: {
  615. wtId: row.wtId,
  616. widget: row.widget,
  617. },
  618. success(res) {
  619. if (res.code == 200) {
  620. if (res.data.length) {
  621. that.gzCgdData = res.data;
  622. if (that.category == "0") {
  623. that.st = Date.parse(new Date(row.tableTime.split(" - ")[0]));
  624. } else {
  625. that.st = Date.parse(new Date(row.faultTime));
  626. }
  627. that.gzCgd = true;
  628. } else {
  629. that.BASE.showMsg({
  630. msg: "暂无数据",
  631. });
  632. }
  633. }
  634. },
  635. });
  636. }
  637. },
  638. onClickDialogClose() {
  639. // 弹窗右上角关闭按钮
  640. this.gzCgd = false;
  641. },
  642. formatDate(dates) {
  643. var date = new Date(dates);
  644. var YY = date.getFullYear() + "-";
  645. var MM =
  646. (date.getMonth() + 1 < 10
  647. ? "0" + (date.getMonth() + 1)
  648. : date.getMonth() + 1) + "-";
  649. var DD = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
  650. var hh =
  651. (date.getHours() < 10 ? "0" + date.getHours() : date.getHours()) + ":";
  652. var mm =
  653. (date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes()) +
  654. ":";
  655. var ss =
  656. date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds();
  657. return YY + MM + DD + " " + hh + mm + ss;
  658. },
  659. list() {
  660. var that = this;
  661. let station = "",
  662. widget = "";
  663. if (typeof that.time[0].valueOf() != "string") {
  664. that.time[0] = that.formatDate(that.time[0].valueOf());
  665. }
  666. if (typeof that.time[1].valueOf() != "string") {
  667. that.time[1] = that.formatDate(that.time[1].valueOf());
  668. }
  669. if (typeof that.station.valueOf() == "string") {
  670. that.ChangZhan.forEach((ele) => {
  671. if (ele.name == that.station) {
  672. station = ele.id;
  673. }
  674. });
  675. }
  676. if (typeof that.widget.valueOf() == "string") {
  677. that.widgetArr.forEach((ele) => {
  678. if (ele.label == that.widget) {
  679. widget = ele.value;
  680. }
  681. });
  682. }
  683. if (that.model.length == 0) {
  684. that.BASE.showMsg({
  685. type: "warning",
  686. msg: "请选择风机型号",
  687. });
  688. return;
  689. }
  690. if (that.widget.length == 0) {
  691. that.BASE.showMsg({
  692. type: "warning",
  693. msg: "请选择部件",
  694. });
  695. return;
  696. }
  697. that.tableData.data = [];
  698. that.tableData2.data = [];
  699. that.API.requestData({
  700. showLoading: true,
  701. method: "GET",
  702. baseURL: "http://192.168.1.18:9002/",
  703. subUrl: "case/fault/list",
  704. data: {
  705. widget: widget ? widget : that.widget,
  706. station: station ? station : that.station,
  707. model: that.model,
  708. category: that.category,
  709. st: that.time[0].valueOf(),
  710. et: that.time[1].valueOf(),
  711. },
  712. success(res) {
  713. if (res.code === 200 && res.data.length) {
  714. let data = res.data;
  715. that.sourceTableData = res.data;
  716. if (that.category == "0") {
  717. let k = 0;
  718. for (var i = 0; i < data.length; i++) {
  719. k++;
  720. let obj = {
  721. index: k,
  722. dataIndex: i,
  723. tableTag: data[i].faulttype,
  724. symptom: data[i].symptom,
  725. tableModel: data[i].model,
  726. tableTime: data[i].starttime + " - " + data[i].endtime,
  727. tableManufacturer: data[i].manufacturer,
  728. wtId: data[i].windturbineid,
  729. widget: data[i].faultcode,
  730. id: data[i].id,
  731. };
  732. that.tableData.data.push(obj);
  733. }
  734. } else {
  735. that.tableData2.data = [];
  736. let k = 0;
  737. for (var j = 0; j < data.length; j++) {
  738. k++;
  739. let obj = {
  740. index: k,
  741. dataIndex: i,
  742. wtId: data[j].windturbineid,
  743. faulttype: data[j].faulttype,
  744. modelId: data[j].model,
  745. faultTime: data[j].starttime,
  746. widget: data[j].faultcode,
  747. };
  748. that.tableData2.data.push(obj);
  749. }
  750. }
  751. }
  752. },
  753. });
  754. },
  755. formatJson(filterVal, jsonData) {
  756. return jsonData.map((v) => filterVal.map((j) => v[j]));
  757. },
  758. exportData() {
  759. let that = this;
  760. const { export_json_to_excel } = require("@tools/excel/Export2Excel.js"); // 注意这个Export2Excel路径
  761. let tHeader = []; // 上面设置Excel的表格第一行的标题
  762. let filterVal = []; // 上面的index、nickName、name是tableData里对象的属性key值
  763. that.tableData.column.forEach((ele) => {
  764. if (ele.field != "cz") {
  765. tHeader.push(ele.name);
  766. filterVal.push(ele.field);
  767. }
  768. });
  769. const data = that.formatJson(filterVal, that.tableData.data);
  770. export_json_to_excel(tHeader, data, "故障样本库"); // 最后一个是表名字
  771. },
  772. delete(e, row) {
  773. const that = this;
  774. ElMessageBox.alert("确定删除该条数据?此操作不可逆", "", {
  775. showCancelButton: true,
  776. showConfirmButton: true,
  777. confirmButtonText: "确定",
  778. cancelButtonText: "我再想想",
  779. callback(action) {
  780. if (action === "confirm") {
  781. that.API.requestData({
  782. method: "GET",
  783. baseURL: "http://192.168.1.18:9002/",
  784. subUrl: "case/fault/delete",
  785. data: {
  786. id: row.id,
  787. },
  788. success() {
  789. that.BASE.showMsg({
  790. type: "success",
  791. msg: "删除成功",
  792. });
  793. that.list();
  794. },
  795. });
  796. }
  797. },
  798. });
  799. },
  800. add() {
  801. this.addDialogTitle = "新增";
  802. this.addDialogForm.stationen = this.ChangZhan[0]?.id;
  803. this.addDialogStationChange(this.ChangZhan[0]?.id);
  804. this.addDialogShow = true;
  805. },
  806. addDialogStationChange(res, fjId) {
  807. let fjxh = [];
  808. this.fjxhArr.forEach((ele) => {
  809. if (ele.id === res) {
  810. ele.value.forEach((ele2) => {
  811. fjxh.push({
  812. label: ele2,
  813. value: ele2,
  814. });
  815. });
  816. }
  817. });
  818. this.addDialogFjxh = fjxh;
  819. this.addDialogForm.model = fjxh[0].value;
  820. this.addDialogForm.stationcn = this.ChangZhan.find((ele) => {
  821. return ele.id === res;
  822. })?.name;
  823. this.getFengji(fjId);
  824. },
  825. getFengji(fjId) {
  826. const that = this;
  827. that.API.requestData({
  828. method: "GET",
  829. baseURL: "http://10.155.32.4:9001/",
  830. subUrl: "benchmarking/wtList",
  831. data: {
  832. wpid: that.addDialogForm.stationen,
  833. },
  834. success(res) {
  835. that.fengjiArray = res.data;
  836. that.addDialogForm.windturbineid = fjId || res.data[0].id;
  837. },
  838. });
  839. },
  840. addDialogFaulttypeChange(res) {
  841. this.addDialogForm.faultcode = this.widgetArr.find((ele) => {
  842. return ele.value === res;
  843. })?.value;
  844. },
  845. cancelAdd(ref) {
  846. const that = this;
  847. ElMessageBox.alert(
  848. `确定取消${that.addDialogTitle}吗?之前所做的操作将不被保存`,
  849. "",
  850. {
  851. showCancelButton: true,
  852. showConfirmButton: true,
  853. confirmButtonText: "确定",
  854. cancelButtonText: "取消",
  855. callback(action) {
  856. if (action === "confirm") {
  857. that.resetForm(ref);
  858. that.addDialogShow = false;
  859. }
  860. },
  861. }
  862. );
  863. },
  864. resetForm(ref) {
  865. this.addDialogForm = {
  866. tag: 0,
  867. category: 0,
  868. stationcn: "",
  869. stationen: "",
  870. windturbineid: "",
  871. faulttype: "",
  872. faultcode: "",
  873. time: [],
  874. symptom: "",
  875. manufacturer: "",
  876. };
  877. this.$refs[ref].resetFields();
  878. },
  879. submitForm(ref) {
  880. const that = this;
  881. that.$refs[ref].validate((valid, fields) => {
  882. if (valid) {
  883. let data = that.BASE.deepCopy(that.addDialogForm);
  884. data.starttime = data.time[0];
  885. data.endtime = data.time[1];
  886. data.faulttype = that.widgetArr.find((ele) => {
  887. return ele.value === data.faulttype;
  888. })?.label;
  889. data.time && delete data.time;
  890. axios({
  891. method: "post",
  892. url: `http://192.168.1.18:9002/case/fault/${
  893. that.addDialogTitle === "新增" ? "insert" : "edit"
  894. }`,
  895. data: that.addDialogTitle === "新增" ? [data] : data,
  896. header: {
  897. "Content-Type": "application/json",
  898. },
  899. }).then((res) => {
  900. if (res.data.code === 200) {
  901. that.BASE.showMsg({
  902. type: "success",
  903. msg: `${that.addDialogTitle}成功`,
  904. });
  905. that.addDialogShow = false;
  906. that.resetForm();
  907. }
  908. });
  909. }
  910. });
  911. },
  912. edit(e, row) {
  913. const that = this;
  914. const editItem = that.sourceTableData[row.dataIndex];
  915. for (let key in that.addDialogForm) {
  916. if (key === "time") {
  917. that.addDialogForm[key] = [editItem.starttime, editItem.endtime];
  918. } else if (key === "faulttype") {
  919. that.addDialogForm[key] = editItem.faultcode;
  920. } else {
  921. that.addDialogForm[key] = editItem[key];
  922. }
  923. }
  924. that.addDialogForm.id = editItem.id;
  925. that.addDialogStationChange(editItem.stationen, editItem.windturbineid);
  926. that.addDialogTitle = "编辑";
  927. that.addDialogShow = true;
  928. },
  929. },
  930. created() {
  931. this.startAjax();
  932. },
  933. };
  934. </script>
  935. <style lang="less" scoped>
  936. .mb10 {
  937. margin-bottom: 10px;
  938. }
  939. .el-select.w {
  940. width: 100%;
  941. }
  942. // .el-range-editor.w{width: 100%;}
  943. </style>
  944. <style lang="less">
  945. .currentAddDialog {
  946. .el-form {
  947. display: flex;
  948. justify-content: start;
  949. align-items: center;
  950. flex-wrap: wrap;
  951. .inlineItem {
  952. width: 50%;
  953. display: flex;
  954. justify-content: start;
  955. align-items: center;
  956. .el-form-item {
  957. width: 100%;
  958. margin-bottom: 40px;
  959. .el-input__count {
  960. background: rgba(83, 98, 104, 0.2);
  961. color: #b3bdc0;
  962. }
  963. }
  964. }
  965. }
  966. }
  967. </style>