statisticalAnalysisOfHazardSources.vue 10 KB

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