1
0

index.vue 12 KB

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