s8sheBeiHeChaCol2.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  1. <template>
  2. <div @click="toDetailed()" class="statisticsPage" :style="{width:width}">
  3. <div :id="id" :style="{height:height}"/>
  4. <!-- 打开详情弹窗-->
  5. <div v-if="dialogOff">
  6. <dialogView
  7. :dialogOff = "dialogOff"
  8. @close = "close"
  9. :title="title"
  10. :data="data"
  11. />
  12. </div>
  13. </div>
  14. </template>
  15. <script>
  16. import echarts from 'echarts'
  17. import dialogView from '../properties/s8sheBeiHeChaPro.vue'
  18. import {GetPercent,GetMax} from '../js/config.js'
  19. export default {
  20. components:{
  21. dialogView
  22. },
  23. props: {
  24. data: {
  25. type: Object,
  26. },
  27. width:{
  28. type:String,
  29. default:"20%"
  30. },
  31. height:{
  32. type:String,
  33. default: window.screen.height/5+"px"
  34. },
  35. id:{
  36. type:String,
  37. default:"s8sheBeiHeCha"
  38. },
  39. click:{
  40. type:String,
  41. default:'true'
  42. },
  43. colorw:{
  44. type:String,
  45. default:'true'
  46. }
  47. },
  48. data () {
  49. return {
  50. title:'各个设备期间核查计划数量',
  51. dialogOff:false,
  52. }
  53. },
  54. mounted(){
  55. this.drawLine();
  56. },
  57. methods: {
  58. close(){
  59. this.dialogOff = false
  60. },
  61. /* 跳转统计页面*/
  62. toDetailed(){
  63. if(this.click == "true"){
  64. this.dialogOff = true
  65. }
  66. },
  67. drawLine(){
  68. let s8sheBeiHeCha = echarts.init(document.getElementById(this.id))
  69. // let beginInof = GetPercent(Number(this.data.t_sbhcjlbBegin.number),Number(this.data.t_sbhcjhBegin.number))
  70. // let endInof = GetPercent(Number(this.data.t_sbhcjlbEnd.number),Number(this.data.t_sbhcjhEnd.number))
  71. // let data1 = [];
  72. // data1.push(this.data.t_sbhcjhBegin.number);
  73. // data1.push(this.data.t_sbhcjhEnd.number);
  74. // let data2 = [];
  75. // data2.push(this.data.t_sbhcjlbBegin.number);
  76. // data2.push(this.data.t_sbhcjlbEnd.number);
  77. // let data3 = [];
  78. // data3.push(this.data.t_sbhcjlbBegin.date);
  79. // data3.push(this.data.t_sbhcjlbEnd.date);
  80. // let max1=GetMax(data1)+1;
  81. // let max2=GetMax(data2)+1;
  82. // let maxVal=max1>max2?max1:max2;
  83. // console.log("max1:",max1,"max2:",max2);
  84. let option = {
  85. //v3
  86. title: {
  87. text: this.title,
  88. textStyle:{ fontSize:14,color: this.colorw }
  89. // subtext: this.data.t_sbhcjlbNum.date+"年核查次数"
  90. },
  91. tooltip: {
  92. trigger: 'axis',
  93. axisPointer: {
  94. type: 'shadow'
  95. },
  96. formatter: function (datas) {
  97. console.log(datas)
  98. var res=datas[0].name+"<BR>"+'计划外核查:'+datas[0].data+"<BR>"
  99. res+='年度核查'+datas[1].data+"<BR>"
  100. // res+='百分比:'+(datas[1].value==null||datas[1].value==0?"0.00":(datas[0].value/datas[1].value*100).toFixed(2))+"%"
  101. return res
  102. }
  103. },
  104. legend: {},
  105. grid: {
  106. top: '10%',
  107. left: '3%',
  108. right: '4%',
  109. bottom: '5%',
  110. containLabel: true
  111. },
  112. xAxis: {
  113. type: 'value',
  114. boundaryGap: [0, 0.01]
  115. },
  116. yAxis: {
  117. type: 'category',
  118. data: this.data.t_sbhcjlbNum.name,
  119. axisLabel: {
  120. show: true, // 是否显示X轴的内容,不包含两端的文字
  121. interval: 0,
  122. // rotate: '50', // 旋转50°
  123. lineHeight: 18,
  124. // formatter: function(params) {
  125. // // console.log('formatter', params, params.length)
  126. // var newParamsName = ''// 最终拼接成的字符串
  127. // var paramsNameNumber = params.length// 实际标签的个数
  128. // var provideNumber = 3// 每行能显示的字的个数
  129. // // 判断标签的个数是否大于规定的个数, 如果大于,则进行换行处理 如果不大于,即等于或小于,就返回原标签
  130. // if (paramsNameNumber > provideNumber) {
  131. // // ********重点在这里********
  132. // newParamsName = params.substring(0, 3) + '..'// 最终拼成的字符串
  133. // } else { // 将旧标签的值赋给新标签
  134. // newParamsName = params
  135. // }
  136. // // 将最终的字符串返回
  137. // return newParamsName
  138. // }
  139. },
  140. },
  141. series: [
  142. {
  143. type: 'bar',
  144. data: this.data.t_sbhcjlbNum.number,
  145. label: {
  146. show: true,
  147. position: 'right'
  148. },
  149. itemStyle: {
  150. color: '#66CC00'
  151. },
  152. },
  153. {
  154. type: 'bar',
  155. data: this.data.t_sbhcjlbNum.numberAll,
  156. label: {
  157. show: true,
  158. position: 'right'
  159. },
  160. itemStyle: {
  161. color: '#FFCC00'
  162. },
  163. },
  164. ],
  165. dataZoom: [
  166. {
  167. id: 'dataZoomY',
  168. type: 'inside',
  169. yAxisIndex: [0],
  170. filterMode: 'empty'
  171. }
  172. ],
  173. //v1
  174. // grid: {
  175. // top: '20%',
  176. // left: '3%',
  177. // right: '4%',
  178. // bottom: '10%',
  179. // containLabel: true
  180. // },
  181. // tooltip: {
  182. // trigger: 'axis',
  183. // axisPointer: {
  184. // type: 'shadow'
  185. // },
  186. // formatter: function (datas) {
  187. // var res='计划:'+datas[0].value+"<BR>"
  188. // res+='记录:'+datas[1].value+"<BR>"
  189. // res+='百分比:'+(datas[0].value==null||datas[0].value==0?"0.00":(datas[1].value/datas[0].value*100).toFixed(2))+"%"
  190. // return res
  191. // }
  192. // },
  193. // title: {
  194. // text: this.title,
  195. // subtext: this.data.t_sbhcjlbBegin.date+"-"+this.data.t_sbhcjlbEnd.date+"年核查次数"
  196. // //subtext: this.data.t_sbhcjhBegin.date+'完成率为:' + beginInof +'\n'+this.data.t_sbhcjhEnd.date+'完成率为:'+endInof,
  197. // },
  198. // color: ['#003366', '#006699', '#4cabce', '#e5323e'],
  199. // legend: {
  200. // show:false
  201. // },
  202. // xAxis: [
  203. // {
  204. // type: 'category',
  205. // axisTick: {show: false},
  206. // data: data3
  207. // }
  208. // ],
  209. // yAxis: [
  210. // {
  211. // max:maxVal,
  212. // min:0,
  213. // type: 'value'
  214. // }
  215. // ]
  216. // ,
  217. // series: [
  218. // {
  219. // name: '计划条数',
  220. // type: 'bar',
  221. // barGap: 0,
  222. // data: data1
  223. // },
  224. // {
  225. // name: '记录条数',
  226. // type: 'bar',
  227. // barGap: 0,
  228. // data: data2
  229. // },
  230. // ]
  231. };
  232. option && s8sheBeiHeCha.setOption(option);
  233. }
  234. }
  235. }
  236. </script>
  237. <style scoped>
  238. #s8sheBeiHeCha:hover{
  239. transition: all 0.5s;
  240. transform:scale(1.03);
  241. }
  242. .statisticsPage{
  243. box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
  244. float: left;
  245. }
  246. </style>