ControlArea.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. /* 控制区 */
  2. <template>
  3. <gy-card
  4. title="控制区"
  5. area-style="control"
  6. circle-style="green"
  7. content-style="44"
  8. @contextmenu="contextmenu"
  9. >
  10. <ControlMatrixCard title="待启动" :datas="ls.start" ref="start"></ControlMatrixCard>
  11. <ControlMatrixCard title="待停机" :datas="ls.stop" ref="stop"></ControlMatrixCard>
  12. <ControlMatrixCard title="待维护" :datas="ls.maintain" ref="maintain"></ControlMatrixCard>
  13. <ControlMatrixCard title="待取消维护" :datas="ls.unmaintain" ref="unmaintain"></ControlMatrixCard>
  14. <ControlMatrixCard title="待复位" :datas="ls.reset" ref="reset"></ControlMatrixCard>
  15. <el-button style="z-index:2;position:absolute;bottom:10px;right:10px;background: #292929;font-size:15px;width:90px;border:none;color:rgb(220,220,220);" size="small" @click="menuClicked({type:'marking'})">发送</el-button>
  16. </gy-card>
  17. <el-button-group style="z-index:3;position:absolute;top:16px;left:120px;">
  18. <el-button style="background: black;font-size:14px;width:80px;border:none;color:rgb(220,220,220);" size="mini" round>自动</el-button>
  19. <el-button style="background: #202020;font-size:14px;width:80px;border:none;color:rgb(220,220,220);" size="mini" round>手动</el-button>
  20. </el-button-group>
  21. </template>
  22. <script>
  23. import ControlMatrixCard from "./windturbine/control/ControlMatrixCard.vue";
  24. import MessageBridge from "../../assets/script/MessageBridge";
  25. import BackgroundData from "../../assets/script/BackgroundData";
  26. export default {
  27. name: "ControlArea",
  28. components: {
  29. ControlMatrixCard,
  30. },
  31. created: function () {
  32. this.initData();
  33. },
  34. data() {
  35. return {
  36. ls: {
  37. start: { key: "待启动", value: [] },
  38. stop: { key: "待停机", value: [] },
  39. maintain: { key: "待维护", value: [] },
  40. unmaintain: { key: "待取消维护", value: [] },
  41. reset: { key: "待复位", value: [] },
  42. },
  43. };
  44. },
  45. methods: {
  46. initData: function () {
  47. var mb = MessageBridge.getInstance();
  48. var vs = [
  49. { key: "/topic/suggestion", action: this.suggestion },
  50. ];
  51. mb.register(vs);
  52. },
  53. suggestion(msg) {
  54. var val = JSON.parse(msg);
  55. for (var vv in val) {
  56. var v = val[vv];
  57. var windturbineId = v.windturbineId;
  58. if (v.adviceOperateStyle == "UnMaintain") {
  59. if (!this.ls.unmaintain.value.includes(windturbineId)) {
  60. this.ls.unmaintain.value.push(windturbineId);
  61. }
  62. } else if (v.adviceOperateStyle == "Start") {
  63. //推荐启动
  64. if (!this.ls.start.value.includes(windturbineId)) {
  65. this.ls.start.value.push(windturbineId);
  66. }
  67. } else if (v.adviceOperateStyle == "Stop") {
  68. // 推荐停机
  69. if (!this.ls.stop.value.includes(windturbineId)) {
  70. this.ls.stop.value.push(windturbineId);
  71. }
  72. } else if (v.adviceOperateStyle == "Reset") {
  73. // 推荐复位
  74. if (!this.ls.reset.value.includes(windturbineId)) {
  75. this.ls.reset.value.push(windturbineId);
  76. }
  77. } else if (v.adviceOperateStyle == "Maintain") {
  78. // 推荐维护
  79. if (!this.ls.maintain.value.includes(windturbineId)) {
  80. this.ls.maintain.value.push(windturbineId);
  81. }
  82. }
  83. }
  84. },
  85. /* 右键菜单 */
  86. contextmenu() {
  87. const { remote } = require("electron");
  88. var that = this;
  89. const menuTemplate = [
  90. {
  91. label: "发送",
  92. click() {
  93. that.menuClicked({ type: "send" });
  94. },
  95. },
  96. {
  97. label: "挂牌",
  98. submenu: [
  99. {
  100. label: "检修",
  101. click() {
  102. that.menuClicked({ type: "lock", value: 8 });
  103. },
  104. },
  105. {
  106. label: "故障维修",
  107. click() {
  108. that.menuClicked({ type: "lock", value: 7 });
  109. },
  110. },
  111. {
  112. label: "场内受累检修",
  113. click() {
  114. that.menuClicked({ type: "lock", value: 2 });
  115. },
  116. },
  117. {
  118. label: "场内受累故障",
  119. click() {
  120. that.menuClicked({ type: "lock", value: 3 });
  121. },
  122. },
  123. {
  124. label: "场外受累电网",
  125. click() {
  126. that.menuClicked({ type: "lock", value: 4 });
  127. },
  128. },
  129. {
  130. label: "场外受累天气",
  131. click() {
  132. that.menuClicked({ type: "lock", value: 5 });
  133. },
  134. },
  135. ],
  136. },
  137. {
  138. label: "标注",
  139. click() {
  140. that.menuClicked({ type: "marking" });
  141. },
  142. },
  143. ];
  144. const menu = remote.Menu.buildFromTemplate(menuTemplate);
  145. menu.popup(remote.getCurrentWindow());
  146. },
  147. menuClicked(msg) {
  148. var bd = BackgroundData.getInstance();
  149. if (!bd.LoginUser) {
  150. bd.showdialog("提示", "请登录:", "在控制之前需要先登录!");
  151. return;
  152. }
  153. if (msg.type == "lock") {
  154. // 挂牌
  155. } else if (msg.type == "send") {
  156. // 发送
  157. } else if (msg.type == "marking") {
  158. // 标注
  159. var vs = this.getSelectedItems();
  160. bd.marking(vs);
  161. }
  162. this.clearSelected();
  163. },
  164. /* 获取选中的项目,isControl:是否是控制 */
  165. getSelectedItems(isControl){
  166. var ls = new Array();
  167. this.$refs.start.outputSelectedItems(ls);
  168. this.$refs.stop.outputSelectedItems(ls);
  169. if(isControl) return ls;
  170. this.$refs.maintain.outputSelectedItems(ls);
  171. this.$refs.unmaintain.outputSelectedItems(ls);
  172. this.$refs.reset.outputSelectedItems(ls);
  173. return ls;
  174. },
  175. /* 清除所有选择 */
  176. clearSelected(){
  177. this.$refs.start.clearSelected();
  178. this.$refs.stop.clearSelected();
  179. this.$refs.maintain.clearSelected();
  180. this.$refs.unmaintain.clearSelected();
  181. this.$refs.reset.clearSelected();
  182. }
  183. },
  184. };
  185. </script>
  186. <style scoped>
  187. </style>