ControlMatrixCard.vue 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369
  1. <template>
  2. <div class="main" v-if="values.length > 0">
  3. <div>{{ title }}</div>
  4. <div class="content">
  5. <div
  6. class="card"
  7. v-for="(item, index) in values"
  8. :key="index"
  9. :class="
  10. item.active
  11. ? 'card-select-' + item.status
  12. : 'card-unselect-' + item.status
  13. "
  14. @click="onSelectHandler(item.active, item.windturbineId)"
  15. >
  16. <div
  17. class="card-left"
  18. :class="
  19. item.active
  20. ? 'card-left-select-' + item.status
  21. : 'card-left-unselect-' + item.status
  22. "
  23. >
  24. <div>{{ item.windturbineId.slice(0, 2) }}</div>
  25. <div>{{ item.windturbineId.slice(5) }}</div>
  26. </div>
  27. <div
  28. class="card-right"
  29. :class="
  30. item.active
  31. ? 'card-right-select-' + item.status
  32. : 'card-right-unselect-' + item.status
  33. "
  34. >
  35. <div>{{ item.power.toFixed(2) }} kw</div>
  36. <div>{{ item.windSpeed.toFixed(2) }} m/s</div>
  37. <div>{{ item.rollSpeed.toFixed(2) }} rpm</div>
  38. </div>
  39. </div>
  40. </div>
  41. <div class="bottom"></div>
  42. </div>
  43. </template>
  44. <script>
  45. import MessageBridge from "../../../../assets/script/MessageBridge";
  46. export default {
  47. name: "ControlMatrixCard",
  48. props: { title: String, datas: Object },
  49. data() {
  50. return {
  51. values: [],
  52. count: 0,
  53. };
  54. },
  55. created: function () {
  56. this.initData();
  57. },
  58. computed: {},
  59. methods: {
  60. initData: function () {
  61. var mb = MessageBridge.getInstance();
  62. var vs = [{ key: "/topic/windturbine", action: this.windturbineMessage }];
  63. mb.register(vs);
  64. },
  65. windturbineMessage: function (msg) {
  66. var json = JSON.parse(msg);
  67. for (var i = 0; i < this.datas.value.length; i++) {
  68. var key = this.datas.value[i];
  69. var data = json[key];
  70. var active = undefined;
  71. var status = data.status;
  72. // 设置当前状态
  73. this.values.forEach((item) => {
  74. if (item.windturbineId == key) {
  75. active = item.active;
  76. }
  77. });
  78. var obj = {
  79. active: active,
  80. status: status,
  81. power: data.power,
  82. windSpeed: data.windSpeed,
  83. rollSpeed: data.rollSpeed,
  84. windturbineId: key,
  85. };
  86. // 替换实时刷新的值
  87. this.values.splice(i, 1, obj);
  88. }
  89. },
  90. // 点击卡片事件
  91. onSelectHandler(active, windturbineId) {
  92. this.values.forEach((item) => {
  93. if (item.windturbineId == windturbineId) item.active = !active;
  94. });
  95. },
  96. },
  97. components: {
  98. // ControlWindCard,
  99. },
  100. };
  101. </script>
  102. <style scoped>
  103. .content {
  104. display: flex;
  105. flex-direction: row;
  106. flex-wrap: wrap;
  107. }
  108. .bottom {
  109. background-color: #292929;
  110. width: 100%;
  111. height: 2px;
  112. margin-top: 5px;
  113. }
  114. .main {
  115. margin: 0 5px 15px 5px;
  116. }
  117. /* 最外层卡片 */
  118. .card {
  119. width: 112px;
  120. height: 50px;
  121. font-size: 12px;
  122. margin-right: 3px;
  123. display: flex;
  124. flex-direction: row;
  125. cursor: pointer;
  126. /* border: 2px solid rgb(75, 85, 174); */
  127. }
  128. /* 卡片左边部分 */
  129. .card-left {
  130. width: 25px;
  131. margin: 3px;
  132. font-size: 14px;
  133. display: flex;
  134. flex-direction: column;
  135. justify-content: space-around;
  136. align-items: center;
  137. /* background-color: rgb(75, 85, 174); */
  138. }
  139. /* 卡片右边部分 */
  140. .card-right {
  141. display: flex;
  142. flex: 1;
  143. flex-direction: column;
  144. justify-content: space-around;
  145. align-items: flex-end;
  146. padding-right: 3px;
  147. /* border-left: 2px dashed rgb(75, 85, 174); */
  148. }
  149. /* ***********颜色************ */
  150. /* *********************** */
  151. /* 最外层卡片选中和未选中 */
  152. .card-select-0 {
  153. border: 2px solid rgb(255, 255, 255, 0.5);
  154. }
  155. .card-unselect-0 {
  156. border: 2px solid rgb(255, 255, 255);
  157. }
  158. .card-select-0 {
  159. border: 2px solid rgb(255, 255, 255, 0.5);
  160. }
  161. /* 左边卡片选中和未选中 */
  162. .card-left-select-0 {
  163. background-color: rgb(255, 255, 255, 0.5);
  164. }
  165. .card-left-unselect-0 {
  166. background-color: rgb(255, 255, 255);
  167. }
  168. /* 右边卡片选中和未选中 */
  169. .card-right-select-0 {
  170. border-left: 2px dashed rgb(255, 255, 255, 0.5);
  171. }
  172. .card-right-unselect-0 {
  173. border-left: 2px dashed rgb(255, 255, 255);
  174. }
  175. /* ***********颜色************ */
  176. /* *********************** */
  177. /* 最外层卡片选中和未选中 */
  178. .card-select-1 {
  179. border: 2px solid rgb(121, 73, 81, 0.5);
  180. }
  181. .card-unselect-1 {
  182. border: 2px solid rgb(121, 73, 81);
  183. }
  184. .card-select-1 {
  185. border: 2px solid rgb(121, 73, 81, 0.5);
  186. }
  187. /* 左边卡片选中和未选中 */
  188. .card-left-select-1 {
  189. background-color: rgb(121, 73, 81, 0.5);
  190. }
  191. .card-left-unselect-1 {
  192. background-color: rgb(121, 73, 81);
  193. }
  194. /* 右边卡片选中和未选中 */
  195. .card-right-select-1 {
  196. border-left: 2px dashed rgb(121, 73, 81, 0.5);
  197. }
  198. .card-right-unselect-1 {
  199. border-left: 2px dashed rgb(121, 73, 81);
  200. }
  201. /* ***********颜色************ */
  202. /* *********************** */
  203. /* 最外层卡片选中和未选中 */
  204. .card-select-2 {
  205. border: 2px solid rgb(05, 187, 76, 0.5);
  206. }
  207. .card-unselect-2 {
  208. border: 2px solid rgb(05, 187, 76);
  209. }
  210. .card-select-2 {
  211. border: 2px solid rgb(05, 187, 76, 0.5);
  212. }
  213. /* 左边卡片选中和未选中 */
  214. .card-left-select-2 {
  215. background-color: rgb(05, 187, 76, 0.5);
  216. }
  217. .card-left-unselect-2 {
  218. background-color: rgb(05, 187, 76);
  219. }
  220. /* 右边卡片选中和未选中 */
  221. .card-right-select-2 {
  222. border-left: 2px dashed rgb(05, 187, 76, 0.5);
  223. }
  224. .card-right-unselect-2 {
  225. border-left: 2px dashed rgb(05, 187, 76);
  226. }
  227. /* ***********颜色************ */
  228. /* *********************** */
  229. /* 最外层卡片选中和未选中 */
  230. .card-select-3 {
  231. border: 2px solid rgb(05, 187, 76, 0.5);
  232. }
  233. .card-unselect-3 {
  234. border: 2px solid rgb(05, 187, 76);
  235. }
  236. .card-select-3 {
  237. border: 2px solid rgb(05, 187, 76, 0.5);
  238. }
  239. /* 左边卡片选中和未选中 */
  240. .card-left-select-3 {
  241. background-color: rgb(05, 187, 76, 0.5);
  242. }
  243. .card-left-unselect-3 {
  244. background-color: rgb(05, 187, 76);
  245. }
  246. /* 右边卡片选中和未选中 */
  247. .card-right-select-3 {
  248. border-left: 2px dashed rgb(05, 187, 76, 0.5);
  249. }
  250. .card-right-unselect-3 {
  251. border-left: 2px dashed rgb(05, 187, 76);
  252. }
  253. /* ***********颜色************ */
  254. /* *********************** */
  255. /* 最外层卡片选中和未选中 */
  256. .card-select-4 {
  257. border: 2px solid rgb(75, 85, 174, 0.5);
  258. }
  259. .card-unselect-4 {
  260. border: 2px solid rgb(75, 85, 174);
  261. }
  262. .card-select-4 {
  263. border: 2px solid rgb(75, 85, 174, 0.5);
  264. }
  265. /* 左边卡片选中和未选中 */
  266. .card-left-select-4 {
  267. background-color: rgb(75, 85, 174, 0.5);
  268. }
  269. .card-left-unselect-4 {
  270. background-color: rgb(75, 85, 174);
  271. }
  272. /* 右边卡片选中和未选中 */
  273. .card-right-select-4 {
  274. border-left: 2px dashed rgb(75, 85, 174, 0.5);
  275. }
  276. .card-right-unselect-4 {
  277. border-left: 2px dashed rgb(75, 85, 174);
  278. }
  279. /* ***********颜色************ */
  280. /* *********************** *
  281. /* 最外层卡片选中和未选中 */
  282. .card-select-5 {
  283. border: 2px solid rgb(186, 50, 55, 0.5);
  284. }
  285. .card-unselect-5 {
  286. border: 2px solid rgb(186, 50, 55);
  287. }
  288. .card-select-5 {
  289. border: 2px solid rgb(186, 50, 55, 0.5);
  290. }
  291. /* 左边卡片选中和未选中 */
  292. .card-left-select-5 {
  293. background-color: rgb(186, 50, 55, 0.5);
  294. }
  295. .card-left-unselect-5 {
  296. background-color: rgb(186, 50, 55);
  297. }
  298. /* 右边卡片选中和未选中 */
  299. .card-right-select-5 {
  300. border-left: 2px dashed rgb(186, 50, 55, 0.5);
  301. }
  302. .card-right-unselect-5 {
  303. border-left: 2px dashed rgb(186, 50, 55);
  304. }
  305. /* ***********颜色************ */
  306. /* *********************** *
  307. /* 最外层卡片选中和未选中 */
  308. .card-select-6 {
  309. border: 2px solid rgb(225, 125, 36, 0.5);
  310. }
  311. .card-unselect-6 {
  312. border: 2px solid rgb(225, 125, 36);
  313. }
  314. .card-select-6 {
  315. border: 2px solid rgb(225, 125, 36, 0.5);
  316. }
  317. /* 左边卡片选中和未选中 */
  318. .card-left-select-6 {
  319. background-color: rgb(225, 125, 36, 0.5);
  320. }
  321. .card-left-unselect-6 {
  322. background-color: rgb(225, 125, 36);
  323. }
  324. /* 右边卡片选中和未选中 */
  325. .card-right-select-6 {
  326. border-left: 2px dashed rgb(225, 125, 36, 0.5);
  327. }
  328. .card-right-unselect-6 {
  329. border-left: 2px dashed rgb(225, 125, 36);
  330. }
  331. /* ***********颜色************ */
  332. /* *********************** *
  333. /* 最外层卡片选中和未选中 */
  334. .card-select-7 {
  335. border: 2px solid rgb(159, 163, 165, 0.5);
  336. }
  337. .card-unselect-7 {
  338. border: 2px solid rgb(159, 163, 165);
  339. }
  340. .card-select-7 {
  341. border: 2px solid rgb(159, 163, 165, 0.5);
  342. }
  343. /* 左边卡片选中和未选中 */
  344. .card-left-select-7 {
  345. background-color: rgb(159, 163, 165, 0.5);
  346. }
  347. .card-left-unselect-7 {
  348. background-color: rgb(2159, 163, 165);
  349. }
  350. /* 右边卡片选中和未选中 */
  351. .card-right-select-7 {
  352. border-left: 2px dashed rgb(159, 163, 165, 0.5);
  353. }
  354. .card-right-unselect-7 {
  355. border-left: 2px dashed rgb(159, 163, 165);
  356. }
  357. </style>