ControlArea.vue 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313
  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: 6px; 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. computed: {
  79. buttonLeftStyle: function () {
  80. return this.IsAutoControl ? "button-unselected" : "button-selected";
  81. },
  82. buttonRightStyle: function () {
  83. return this.IsAutoControl ? "button-selected" : "button-unselected";
  84. },
  85. },
  86. created: function () {
  87. this.initData();
  88. },
  89. data() {
  90. return {
  91. ls: {
  92. start: { key: "待启动", value: [] },
  93. stop: { key: "待停机", value: [] },
  94. maintain: { key: "待维护", value: [] },
  95. unmaintain: { key: "待取消维护", value: [] },
  96. reset: { key: "待复位", value: [] },
  97. },
  98. IsAutoControl: false,
  99. };
  100. },
  101. methods: {
  102. initData: function () {
  103. var mb = MessageBridge.getInstance();
  104. var vs = [{ key: "/topic/suggestion", action: this.suggestion }];
  105. mb.register(vs);
  106. },
  107. suggestion(msg,headers) {
  108. var val = JSON.parse(msg);
  109. var tp = headers["operate-type"];
  110. if (tp == "UnMaintain") {
  111. this.updateSuggestion(this.ls.unmaintain.value, val);
  112. } else if (tp == "Start") {
  113. //推荐启动
  114. this.updateSuggestion(this.ls.start.value, val);
  115. } else if (tp == "Stop") {
  116. // 推荐停机
  117. this.updateSuggestion(this.ls.stop.value, val);
  118. } else if (tp == "Reset") {
  119. // 推荐复位
  120. this.updateSuggestion(this.ls.reset.value, val);
  121. } else if (tp == "Maintain") {
  122. // 推荐维护
  123. this.updateSuggestion(this.ls.maintain.value, val);
  124. }
  125. },
  126. /* 获取推荐类型 */
  127. getSuggestionType(val) {
  128. if (typeof val === "undefined") return null;
  129. for (var v in val) {
  130. return val[v].adviceOperateStyle;
  131. }
  132. return null;
  133. },
  134. /* 更新推荐数据 */
  135. updateSuggestion(ll,val) {
  136. var lls = new Array();
  137. for(var v1 in ll){
  138. var v2 = val[ll[v1]];
  139. if(typeof(v2)==='undefined'){
  140. lls.push(v1);
  141. }
  142. }
  143. for(var v3 in lls){
  144. ll.splice(v3,1);
  145. }
  146. for(var v in val){
  147. var vl = val[v];
  148. if(!ll.includes(vl.windturbineId)){
  149. ll.push(vl.windturbineId);
  150. }
  151. }
  152. },
  153. /* 右键菜单 */
  154. contextmenu() {
  155. const { remote } = require("electron");
  156. var that = this;
  157. const menuTemplate = [
  158. {
  159. label: "发送",
  160. click() {
  161. that.menuClicked({ type: "send" });
  162. },
  163. },
  164. {
  165. label: "挂牌",
  166. submenu: [
  167. {
  168. label: "检修",
  169. click() {
  170. that.menuClicked({ type: "lock", value: "CheckLock" });
  171. },
  172. },
  173. {
  174. label: "故障维修",
  175. click() {
  176. that.menuClicked({ type: "lock", value: "FaultLock" });
  177. },
  178. },
  179. {
  180. label: "场内受累检修",
  181. click() {
  182. that.menuClicked({ type: "lock", value: "StationCheckLock" });
  183. },
  184. },
  185. {
  186. label: "场内受累故障",
  187. click() {
  188. that.menuClicked({ type: "lock", value: "StationFaulLock" });
  189. },
  190. },
  191. {
  192. label: "场外受累电网",
  193. click() {
  194. that.menuClicked({
  195. type: "lock",
  196. value: "StationPowerLineLock",
  197. });
  198. },
  199. },
  200. {
  201. label: "场外受累天气",
  202. click() {
  203. that.menuClicked({ type: "lock", value: "StationWeatherLock" });
  204. },
  205. },
  206. ],
  207. },
  208. {
  209. label: "标注",
  210. click() {
  211. that.menuClicked({ type: "marking" });
  212. },
  213. },
  214. ];
  215. const menu = remote.Menu.buildFromTemplate(menuTemplate);
  216. menu.popup(remote.getCurrentWindow());
  217. },
  218. menuClicked(msg) {
  219. var bd = BackgroundData.getInstance();
  220. if (!bd.LoginUser) {
  221. this.$confirm("控制风机前需要登录!", "请登录", {
  222. confirmButtonText: "确定",
  223. cancelButtonText: "取消",
  224. type: "warning",
  225. });
  226. //bd.showdialog("提示", "请登录:", "在控制之前需要先登录!");
  227. return;
  228. }
  229. if (msg.type == "lock") {
  230. // 挂牌
  231. var los = this.getSelectedItems();
  232. for (var id in los) {
  233. los[id].lockType = msg.value;
  234. }
  235. bd.windturbineControl(los, true);
  236. } else if (msg.type == "send") {
  237. // 发送
  238. var vs = this.getSelectedItems(true);
  239. bd.windturbineControl(vs, false);
  240. } else if (msg.type == "marking") {
  241. // 标注
  242. var vvs = this.getSelectedItems();
  243. bd.marking(vvs);
  244. }
  245. this.clearSelected();
  246. },
  247. /* 获取选中的项目,isControl:是否是控制 */
  248. getSelectedItems(isControl) {
  249. var ls = new Array();
  250. this.$refs.start.outputSelectedItems(ls);
  251. this.$refs.stop.outputSelectedItems(ls);
  252. if (isControl) return ls;
  253. this.$refs.maintain.outputSelectedItems(ls);
  254. this.$refs.unmaintain.outputSelectedItems(ls);
  255. this.$refs.reset.outputSelectedItems(ls);
  256. return ls;
  257. },
  258. /* 清除所有选择 */
  259. clearSelected() {
  260. this.$refs.start.clearSelected();
  261. this.$refs.stop.clearSelected();
  262. this.$refs.maintain.clearSelected();
  263. this.$refs.unmaintain.clearSelected();
  264. this.$refs.reset.clearSelected();
  265. },
  266. controlClick(isAuto) {
  267. this.IsAutoControl = isAuto;
  268. if (isAuto) {
  269. this.AutoSendTimer = setInterval(this.AutoSend, 60000);
  270. } else {
  271. clearInterval(this.AutoSendTimer);
  272. }
  273. },
  274. /* 自动发送命令 */
  275. AutoSend() {
  276. var ls = new Array();
  277. this.$refs.start.outputAllItems(ls);
  278. this.$refs.stop.outputAllItems(ls);
  279. console.log("自动发送命令 " + ls.length);
  280. if (ls.length <= 0) return;
  281. var bd = BackgroundData.getInstance();
  282. bd.windturbineControlSystem(ls, false);
  283. },
  284. },
  285. };
  286. </script>
  287. <style scoped>
  288. .button-selected {
  289. background: black;
  290. font-size: 14px;
  291. width: 80px;
  292. border: none;
  293. color: rgb(220, 220, 220);
  294. }
  295. .button-unselected {
  296. background: #202020;
  297. font-size: 14px;
  298. width: 80px;
  299. border: none;
  300. color: rgb(220, 220, 220);
  301. }
  302. </style>