controlAllArea.vue 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762
  1. <template>
  2. <div class="problem" @contextmenu="contextmenu">
  3. <div class="body">
  4. <img class="logo" src="../../assets/img/logo.png" alt="">
  5. <div class="titleBar">
  6. <div class="title">设备区</div>
  7. <el-select @change="listedChange()" class="inputs" v-model="selectValue" placeholder="请选择">
  8. <el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value">
  9. </el-option>
  10. </el-select>
  11. </div>
  12. <div style="margin-top: 20px; margin-left: 35px; height:85%;">
  13. <el-scrollbar>
  14. <div class="scoll">
  15. <div class="matrix" v-if="showList.length>0">
  16. <!-- <div class="problemTitle">待启动</div> -->
  17. <MatrixBlock @choose-click="handleClick" @on-click="handleDetails" :dataList="showList">
  18. </MatrixBlock>
  19. </div>
  20. </div>
  21. </el-scrollbar>
  22. </div>
  23. </div>
  24. <WindturbineDetailPages v-model="dialogVisible" :showSvg="showSvg" @close="handleClose" :svgWeb="svgWeb"
  25. :windturbine="currentWindturbine"></WindturbineDetailPages>
  26. </div>
  27. </template>
  28. <script>
  29. import WindturbineDetailPages from "../WindturbineDetailPages.vue";
  30. import MatrixBlock from "../matrixBlock.vue";
  31. import BackgroundData from 'utils/BackgroundData'
  32. import MessageBridge from 'utils/MessageBridge'
  33. export default {
  34. name: "ProblemArea",
  35. components: {
  36. WindturbineDetailPages,
  37. MatrixBlock,
  38. },
  39. props: {
  40. current: {
  41. type: Number,
  42. },
  43. datas: {
  44. type: String,
  45. },
  46. },
  47. data() {
  48. return {
  49. dataList: [],
  50. showList: [],
  51. chooseList: [],
  52. totleList: [],
  53. currentWindturbine: {},
  54. dialogVisible: false,
  55. showSvg: false,
  56. svgWeb: '',
  57. windturbinelist: {},
  58. options: [
  59. {
  60. value: '0',
  61. label: '问题设备'
  62. },
  63. {
  64. value: '1',
  65. label: '故障'
  66. },
  67. {
  68. value: '2',
  69. label: '维护'
  70. },
  71. {
  72. value: '3',
  73. label: '离线'
  74. },
  75. {
  76. value: '4',
  77. label: '挂牌'
  78. },
  79. {
  80. value: '5',
  81. label: '麻黄山'
  82. },
  83. {
  84. value: '6',
  85. label: '牛首山'
  86. },
  87. {
  88. value: '7',
  89. label: '青山'
  90. },
  91. {
  92. value: '8',
  93. label: '石板泉'
  94. },
  95. {
  96. value: '9',
  97. label: '香山'
  98. },
  99. ],
  100. selectValue: '0',
  101. controlErorCodes: [
  102. "控制成功",
  103. "控制命令发送失败",
  104. "无效的控制地址",
  105. "被控设备异常",
  106. "无效的控制功能",
  107. "网络连接错误,检查场站通信",
  108. "控制结果读取超时",
  109. "未知错误",
  110. "控制命令错误",
  111. "收到无法识别数据",
  112. "未读取到数据包",
  113. "未知错误",
  114. "风机操作过频繁",
  115. "风机被挂牌",
  116. "风机操作与风机状态不符",
  117. "需要登录",
  118. ],
  119. };
  120. },
  121. computed: {},
  122. created: function () {
  123. this.initData();
  124. this.controls()
  125. console.log(this.datas);
  126. },
  127. methods: {
  128. controls() {
  129. let json = this.$store.state.windturbinelist
  130. this.dataList = []
  131. this.showList = []
  132. let arr = Object.keys(json).sort()
  133. for (var id of arr) {
  134. var val = json[id];
  135. this.chooseList.forEach(item => {
  136. if (item.windturbineId === val.windturbineId) {
  137. val.active = true
  138. }
  139. })
  140. this.dataList.push(val)
  141. switch (Number(this.selectValue)) {
  142. case 0:
  143. if (val.status === 5 || val.status === 6 || val.status === 7 || val.lockValue > 0) {
  144. this.showList.push(val)
  145. }
  146. break;
  147. case 1:
  148. val.status === 5 ? this.showList.push(val) : ''
  149. break;
  150. case 2:
  151. val.status === 6 ? this.showList.push(val) : ''
  152. break;
  153. case 3:
  154. val.status === 7 ? this.showList.push(val) : ''
  155. break;
  156. case 4:
  157. val.lockValue > 0 ? this.showList.push(val) : ''
  158. break;
  159. case 5:
  160. val.windturbineId.substring(0, 2) === 'MG' ? this.showList.push(val) : ''
  161. break;
  162. case 6:
  163. val.windturbineId.substring(0, 2) === 'NG' ? this.showList.push(val) : ''
  164. break;
  165. case 7:
  166. val.windturbineId.substring(0, 2) === 'QG' ? this.showList.push(val) : ''
  167. break;
  168. case 8:
  169. val.windturbineId.substring(0, 2) === 'SG' ? this.showList.push(val) : ''
  170. break;
  171. case 9:
  172. val.windturbineId.substring(0, 2) === 'XG' ? this.showList.push(val) : ''
  173. break;
  174. }
  175. // if (val.lockValue > 0) {
  176. // this.listedList.push(val)
  177. // }
  178. }
  179. console.log(this.showList);
  180. let checkoutList = BackgroundData.getInstance().checkouts;
  181. checkoutList.forEach(item => {
  182. let showIndex = null
  183. this.showList.forEach((param, index) => {
  184. if (item.windturbineId === param.windturbineId) {
  185. showIndex = index
  186. }
  187. })
  188. this.showList.splice(showIndex, 1);
  189. })
  190. console.log(this.showList);
  191. },
  192. initData: function () {
  193. var mb = MessageBridge.getInstance();
  194. var vss = [{ key: "/topic/voice-control", action: this.windturbineMessage }];
  195. mb.register(vss);
  196. },
  197. windturbineMessage(msg) {
  198. if (this.$store.state.current === 2) {
  199. let arr = []
  200. if (msg === 'CLOSE') {
  201. arr.push(msg)
  202. } else {
  203. arr = msg.split('-')
  204. }
  205. this.dialogVisible = false
  206. this.showSvg = false
  207. this.svgWeb = ''
  208. console.log(arr);
  209. if (arr[0] === 'OPEN_FJ') {
  210. this.currentWindturbine = this.windturbinelist[arr[1]]
  211. this.dialogVisible = true;
  212. } else if (arr[0] === 'CLOSE') {
  213. this.dialogVisible = false
  214. } else if (arr[0] === 'OPEN_SYZ') {
  215. this.showSvg = true
  216. this.dialogVisible = true
  217. this.svgWeb = arr[1];
  218. } else if (arr[0] === 'CONTROL_START' || arr[0] === 'CONTROL_STOP' || arr[0] === 'CONTROL_MAINTAIN') {
  219. let windControlList = [];
  220. let mss = {}
  221. arr.forEach(item => {
  222. if (item === (this.windturbinelist[item] ? this.windturbinelist[item].windturbineId : '')) {
  223. switch (arr[0]) {
  224. case 'CONTROL_START':
  225. this.windturbinelist[item].controlType = '1'
  226. break
  227. case 'CONTROL_STOP':
  228. this.windturbinelist[item].controlType = '2'
  229. break
  230. case 'CONTROL_MAINTAIN':
  231. this.windturbinelist[item].controlType = '6'
  232. break
  233. case 'CONTROL_UNMAINTAIN':
  234. this.windturbinelist[item].controlType = '8'
  235. break
  236. }
  237. windControlList.push(this.windturbinelist[item])
  238. }
  239. })
  240. mss.type = 'send'
  241. this.menuClicked(mss, windControlList, 'automatic')
  242. }
  243. else if (arr[0] === 'CONTROL_LOCK_OVERHAUL' || arr[0] === 'CONTROL_LOCK_MAINTAIN' || arr[0] === 'CONTROL_LOCK_LNVOLVED_OVERHAUL' ||
  244. arr[0] === 'CONTROL_LOCK_LNVOLVED_MAINTAIN' || arr[0] === 'CONTROL_LOCK_LNVOLVED_PG' || arr[0] === 'CONTROL_LOCK_LNVOLVED_WEATHER' || arr[0] === 'CONTROL_UNLOCK') {
  245. let windturbine = this.windturbinelist[arr[1]]
  246. switch (arr[0]) {
  247. case 'CONTROL_LOCK_OVERHAUL':
  248. this.menuClicked({ type: "lock", value: "CheckLock" }, windturbine);
  249. break;
  250. case 'CONTROL_LOCK_MAINTAIN':
  251. this.menuClicked({ type: "lock", value: "FaultLock" }, windturbine);
  252. break;
  253. case 'CONTROL_LOCK_LNVOLVED_OVERHAUL':
  254. this.menuClicked({ type: "lock", value: "StationCheckLock" }, windturbine);
  255. break;
  256. case 'CONTROL_LOCK_LNVOLVED_MAINTAIN':
  257. this.menuClicked({ type: "lock", value: "StationFaulLock" }, windturbine);
  258. break;
  259. case 'CONTROL_LOCK_LNVOLVED_PG':
  260. this.menuClicked({ type: "lock", value: "StationPowerLineLock" }, windturbine);
  261. break;
  262. case 'CONTROL_LOCK_LNVOLVED_WEATHER':
  263. this.menuClicked({ type: "lock", value: "StationWeatherLock" }, windturbine);
  264. break;
  265. case 'CONTROL_UNLOCK':
  266. this.menuClicked({ type: "lock", value: "UnLock" }, windturbine);
  267. break;
  268. }
  269. }
  270. }
  271. },
  272. /* 右键菜单 */
  273. contextmenu() {
  274. const remote = require('electron').remote;
  275. var that = this;
  276. let menuTemplate = []
  277. if (this.selectValue === '0' || this.selectValue === '1' || this.selectValue === '2' || this.selectValue === '3' || this.selectValue === '4') {
  278. menuTemplate = [
  279. // {
  280. // label: "标注",
  281. // click() {
  282. // that.menuClicked({ type: "marking" });
  283. // },
  284. // },
  285. {
  286. label: "挂牌",
  287. submenu: [
  288. {
  289. label: "检修",
  290. click() {
  291. that.menuClicked({ type: "lock", value: "CheckLock" });
  292. },
  293. },
  294. {
  295. label: "故障维修",
  296. click() {
  297. that.menuClicked({ type: "lock", value: "FaultLock" });
  298. },
  299. },
  300. {
  301. label: "场内受累检修",
  302. click() {
  303. that.menuClicked({ type: "lock", value: "StationCheckLock" });
  304. },
  305. },
  306. {
  307. label: "场内受累故障",
  308. click() {
  309. that.menuClicked({ type: "lock", value: "StationFaulLock" });
  310. },
  311. },
  312. {
  313. label: "场外受累电网",
  314. click() {
  315. that.menuClicked({ type: "lock", value: "StationPowerLineLock" });
  316. },
  317. },
  318. {
  319. label: "场外受累天气",
  320. click() {
  321. that.menuClicked({ type: "lock", value: "StationWeatherLock" });
  322. },
  323. },
  324. ],
  325. },
  326. {
  327. label: "取消挂牌",
  328. click() {
  329. that.menuClicked({ type: "lock", value: "UnLock" });
  330. },
  331. },
  332. ];
  333. } else {
  334. menuTemplate = [
  335. {
  336. label: "启动",
  337. click() {
  338. that.menuClicked({ type: "send", controlType: '1' });
  339. },
  340. },
  341. {
  342. label: "停机",
  343. click() {
  344. that.menuClicked({ type: "send", controlType: '2' });
  345. },
  346. },
  347. {
  348. label: "复位",
  349. click() {
  350. that.menuClicked({ type: "send", controlType: '5' });
  351. },
  352. },
  353. {
  354. label: "维护",
  355. click() {
  356. that.menuClicked({ type: "send", controlType: '6' });
  357. },
  358. },
  359. {
  360. label: "取消维护",
  361. click() {
  362. that.menuClicked({ type: "send", controlType: '8' });
  363. },
  364. },
  365. {
  366. label: "挂牌",
  367. submenu: [
  368. {
  369. label: "检修",
  370. click() {
  371. that.menuClicked({ type: "lock", value: "CheckLock" });
  372. },
  373. },
  374. {
  375. label: "故障维修",
  376. click() {
  377. that.menuClicked({ type: "lock", value: "FaultLock" });
  378. },
  379. },
  380. {
  381. label: "场内受累检修",
  382. click() {
  383. that.menuClicked({ type: "lock", value: "StationCheckLock" });
  384. },
  385. },
  386. {
  387. label: "场内受累故障",
  388. click() {
  389. that.menuClicked({ type: "lock", value: "StationFaulLock" });
  390. },
  391. },
  392. {
  393. label: "场外受累电网",
  394. click() {
  395. that.menuClicked({
  396. type: "lock",
  397. value: "StationPowerLineLock",
  398. });
  399. },
  400. },
  401. {
  402. label: "场外受累天气",
  403. click() {
  404. that.menuClicked({ type: "lock", value: "StationWeatherLock" });
  405. },
  406. },
  407. ],
  408. },
  409. {
  410. label: "取消挂牌",
  411. click() {
  412. that.menuClicked({ type: 'lock', value: 'UnLock' });
  413. },
  414. },
  415. // {
  416. // label: "标注",
  417. // click() {
  418. // that.menuClicked({ type: "marking" });
  419. // },
  420. // },
  421. ];
  422. }
  423. const menu = remote.Menu.buildFromTemplate(menuTemplate);
  424. menu.popup(remote.getCurrentWindow());
  425. },
  426. menuClicked(msg, windturbine, automatic) {
  427. var bd = BackgroundData.getInstance();
  428. if (!bd.LoginUser) {
  429. this.$notify({
  430. title: "请登录",
  431. message: "控制风机需要先登录!",
  432. type: "warning",
  433. position: "bottom-right",
  434. offset: 60,
  435. duration: 3000,
  436. });
  437. return;
  438. }
  439. if (msg.type == "lock") {
  440. // 挂牌
  441. let sendList = []
  442. // 挂牌
  443. if (windturbine) {
  444. windturbine.lockType = msg.value;
  445. sendList.push(windturbine)
  446. } else {
  447. this.chooseList.forEach(item => {
  448. item.lockType = msg.value;
  449. })
  450. sendList = this.chooseList
  451. }
  452. if (sendList.length > 0) {
  453. bd.windturbineControl(
  454. sendList,
  455. true,
  456. '',
  457. '',
  458. this.controlSuccess,
  459. this.controlError
  460. );
  461. }
  462. } else if (msg.type == "send") {
  463. // 发送
  464. let sendList = []
  465. if (automatic) {
  466. sendList = windturbine
  467. }
  468. else if (windturbine) {
  469. windturbine.controlType = msg.controlType
  470. sendList.push(windturbine)
  471. } else {
  472. this.chooseList.forEach(item => {
  473. item.controlType = Number(msg.controlType)
  474. })
  475. sendList = this.chooseList
  476. }
  477. if (sendList.length > 0) {
  478. bd.checkout(sendList);
  479. if (automatic) {
  480. bd.windturbineControl(
  481. sendList,
  482. false,
  483. 'automatic',
  484. '',
  485. this.controlSuccess,
  486. this.controlError
  487. );
  488. } else {
  489. bd.windturbineControl(
  490. sendList,
  491. false,
  492. '',
  493. '',
  494. this.controlSuccess,
  495. this.controlError
  496. );
  497. }
  498. }
  499. } else if (msg.type == "marking") {
  500. // 标注
  501. bd.marking(this.chooseList);
  502. }
  503. this.clearSelected();
  504. },
  505. /* 清除所有选择 */
  506. clearSelected() {
  507. this.chooseList = []
  508. },
  509. /* 控制成功 */
  510. controlSuccess(msg) {
  511. console.log(msg);
  512. var mss = ''; // 信息
  513. var iserror = false;// 是否有控制错误的风机
  514. for (var v in msg.data) {
  515. var val = msg.data[v];
  516. if (val.errorCode > 0) {
  517. iserror = true;
  518. mss += `${val.windturbineId} ${this.controlErorCodes[val.errorCode]}\n`;
  519. }
  520. }
  521. var tp = iserror ? "warning" : "success";
  522. var dt = iserror ? 0 : 4500;
  523. if (!iserror) {
  524. mss = "控制成功";
  525. }
  526. this.$notify({
  527. title: "控制",
  528. message: mss,
  529. type: tp,
  530. position: "bottom-right",
  531. offset: 60,
  532. duration: 3000,
  533. });
  534. },
  535. /* 控制失败 */
  536. controlError(err) {
  537. this.$notify({
  538. title: "控制出现错误",
  539. message: err.message,
  540. type: "warning",
  541. position: "bottom-right",
  542. offset: 60,
  543. duration: 3000,
  544. });
  545. },
  546. handleClick(values) {
  547. if (values.active) {
  548. let showIndex = null
  549. this.chooseList.forEach((item, index) => {
  550. if (item.windturbineId === values.windturbineId) {
  551. showIndex = index
  552. }
  553. })
  554. this.chooseList.splice(showIndex, 1);
  555. } else {
  556. this.chooseList.push(values)
  557. }
  558. this.showList.forEach(item => { if (item.windturbineId === values.windturbineId) { item.active = !item.active } })
  559. },
  560. listedChange() {
  561. this.chooseList = []
  562. this.showList = []
  563. this.dataList.forEach(val => {
  564. val.active = false
  565. switch (Number(this.selectValue)) {
  566. case 0:
  567. if (val.status === 5 || val.status === 6 || val.status === 7 || val.lockValue > 0) {
  568. this.showList.push(val)
  569. }
  570. break;
  571. case 1:
  572. val.status === 5 ? this.showList.push(val) : ''
  573. break;
  574. case 2:
  575. val.status === 6 ? this.showList.push(val) : ''
  576. break;
  577. case 3:
  578. val.status === 7 ? this.showList.push(val) : ''
  579. break;
  580. case 4:
  581. val.lockValue > 0 ? this.showList.push(val) : ''
  582. break;
  583. case 5:
  584. val.windturbineId.substring(0, 2) === 'MG' ? this.showList.push(val) : ''
  585. break;
  586. case 6:
  587. val.windturbineId.substring(0, 2) === 'NG' ? this.showList.push(val) : ''
  588. break;
  589. case 7:
  590. val.windturbineId.substring(0, 2) === 'QG' ? this.showList.push(val) : ''
  591. break;
  592. case 8:
  593. val.windturbineId.substring(0, 2) === 'SG' ? this.showList.push(val) : ''
  594. break;
  595. case 9:
  596. val.windturbineId.substring(0, 2) === 'XG' ? this.showList.push(val) : ''
  597. break;
  598. }
  599. })
  600. },
  601. handleDetails(itm) {
  602. this.dialogVisible = true;
  603. this.currentWindturbine = itm;
  604. },
  605. handleClose() {
  606. this.dialogVisible = false
  607. this.showSvg = false
  608. },
  609. },
  610. watch: {
  611. "$store.getters.windturbinelist": {
  612. deep: true,
  613. handler: function (json) {
  614. this.windturbinelist = json
  615. this.dataList = []
  616. this.showList = []
  617. let arr = Object.keys(json).sort()
  618. for (var id of arr) {
  619. var val = json[id];
  620. this.chooseList.forEach(item => {
  621. if (item.windturbineId === val.windturbineId) {
  622. val.active = true
  623. }
  624. })
  625. this.dataList.push(val)
  626. switch (Number(this.selectValue)) {
  627. case 0:
  628. if (val.status === 5 || val.status === 6 || val.status === 7 || val.lockValue > 0) {
  629. this.showList.push(val)
  630. }
  631. break;
  632. case 1:
  633. val.status === 5 ? this.showList.push(val) : ''
  634. break;
  635. case 2:
  636. val.status === 6 ? this.showList.push(val) : ''
  637. break;
  638. case 3:
  639. val.status === 7 ? this.showList.push(val) : ''
  640. break;
  641. case 4:
  642. val.lockValue > 0 ? this.showList.push(val) : ''
  643. break;
  644. case 5:
  645. val.windturbineId.substring(0, 2) === 'MG' ? this.showList.push(val) : ''
  646. break;
  647. case 6:
  648. val.windturbineId.substring(0, 2) === 'NG' ? this.showList.push(val) : ''
  649. break;
  650. case 7:
  651. val.windturbineId.substring(0, 2) === 'QG' ? this.showList.push(val) : ''
  652. break;
  653. case 8:
  654. val.windturbineId.substring(0, 2) === 'SG' ? this.showList.push(val) : ''
  655. break;
  656. case 9:
  657. val.windturbineId.substring(0, 2) === 'XG' ? this.showList.push(val) : ''
  658. break;
  659. }
  660. // if (val.lockValue > 0) {
  661. // this.listedList.push(val)
  662. // }
  663. }
  664. console.log(this.showList);
  665. let checkoutList = BackgroundData.getInstance().checkouts;
  666. checkoutList.forEach(item => {
  667. let showIndex = null
  668. this.showList.forEach((param, index) => {
  669. if (item.windturbineId === param.windturbineId) {
  670. showIndex = index
  671. }
  672. })
  673. this.showList.splice(showIndex, 1);
  674. })
  675. console.log(this.showList);
  676. },
  677. },
  678. },
  679. };
  680. </script>
  681. <style scoped>
  682. .problem {
  683. height: 100%;
  684. }
  685. .body {
  686. border: 1px solid #373737;
  687. width: 100%;
  688. margin-left: 15px;
  689. margin-top: 10px;
  690. height: 61vh;
  691. }
  692. .body .scoll {
  693. height: 91%;
  694. }
  695. .titleBar {
  696. display: flex;
  697. flex-direction: row;
  698. align-items: center;
  699. }
  700. .title {
  701. color: #ffffff;
  702. font-size: 14px;
  703. margin-left: 32px;
  704. /* margin-top: 12px; */
  705. margin-bottom: 10px;
  706. /* width: 570px; */
  707. width: 29vw;
  708. height: 50px;
  709. display: flex;
  710. align-items: center;
  711. position: absolute;
  712. background-color: #000000;
  713. }
  714. .title::before {
  715. z-index: 1;
  716. content: '';
  717. position: absolute;
  718. left: -18px !important;
  719. /* top: 30px !important; */
  720. width: 5px;
  721. height: 5px;
  722. background-color: #54B75A;
  723. border-radius: 50%;
  724. }
  725. .inputs {
  726. border: none;
  727. width: 174px !important;
  728. margin-left: 110px;
  729. }
  730. .el-input__inner {
  731. background-color: rgb(100, 100, 100) !important;
  732. color: rgb(220, 220, 220) !important;
  733. border: 1px solid red !important;
  734. }
  735. .logo {
  736. position: absolute;
  737. top: 2px;
  738. left: 12px;
  739. }
  740. </style>