ControlMatrixCard.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446
  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)"
  15. @dblclick="sendMsg(item)"
  16. >
  17. <div
  18. class="card-left"
  19. :class="
  20. item.active
  21. ? 'card-left-select-' + item.status
  22. : 'card-left-unselect-' + item.status
  23. "
  24. >
  25. <div>{{ item.windturbineId.slice(0, 2) }}</div>
  26. <div>{{ item.windturbineId.slice(5) }}</div>
  27. </div>
  28. <div
  29. class="card-right"
  30. :class="
  31. item.active
  32. ? 'card-right-select-' + item.status
  33. : 'card-right-unselect-' + item.status
  34. "
  35. >
  36. <div>{{ item.power.toFixed(2) }} kw</div>
  37. <div>{{ item.windSpeed.toFixed(2) }} m/s</div>
  38. <div>{{ item.rollSpeed.toFixed(2) }} rpm</div>
  39. </div>
  40. </div>
  41. </div>
  42. <div class="bottom"></div>
  43. </div>
  44. <WindturbineDetailPages
  45. v-model="dialogVisible"
  46. :windturbine="currentWindturbine"
  47. ></WindturbineDetailPages>
  48. </template>
  49. <script>
  50. import WindturbineDetailPages from "../WindturbineDetailPages.vue";
  51. export default {
  52. name: "ControlMatrixCard",
  53. props: { title: String, datas: Object, operateStyle: Number },
  54. data() {
  55. return {
  56. values: [],
  57. dialogVisible: false,
  58. currentWindturbine: {},
  59. };
  60. },
  61. components: {
  62. WindturbineDetailPages,
  63. },
  64. created() {
  65. //this.CheckTimer = setInterval(this.checkCard,2000);
  66. },
  67. methods: {
  68. // 点击卡片事件
  69. onSelectHandler(item) {
  70. item.active = !item.active;
  71. },
  72. sendMsg: function (itm) {
  73. this.dialogVisible = true;
  74. this.currentWindturbine = itm;
  75. },
  76. /* 获取选中的项目 */
  77. getSelectedItems() {
  78. var ls = new Array();
  79. this.values.forEach((item) => {
  80. if (item.active) {
  81. ls.push(item);
  82. }
  83. });
  84. return ls;
  85. },
  86. /* 将选中的项目填充到数组中 */
  87. outputSelectedItems(ls) {
  88. this.values.forEach((item) => {
  89. if (item.active) {
  90. ls.push(item);
  91. }
  92. });
  93. },
  94. /* 导出所有的项目 */
  95. outputAllItems(ls) {
  96. this.values.forEach((item) => {
  97. ls.push(item);
  98. });
  99. },
  100. /* 清除选中的项目 */
  101. clearSelected() {
  102. this.values.forEach((item) => (item.active = false));
  103. },
  104. /* checkCard(){
  105. var st = 2;// 待机
  106. if(this.operateStyle==2){
  107. st = 4;
  108. }else if(this.operateStyle==1){
  109. st = 2;
  110. }else{
  111. return;
  112. }
  113. var ll = new Array();
  114. for(var vvs in this.values){
  115. if(this.values[vvs].status!=st){
  116. ll.push(vvs);
  117. }
  118. }
  119. for(var it in ll){
  120. this.values.splice(it,1);
  121. }
  122. }, */
  123. },
  124. watch: {
  125. "$store.getters.windturbinelist": {
  126. deep: true,
  127. handler: function (json) {
  128. var val = {};
  129. this.datas.value.forEach((item) => {
  130. var data = json[item];
  131. var active = undefined;
  132. var status = data.status;
  133. // 设置当前状态
  134. for (var i = 0; i < this.values.length; i++) {
  135. if (this.values[i].windturbineId == item) {
  136. active = this.values[i].active;
  137. break;
  138. }
  139. }
  140. val[item] = 0;
  141. var obj = {
  142. active: active,
  143. status: status,
  144. power: data.power,
  145. windSpeed: data.windSpeed,
  146. rollSpeed: data.rollSpeed,
  147. windturbineId: item,
  148. modelId: data.modelId,
  149. projectId: data.projectId,
  150. stationId: data.stationId,
  151. controlType: this.operateStyle,
  152. };
  153. if (obj.modelId.indexOf("105") >= 0) {
  154. obj.rollSpeed *= 9.55;
  155. }
  156. // 替换实时刷新的值
  157. this.values.splice(i, 1, obj);
  158. });
  159. var lls = new Array();
  160. for (var i1 = 0; i1 < this.values.length; ++i1) {
  161. var vvv = this.values[i1];
  162. if (typeof val[vvv.windturbineId] === "undefined") {
  163. lls.push(i1);
  164. }
  165. }
  166. for (var v2 in lls) {
  167. this.values.splice(v2, 1);
  168. }
  169. },
  170. },
  171. },
  172. };
  173. </script>
  174. <style scoped>
  175. .content {
  176. display: flex;
  177. flex-direction: row;
  178. flex-wrap: wrap;
  179. }
  180. .bottom {
  181. background-color: #292929;
  182. width: 100%;
  183. height: 2px;
  184. margin-top: 5px;
  185. }
  186. .main {
  187. margin: 0 5px 15px 5px;
  188. }
  189. /* 最外层卡片 */
  190. .card {
  191. width: 110px;
  192. height: 49px;
  193. font-size: 12px;
  194. margin-top: 5px;
  195. margin-left: 4px;
  196. display: flex;
  197. flex-direction: row;
  198. cursor: pointer;
  199. /* border: 2px solid rgb(75, 85, 174); */
  200. }
  201. /* 卡片左边部分 */
  202. .card-left {
  203. width: 25px;
  204. margin: 3px;
  205. font-size: 14px;
  206. display: flex;
  207. flex-direction: column;
  208. justify-content: space-around;
  209. align-items: center;
  210. /* background-color: rgb(75, 85, 174); */
  211. }
  212. /* 卡片右边部分 */
  213. .card-right {
  214. display: flex;
  215. flex: 1;
  216. flex-direction: column;
  217. justify-content: space-around;
  218. align-items: flex-end;
  219. padding-right: 3px;
  220. /* border-left: 2px dashed rgb(75, 85, 174); */
  221. }
  222. /* ***********颜色************ */
  223. /* *********************** */
  224. /* 最外层卡片选中和未选中 */
  225. .card-select-0 {
  226. border: 2px solid rgb(255, 255, 255, 0.5);
  227. }
  228. .card-unselect-0 {
  229. border: 2px solid rgb(255, 255, 255);
  230. }
  231. .card-select-0 {
  232. border: 2px solid rgb(255, 255, 255, 0.5);
  233. }
  234. /* 左边卡片选中和未选中 */
  235. .card-left-select-0 {
  236. background-color: rgb(255, 255, 255, 0.5);
  237. }
  238. .card-left-unselect-0 {
  239. background-color: rgb(255, 255, 255);
  240. }
  241. /* 右边卡片选中和未选中 */
  242. .card-right-select-0 {
  243. border-left: 2px dashed rgb(255, 255, 255, 0.5);
  244. }
  245. .card-right-unselect-0 {
  246. border-left: 2px dashed rgb(255, 255, 255);
  247. }
  248. /* ***********颜色************ */
  249. /* *********************** */
  250. /* 最外层卡片选中和未选中 */
  251. .card-select-1 {
  252. border: 2px solid rgb(121, 73, 81, 0.5);
  253. }
  254. .card-unselect-1 {
  255. border: 2px solid rgb(121, 73, 81);
  256. }
  257. .card-select-1 {
  258. border: 2px solid rgb(121, 73, 81, 0.5);
  259. }
  260. /* 左边卡片选中和未选中 */
  261. .card-left-select-1 {
  262. background-color: rgb(121, 73, 81, 0.5);
  263. }
  264. .card-left-unselect-1 {
  265. background-color: rgb(121, 73, 81);
  266. }
  267. /* 右边卡片选中和未选中 */
  268. .card-right-select-1 {
  269. border-left: 2px dashed rgb(121, 73, 81, 0.5);
  270. }
  271. .card-right-unselect-1 {
  272. border-left: 2px dashed rgb(121, 73, 81);
  273. }
  274. /* ***********颜色************ */
  275. /* *********************** */
  276. /* 最外层卡片选中和未选中 */
  277. .card-select-2 {
  278. border: 2px solid rgb(05, 187, 76, 0.5);
  279. }
  280. .card-unselect-2 {
  281. border: 2px solid rgb(05, 187, 76);
  282. }
  283. .card-select-2 {
  284. border: 2px solid rgb(05, 187, 76, 0.5);
  285. }
  286. /* 左边卡片选中和未选中 */
  287. .card-left-select-2 {
  288. background-color: rgb(05, 187, 76, 0.5);
  289. }
  290. .card-left-unselect-2 {
  291. background-color: rgb(05, 187, 76);
  292. }
  293. /* 右边卡片选中和未选中 */
  294. .card-right-select-2 {
  295. border-left: 2px dashed rgb(05, 187, 76, 0.5);
  296. }
  297. .card-right-unselect-2 {
  298. border-left: 2px dashed rgb(05, 187, 76);
  299. }
  300. /* ***********颜色************ */
  301. /* *********************** */
  302. /* 最外层卡片选中和未选中 */
  303. .card-select-3 {
  304. border: 2px solid rgb(05, 187, 76, 0.5);
  305. }
  306. .card-unselect-3 {
  307. border: 2px solid rgb(05, 187, 76);
  308. }
  309. .card-select-3 {
  310. border: 2px solid rgb(05, 187, 76, 0.5);
  311. }
  312. /* 左边卡片选中和未选中 */
  313. .card-left-select-3 {
  314. background-color: rgb(05, 187, 76, 0.5);
  315. }
  316. .card-left-unselect-3 {
  317. background-color: rgb(05, 187, 76);
  318. }
  319. /* 右边卡片选中和未选中 */
  320. .card-right-select-3 {
  321. border-left: 2px dashed rgb(05, 187, 76, 0.5);
  322. }
  323. .card-right-unselect-3 {
  324. border-left: 2px dashed rgb(05, 187, 76);
  325. }
  326. /* ***********颜色************ */
  327. /* *********************** */
  328. /* 最外层卡片选中和未选中 */
  329. .card-select-4 {
  330. border: 2px solid rgb(75, 85, 174, 0.5);
  331. }
  332. .card-unselect-4 {
  333. border: 2px solid rgb(75, 85, 174);
  334. }
  335. .card-select-4 {
  336. border: 2px solid rgb(75, 85, 174, 0.5);
  337. }
  338. /* 左边卡片选中和未选中 */
  339. .card-left-select-4 {
  340. background-color: rgb(75, 85, 174, 0.5);
  341. }
  342. .card-left-unselect-4 {
  343. background-color: rgb(75, 85, 174);
  344. }
  345. /* 右边卡片选中和未选中 */
  346. .card-right-select-4 {
  347. border-left: 2px dashed rgb(75, 85, 174, 0.5);
  348. }
  349. .card-right-unselect-4 {
  350. border-left: 2px dashed rgb(75, 85, 174);
  351. }
  352. /* ***********颜色************ */
  353. /* *********************** *
  354. /* 最外层卡片选中和未选中 */
  355. .card-select-5 {
  356. border: 2px solid rgb(186, 50, 55, 0.5);
  357. }
  358. .card-unselect-5 {
  359. border: 2px solid rgb(186, 50, 55);
  360. }
  361. .card-select-5 {
  362. border: 2px solid rgb(186, 50, 55, 0.5);
  363. }
  364. /* 左边卡片选中和未选中 */
  365. .card-left-select-5 {
  366. background-color: rgb(186, 50, 55, 0.5);
  367. }
  368. .card-left-unselect-5 {
  369. background-color: rgb(186, 50, 55);
  370. }
  371. /* 右边卡片选中和未选中 */
  372. .card-right-select-5 {
  373. border-left: 2px dashed rgb(186, 50, 55, 0.5);
  374. }
  375. .card-right-unselect-5 {
  376. border-left: 2px dashed rgb(186, 50, 55);
  377. }
  378. /* ***********颜色************ */
  379. /* *********************** *
  380. /* 最外层卡片选中和未选中 */
  381. .card-select-6 {
  382. border: 2px solid rgb(225, 125, 36, 0.5);
  383. }
  384. .card-unselect-6 {
  385. border: 2px solid rgb(225, 125, 36);
  386. }
  387. .card-select-6 {
  388. border: 2px solid rgb(225, 125, 36, 0.5);
  389. }
  390. /* 左边卡片选中和未选中 */
  391. .card-left-select-6 {
  392. background-color: rgb(225, 125, 36, 0.5);
  393. }
  394. .card-left-unselect-6 {
  395. background-color: rgb(225, 125, 36);
  396. }
  397. /* 右边卡片选中和未选中 */
  398. .card-right-select-6 {
  399. border-left: 2px dashed rgb(225, 125, 36, 0.5);
  400. }
  401. .card-right-unselect-6 {
  402. border-left: 2px dashed rgb(225, 125, 36);
  403. }
  404. /* ***********颜色************ */
  405. /* *********************** *
  406. /* 最外层卡片选中和未选中 */
  407. .card-select-7 {
  408. border: 2px solid rgb(159, 163, 165, 0.5);
  409. }
  410. .card-unselect-7 {
  411. border: 2px solid rgb(159, 163, 165);
  412. }
  413. .card-select-7 {
  414. border: 2px solid rgb(159, 163, 165, 0.5);
  415. }
  416. /* 左边卡片选中和未选中 */
  417. .card-left-select-7 {
  418. background-color: rgb(159, 163, 165, 0.5);
  419. }
  420. .card-left-unselect-7 {
  421. background-color: rgb(2159, 163, 165);
  422. }
  423. /* 右边卡片选中和未选中 */
  424. .card-right-select-7 {
  425. border-left: 2px dashed rgb(159, 163, 165, 0.5);
  426. }
  427. .card-right-unselect-7 {
  428. border-left: 2px dashed rgb(159, 163, 165);
  429. }
  430. </style>