ControlArea.vue 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  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
  11. title="待启动"
  12. :datas="ls.start"
  13. :operateStyle="1"
  14. ref="start"
  15. ></ControlMatrixCard>
  16. <ControlMatrixCard
  17. title="待停机"
  18. :datas="ls.stop"
  19. :operateStyle="2"
  20. ref="stop"
  21. ></ControlMatrixCard>
  22. <ControlMatrixCard
  23. title="待维护"
  24. :datas="ls.maintain"
  25. :operateStyle="6"
  26. ref="maintain"
  27. ></ControlMatrixCard>
  28. <ControlMatrixCard
  29. title="待取消维护"
  30. :datas="ls.unmaintain"
  31. :operateStyle="8"
  32. ref="unmaintain"
  33. ></ControlMatrixCard>
  34. <ControlMatrixCard
  35. title="待复位"
  36. :datas="ls.reset"
  37. :operateStyle="5"
  38. ref="reset"
  39. ></ControlMatrixCard>
  40. <el-button
  41. style="
  42. z-index: 2;
  43. position: absolute;
  44. bottom: 10px;
  45. right: 10px;
  46. background: #292929;
  47. font-size: 15px;
  48. width: 90px;
  49. border: none;
  50. color: rgb(220, 220, 220);
  51. "
  52. size="small"
  53. @click="menuClicked({ type: 'send' })"
  54. >发送</el-button
  55. >
  56. </gy-card>
  57. <el-button-group
  58. style="z-index: 3; position: absolute; top: 16px; left: 120px"
  59. >
  60. <el-button :class="buttonLeftStyle" size="mini" @click="controlClick(false)"
  61. >手动</el-button
  62. >
  63. <el-button :class="buttonRightStyle" size="mini" @click="controlClick(true)"
  64. >自动</el-button
  65. >
  66. </el-button-group>
  67. </template>
  68. <script>
  69. import ControlMatrixCard from "./windturbine/control/ControlMatrixCard.vue";
  70. import MessageBridge from "../../assets/script/MessageBridge";
  71. import BackgroundData from "../../assets/script/BackgroundData";
  72. export default {
  73. name: "ControlArea",
  74. components: {
  75. ControlMatrixCard,
  76. },
  77. props: {
  78. },
  79. computed: {
  80. buttonLeftStyle: function () {
  81. return this.IsAutoControl ? "button-unselected" : "button-selected";
  82. },
  83. buttonRightStyle: function () {
  84. return this.IsAutoControl ? "button-selected" : "button-unselected";
  85. },
  86. },
  87. created: function () {
  88. this.initData();
  89. },
  90. data() {
  91. return {
  92. ls: {
  93. start: { key: "待启动", value: [] },
  94. stop: { key: "待停机", value: [] },
  95. maintain: { key: "待维护", value: [] },
  96. unmaintain: { key: "待取消维护", value: [] },
  97. reset: { key: "待复位", value: [] },
  98. },
  99. IsAutoControl:false,
  100. };
  101. },
  102. methods: {
  103. initData: function () {
  104. var mb = MessageBridge.getInstance();
  105. var vs = [{ key: "/topic/suggestion", action: this.suggestion }];
  106. mb.register(vs);
  107. },
  108. suggestion(msg) {
  109. var val = JSON.parse(msg);
  110. for (var vv in val) {
  111. var v = val[vv];
  112. var windturbineId = v.windturbineId;
  113. if (v.adviceOperateStyle == "UnMaintain") {
  114. if (!this.ls.unmaintain.value.includes(windturbineId)) {
  115. this.ls.unmaintain.value.push(windturbineId);
  116. }
  117. } else if (v.adviceOperateStyle == "Start") {
  118. //推荐启动
  119. if (!this.ls.start.value.includes(windturbineId)) {
  120. this.ls.start.value.push(windturbineId);
  121. }
  122. } else if (v.adviceOperateStyle == "Stop") {
  123. // 推荐停机
  124. if (!this.ls.stop.value.includes(windturbineId)) {
  125. this.ls.stop.value.push(windturbineId);
  126. }
  127. } else if (v.adviceOperateStyle == "Reset") {
  128. // 推荐复位
  129. if (!this.ls.reset.value.includes(windturbineId)) {
  130. this.ls.reset.value.push(windturbineId);
  131. }
  132. } else if (v.adviceOperateStyle == "Maintain") {
  133. // 推荐维护
  134. if (!this.ls.maintain.value.includes(windturbineId)) {
  135. this.ls.maintain.value.push(windturbineId);
  136. }
  137. }
  138. }
  139. },
  140. /* 右键菜单 */
  141. contextmenu() {
  142. const { remote } = require("electron");
  143. var that = this;
  144. const menuTemplate = [
  145. {
  146. label: "发送",
  147. click() {
  148. that.menuClicked({ type: "send" });
  149. },
  150. },
  151. {
  152. label: "挂牌",
  153. submenu: [
  154. {
  155. label: "检修",
  156. click() {
  157. that.menuClicked({ type: "lock", value: "CheckLock" });
  158. },
  159. },
  160. {
  161. label: "故障维修",
  162. click() {
  163. that.menuClicked({ type: "lock", value: "FaultLock" });
  164. },
  165. },
  166. {
  167. label: "场内受累检修",
  168. click() {
  169. that.menuClicked({ type: "lock", value: "StationCheckLock" });
  170. },
  171. },
  172. {
  173. label: "场内受累故障",
  174. click() {
  175. that.menuClicked({ type: "lock", value: "StationFaulLock" });
  176. },
  177. },
  178. {
  179. label: "场外受累电网",
  180. click() {
  181. that.menuClicked({
  182. type: "lock",
  183. value: "StationPowerLineLock",
  184. });
  185. },
  186. },
  187. {
  188. label: "场外受累天气",
  189. click() {
  190. that.menuClicked({ type: "lock", value: "StationWeatherLock" });
  191. },
  192. },
  193. ],
  194. },
  195. {
  196. label: "标注",
  197. click() {
  198. that.menuClicked({ type: "marking" });
  199. },
  200. },
  201. ];
  202. const menu = remote.Menu.buildFromTemplate(menuTemplate);
  203. menu.popup(remote.getCurrentWindow());
  204. },
  205. menuClicked(msg) {
  206. var bd = BackgroundData.getInstance();
  207. if (!bd.LoginUser) {
  208. this.$confirm("控制风机前需要登录!","请登录",{confirmButtonText:'确定',cancelButtonText:'取消',type:'warning'});
  209. //bd.showdialog("提示", "请登录:", "在控制之前需要先登录!");
  210. return;
  211. }
  212. if (msg.type == "lock") {
  213. // 挂牌
  214. var los = this.getSelectedItems();
  215. for (var id in los) {
  216. los[id].lockType = msg.value;
  217. }
  218. bd.windturbineControl(los, true);
  219. } else if (msg.type == "send") {
  220. // 发送
  221. var vs = this.getSelectedItems(true);
  222. bd.windturbineControl(vs, false);
  223. } else if (msg.type == "marking") {
  224. // 标注
  225. var vvs = this.getSelectedItems();
  226. bd.marking(vvs);
  227. }
  228. this.clearSelected();
  229. },
  230. /* 获取选中的项目,isControl:是否是控制 */
  231. getSelectedItems(isControl) {
  232. var ls = new Array();
  233. this.$refs.start.outputSelectedItems(ls);
  234. this.$refs.stop.outputSelectedItems(ls);
  235. if (isControl) return ls;
  236. this.$refs.maintain.outputSelectedItems(ls);
  237. this.$refs.unmaintain.outputSelectedItems(ls);
  238. this.$refs.reset.outputSelectedItems(ls);
  239. return ls;
  240. },
  241. /* 清除所有选择 */
  242. clearSelected() {
  243. this.$refs.start.clearSelected();
  244. this.$refs.stop.clearSelected();
  245. this.$refs.maintain.clearSelected();
  246. this.$refs.unmaintain.clearSelected();
  247. this.$refs.reset.clearSelected();
  248. },
  249. controlClick(isAuto) {
  250. this.IsAutoControl = isAuto;
  251. if (isAuto) {
  252. this.AutoSendTimer = setInterval(this.AutoSend, 60000);
  253. } else {
  254. clearInterval(this.AutoSendTimer);
  255. }
  256. },
  257. /* 自动发送命令 */
  258. AutoSend() {
  259. var ls = new Array();
  260. this.$refs.start.outputAllItems(ls);
  261. this.$refs.stop.outputAllItems(ls);
  262. console.log("自动发送命令 " + ls.length);
  263. if (ls.length <= 0) return;
  264. var bd = BackgroundData.getInstance();
  265. bd.windturbineControl(ls, false);
  266. },
  267. },
  268. };
  269. </script>
  270. <style scoped>
  271. .button-selected {
  272. background: black;
  273. font-size: 14px;
  274. width: 80px;
  275. border: none;
  276. color: rgb(220, 220, 220);
  277. }
  278. .button-unselected {
  279. background: #202020;
  280. font-size: 14px;
  281. width: 80px;
  282. border: none;
  283. color: rgb(220, 220, 220);
  284. }
  285. </style>