Analysis.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660
  1. <template>
  2. <div class="index-container">
  3. <!-- 首行--运维 -->
  4. <div class="opera-container u-flex-jab">
  5. <router-link class="item f1 repair" v-for="(item, index) in operaContent" :key="index" :to="item.to">
  6. <div class="common-title u-flex">
  7. <span class="text">{{ item.title }}</span>
  8. </div>
  9. <div class="content u-flex-jab">
  10. <div class="tongji u-flex-cjac">
  11. <div class="number">{{ operaStatistics[item.incomplete] }} / <span class="number1">{{operaStatistics[item.completed]}}</span></div>
  12. <!-- <div class="number">{{ operaStatistics[item.incomplete] }}</div> -->
  13. <div class="text">{{ operaTitle[item.incompleteTitle] }} / {{operaTitle[item.completedTitle]}}</div>
  14. </div>
  15. <div class="legend f1 u-flex-jac">
  16. <a-icon :type="item.legend" :class="item.class" class="u-flex-jac"/>
  17. </div>
  18. </div>
  19. </router-link>
  20. </div>
  21. <!-- 消息通知+报警通知 -->
  22. <a-row :gutter="20" class="mt20 alarmandnotice">
  23. <a-col :span="14">
  24. <a-card class="box-card">
  25. <div class="u-flex-jab">
  26. <div class="common-title u-flex">
  27. <span class="text">报警通知</span>
  28. </div>
  29. <!-- <router-link to="/alarmManage/handleAlarm">
  30. <a-button style="float: right; padding: 3px 0" type="text">处理/查看</a-button>
  31. </router-link> -->
  32. </div>
  33. <a-table
  34. rowKey="id"
  35. size="middle"
  36. bordered
  37. :columns="alarmcolumns"
  38. :dataSource="alarmList"
  39. :pagination="false"
  40. >
  41. <template slot="htmlSlot" slot-scope="text">
  42. <div v-html="text"></div>
  43. </template>
  44. <template slot="imgSlot" slot-scope="text, record">
  45. <div style="font-size: 12px; font-style: italic">
  46. <span v-if="!text">无图片</span>
  47. <img v-else :src="getImgView(text)" :preview="record.id" alt="" style="max-width: 80px; height: 25px" />
  48. </div>
  49. </template>
  50. <template slot="fileSlot" slot-scope="text">
  51. <span v-if="!text" style="font-size: 12px; font-style: italic">无文件</span>
  52. <a-button v-else ghost type="primary" icon="download" size="small" @click="downloadFile(text)">
  53. <span>下载</span>
  54. </a-button>
  55. </template>
  56. </a-table>
  57. </a-card>
  58. </a-col>
  59. <a-col :span="10">
  60. <a-card class="box-card">
  61. <div class="u-flex-jab">
  62. <div class="common-title u-flex">
  63. <span class="text">消息通知</span>
  64. </div>
  65. <!-- <router-link to="/alarmManage/notice">
  66. <a-button style="float: right; padding: 3px 0" type="text">处理/查看</a-button>
  67. </router-link> -->
  68. </div>
  69. <a-table
  70. rowKey="id"
  71. size="middle"
  72. bordered
  73. :columns="noticecolumns"
  74. :dataSource="noticeList"
  75. :pagination="false"
  76. >
  77. <template slot="htmlSlot" slot-scope="text">
  78. <div v-html="text"></div>
  79. </template>
  80. <template slot="imgSlot" slot-scope="text, record">
  81. <div style="font-size: 12px; font-style: italic">
  82. <span v-if="!text">无图片</span>
  83. <img v-else :src="getImgView(text)" :preview="record.id" alt="" style="max-width: 80px; height: 25px" />
  84. </div>
  85. </template>
  86. <template slot="fileSlot" slot-scope="text">
  87. <span v-if="!text" style="font-size: 12px; font-style: italic">无文件</span>
  88. <a-button v-else ghost type="primary" icon="download" size="small" @click="downloadFile(text)">
  89. <span>下载</span>
  90. </a-button>
  91. </template>
  92. </a-table>
  93. </a-card>
  94. </a-col>
  95. </a-row>
  96. <a-row :gutter="20" class="mt20">
  97. <a-col :span="14">
  98. <div class="trend-charts" ref="elecCharts"></div>
  99. </a-col>
  100. <a-col :span="10">
  101. <div class="trend-charts" ref="envirCharts"></div>
  102. </a-col>
  103. </a-row>
  104. </div>
  105. </template>
  106. <script>
  107. import * as echarts from 'echarts'
  108. // import { listAlarmdata } from "@/api/alarm/alarmdata.js";
  109. // import { listNotice } from "@/api/system/notice";
  110. // import { firstload } from "@/api/homepage.js";
  111. // import { envirinfo } from "@/api/environSafe/hsmsstatistics.js";
  112. import { httpAction, getAction } from '@/api/manage'
  113. import { emsdata } from '../module_ems/energyAnalyse/emsdata';
  114. export default {
  115. name: 'Index',
  116. dicts: ['sys_alarm_type', 'sys_alarm_level', 'sys_notice_type'],
  117. data() {
  118. return {
  119. noticecolumns: [
  120. {
  121. title: '消息标题',
  122. align: 'center',
  123. dataIndex: 'noticeTitle',
  124. customRender: function (text) {
  125. return !text ? '' : text.length > 20 ? text.substr(0, 20) + "..." : text
  126. },
  127. },
  128. {
  129. title: '消息类型',
  130. align: 'center',
  131. dataIndex: 'noticeType',
  132. },
  133. {
  134. title: '生成时间',
  135. align: 'center',
  136. dataIndex: 'createTime',
  137. },
  138. ],
  139. alarmcolumns: [
  140. {
  141. title: '设备名称',
  142. align: 'center',
  143. dataIndex: 'equipmentname',
  144. },
  145. {
  146. title: '报警描述',
  147. align: 'center',
  148. dataIndex: 'remark',
  149. },
  150. {
  151. title: '报警类型',
  152. align: 'center',
  153. dataIndex: 'alarmtype',
  154. },
  155. {
  156. title: '报警时间',
  157. align: 'center',
  158. dataIndex: 'alarmtime',
  159. },
  160. ],
  161. // 运维统计前端绘制
  162. operaContent: [
  163. { type: 'repair', title: '设备当前运行数', completed: 'machineCompleted', completedTitle: 'machineCompleted', incomplete: 'machineIncomplete',
  164. incompleteTitle: 'machineIncomplete', legend: 'hdd', class: 'spotcheck', to: '/equipment/equipmentstatus' },
  165. // { type: 'repair', title: '未处理报警', completed: 'alarmCompleted', completedTitle: 'alarmCompleted', incomplete: 'alarmIncomplete',
  166. // incompleteTitle: 'alarmIncomplete', legend: 'a-icon-warning warning', to: '/alarmManage/handleAlarm' },
  167. { type: 'repair', title: '待维修任务', completed: 'repairCompleted', completedTitle: 'repairCompleted', incomplete: 'repairIncomplete',
  168. incompleteTitle: 'repairIncomplete', legend: 'setting', class: 'repair', to: '/cmms/repair/myRepair' },
  169. { type: 'repair', title: '待保养任务', completed: 'upkeepCompleted', completedTitle: 'upkeepCompleted', incomplete: 'upkeepIncomplete',
  170. incompleteTitle: 'upkeepIncomplete', legend: 'book', class: 'upkeep', to: '/cmms/upkeep/upkeep' },
  171. { type: 'repair', title: '待巡检任务', completed: 'inspectCompleted', completedTitle: 'inspectCompleted', incomplete: 'inspectIncomplete',
  172. incompleteTitle: 'inspectIncomplete', legend: 'interaction', class: 'inspect', to: '/cmms/inspect' },
  173. ],
  174. // 运维统计后端数据
  175. operaStatistics: {
  176. repairCompleted: '-',
  177. repairIncomplete: '-',
  178. upkeepCompleted: '-',
  179. upkeepIncomplete: '-',
  180. alarmCompleted: '-',
  181. alarmIncomplete: '-',
  182. inspectCompleted: '-',
  183. inspectIncomplete: '-',
  184. machineCompleted: '-',
  185. machineIncomplete: '-',
  186. },
  187. // 运维统计后端数据
  188. operaTitle: {
  189. repairCompleted: '总数',
  190. repairIncomplete: '今日数',
  191. upkeepCompleted: '总数',
  192. upkeepIncomplete: '今日数',
  193. alarmCompleted: '总数',
  194. alarmIncomplete: '今日数',
  195. inspectCompleted: '总数',
  196. inspectIncomplete: '今日数',
  197. machineCompleted: '总数',
  198. machineIncomplete: '运行数',
  199. },
  200. // 报警数据表格数据
  201. alarmList: [],
  202. // 消息数据表格数据
  203. noticeList: [],
  204. // 今日用电量
  205. TodayElectricity: [],
  206. // 环境温度
  207. EnvironmentTemp: [],
  208. temperatureData: [],
  209. //设备名称
  210. equipmentnames:[],
  211. //温度
  212. temps:[],
  213. //湿度
  214. humis:[],
  215. url: {
  216. list: "/homepate/statistics/firstload",
  217. },
  218. }
  219. },
  220. created() {
  221. },
  222. mounted() {
  223. this.$nextTick(() => {
  224. // 延迟绘制,否则echarts会超出父容器
  225. setTimeout(() => {
  226. this.getList();
  227. },1000);
  228. // this.getDemandanalysis()
  229. })
  230. // this.getAlarmList()
  231. // this.getNoticeList()
  232. var _this = this;
  233. setInterval(function () {
  234. // _this.getInfo();
  235. _this.getTest();
  236. }, 60000);
  237. },
  238. methods: {
  239. /** 首次打开加载整个页面 */
  240. getList() {
  241. // this.getInfo();
  242. this.getTest();
  243. },
  244. // 正式需要删除
  245. getTest() {
  246. if (emsdata.homedata.RepairSum != null) {
  247. this.operaStatistics.repairCompleted = emsdata.homedata.RepairSum[0].howManyTimes;
  248. this.operaStatistics.repairIncomplete = emsdata.homedata.RepairSum[1].howManyTimes;
  249. }
  250. if (emsdata.homedata.UpkeepSum != null) {
  251. this.operaStatistics.upkeepCompleted = emsdata.homedata.UpkeepSum[0].howManyTimes;
  252. this.operaStatistics.upkeepIncomplete = emsdata.homedata.UpkeepSum[1].howManyTimes;
  253. }
  254. if (emsdata.homedata.AlarmSum != null) {
  255. this.operaStatistics.alarmCompleted = emsdata.homedata.AlarmSum[0].howManyTimes;
  256. this.operaStatistics.alarmIncomplete = emsdata.homedata.AlarmSum[1].howManyTimes;
  257. }
  258. if (emsdata.homedata.InspeceSum != null) {
  259. this.operaStatistics.inspectCompleted = emsdata.homedata.InspeceSum[0].howManyTimes;
  260. this.operaStatistics.inspectIncomplete = emsdata.homedata.InspeceSum[1].howManyTimes;
  261. }
  262. if (emsdata.homedata.MachineSum != null) {
  263. this.operaStatistics.machineIncomplete = emsdata.homedata.MachineSum[1].howManyTimes;
  264. this.operaStatistics.machineCompleted = emsdata.homedata.MachineSum[4].howManyTimes;
  265. }
  266. this.TodayElectricity = emsdata.homedata.TodayElectricity;
  267. this.EnvironmentTemp = emsdata.homedata.EnvironmentTemp;
  268. this.alarmList = emsdata.homedata.alarmData;
  269. this.noticeList = emsdata.homedata.noticeData;
  270. this.temperatureData = emsdata.homedata.envirData;
  271. this.initEcharts();
  272. this.initTempAndHumiEcharts();
  273. },
  274. getInfo() {
  275. getAction(this.url.list, null).then((response) => {
  276. console.log(response.data)
  277. if (response.data.RepairSum != null) {
  278. this.operaStatistics.repairCompleted = response.data.RepairSum[0].howManyTimes;
  279. this.operaStatistics.repairIncomplete = response.data.RepairSum[1].howManyTimes;
  280. }
  281. if (response.data.UpkeepSum != null) {
  282. this.operaStatistics.upkeepCompleted = response.data.UpkeepSum[0].howManyTimes;
  283. this.operaStatistics.upkeepIncomplete = response.data.UpkeepSum[1].howManyTimes;
  284. }
  285. if (response.data.AlarmSum != null) {
  286. this.operaStatistics.alarmCompleted = response.data.AlarmSum[0].howManyTimes;
  287. this.operaStatistics.alarmIncomplete = response.data.AlarmSum[1].howManyTimes;
  288. }
  289. if (response.data.InspeceSum != null) {
  290. this.operaStatistics.inspectCompleted = response.data.InspeceSum[0].howManyTimes;
  291. this.operaStatistics.inspectIncomplete = response.data.InspeceSum[1].howManyTimes;
  292. }
  293. if (response.data.MachineSum != null) {
  294. this.operaStatistics.machineIncomplete = response.data.MachineSum[1].howManyTimes;
  295. this.operaStatistics.machineCompleted = response.data.MachineSum[4].howManyTimes;
  296. }
  297. this.TodayElectricity = response.data.TodayElectricity;
  298. this.EnvironmentTemp = response.data.EnvironmentTemp;
  299. this.initEcharts();
  300. });
  301. envirinfo().then((response) => {
  302. this.temperatureData = response.data;
  303. // console.log("--------start--------");
  304. // for(var i in this.temperatureData){
  305. // console.log("-->"+this.temperatureData[i].equipmentname+"--"+this.temperatureData[i].howManyTimes+"--"+this.temperatureData[i].howManyTimes2);
  306. // }
  307. // console.log("--------end----------");
  308. this.initTempAndHumiEcharts();
  309. });
  310. },
  311. /** 查询报警数据列表 */
  312. getAlarmList() {
  313. var queryParams = {
  314. pageNum: 1,
  315. pageSize: 5,
  316. status: '0',
  317. }
  318. listAlarmdata(queryParams).then((response) => {
  319. this.alarmList = response.rows;
  320. });
  321. },
  322. /** 查询消息列表 */
  323. getNoticeList() {
  324. var queryParams = {
  325. pageNum: 1,
  326. pageSize: 5,
  327. }
  328. listNotice(queryParams).then(response => {
  329. this.noticeList = response.rows;
  330. });
  331. },
  332. initEcharts(){
  333. var _this = this
  334. var chartDom = this.$refs.elecCharts
  335. var myChart = echarts.init(chartDom);
  336. var option;
  337. option = {
  338. tooltip: {
  339. trigger: 'axis',
  340. position: function (pt) {
  341. return [pt[0], '10%'];
  342. }
  343. },
  344. title: {
  345. left: 'center',
  346. text: '今日用电量'
  347. },
  348. // toolbox: {
  349. // feature: {
  350. // dataZoom: {
  351. // yAxisIndex: 'none'
  352. // },
  353. // restore: {},
  354. // saveAsImage: {}
  355. // }
  356. // },
  357. xAxis: {
  358. type: 'category',
  359. boundaryGap: false,
  360. data: this.TodayElectricity.hours
  361. },
  362. yAxis: {
  363. type: 'value',
  364. boundaryGap: [0, '100%']
  365. },
  366. dataZoom: [
  367. {
  368. type: 'inside',
  369. start: 0,
  370. end: 100
  371. },
  372. {
  373. start: 0,
  374. end: 10
  375. }
  376. ],
  377. series: [
  378. {
  379. name: '分时用电量',
  380. type: 'line',
  381. symbol: 'none',
  382. sampling: 'lttb',
  383. itemStyle: {
  384. color: 'rgb(255, 70, 131)'
  385. },
  386. areaStyle: {
  387. color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
  388. {
  389. offset: 0,
  390. color: 'rgb(255, 158, 68)'
  391. },
  392. {
  393. offset: 1,
  394. color: 'rgb(255, 70, 131)'
  395. }
  396. ])
  397. },
  398. data: this.TodayElectricity.elec
  399. }
  400. ]
  401. };
  402. option && myChart.setOption(option);
  403. window.addEventListener("resize",function (){
  404. myChart.resize();
  405. });
  406. },
  407. initTempAndHumiEcharts(){
  408. for(var i in this.temperatureData){
  409. console.log("-->"+this.temperatureData[i].equipmentname+"--"+this.temperatureData[i].howManyTimes+"--"+this.temperatureData[i].howManyTimes2);
  410. this.equipmentnames[i] = this.temperatureData[i].equipmentname;
  411. this.temps[i] = this.temperatureData[i].howManyTimes;
  412. this.humis[i] = this.temperatureData[i].howManyTimes2;
  413. }
  414. var _this = this
  415. var chartDom = this.$refs.envirCharts
  416. console.log("温湿度", this.$refs)
  417. console.log("温湿度1", this.$refs.envirCharts)
  418. console.log("温湿度2", this.$refs.elecCharts)
  419. var myChart = echarts.init(chartDom);
  420. var option;
  421. option = {
  422. tooltip: {
  423. trigger: 'axis',
  424. axisPointer: {
  425. type: 'cross',
  426. crossStyle: {
  427. color: '#999'
  428. }
  429. }
  430. },
  431. legend: {
  432. data: ['湿度', '温度']
  433. },
  434. xAxis: [
  435. {
  436. type: 'category',
  437. data: this.equipmentnames,
  438. axisPointer: {
  439. type: 'shadow'
  440. },
  441. axisLabel: {
  442. rotate: 45, // 设置刻度标签旋转角度为45度
  443. formatter: function(value) {
  444. if (value.length > 8) { // 当文本长度大于5时,截断并显示省略号
  445. return value.substring(0, 8) + '...';
  446. } else {
  447. return value;
  448. }
  449. },
  450. },
  451. }
  452. ],
  453. yAxis: [
  454. {
  455. type: 'value',
  456. name: '湿度',
  457. interval: 50,
  458. axisLabel: {
  459. formatter: '{value} %'
  460. }
  461. },
  462. {
  463. type: 'value',
  464. name: '温度',
  465. interval: 5,
  466. axisLabel: {
  467. formatter: '{value} °C'
  468. }
  469. }
  470. ],
  471. series: [
  472. {
  473. name: '湿度',
  474. type: 'bar',
  475. tooltip: {
  476. valueFormatter: function (value) {
  477. return value + ' %';
  478. }
  479. },
  480. data: this.humis
  481. },
  482. {
  483. name: '温度',
  484. type: 'line',
  485. yAxisIndex: 1,
  486. tooltip: {
  487. valueFormatter: function (value) {
  488. return value + ' °C';
  489. }
  490. },
  491. data: this.temps
  492. }
  493. ]
  494. };
  495. option && myChart.setOption(option);
  496. window.addEventListener("resize",function (){
  497. myChart.resize();
  498. });
  499. },
  500. }
  501. }
  502. </script>
  503. <style lang="less" scoped>
  504. @import '~@/assets/less/uStyle.less';
  505. </style>
  506. <style lang="less" scoped>
  507. .index-container {
  508. width: 100%;
  509. min-height: calc(100vh - 124px);
  510. .common-title{
  511. &::before{
  512. content: '';
  513. display: inline-block;
  514. width: 4px;
  515. height: 20px;
  516. background-image: linear-gradient(150deg, #5EB3F7, #6680F4);
  517. border-radius: 2px;
  518. }
  519. .text{
  520. padding-left: 8px;
  521. line-height: 20px;
  522. font-size: 14px;
  523. }
  524. }
  525. .opera-container{
  526. .item{
  527. padding: 16px 0 16px 20px;
  528. background: #fff;
  529. box-shadow: 0 2px 12px 0 rgba(48, 65, 86, 0.12);
  530. border-radius: 6px;
  531. margin-right: 12px;
  532. .content{
  533. padding: 20px 0 12px 10px;
  534. .tongji{
  535. .number{
  536. font-weight: bolder;
  537. font-size: 28px;
  538. color: #3ea9ff;
  539. font-family: '微软雅黑', serif;
  540. .number1{
  541. color: #ffb048;
  542. font-size: 30px;
  543. }
  544. }
  545. .text{
  546. font-size: 12px;
  547. margin-top: 4px;
  548. color: #737373;
  549. letter-spacing: 0.1em;
  550. }
  551. }
  552. .legend{
  553. // width: 50%;
  554. i{
  555. font-size: 2vw;
  556. border-radius: 100%;
  557. width: 60px;
  558. height: 60px;
  559. // text-align: center;
  560. // line-height: 60px;
  561. }
  562. .repair{
  563. color: #6680f4;
  564. background-image: linear-gradient(150deg, #5eb2f77c, #6680f47f);
  565. }
  566. .upkeep{
  567. color: #f9ba27;
  568. background-image: linear-gradient(150deg, #f7e55e76, #f9ba276b);
  569. }
  570. .spotcheck{
  571. color: #27b150;
  572. background-image: linear-gradient(150deg, #5ef78c72, #40cbe174);
  573. }
  574. .inspect{
  575. color: #e16b40;
  576. background-image: linear-gradient(150deg, #ffd3c372, #e16b406e);
  577. }
  578. .warning{
  579. color: #ff4949;
  580. background-image: linear-gradient(150deg, #eb7f7f77, #ff494979);
  581. }
  582. }
  583. }
  584. }
  585. .item:last-of-type{
  586. margin-right: 0;
  587. }
  588. }
  589. .box-card{
  590. .a-card__header{
  591. border: none;
  592. }
  593. .a-table th.a-table__cell.is-leaf, .a-table td.a-table__cell{
  594. border-right: none;
  595. }
  596. .a-table th.a-table__cell > .cell{
  597. color: #556485;
  598. // color: #648ff5;
  599. }
  600. .a-table .a-table__header-wrapper th, .a-table .a-table__fixed-header-wrapper th{
  601. background-color: #f2f7fd;
  602. // background-color: #e6f2ff;
  603. }
  604. }
  605. .trend-charts{
  606. width: 100%;
  607. min-height: calc(100vh - 18vh - 5.8vh - 84px - 58px - 57px - 50px);
  608. padding: 10px;
  609. margin-top: 10px;
  610. box-shadow: 0 2px 10px rgba(0,0,0,.1);
  611. background: #fff;
  612. border-radius: 4px;
  613. }
  614. .alarmandnotice{
  615. margin-top: 10px;
  616. }
  617. .ant-table-wrapper {
  618. margin-top: 10px;
  619. }
  620. }
  621. </style>