index.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380
  1. <!-- 危险源统计分析 -->
  2. <template>
  3. <div class="statisticalAnalysisOfHazardSources">
  4. <titleComponentsMin :propsData="propsData"></titleComponentsMin>
  5. <div class="statisticalAnalysisOfHazardSourcesPage">
  6. <div class="title-num-max-box">
  7. <div class="num-box">
  8. <p>全部危险源</p>
  9. <dv-digital-flop :config="hazardTotal" class="dvDigitalFlop"/>
  10. </div>
  11. <div class="num-box" style="margin-left:20px;">
  12. <p>今日新增</p>
  13. <dv-digital-flop :config="todayAdded" class="dvDigitalFlop"/>
  14. </div>
  15. </div>
  16. <div id="statisticalAnalysisOfHazardSourcesECharts"></div>
  17. </div>
  18. <!--<add-page :propsData="propsData" v-if="pageType === 2"></add-page>-->
  19. </div>
  20. </template>
  21. <script>
  22. const configData = {
  23. content: '{nt}',
  24. textAlign: 'center',
  25. style: {
  26. fill: '#fff',
  27. fontSize: 60,
  28. fontWeight: 700,
  29. fontFamily: 'YouSheBiaoTiHei',
  30. gradientColor: ['#fff', '#FFB31A'],
  31. gradientType: 'linear',//'linear' | 'radial'
  32. gradientWith: 'fill',//'stroke' | 'fill'
  33. gradientParams: [0, 0, 0, 80]
  34. }
  35. }
  36. import { chemicalStockHazardClassStatistics } from "@/api/index";
  37. import titleComponentsMin from '@/components/titleComponentsMin/index.vue'
  38. export default {
  39. name: 'index',
  40. components: {
  41. titleComponentsMin
  42. },
  43. data () {
  44. return {
  45. hazardTotal: {
  46. number: [0],
  47. content: configData.content,
  48. textAlign: configData.textAlign,
  49. style: configData.style
  50. },
  51. todayAdded: {
  52. number: [0],
  53. content: configData.content,
  54. textAlign: configData.textAlign,
  55. style: configData.style
  56. },
  57. //组件传参
  58. propsData: {
  59. title: '危险源统计分析'
  60. },
  61. //echarts数据
  62. echartsBox:null,
  63. // 定时器
  64. echartsTimer:null,
  65. }
  66. },
  67. created () {
  68. },
  69. mounted () {
  70. this.getList();
  71. this.timeFunction();
  72. },
  73. methods: {
  74. getList(){
  75. chemicalStockHazardClassStatistics().then(response => {
  76. this.$set(this, 'hazardTotal', {
  77. number: [response.data.hazardTotal],
  78. content: configData.content,
  79. textAlign: configData.textAlign,
  80. style: configData.style
  81. })
  82. this.$set(this, 'todayAdded', {
  83. number: [response.data.todayAdded],
  84. content: configData.content,
  85. textAlign: configData.textAlign,
  86. style: configData.style
  87. })
  88. let payload = {
  89. id: 'left-center-1',
  90. toolTip: false,
  91. data: {
  92. total: '',
  93. data: [],
  94. x: [],
  95. },
  96. };
  97. let num = 0;
  98. response.data.chemicalStockStatisticsVo.forEach((item)=>{
  99. if(item.chemicalNumber > 0){
  100. payload.data.x.push(item.chemicalCategory);
  101. payload.data.data.push(item.chemicalNumber);
  102. num = num + item.chemicalNumber
  103. }
  104. })
  105. payload.data.total = num;
  106. this.eChartsMethod(payload);
  107. })
  108. },
  109. eChartsMethod(payload){
  110. let data = [];
  111. const color = [
  112. "#43D0FF",
  113. "#E7D961",
  114. "#49A8FF",
  115. "#FF5B5B",
  116. "#FFAD69",
  117. "#37B028",
  118. "#6950a1",
  119. "#00a6ac",
  120. "#426ab3",
  121. "#f58220",
  122. "#005831",
  123. "#ea66a6",
  124. "#84bf96",
  125. ];
  126. payload.data.x.forEach((item, index) => {
  127. data.push({ value: payload.data.data[index], name: item, label: { color: color[index] } });
  128. });
  129. const tooltip = payload.toolTip !== undefined ? payload.toolTip : true;
  130. let countdata = payload.data.data.reduce((a, b) => Number(a) + Number(b));
  131. let option = {
  132. grid: {
  133. left: 0,
  134. right: 0,
  135. bottom: 0,
  136. top: 0,
  137. containLabel: true,
  138. },
  139. tooltip: {
  140. show: tooltip,
  141. backgroundColor: 'rgba(9, 30, 60, 0.6)',
  142. extraCssText: 'box-shadow: 0 0 8px rgba(0, 128, 255, 0.27) inset;',
  143. borderWidth: 0,
  144. confine: false,
  145. appendToBody: true,
  146. textStyle: {
  147. color: '#fff',
  148. fontSize: 30,
  149. },
  150. // 轴触发提示才有效
  151. axisPointer: {
  152. type: 'shadow',
  153. },
  154. shadowStyle: {
  155. color: 'rgba(157, 168, 245, 0.1)',
  156. },
  157. formatter: function (parms) {
  158. var str =
  159. // parms.seriesName + "</br>" +
  160. parms.marker + parms.name + " </br>" +
  161. "数量:" + parms.data.value + "</br>";
  162. // "占比:" + parms.percent + "%";
  163. return str;
  164. }
  165. },
  166. legend: {
  167. show: false,
  168. },
  169. series: [
  170. {
  171. name: payload.title,
  172. type: 'pie',
  173. roseType: "area", // 展示南丁格尔图
  174. radius: ['24%', '75%'],
  175. minAngle: 8,
  176. itemStyle: {
  177. color(params) {
  178. return color[params.dataIndex];
  179. },
  180. },
  181. labelLine: {
  182. // length2: 55,
  183. length: 40,
  184. length2: 240,
  185. lineStyle: {
  186. // type: "dashed",
  187. width: 2,
  188. },
  189. },
  190. label: {
  191. position: 'outer',
  192. alignTo: 'none',
  193. bleedMargin: 15,
  194. formatter: ' {a|{c}}\n{b|{b}}',
  195. padding: -85,
  196. rich: {
  197. a: {
  198. padding: [-20, 0, 5, 0],
  199. fontSize: 40,
  200. lineHeight: 40,
  201. color: '#fff',
  202. align:'center'
  203. },
  204. b: {
  205. padding: [50, 0, 5, 0],
  206. fontSize: 34,
  207. lineHeight: 34,
  208. color: '#fff',
  209. align:'center'
  210. },
  211. },
  212. },
  213. data,
  214. },
  215. {
  216. //内环
  217. type: "pie",
  218. radius: ["16%", "19%"],
  219. center: ["50%", "50%"],
  220. emphasis: {
  221. scale: false,
  222. },
  223. labelLine: {
  224. show: false,
  225. length: 30,
  226. length2: 55,
  227. },
  228. data: [
  229. {
  230. name: "",
  231. value: 0,
  232. itemStyle: {
  233. color: "#00B7FF",
  234. },
  235. tooltip: {
  236. show: false,
  237. },
  238. },
  239. ],
  240. },
  241. {
  242. type: "pie",
  243. radius: ["24%", "90%"],
  244. center: ["50%", "50%"],
  245. emphasis: {
  246. scale: false,
  247. },
  248. labelLine: {
  249. show: false,
  250. length: 30,
  251. length2: 55,
  252. },
  253. data: [
  254. {
  255. name: "",
  256. value: 0,
  257. itemStyle: {
  258. color: "rgba(0,183,255,0.1)",
  259. },
  260. tooltip: {
  261. show: false,
  262. },
  263. },
  264. ],
  265. },
  266. {
  267. type: "pie",
  268. radius: ["90%", "91%"],
  269. center: ["50%", "50%"],
  270. emphasis: {
  271. scale: false,
  272. },
  273. labelLine: {
  274. show: false,
  275. length: 30,
  276. length2: 55,
  277. },
  278. data: [
  279. {
  280. name: "",
  281. value: 0,
  282. itemStyle: {
  283. color: "rgba(0,183,255,0.8)",
  284. },
  285. tooltip: {
  286. show: false,
  287. },
  288. },
  289. ],
  290. },
  291. {
  292. type: "pie",
  293. radius: ["97%", "98%"],
  294. center: ["50%", "50%"],
  295. emphasis: {
  296. scale: false,
  297. },
  298. labelLine: {
  299. show: false,
  300. length: 30,
  301. length2: 55,
  302. },
  303. data: [
  304. {
  305. name: "",
  306. value: 0,
  307. itemStyle: {
  308. color: "rgba(0,183,255,0.8)",
  309. },
  310. tooltip: {
  311. show: false,
  312. },
  313. },
  314. ],
  315. },
  316. ],
  317. };
  318. this.echartsBox = this.$echarts.init(document.getElementById('statisticalAnalysisOfHazardSourcesECharts'));
  319. this.echartsBox.clear();
  320. this.echartsBox.setOption(option);
  321. },
  322. //时间定时器
  323. timeFunction(){
  324. let self = this;
  325. this.echartsTimer = window.setInterval(showTime, 180000);
  326. function showTime() {
  327. self.getList();
  328. }
  329. },
  330. },
  331. beforeDestroy() {
  332. //清除定时器
  333. window.clearInterval(this.echartsTimer);
  334. },
  335. destroyed() {
  336. //清除定时器
  337. window.clearInterval(this.echartsTimer);
  338. }
  339. }
  340. </script>
  341. <style scoped lang="scss">
  342. .statisticalAnalysisOfHazardSources{
  343. margin: 216px 0 0 0;
  344. .statisticalAnalysisOfHazardSourcesPage{
  345. width:1194px;
  346. height:792px;
  347. overflow: hidden;
  348. .title-num-max-box{
  349. margin-left:231px;
  350. margin-top:40px;
  351. display: flex;
  352. .num-box{
  353. display: flex;
  354. p{
  355. font-family: SOURCEHANSANSCN;
  356. color:#fff;
  357. padding:0 10px;
  358. font-size:40px;
  359. height:60px;
  360. line-height:60px;
  361. text-align: center;
  362. }
  363. .dvDigitalFlop{
  364. width:230px;
  365. height:60px;
  366. line-height:60px;
  367. }
  368. }
  369. }
  370. #statisticalAnalysisOfHazardSourcesECharts{
  371. margin-top:100px;
  372. width:1194px;
  373. height:500px;
  374. }
  375. }
  376. }
  377. </style>