Health6.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455
  1. <template>
  2. <div class="health-6">
  3. <div class="header-info mg-b-16">
  4. <div class="selections">
  5. <div class="item" @click="tabSelect('1')" :class="{ active: type === '1' }">
  6. <i class="svg-icon svg-icon-sm">
  7. <svg-icon :svgid="'svg-wind-site'" />
  8. </i>
  9. <span>风场</span>
  10. </div>
  11. <div class="item" @click="tabSelect('2')" :class="{ active: type === '2' }">
  12. <i class="svg-icon svg-icon-sm">
  13. <svg-icon :svgid="'svg-h-project'" />
  14. </i>
  15. <span>项目</span>
  16. </div>
  17. </div>
  18. <div class="state" v-if="false">
  19. <div class="state-item green">
  20. <div class="dot "></div>
  21. <div class="text">良好数量:</div>
  22. <div class="value">999</div>
  23. </div>
  24. <div class="state-item purple">
  25. <div class="dot "></div>
  26. <div class="text">正常数量:</div>
  27. <div class="value">999</div>
  28. </div>
  29. <div class="state-item yellow">
  30. <div class="dot "></div>
  31. <div class="text">注意数量:</div>
  32. <div class="value">999</div>
  33. </div>
  34. <div class="state-item orange">
  35. <div class="dot "></div>
  36. <div class="text">严重数量:</div>
  37. <div class="value">999</div>
  38. </div>
  39. </div>
  40. </div>
  41. <row :type="'flex'" class="mg-b-16">
  42. <Col :span="12">
  43. <panel :title="'报警统计图'" :showLine="false">
  44. <dual-pie-chart :innerData="healPieData" :outerData="healPieData" :height="'250px'" />
  45. </panel>
  46. </Col>
  47. <Col :span="12">
  48. <panel :title="'故障统计图'" :showLine="false">
  49. <dual-pie-chart :innerData="stopPieData" :outerData="stopPieData" :height="'250px'" />
  50. </panel>
  51. </Col>
  52. <!-- <Col :span="16">
  53. <panel :title="'矩阵'" :showLine="false">
  54. <div class="matrix">
  55. <div class="item green">1号</div>
  56. <div class="item purple">2号</div>
  57. <div class="item orange">3号</div>
  58. <div class="item" v-for="index of 150" :key="index">{{ index + 3 }}号</div>
  59. <div class="blank" v-for="index of 30" :key="index"></div>
  60. </div>
  61. </panel>
  62. </Col> -->
  63. </row>
  64. <div class="mg-b-16">
  65. <panel :title="'健康状态占比'" :showLine="false">
  66. <bar-line-chart :bardata="barData" :lineData="[]" :height="'250px'" :pageSize="6" />
  67. </panel>
  68. </div>
  69. <div class="mg-b-16 curStyle">
  70. <panel :title="'健康趋势'" :showLine="false">
  71. <MultipleLineChart :list="statusData" :units="['']" :height="'250px'" />
  72. </panel>
  73. <div class="selections">
  74. <div class="item" @click="changeStatus('1')" :class="{ green: status === '1' }">
  75. 良好
  76. </div>
  77. <div class="item" @click="changeStatus('2')" :class="{ green: status === '2' }">
  78. 注意
  79. </div>
  80. </div>
  81. </div>
  82. </div>
  83. </template>
  84. <script>
  85. import BarLineChart from "../../components/chart/combination/bar-line-chart.vue";
  86. import MultipleLineChart from "../../components/chart/line/double-line-chart.vue";
  87. import DualPieChart from "../../components/chart/pie/dual-pie-chart.vue";
  88. import Col from "../../components/coms/grid/col.vue";
  89. import Row from "../../components/coms/grid/row.vue";
  90. import SvgIcon from "../../components/coms/icon/svg-icon.vue";
  91. import Panel from "../../components/coms/panel/panel.vue";
  92. export default {
  93. setup() {},
  94. components: { SvgIcon, Panel, MultipleLineChart, BarLineChart, Row, Col, DualPieChart },
  95. data() {
  96. return {
  97. type: "2",
  98. status: "1",
  99. healPieData: [],
  100. stopPieData: [],
  101. statusData: [],
  102. barData: {
  103. area: [],
  104. legend: [],
  105. data: [],
  106. },
  107. };
  108. },
  109. created() {
  110. this.requestData();
  111. },
  112. methods: {
  113. requestData() {
  114. this.getWpwarn();
  115. this.getStop();
  116. this.getWpOrProStatus();
  117. this.getStatus();
  118. },
  119. // 获取健康走势图
  120. getWpwarn() {
  121. let that = this;
  122. that.API.requestData({
  123. method: "POST",
  124. subUrl: "healthoperation/countWpwarn",
  125. data: {
  126. type: that.type,
  127. },
  128. success(res) {
  129. let healPieData = [];
  130. res.data.forEach((ele) => {
  131. healPieData.push({
  132. value: ele.value,
  133. unit: "次",
  134. name: ele.name,
  135. });
  136. });
  137. that.healPieData = healPieData;
  138. },
  139. });
  140. },
  141. // 获取故障统计图
  142. getStop() {
  143. let that = this;
  144. that.API.requestData({
  145. method: "POST",
  146. subUrl: "healthoperation/countStop",
  147. data: {
  148. type: that.type,
  149. },
  150. success(res) {
  151. let stopPieData = [];
  152. res.data.forEach((ele) => {
  153. stopPieData.push({
  154. value: ele.value,
  155. unit: "次",
  156. name: ele.name,
  157. });
  158. });
  159. that.stopPieData = stopPieData;
  160. },
  161. });
  162. },
  163. // 获取健康状态占比
  164. getWpOrProStatus() {
  165. let that = this;
  166. that.API.requestData({
  167. method: "POST",
  168. subUrl: "healthoperation/countWpOrProStatus",
  169. data: {
  170. type: that.type,
  171. },
  172. success(res) {
  173. let barData = {
  174. area: res.data.name,
  175. legend: ["良好数量", "正常数量", "注意数量", "严重数量"],
  176. data: [],
  177. };
  178. let length = res.data.name.length;
  179. for (let i = 0; i < length; i++) {
  180. barData.data.push([]);
  181. }
  182. for (let i = 0; i < length; i++) {
  183. barData.data[i].push(res.data.lhList[i]);
  184. barData.data[i].push(res.data.hgList[i]);
  185. barData.data[i].push(res.data.zyList[i]);
  186. barData.data[i].push(res.data.yzList[i]);
  187. }
  188. that.barData = barData;
  189. },
  190. });
  191. },
  192. // 获取健康状态
  193. getStatus() {
  194. let that = this;
  195. that.API.requestData({
  196. method: "POST",
  197. subUrl: "healthoperation/findWpOrProStatusForHistory",
  198. data: {
  199. type: that.type,
  200. status: that.status,
  201. },
  202. success(res) {
  203. let statusData = [];
  204. const time = res.data.time;
  205. for (let key in res.data) {
  206. if (key !== "name" && key !== "time") {
  207. let item = res.data[key];
  208. let statusItem = {
  209. title: res.data.name[0][key],
  210. smooth:true,
  211. value: [],
  212. };
  213. time.forEach((text, index) => {
  214. statusItem.value.push({
  215. text: text,
  216. value: item[index],
  217. });
  218. });
  219. statusData.push(statusItem);
  220. }
  221. }
  222. that.statusData = statusData;
  223. },
  224. });
  225. },
  226. tabSelect(type) {
  227. this.type = type;
  228. this.requestData();
  229. },
  230. changeStatus(status) {
  231. this.status = status;
  232. this.getStatus();
  233. },
  234. },
  235. };
  236. </script>
  237. <style lang="less">
  238. .health-6 {
  239. .curStyle {
  240. position: relative;
  241. .selections {
  242. position: absolute;
  243. display: flex;
  244. right: 0;
  245. top: 0;
  246. width: 50%;
  247. justify-content: flex-end;
  248. color: @gray;
  249. .item {
  250. margin-right: 15px;
  251. cursor: pointer;
  252. // flex: 0 0 80px;
  253. // text-align: center;
  254. // line-height: 33px;
  255. // margin-right: 8px;
  256. // color: @font-color;
  257. // font-size: @fontsize-s;
  258. // background: fade(@gray, 20);
  259. // border: 1px solid fade(@gray, 20);
  260. // display: flex;
  261. // justify-content: center;
  262. // align-items: center;
  263. // cursor: pointer;
  264. .green{
  265. color: @green;
  266. }
  267. &:hover,
  268. &.active {
  269. // background: fade(@green, 20);
  270. // border: 1px solid @green;
  271. color: @green;
  272. // cursor: pointer;
  273. i svg use {
  274. fill: @green;
  275. }
  276. }
  277. }
  278. }
  279. }
  280. .header-info {
  281. display: flex;
  282. .selections {
  283. display: flex;
  284. flex: 0 0 200px;
  285. .item {
  286. flex: 0 0 80px;
  287. text-align: center;
  288. height: 33px;
  289. line-height: 33px;
  290. margin-right: 8px;
  291. color: @font-color;
  292. font-size: @fontsize-s;
  293. background: fade(@gray, 20);
  294. border: 1px solid fade(@gray, 20);
  295. display: flex;
  296. justify-content: center;
  297. align-items: center;
  298. i {
  299. margin-right: 8px;
  300. svg use {
  301. fill: @gray;
  302. }
  303. }
  304. &:hover,
  305. &.active {
  306. background: fade(@green, 20);
  307. border: 1px solid @green;
  308. color: @green;
  309. cursor: pointer;
  310. i svg use {
  311. fill: @green;
  312. }
  313. }
  314. }
  315. }
  316. .state {
  317. display: flex;
  318. .state-item {
  319. display: flex;
  320. height: 32px;
  321. align-items: center;
  322. .dot {
  323. width: 8px;
  324. height: 8px;
  325. margin-right: 8px;
  326. }
  327. .text {
  328. margin-left: 8px;
  329. }
  330. .value {
  331. height: 32px;
  332. line-height: 32px;
  333. background: fade(@gray, 20);
  334. padding: 0 16px;
  335. }
  336. &.green {
  337. .dot {
  338. background: @green;
  339. }
  340. }
  341. &.purple {
  342. .dot {
  343. background: @purple;
  344. }
  345. }
  346. &.yellow {
  347. .dot {
  348. background: @yellow;
  349. }
  350. }
  351. &.orange {
  352. .dot {
  353. background: @orange;
  354. }
  355. }
  356. & + .state-item {
  357. margin-left: 16px;
  358. }
  359. }
  360. }
  361. }
  362. .matrix {
  363. display: flex;
  364. flex-wrap: wrap;
  365. .item {
  366. flex: 1 0 calc(100% / 20 - 4px);
  367. line-height: 26px;
  368. background: fade(@gray, 20);
  369. color: @gray-l;
  370. font-size: 12px;
  371. margin-bottom: 4px;
  372. text-align: center;
  373. border: 1px solid transparent;
  374. & + .item {
  375. margin-left: 4px;
  376. }
  377. &:nth-child(20n + 1) {
  378. margin-left: 0px;
  379. }
  380. &.green {
  381. color: @green;
  382. background: fade(@green, 20);
  383. border-color: @green;
  384. }
  385. &.purple {
  386. color: @purple;
  387. background: fade(@purple, 20);
  388. border-color: @purple;
  389. }
  390. &.orange {
  391. color: @orange;
  392. background: fade(@orange, 20);
  393. border-color: @orange;
  394. }
  395. &.red {
  396. color: @red;
  397. background: fade(@red, 20);
  398. border-color: @red;
  399. }
  400. }
  401. .blank {
  402. flex: 1 0 calc(100% / 20 - 4px);
  403. margin-left: 4px;
  404. }
  405. }
  406. }
  407. </style>