s9neiBuZhiLiangCol.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. <template>
  2. <!-- <div @click="toDetailed()" class="statisticsPage" :style="{width:width}"> -->
  3. <div class="statisticsPage" :style="{width:width}">
  4. <div :id="id" :style="{height:height}"/>
  5. <!-- 打开详情弹窗-->
  6. <div v-if="dialogOff">
  7. <dialogView
  8. :dialogOff = "dialogOff"
  9. @close = "close"
  10. :title="title"
  11. :data="data"
  12. />
  13. </div>
  14. </div>
  15. </template>
  16. <script>
  17. import echarts from 'echarts'
  18. import dialogView from '../properties/s9neiBuZhiLiangPro.vue'
  19. import {GetPercent,GetMax} from '../js/config.js'
  20. export default {
  21. components:{
  22. dialogView
  23. },
  24. props: {
  25. data: {
  26. type: Object,
  27. },
  28. width:{
  29. type:String,
  30. default:"20%"
  31. },
  32. height:{
  33. type:String,
  34. default: "100%"
  35. },
  36. id:{
  37. type:String,
  38. default:"s9neibufb"
  39. },
  40. click:{
  41. type:String,
  42. default:'true'
  43. },
  44. colorw:{
  45. type:String,
  46. default:'true'
  47. },
  48. direction:{
  49. type:String,
  50. default:'y'
  51. }
  52. },
  53. data () {
  54. return {
  55. title:'内部比对实验各部门完成率',
  56. dialogOff:false,
  57. measured:[]
  58. }
  59. },
  60. mounted(){
  61. this.drawLine();
  62. },
  63. methods: {
  64. close(){
  65. this.dialogOff = false
  66. },
  67. /* 跳转统计页面*/
  68. toDetailed(){
  69. if(this.click == "true"){
  70. this.dialogOff = true
  71. }
  72. },
  73. drawLine(){
  74. // let beginInof = Number(this.data.t_complaintBegin.number)
  75. // let endInof = Number(this.data.t_complaintEnd.number)
  76. let s9neibucol = echarts.init(document.getElementById(this.id))
  77. let option;
  78. let that = this
  79. let barColor = ['#00CCFF','#33FF00','#FF0000','#FFBF00','#097969','#FF66CC','#EC5800','#AAFF00','#F8DE7E','#B87333','#FF4433',' #9F2B68','#C9A9A6','#C3B1E1','#880808','#097969','#89CFF0','#5D3FD3',' #FBCEB1','#E49B0F','#ECFFDC','#A52A2A','#D27D2D','#FFBF00','#A0522D','#FF00FF','#FFB6C1','#F89880','#D8BFD8','#5D3FD3','#770737','#DA70D6']
  80. let barNum = []
  81. for (let i = 0; i < this.data.num.title.length-1; i++) {
  82. if(i==this.data.num.title.length-3){
  83. barNum.push({
  84. type: 'bar',
  85. itemStyle: {color: barColor[i]},
  86. label:{
  87. show: true,
  88. formatter:function(params){ //标签内容
  89. let str = that.direction=='x'?params.value[params.seriesName]+' '+params.data.chu+'%':params.data.chu+'%\n'+params.value[params.seriesName]
  90. return str
  91. },
  92. position: this.direction=='x'?'right':'top',
  93. textStyle:{
  94. fontSize:8,
  95. color:'#B0CEFC'
  96. }
  97. }
  98. })
  99. }else{
  100. barNum.push({
  101. type: 'bar',
  102. itemStyle: {color: barColor[i]},
  103. label:{
  104. normal:{
  105. show:true,
  106. position:this.direction=='x'?'right':'top',
  107. textStyle:{
  108. fontSize:8,
  109. color:'#B0CEFC'
  110. }
  111. }
  112. }
  113. })
  114. }
  115. }
  116. let heng = {
  117. splitLine:{show: false},
  118. type: 'category',
  119. axisLabel: {
  120. show: true,
  121. textStyle: {
  122. color: this.colorw //这里用参数代替了
  123. },
  124. fontSize: 8
  125. },
  126. axisLine:{
  127. lineStyle:{
  128. color:this.colorw,
  129. width:1, //x轴线的宽度
  130. }
  131. }
  132. }
  133. let zong = {
  134. splitLine:{show: false},
  135. axisLabel: {
  136. show: true,
  137. textStyle: {
  138. color: this.colorw //这里用参数代替了
  139. },
  140. fontSize: 8
  141. },
  142. axisLine:{
  143. lineStyle:{
  144. color:this.colorw,
  145. width:1, //x轴线的宽度
  146. }
  147. }
  148. }
  149. option = {
  150. title: {
  151. text: this.title,
  152. textStyle:{ fontSize:14,color: this.colorw }
  153. },
  154. legend: {
  155. textStyle: {
  156. fontSize: 8,
  157. color: '#B0CEFC' // 图例文字颜色
  158. },
  159. top:"5%",
  160. formatter: function (name) {
  161. if(name === 'wnum'){
  162. return '未完成数量';
  163. }else if(name === 'num'){
  164. return '已完成数量(完成率)';
  165. }else if(name === 'numA'){
  166. return '计划数量';
  167. }
  168. }
  169. },
  170. grid: {
  171. top: '15%',
  172. left: '3%',
  173. right: '4%',
  174. bottom: '5%',
  175. containLabel: true
  176. },
  177. xAxis: this.direction=='x'?zong:heng,
  178. yAxis: this.direction=='x'?heng:zong,
  179. dataset: {
  180. dimensions: this.data.num.title,
  181. source: this.data.num.number
  182. },
  183. series: barNum,
  184. dataZoom: [
  185. {
  186. id: 'dataZoomY',
  187. type: 'inside',
  188. yAxisIndex: [0],
  189. filterMode: 'empty'
  190. }
  191. ],
  192. };
  193. option && s9neibucol.setOption(option);
  194. }
  195. }
  196. }
  197. </script>
  198. <style scoped>
  199. #s9neibu:hover{
  200. transition: all 0.5s;
  201. transform:scale(1.03);
  202. }
  203. .statisticsPage{
  204. box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
  205. float: left;
  206. }
  207. </style>