Info.vue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305
  1. <template>
  2. <div class="mg-b-8">
  3. <btn-group-double :btnGroups="btnGroups" :rowIndex="0" :index="1" @select="select" />
  4. </div>
  5. <div class="wind-site-info">
  6. <div class="wind-site-menu">
  7. <div class="wind-site-title">选择风机</div>
  8. <div class="wind-site-body">
  9. <collapse-list :list="WindSites" :allowScroll="true" scrollHeight="calc(100vh - 175px)" />
  10. </div>
  11. </div>
  12. <div class="wind-site-info-body">
  13. <div class="info-menu mg-b-16">
  14. <div class="info-menu-item" v-for="(item, index) in InfoBtns.data" :key="item" :class="{ active: InfoBtns.activeIndex == index }" @click="onInfoMenuItemClick(item, index)">{{ item.text }}</div>
  15. </div>
  16. <el-row>
  17. <el-col :span="16" style="position:relative;">
  18. <!-- 基本信息 使用 v-if 每次点击重新加载 -->
  19. <!-- 使用 v-show 首次全部加载 之后隐藏 点击后显示 -->
  20. <base-info v-show="InfoBtns.activeIndex == 0" :data="sourceMap" />
  21. <!-- <base-info v-if="InfoBtns.activeIndex == 2" /> -->
  22. <div style="text-align:center;">
  23. <StandAloneImg class="sai" v-show="InfoBtns.activeIndex != 0" :activeIndex="InfoBtns.activeIndex" @selectSvg="selectSvg"></StandAloneImg>
  24. </div>
  25. <generator class="saig" v-show="InfoBtns.activeIndex != 0" :index="InfoBtns.activeIndex" :data="sourceMap"></generator>
  26. </el-col>
  27. <el-col :span="8">
  28. <warning :data="WarnData" />
  29. </el-col>
  30. </el-row>
  31. </div>
  32. </div>
  33. </template>
  34. <script>
  35. import collapseList from "@/components/coms/collapse/collapse-list.vue";
  36. import BaseInfo from "./Base-Info.vue";
  37. import Warning from "./Warning.vue";
  38. import StandAloneImg from "./StandAloneImg.vue";
  39. import generator from "./pages/generator.vue";
  40. import BtnGroupDouble from "../../../../components/coms/btn/btn-group-double.vue";
  41. export default {
  42. components: { collapseList, BaseInfo, Warning, StandAloneImg, generator, BtnGroupDouble },
  43. props: {
  44. id: {
  45. type: String,
  46. default: "",
  47. },
  48. },
  49. data() {
  50. return {
  51. timmer: null, // 计时器
  52. wtId: "", // 风机ID
  53. sourceMap: {},
  54. WarnData: {},
  55. WindSites: [],
  56. InfoBtns: {
  57. activeIndex: 0,
  58. data: [
  59. {
  60. id: "base-info",
  61. text: "基本信息",
  62. },
  63. {
  64. id: "generator",
  65. text: "发电机",
  66. },
  67. {
  68. id: "gear-box",
  69. text: "齿轮箱",
  70. },
  71. {
  72. id: "pitch",
  73. text: "变桨",
  74. },
  75. {
  76. id: "yaw",
  77. text: "偏航",
  78. },
  79. {
  80. id: "hydraulic-pressure",
  81. text: "液压",
  82. },
  83. {
  84. id: "cabin-info",
  85. text: "机舱信息",
  86. },
  87. // {
  88. // id: "principal-axis",
  89. // text: "主轴",
  90. // },
  91. ],
  92. },
  93. };
  94. },
  95. methods: {
  96. onInfoMenuItemClick(item, index) {
  97. this.InfoBtns.activeIndex = index;
  98. },
  99. selectSvg(index) {
  100. this.InfoBtns.activeIndex = index;
  101. },
  102. // 根据风机状态码返回对应 class
  103. getColor(fjzt) {
  104. switch (fjzt) {
  105. case 0:
  106. return "green";
  107. case 1:
  108. return "blue";
  109. case 2:
  110. return "red";
  111. case 3:
  112. return "gray";
  113. case 4:
  114. return "orange";
  115. case 5:
  116. return "purple";
  117. case 6:
  118. return "write";
  119. }
  120. },
  121. // 请求服务
  122. requestData(showLoading) {
  123. this.getSimpleMatrixAll(showLoading);
  124. },
  125. // 获取场列表
  126. getSimpleMatrixAll(showLoading) {
  127. let that = this;
  128. that.API.requestData({
  129. showLoading,
  130. method: "POST",
  131. subUrl: "matrix/findSimpleMatrixAll",
  132. data: {
  133. wpId: that.wpId,
  134. },
  135. success(res) {
  136. let WindSites = [];
  137. res.data.forEach((ele, index) => {
  138. WindSites.push({
  139. id: String(index),
  140. text: ele.wpName,
  141. children: [],
  142. });
  143. });
  144. res.data.forEach((pEle, pIndex) => {
  145. pEle.fjls[0].forEach((cEle) => {
  146. WindSites[pIndex].children.push({
  147. id: cEle.wtId,
  148. wpId: cEle.wpId,
  149. text: cEle.wtnum,
  150. color: that.getColor(cEle.fjzt),
  151. });
  152. });
  153. });
  154. that.WindSites = WindSites;
  155. if (res.data.length) {
  156. that.wtId = that.wtId || res.data[0].fjls[0][0].wtId;
  157. that.getWtInfo();
  158. }
  159. },
  160. });
  161. },
  162. // 获取风机信息
  163. getWtInfo() {
  164. let that = this;
  165. that.API.requestData({
  166. method: "POST",
  167. subUrl: "monitorwt/findWtInfo",
  168. data: {
  169. wtId: that.wtId,
  170. },
  171. success(res) {
  172. let map = ['bjmap','fdjmap','clxmap','yymap','phmap','jcmap'];
  173. let data = res.data;
  174. for(var key in data){
  175. if(map.includes(key) && key.endsWith("map")){
  176. let json = data[key];
  177. let arrayai = [];
  178. let arraydi = [];
  179. for(var i = 0; i < json.length; i++){
  180. let obj = {
  181. name: json[i][0],
  182. unit: json[i][1],
  183. value: json[i][3]
  184. }
  185. if(json[i][2] == "ai") arrayai.push(obj);
  186. else arraydi.push(obj);
  187. }
  188. data[key] = {ai: arrayai, di: arraydi}
  189. }
  190. }
  191. that.sourceMap = data;
  192. that.getWarnInfo();
  193. },
  194. });
  195. },
  196. // 获取报警信息
  197. getWarnInfo() {
  198. let that = this;
  199. that.API.requestData({
  200. method: "POST",
  201. subUrl: "monitorwt/findWtWarnInfo",
  202. data: {
  203. wtId: that.wtId,
  204. },
  205. success(res) {
  206. that.WarnData = res.data;
  207. },
  208. });
  209. },
  210. // 点击左侧菜单
  211. clickMenu(res) {
  212. this.wtId = res.id;
  213. this.getWtInfo();
  214. },
  215. },
  216. created() {
  217. let that = this;
  218. that.wpId = that.$route.params.wpId;
  219. that.$nextTick(() => {
  220. that.requestData(false);
  221. that.timmer = setInterval(() => {
  222. that.requestData(false);
  223. }, that.$store.state.websocketTimeSec);
  224. });
  225. },
  226. unmounted() {
  227. clearInterval(this.timmer);
  228. this.timmer = null;
  229. },
  230. };
  231. </script>
  232. <style lang="less" scoped>
  233. .wind-site-info {
  234. display: flex;
  235. .sai {
  236. width: 70%;
  237. }
  238. .saig {
  239. position: absolute;
  240. width: 100%;
  241. bottom: 0;
  242. }
  243. .wind-site-menu {
  244. flex: 0 0 13.889vh;
  245. color: @gray;
  246. background: fade(@darkgray, 10);
  247. height: calc(100vh - 122px);
  248. .wind-site-title {
  249. font-size: 14px;
  250. font-weight: 600;
  251. padding: 16px;
  252. }
  253. }
  254. .wind-site-info-body {
  255. flex: auto;
  256. padding-left: 1.481vh;
  257. .info-menu {
  258. .info-menu-item {
  259. display: inline-block;
  260. border: 1px solid fade(@darkgray, 80);
  261. border-radius: 2px;
  262. color: @gray;
  263. font-size: @fontsize-s;
  264. letter-spacing: 1px;
  265. cursor: pointer;
  266. width: 85px;
  267. height: 30px;
  268. line-height: 30px;
  269. text-align: center;
  270. &.active {
  271. color: @white;
  272. background: fade(@purple, 60);
  273. border-color: fade(@purple, 60);
  274. }
  275. & + .info-menu-item {
  276. margin-left: 0.741vh;
  277. }
  278. }
  279. }
  280. }
  281. }
  282. </style>