temperature.vue 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393
  1. <template>
  2. <div class="MAXdiv">
  3. <div class="TopBox">
  4. <div class="rightdiv">
  5. <el-table
  6. ref="multipleTable"
  7. :data="tableData"
  8. tooltip-effect="dark"
  9. style="width: 100%"
  10. height="250"
  11. >
  12. <el-table-column prop="time_stamp" label="时间" align="center" />
  13. <el-table-column
  14. prop="temp_channel"
  15. label="部件名称"
  16. align="center"
  17. />
  18. <el-table-column prop="status" label="温度状态" align="center" />
  19. </el-table>
  20. <div class="fenye">
  21. <p><span>状态码说明:</span>0正常,1报警</p>
  22. <el-pagination
  23. @current-change="handleCurrentChange"
  24. :current-page="currentPage"
  25. layout="total, prev, pager, next, jumper"
  26. :total="totalCount"
  27. :page-size="500"
  28. />
  29. </div>
  30. </div>
  31. <div class="leftdiv">
  32. <div class="stateBox">
  33. <h4>温度状态</h4>
  34. <div class="state">
  35. <p :style="{ backgroundColor: getStatusColor('主轴承温度') }">
  36. 主轴承温度
  37. </p>
  38. <p :style="{ backgroundColor: getStatusColor('齿轮箱油温') }">
  39. 齿轮箱油温
  40. </p>
  41. <p
  42. :style="{
  43. backgroundColor: getStatusColor('发电机驱动端轴承温度'),
  44. }"
  45. >
  46. 发电机驱动端轴承温度
  47. </p>
  48. <p
  49. :style="{
  50. backgroundColor: getStatusColor('发电机非驱动端轴承温度'),
  51. }"
  52. >
  53. 发电机非驱动端轴承温度
  54. </p>
  55. </div>
  56. </div>
  57. <div class="Btn">
  58. <div style="height: 200px">
  59. <bing :result="result" />
  60. </div>
  61. <div class="minp">
  62. <p class="PText">
  63. <span><i class="color1"></i>正常</span>
  64. <span><i class="color2"></i>危险</span>
  65. </p>
  66. <h4>诊断步骤:</h4>
  67. <p>1、选择风场风机与起止时间,点击“查询”;</p>
  68. <p>2、点击“查询”输出最终温度状态结果。</p>
  69. </div>
  70. </div>
  71. </div>
  72. </div>
  73. <div class="bottomBox">
  74. <div class="tu" v-for="(item, index) in chartList" :key="index">
  75. <el-empty v-if="!hasData(item.data)" description="暂无数据" />
  76. <zhexian
  77. v-else
  78. :title="item.title"
  79. :lineType="item.lineType"
  80. :lineColor="item.lineColor"
  81. :chartData="item.data"
  82. />
  83. </div>
  84. </div>
  85. </div>
  86. </template>
  87. <script>
  88. import Eecharts from "./Eecharts.vue";
  89. import bing from "./bing.vue";
  90. import Zhexian from "./zhexian.vue";
  91. export default {
  92. components: { Eecharts, bing, Zhexian },
  93. props: {
  94. echartsdata: {
  95. type: Object,
  96. default: () => ({
  97. main_bearing: [],
  98. generator_drive_end: [],
  99. gearbox_oil: [],
  100. generator_nondrive_end: [],
  101. }),
  102. },
  103. codedata: {
  104. type: Array,
  105. default: () => [],
  106. },
  107. totalCount: {
  108. type: Number,
  109. default: 0,
  110. },
  111. totalPage: {
  112. type: Number,
  113. default: 0,
  114. },
  115. },
  116. data() {
  117. return {
  118. tableData: [],
  119. currentPage: 1,
  120. total: 1,
  121. result: {},
  122. bearingStateColors: {
  123. innerRing: "#80808057",
  124. outerRing: "#80808057",
  125. rollingElement: "#80808057",
  126. cage: "#80808057",
  127. },
  128. };
  129. },
  130. computed: {
  131. chartList() {
  132. const list = [
  133. {
  134. title: '主轴承温度趋势图',
  135. data: this.echartsdata.main_bearing,
  136. lineType: 'line',
  137. lineColor: '#02aae9',
  138. },
  139. {
  140. title: '发电机驱动端轴承温度趋势图',
  141. data: this.echartsdata.generator_drive_end,
  142. },
  143. {
  144. title: '齿轮箱油温趋势图',
  145. data: this.echartsdata.gearbox_oil,
  146. lineType: 'line',
  147. lineColor: '#02aae9',
  148. },
  149. {
  150. title: '发电机非驱动端轴承温度趋势图',
  151. data: this.echartsdata.generator_nondrive_end,
  152. },
  153. ]
  154. const sortedList = list.slice().sort((a, b) => {
  155. return this.hasData(b.data) - this.hasData(a.data)
  156. })
  157. console.log('排序后的图表列表:', sortedList.map(i => ({
  158. title: i.title,
  159. hasData: this.hasData(i.data),
  160. })))
  161. return sortedList
  162. }
  163. },
  164. watch: {
  165. codedata: {
  166. handler(newVal) {
  167. this.tableData = newVal;
  168. this.updateBearingStateColors();
  169. this.updateStatusCount(); // 统计调用
  170. },
  171. immediate: true,
  172. deep: true,
  173. },
  174. },
  175. methods: {
  176. updateBearingStateColors() {
  177. // 四个温度类型对应状态颜色key
  178. const statusMap = {
  179. 主轴承温度: "innerRing",
  180. 齿轮箱油温: "outerRing",
  181. 发电机驱动端轴承温度: "rollingElement", // 改成“驱动端”对应数据字段
  182. 发电机非驱动端轴承温度: "cage", // 改成“非驱动端”对应数据字段
  183. };
  184. // 颜色映射,正常绿,异常黄,无数据灰
  185. const colorMap = {
  186. normal: "#8ae359",
  187. danger: "#eecb5f",
  188. unknown: "#80808057",
  189. };
  190. const updatedColors = {};
  191. // 遍历四个温度类型,分别判断它们对应的tableData是否有异常或报警
  192. for (const [label, key] of Object.entries(statusMap)) {
  193. const items = this.tableData.filter(
  194. (item) => item.temp_channel === label
  195. );
  196. if (items.length === 0) {
  197. updatedColors[key] = colorMap.unknown; // 无数据,灰色
  198. } else {
  199. const hasDanger = items.some(
  200. (item) => item.status === "异常" || item.status === "危险"
  201. );
  202. updatedColors[key] = hasDanger ? colorMap.danger : colorMap.normal;
  203. }
  204. }
  205. // 合并更新状态颜色对象
  206. this.bearingStateColors = {
  207. ...this.bearingStateColors,
  208. ...updatedColors,
  209. };
  210. },
  211. updateStatusCount() {
  212. let normalCount = 0;
  213. let dangerCount = 0;
  214. this.tableData.forEach((item) => {
  215. if (item.status === "正常") {
  216. normalCount++;
  217. } else if (
  218. item.status === "异常" ||
  219. item.status === "危险" ||
  220. item.status === "报警"
  221. ) {
  222. dangerCount++;
  223. }
  224. });
  225. this.result = {
  226. normal: normalCount,
  227. danger: dangerCount,
  228. };
  229. },
  230. getStatusColor(tempName) {
  231. const map = {
  232. 主轴承温度: "innerRing",
  233. 齿轮箱油温: "outerRing",
  234. 发电机驱动端轴承温度: "rollingElement",
  235. 发电机非驱动端轴承温度: "cage",
  236. };
  237. // 根据tempName返回对应颜色
  238. return this.bearingStateColors[map[tempName]] || "#80808057";
  239. },
  240. hasData(data) {
  241. if (!data) return false;
  242. if (
  243. typeof data === "object" &&
  244. Array.isArray(data.timestamps) &&
  245. Array.isArray(data.values)
  246. ) {
  247. return data.timestamps.length > 0 || data.values.length > 0;
  248. }
  249. return false;
  250. },
  251. handleCurrentChange(val) {
  252. this.currentPage = val;
  253. this.$emit("updatePage", this.currentPage);
  254. },
  255. },
  256. };
  257. </script>
  258. <style lang="scss" scoped>
  259. h4 {
  260. margin-bottom: 5px;
  261. font-weight: 600;
  262. }
  263. .TopBox {
  264. height: 280px;
  265. display: flex;
  266. justify-content: space-around;
  267. .leftdiv {
  268. width: 50%;
  269. display: flex;
  270. justify-content: space-around;
  271. .stateBox {
  272. .state {
  273. display: flex;
  274. flex-direction: column;
  275. justify-content: center; /* 整体居中 */
  276. align-items: center;
  277. height: 200px;
  278. gap: 20px; /* 控制间距 */
  279. p {
  280. width: 200px;
  281. height: 40px;
  282. background: rgb(227, 227, 227);
  283. color: rgb(50, 50, 50);
  284. text-align: center;
  285. align-content: center;
  286. font-weight: 600;
  287. }
  288. }
  289. .btn-auto {
  290. margin-top: 10px;
  291. width: 100%;
  292. }
  293. }
  294. .Btn {
  295. width: 50%;
  296. display: flex;
  297. flex-direction: column; /* 垂直排列 */
  298. justify-content: space-between; /* 顶部和底部对齐 */
  299. min-height: 100px; /* 确保容器有足够高度 */
  300. margin: 10px 0;
  301. .PText {
  302. display: flex;
  303. justify-content: space-around;
  304. span {
  305. display: flex;
  306. align-items: center;
  307. i {
  308. width: 30px;
  309. height: 15px;
  310. margin-right: 5px;
  311. }
  312. .color1 {
  313. background-color: #8ae359;
  314. }
  315. .color2 {
  316. background-color: #eecb5f;
  317. }
  318. .color3 {
  319. background-color: #f7715f;
  320. }
  321. }
  322. }
  323. margin: 10px 0;
  324. .minp {
  325. font-size: 12px;
  326. margin-top: auto; /* 自动推到最底部 */
  327. }
  328. }
  329. }
  330. .rightdiv {
  331. width: 50%;
  332. .fenye {
  333. display: flex;
  334. //justify-content: center;
  335. justify-content: space-between;
  336. margin: 5px 0;
  337. font-size: 12px;
  338. line-height: 30px;
  339. span {
  340. font-weight: 600;
  341. }
  342. }
  343. }
  344. }
  345. .bottomBox {
  346. margin-top: 20px;
  347. display: flex;
  348. flex-wrap: wrap;
  349. justify-content: space-around;
  350. border: 1px solid rgb(231, 231, 231);
  351. padding: 10px;
  352. .tu {
  353. width: 49%;
  354. height: 350px;
  355. }
  356. }
  357. ::v-deep .el-table__cell {
  358. padding: 2px 0;
  359. font-size: 12px;
  360. }
  361. .MAXdiv {
  362. overflow: hidden;
  363. overflow-y: auto;
  364. height: 70vh;
  365. }
  366. </style>