areaCard.vue 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598
  1. /* 自定义tabs */
  2. <template>
  3. <div class="body" :style="style">
  4. <img class="logo" src="../../assets/img/logo.png" alt="">
  5. <div class="title">{{ title }}</div>
  6. <div style="margin-top: 50px; height:85%;" @contextmenu="contextmenu">
  7. <el-scrollbar>
  8. <div class="scoll">
  9. <div class="matrix" v-if="startList.length>0">
  10. <div class="problemTitle">启动</div>
  11. <MatrixBlock @on-click="handleDetial" @choose-click="handleClick" :dataList="startList">
  12. </MatrixBlock>
  13. </div>
  14. <div class="matrix" v-if="stopList.length>0">
  15. <div class="problemTitle">停机</div>
  16. <MatrixBlock @on-click="handleDetial" @choose-click="handleClick" :dataList="stopList">
  17. </MatrixBlock>
  18. </div>
  19. </div>
  20. </el-scrollbar>
  21. </div>
  22. <div v-if="current===1" class="send" @click="handleSend">发送</div>
  23. <div class="success" v-if="showFlag&&current===0">指令发送成功</div>
  24. </div>
  25. <WindturbineDetailPages v-model="dialogVisible" :showSvg="showSvg" @close="handleClose" :svgWeb="svgWeb" :stationName="stationName"
  26. :windturbine="currentWindturbine"></WindturbineDetailPages>
  27. </template>
  28. <script>
  29. import BackgroundData from 'utils/BackgroundData'
  30. import WindturbineDetailPages from "../WindturbineDetailPages.vue";
  31. import MatrixBlock from "../matrixBlock.vue";
  32. import MessageBridge from 'utils/MessageBridge'
  33. export default {
  34. name: 'gy-card',
  35. components: {
  36. MatrixBlock,
  37. WindturbineDetailPages
  38. },
  39. created: function () {
  40. console.log(this.current);
  41. this.initData();
  42. },
  43. emits: ["parentRun"],
  44. props: {
  45. title: {
  46. type: String,
  47. default: '',
  48. required: true,
  49. },
  50. height: {
  51. type: Number,
  52. default: 200,
  53. },
  54. current: {
  55. type: Number,
  56. },
  57. },
  58. data() {
  59. return {
  60. windturbinelist: {},
  61. titleList: [],
  62. startList: [],
  63. stopList: [],
  64. chooseList: [],
  65. sendList: [],
  66. currentWindturbine: {},
  67. dialogVisible: false,
  68. showSvg: false,
  69. showFlag: false,
  70. svgWeb: '',
  71. stationName: '',
  72. // 定时器
  73. timer: "",
  74. controlErorCodes: [
  75. "控制成功",
  76. "控制命令发送失败",
  77. "无效的控制地址",
  78. "被控设备异常",
  79. "无效的控制功能",
  80. "网络连接错误,检查场站通信",
  81. "控制结果读取超时",
  82. "未知错误",
  83. "控制命令错误",
  84. "收到无法识别数据",
  85. "未读取到数据包",
  86. "未知错误",
  87. "风机操作过频繁",
  88. "风机被挂牌",
  89. "风机操作与风机状态不符",
  90. "需要登录",
  91. ],
  92. boosterStation:{
  93. 'MHS_SYZ':{
  94. name:'麻黄山升压站'
  95. },
  96. 'NSS_SYZ':{
  97. name:'牛首山升压站'
  98. },
  99. 'QS_SYZ':{
  100. name:'青山升压站'
  101. },
  102. 'QS3_SYZ':{
  103. name:'青山三期升压站'
  104. },
  105. 'SBQ_SYZ':{
  106. name:'石板泉升压站'
  107. },
  108. 'XS_SYZ':{
  109. name:'香山升压站'
  110. },
  111. 'DWK_SYZ':{
  112. name:'大武口升压站'
  113. },
  114. 'PL_SYZ':{
  115. name:'平罗升压站'
  116. },
  117. 'PL2_SYZ':{
  118. name:'平罗二期升压站'
  119. },
  120. 'XH_SYZ':{
  121. name:'宣和升压站'
  122. },
  123. 'MCH_SYZ':{
  124. name:'马场湖升压站'
  125. },
  126. 'HZJ_SYZ':{
  127. name:'海子井升压站'
  128. },
  129. }
  130. }
  131. },
  132. computed: {
  133. style() {
  134. return `width: 100%; height: ${this.height}vh;`
  135. },
  136. },
  137. methods: {
  138. initData: function () {
  139. var mb = MessageBridge.getInstance();
  140. var vs = [{ key: "/topic/suggestion", action: this.suggestion }];
  141. var vss = [{ key: "/topic/voice-control", action: this.windturbineMessage }];
  142. mb.register(vs);
  143. mb.register(vss);
  144. },
  145. suggestion(msg, headers) {
  146. this.titleList = JSON.parse(msg)
  147. if (this.current === 0) {
  148. let dateList = []
  149. this.titleList.forEach(item => {
  150. item.operateStyle === 'Start' ? this.windturbinelist[item.windturbineId].controlType = 1 : this.windturbinelist[item.windturbineId].controlType = 2
  151. dateList.push(this.windturbinelist[item.windturbineId])
  152. })
  153. let mss = {}
  154. mss.type = 'send'
  155. this.timer = setTimeout(() => {
  156. this.menuClicked(mss, dateList, 'automatic')
  157. this.showFlag = false
  158. clearInterval(this.timer);
  159. }, 3000);
  160. }
  161. },
  162. windturbineMessage(msg) {
  163. let arr = []
  164. if (msg === 'CLOSE') {
  165. arr.push(msg)
  166. } else {
  167. arr = msg.split('-')
  168. }
  169. this.dialogVisible = false
  170. this.showSvg = false
  171. this.svgWeb = ''
  172. console.log(arr);
  173. if (arr[0] === 'OPEN_FJ') {
  174. this.currentWindturbine = this.windturbinelist[arr[1]]
  175. this.dialogVisible = true;
  176. } else if (arr[0] === 'CLOSE') {
  177. this.dialogVisible = false
  178. } else if (arr[0] === 'OPEN_SYZ') {
  179. this.showSvg = true
  180. this.dialogVisible = true
  181. this.svgWeb = arr[1];
  182. this.stationName = this.boosterStation[arr[1]].name
  183. } else if (arr[0] === 'CONTROL_START' || arr[0] === 'CONTROL_STOP' || arr[0] === 'CONTROL_MAINTAIN') {
  184. let mss = {}
  185. let windturbine = this.windturbinelist[arr[1]]
  186. switch (arr[0]) {
  187. case 'CONTROL_START':
  188. mss.controlType = '1'
  189. break
  190. case 'CONTROL_STOP':
  191. mss.controlType = '2'
  192. break
  193. case 'CONTROL_MAINTAIN':
  194. mss.controlType = '6'
  195. break
  196. }
  197. mss.type = 'send'
  198. this.menuClicked(mss, windturbine)
  199. }
  200. // else if (arr[0] === 'CONTROL_LOCK_OVERHAUL' || arr[0] === 'CONTROL_LOCK_MAINTAIN' || arr[0] === 'CONTROL_LOCK_LNVOLVED_OVERHAUL' ||
  201. // arr[0] === 'CONTROL_LOCK_LNVOLVED_MAINTAIN' || arr[0] === 'CONTROL_LOCK_LNVOLVED_PG' || arr[0] === 'CONTROL_LOCK_LNVOLVED_WEATHER' || arr[0] === 'CONTROL_UNLOCK') {
  202. // let windturbine = this.windturbinelist[arr[1]]
  203. // switch (arr[0]) {
  204. // case 'CONTROL_LOCK_OVERHAUL':
  205. // this.menuClicked({ type: "lock", value: "CheckLock" }, windturbine);
  206. // break;
  207. // case 'CONTROL_LOCK_MAINTAIN':
  208. // this.menuClicked({ type: "lock", value: "FaultLock" }, windturbine);
  209. // break;
  210. // case 'CONTROL_LOCK_LNVOLVED_OVERHAUL':
  211. // this.menuClicked({ type: "lock", value: "StationCheckLock" }, windturbine);
  212. // break;
  213. // case 'CONTROL_LOCK_LNVOLVED_MAINTAIN':
  214. // this.menuClicked({ type: "lock", value: "StationFaulLock" }, windturbine);
  215. // break;
  216. // case 'CONTROL_LOCK_LNVOLVED_PG':
  217. // this.menuClicked({ type: "lock", value: "StationPowerLineLock" }, windturbine);
  218. // break;
  219. // case 'CONTROL_LOCK_LNVOLVED_WEATHER':
  220. // this.menuClicked({ type: "lock", value: "StationWeatherLock" }, windturbine);
  221. // break;
  222. // case 'CONTROL_UNLOCK':
  223. // this.menuClicked({ type: "lock", value: "UnLock" }, windturbine);
  224. // break;
  225. // }
  226. // }
  227. },
  228. handleClick(values) {
  229. if (values.active) {
  230. let showIndex = null
  231. this.chooseList.forEach((item, index) => {
  232. if (item.windturbineId === values.windturbineId) {
  233. showIndex = index
  234. }
  235. })
  236. this.chooseList.splice(showIndex, 1);
  237. } else {
  238. this.chooseList.push(values)
  239. }
  240. this.startList.forEach(item => { if (item.windturbineId === values.windturbineId) { item.active = !item.active } })
  241. this.stopList.forEach(item => { if (item.windturbineId === values.windturbineId) { item.active = !item.active } })
  242. },
  243. handleDetial(itm) {
  244. this.dialogVisible = true;
  245. this.currentWindturbine = itm;
  246. },
  247. handleClose() {
  248. this.dialogVisible = false
  249. this.showSvg = false
  250. },
  251. handleSend() {
  252. if (this.chooseList.length > 0) {
  253. this.menuClicked({ type: "send" });
  254. }
  255. },
  256. /* 右键菜单 */
  257. contextmenu() {
  258. const { remote } = require("electron");
  259. var that = this;
  260. const menuTemplate = [
  261. {
  262. label: "发送",
  263. click() {
  264. that.menuClicked({ type: "send" });
  265. },
  266. },
  267. {
  268. label: "挂牌",
  269. submenu: [
  270. {
  271. label: "检修",
  272. click() {
  273. that.menuClicked({ type: "lock", value: "CheckLock" });
  274. },
  275. },
  276. {
  277. label: "故障维修",
  278. click() {
  279. that.menuClicked({ type: "lock", value: "FaultLock" });
  280. },
  281. },
  282. {
  283. label: "场内受累检修",
  284. click() {
  285. that.menuClicked({ type: "lock", value: "StationCheckLock" });
  286. },
  287. },
  288. {
  289. label: "场内受累故障",
  290. click() {
  291. that.menuClicked({ type: "lock", value: "StationFaulLock" });
  292. },
  293. },
  294. {
  295. label: "场外受累电网",
  296. click() {
  297. that.menuClicked({
  298. type: "lock",
  299. value: "StationPowerLineLock",
  300. });
  301. },
  302. },
  303. {
  304. label: "场外受累天气",
  305. click() {
  306. that.menuClicked({ type: "lock", value: "StationWeatherLock" });
  307. },
  308. },
  309. ],
  310. },
  311. // {
  312. // label: "标注",
  313. // click() {
  314. // that.menuClicked({ type: "marking" });
  315. // },
  316. // },
  317. ];
  318. const menu = remote.Menu.buildFromTemplate(menuTemplate);
  319. menu.popup(remote.getCurrentWindow());
  320. },
  321. menuClicked(msg, windturbine, automatic) {
  322. var bd = BackgroundData.getInstance();
  323. if (!bd.LoginUser) {
  324. this.$notify({
  325. title: "请登录",
  326. message: "控制风机需要先登录!",
  327. type: "warning",
  328. position: "bottom-right",
  329. offset: 60,
  330. duration: 3000,
  331. });
  332. return;
  333. }
  334. if (msg.type == "lock") {
  335. // 挂牌
  336. this.chooseList.forEach(item => {
  337. item.lockType = msg.value;
  338. })
  339. bd.windturbineControl(
  340. this.chooseList,
  341. true,
  342. '',
  343. this.controlSuccess,
  344. this.controlError
  345. );
  346. } else if (msg.type == "send") {
  347. // 发送
  348. let sendList = []
  349. if (automatic) {
  350. sendList = windturbine
  351. }
  352. else if (windturbine) {
  353. windturbine.controlType = msg.controlType
  354. sendList.push(windturbine)
  355. } else {
  356. this.chooseList.forEach(item => {
  357. if (item.operateStyle === "Start") {
  358. item.controlType = 1
  359. } else if (item.operateStyle === "Stop") {
  360. item.controlType = 2
  361. }
  362. })
  363. sendList = this.chooseList
  364. }
  365. this.showFlag = true
  366. bd.checkout(sendList);
  367. if(automatic){
  368. bd.windturbineControl(
  369. sendList,
  370. false,
  371. 'automatic',
  372. this.controlSuccess,
  373. this.controlError
  374. );
  375. }else{
  376. bd.windturbineControl(
  377. sendList,
  378. false,
  379. '',
  380. this.controlSuccess,
  381. this.controlError
  382. );
  383. }
  384. } else if (msg.type == "marking") {
  385. // 标注
  386. var vvs = this.getSelectedItems();
  387. bd.marking(vvs);
  388. }
  389. this.clearSelected();
  390. },
  391. clearSelected() {
  392. this.startList.forEach(item => {
  393. item.active = false
  394. })
  395. this.stopList.forEach(item => {
  396. item.active = false
  397. })
  398. this.chooseList = []
  399. },
  400. /* 控制成功 */
  401. controlSuccess(msg) {
  402. var bd = BackgroundData.getInstance();
  403. console.log(msg);
  404. if (msg.data|| msg.data !== {}) {
  405. var mss = ''; // 信息
  406. var iserror = false;// 是否有控制错误的风机
  407. for (var v in msg.data) {
  408. var val = msg.data[v];
  409. if (val.errorCode > 0) {
  410. iserror = true;
  411. mss += `${val.windturbineId} ${this.controlErorCodes[val.errorCode]}\n`;
  412. }
  413. }
  414. var tp = iserror ? "warning" : "success";
  415. var dt = iserror ? 0 : 4500;
  416. if (!iserror) {
  417. mss = "控制成功";
  418. }
  419. this.$notify({
  420. title: "控制",
  421. message: mss,
  422. type: tp,
  423. position: "bottom-right",
  424. offset: 60,
  425. duration: 3000,
  426. });
  427. } else {
  428. this.$notify({
  429. title: "控制出现错误",
  430. message: '控制失败,请重试',
  431. type: "warning",
  432. position: "bottom-right",
  433. offset: 60,
  434. duration: 3000,
  435. });
  436. }
  437. },
  438. /* 控制失败 */
  439. controlError(err) {
  440. this.$notify({
  441. title: "控制出现错误",
  442. message: err.message,
  443. type: "warning",
  444. position: "bottom-right",
  445. offset: 60,
  446. duration: 3000,
  447. });
  448. },
  449. },
  450. watch: {
  451. "$store.getters.windturbinelist": {
  452. deep: true,
  453. handler: function (json) {
  454. this.windturbinelist = json
  455. let arr = Object.keys(json).sort()
  456. this.stopList = []
  457. this.startList = []
  458. for (var id of arr) {
  459. var val = json[id];
  460. this.chooseList.forEach(item => {
  461. if (item.windturbineId === val.windturbineId) {
  462. val.active = true
  463. }
  464. })
  465. this.titleList.forEach(item => {
  466. if (item.windturbineId === val.windturbineId) {
  467. val.operateStyle = item.operateStyle
  468. if(item.operateStyle === "Start" &&item.status === 2 ){
  469. this.startList.push(val)
  470. }else if(item.operateStyle === "Stop" &&item.status === 4 ){
  471. this.stopList.push(val)
  472. }
  473. }
  474. })
  475. }
  476. let checkoutList = BackgroundData.getInstance().checkouts;
  477. checkoutList.forEach(item => {
  478. let showIndex = null
  479. let starFlag = false
  480. let stopFlag = false
  481. this.startList.forEach((param, index) => {
  482. if (item.windturbineId === param.windturbineId) {
  483. showIndex = index
  484. starFlag = true
  485. }
  486. })
  487. this.stopList.forEach((param, index) => {
  488. if (item.windturbineId === param.windturbineId) {
  489. showIndex = index
  490. stopFlag = true
  491. }
  492. })
  493. starFlag ? this.startList.splice(showIndex, 1) : '';
  494. stopFlag ? this.stopList.splice(showIndex, 1) : '';
  495. })
  496. },
  497. },
  498. },
  499. }
  500. </script>
  501. <style scoped="scoped">
  502. .body {
  503. border: 1px solid #373737;
  504. width: 100%;
  505. margin-left: 15px;
  506. margin-top: 20px;
  507. }
  508. .body .scoll {
  509. height: 91%;
  510. }
  511. .title {
  512. color: #ffffff;
  513. font-size: 14px;
  514. margin-left: 32px;
  515. /* margin-top: 12px; */
  516. margin-bottom: 10px;
  517. /* width: 570px; */
  518. width: 29vw;
  519. height: 50px;
  520. display: flex;
  521. align-items: center;
  522. position: absolute;
  523. background-color: #000000;
  524. }
  525. .title::before {
  526. z-index: 1;
  527. content: '';
  528. position: absolute;
  529. left: -18px !important;
  530. /* top: 30px !important; */
  531. width: 5px;
  532. height: 5px;
  533. background-color: #54B75A;
  534. border-radius: 50%;
  535. }
  536. .logo {
  537. position: absolute;
  538. top: 12px;
  539. left: 12px;
  540. }
  541. .matrix {
  542. margin-left: 32px;
  543. margin-right: 10px;
  544. padding-bottom: 20px;
  545. border-bottom: 1px solid rgba(31, 31, 31, 1);
  546. }
  547. .problemTitle {
  548. font-size: 12px;
  549. color: #BFBFBF;
  550. margin-top: 20px;
  551. margin-bottom: 20px;
  552. }
  553. .send {
  554. width: 86px;
  555. height: 26px;
  556. display: flex;
  557. align-items: center;
  558. justify-content: center;
  559. background-color: rgba(84, 183, 90, 1);
  560. color: #ffffff;
  561. font-size: 14px;
  562. position: absolute;
  563. bottom: 20px;
  564. right: 10px;
  565. }
  566. .success {
  567. display: flex;
  568. align-items: center;
  569. justify-content: center;
  570. width: 250px;
  571. height: 48px;
  572. position: absolute;
  573. bottom: 20px;
  574. right: 20%;
  575. border: 1px solid rgba(55, 55, 55, 1);
  576. border-radius: 10px;
  577. color: #ffffff;
  578. font-size: 14px;
  579. }
  580. </style>