Info.vue 8.1 KB

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