MonthlyStatus.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  1. <template>
  2. <!-- 月度检测完成情况(环形图) -->
  3. <div class="monthlyStatus">
  4. <dv-border-box-7 backgroundColor="rgba(6, 30, 93, 0.5)" >
  5. <div class="monthlyStatus_title">
  6. <span class="monthlyStatus">月度检测情况统计</span>
  7. <el-date-picker
  8. class="chooseMonth"
  9. v-model="NowTime"
  10. type="month"
  11. @change="changeTime"
  12. format="yyyy-MM"
  13. value-format="yyyy-MM"
  14. placeholder="请选择时间">
  15. </el-date-picker>
  16. </div>
  17. <div class="monthlyStatus_content" ref="MonthlyStatus_refs"></div>
  18. </dv-border-box-7>
  19. </div>
  20. </template>
  21. <script>
  22. import curdPost from '@/business/platform/form/utils/custom/joinCURD.js'
  23. export default {
  24. props:{
  25. NowTime1:{
  26. type:String,
  27. default:""
  28. }
  29. },
  30. data(){
  31. return{
  32. monthlyStatus:null,
  33. NowTime:''
  34. }
  35. },
  36. created(){
  37. this.getNowTime()
  38. },
  39. watch: {
  40. NowTime1(newValue, oldValue) {
  41. // this.days.length=0
  42. this.getNowTime()
  43. }
  44. },
  45. mounted(){
  46. this.getCheckSampleData()
  47. },
  48. methods:{
  49. //页面进来显示当前时间
  50. getNowTime(){
  51. // const nowDate = new Date();
  52. // const date = {
  53. // year: nowDate.getFullYear(),
  54. // month: nowDate.getMonth() + 1,
  55. // }
  56. this.yearA = ''
  57. this.monthA = ''
  58. this.yearA = this.NowTime1.split('-')[0]
  59. this.monthA = Number(this.NowTime1.split('-')[1])>=10? Number(this.NowTime1.split('-')[1])+"":"0"+Number(this.NowTime1.split('-')[1])
  60. this.NowTime = this.yearA + '-' + this.monthA
  61. // console.log('页面第一次进来显示时间',date.year,date.month)
  62. //进来获取当前时间 之后获取当前月份天数 传给
  63. // console.log('页面显示的时间',this.NowTime) //2022-11
  64. //把页面第一次进来的 当前年度月份 传给该方法处理 得到day及days
  65. // this.getDaysInMonth(this.yearA,this.monthA)
  66. this.getCheckSampleData()
  67. },
  68. // getNowTime(){
  69. // const nowDate = new Date();
  70. // const date = {
  71. // year: nowDate.getFullYear(),
  72. // month: nowDate.getMonth() + 1,
  73. // }
  74. // this.NowTime = date.year + '-' + date.month
  75. // },
  76. //用户操作改变时间
  77. changeTime(e){
  78. // console.log('改变时间',e) //2022-07
  79. let year = e.slice(0,4)
  80. let month = e.slice(5,7)
  81. this.NowTime = year + '-' + month
  82. this.getCheckSampleData()
  83. },
  84. //查询函数
  85. getCheckSampleData(){
  86. let sql1 = "select yang_pin_bian_hao,DATE_FORMAT(create_time_,'%Y-%m-%d') AS detectionTime FROM t_mjjcbg WHERE yang_pin_bian_hao != '' AND create_time_ LIKE '"+this.NowTime+'%'+"' GROUP BY yang_pin_bian_hao"
  87. let sql2="select yang_pin_bian_hao,DATE_FORMAT(MIN(create_time_),'%Y-%m-%d') AS detectionTime FROM t_jchzb WHERE jian_ce_zhuang_ta != '已完成' AND yang_pin_bian_hao !='' AND create_time_ LIKE '"+this.NowTime+'%'+"' GROUP BY yang_pin_bian_hao"
  88. Promise.all([
  89. curdPost('sql', sql1),
  90. curdPost('sql', sql2),
  91. ]).then(([ res1, res2]) => {
  92. let data1 = res1.variables.data.length
  93. let data2 = res2.variables.data.length
  94. let data3 = data1+ data2
  95. console.log('hhhhhhhhhh',data1,data2,data3)
  96. this.enmonthlyStatusData(data1,data2,data3)
  97. })
  98. },
  99. //检测量统计图
  100. enmonthlyStatusData(data1,data2,data3){
  101. var monthlyStatus = this.$echarts.init(this.$refs.MonthlyStatus_refs);
  102. var monthlyStatusOption ={
  103. grid:{
  104. left:'',
  105. top:'0%',
  106. bottom:'0%',
  107. containLabel:true //?
  108. },
  109. title: {
  110. text: '检测任务总量',
  111. subtext: `${data3}`,
  112. // center: ["40%", "48%"],
  113. x: "50%", //X坐标
  114. y: "42%", //Y坐标
  115. // left:195,//慎用百分比(相对环形图宽度)
  116. // top: '160px',
  117. //主副标题之间的间距
  118. itemGap:10,
  119. textAlign:'center', //竖直居中对齐
  120. // textVerticalAlign:'auto',
  121. textStyle: { //标题样式
  122. fontSize: 18,
  123. fontWeight: "bolder", //bold??
  124. color: "#aaa",
  125. transform: "translate(-50%,-50%)",
  126. marginTop:"-50%",
  127. marginLeft:"-50%",
  128. },
  129. subtextStyle: { //副标题样式
  130. fontSize: 26,
  131. fontWeight: "bolder",
  132. color: "#333",
  133. formatter: '',
  134. marginTop:"-50%",
  135. marginLeft:"-50%",
  136. transfrom:"translate(-50%,-50%)",
  137. // align:'center'
  138. },
  139. },
  140. //鼠标滑过显示信息
  141. tooltip: {
  142. trigger: "item",
  143. formatter: '{d}%\n{b}',//
  144. },
  145. //图例的位置
  146. // legend: {
  147. // orient: 'vertical', //horizontal 水平排列
  148. // // left: 'right',
  149. // right:'10%',
  150. // bottom:'10%',
  151. // lineStyle:{
  152. // }
  153. // },
  154. series: [
  155. {
  156. name: 'Access From',
  157. type: 'pie',
  158. radius: ['40%', '70%'],
  159. center: ["50%", "48%"],//图表的位置 以圆心为基准 水平竖直位置
  160. avoidLabelOverlap: true,//是否启用防止标签重叠策略
  161. label: {
  162. show: true,
  163. formatter: " {b}\n {c} ({d}%)",
  164. // formatter: '{d}%\n{b}',// 显示百分比,
  165. position: 'outside',
  166. color:'#fff'
  167. },
  168. emphasis: {
  169. label: {
  170. show: true,
  171. fontSize: '40',
  172. fontWeight: 'bold'
  173. }
  174. },
  175. labelLine: {
  176. show: false
  177. },
  178. data: [
  179. { value: data1, name: '已检测' },
  180. { value: data2, name: '未检测' }
  181. ]
  182. }
  183. ]
  184. }
  185. monthlyStatus.setOption(monthlyStatusOption);
  186. },
  187. }
  188. }
  189. </script>
  190. <style lang="less" scoped>
  191. *body{
  192. padding: 0px;
  193. margin: 0px;
  194. }
  195. .monthlyStatus{
  196. width: 100%;
  197. height: 100%;
  198. #dv-border-box-7{
  199. background-size: 100% 100%;
  200. display: flex;
  201. flex-direction:column;
  202. align-content:space-between;
  203. }
  204. .monthlyStatus_title{
  205. width: 100%;
  206. height: 50px;
  207. position: relative;
  208. .monthlyStatus{
  209. line-height: 50px;
  210. position: absolute;
  211. left: 50%;
  212. top: 50%;
  213. margin-left: -60px;
  214. margin-top: -25px;
  215. color: '#fff';
  216. font-size:20px;
  217. font-weight:600;
  218. }
  219. .chooseMonth{
  220. display: none;
  221. width: 120px;
  222. line-height: 50px;
  223. margin-left: 10px;
  224. }
  225. }
  226. .monthlyStatus_content{
  227. width: 100%;
  228. height: calc(100% - 50px);
  229. }
  230. }
  231. </style>