onlineQuestion.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. <template>
  2. <div>
  3. <boxCom v-if="pageData" title="线上问题" :page-data="pageData" @change="tabChange">
  4. <!-- <div>线上问题:{{ active }}</div> -->
  5. <div class="echarts-wrapper">
  6. <div class="pie-wrapper">
  7. <div class="total-wrapper">
  8. 总数:<span class="total" @click.stop="reportBizName = ''">{{ tabData.total }}</span>
  9. </div>
  10. <div
  11. id="a_tylo_oo_2ppmn_ayghs"
  12. class="pir"
  13. style="width: 100%; height: 160px"
  14. />
  15. </div>
  16. <div class="detail-wrapper">
  17. <div v-if="tabData && pieData.length">
  18. <div class="fontWeight" style="margin-bottom: 10px;">{{ tabData.title }}</div>
  19. <div
  20. v-for="item in tabData.onlineProblemCopywriters.filter((elm) =>
  21. reportBizName ? elm.reportBizName === reportBizName : true
  22. )"
  23. :key="item.reportBizName"
  24. >
  25. <div v-if="item.problemDetails.length" class="fontWeight" style="margin-top: 5px">{{ item.reportBizName }}:{{ item.priorityStr }}</div>
  26. <div v-for="(pitem, pIndex) in item.problemDetails" :key="pIndex">
  27. <div class="fontWeight" style="color: #ED8F41;margin-top: 10px;">{{ pitem.subClientType }}</div>
  28. <div v-for="(dItem, dIndex) in pitem.details" :key="dIndex" style="padding-left: 10px">
  29. <div style="margin-top: 5px;">
  30. <span class="fontWeight">{{ dIndex + 1 }}、</span
  31. ><span class="fontWeight">{{ dItem.priority }}问题:</span
  32. >{{ dItem.problem }}
  33. </div>
  34. <div v-html="dItem.reason" />
  35. </div>
  36. </div>
  37. </div>
  38. </div>
  39. </div>
  40. <div v-if="!pieData.length" class="no-data">各业务线{{ active }}类线上问题为 <span style="font-size: 16px">0</span>!</div>
  41. </div>
  42. </boxCom>
  43. </div>
  44. </template>
  45. <script type="text/javascript">
  46. import { getOnlineProblemPieChart } from '@/api/qualityMonthlyReport/edit'
  47. import echarts from 'echarts'
  48. import boxCom from './box'
  49. export default {
  50. name: 'OnlineQuestion',
  51. components: {
  52. boxCom
  53. },
  54. data() {
  55. return {
  56. active: 'APP',
  57. myChart: null,
  58. pageData: null,
  59. tabData: null,
  60. reportBizName: null,
  61. option: null,
  62. pieData: []
  63. }
  64. },
  65. mounted() {
  66. this.init()
  67. // this.echartsInit()
  68. },
  69. methods: {
  70. async init() {
  71. const res = await getOnlineProblemPieChart(this.$route.query.reportId)
  72. this.pageData = res.data.map((elm) => {
  73. return {
  74. ...elm,
  75. onlineProblemCopywriters: elm.onlineProblemCopywriters.map((item) => {
  76. return {
  77. ...item,
  78. value: item.total,
  79. name: item.reportBizName
  80. }
  81. })
  82. }
  83. })
  84. this.active = this.pageData[0].clientType
  85. this.tabData = this.pageData[0]
  86. this.$nextTick(() => {
  87. this.echartsInit()
  88. })
  89. },
  90. echartsInit() {
  91. this.pieData = this.tabData.onlineProblemCopywriters.filter(elm => elm.total)
  92. this.option = {
  93. color: [
  94. '#5470c6',
  95. '#91cc75',
  96. '#fac858',
  97. '#ee6666',
  98. '#73c0de',
  99. '#3ba272',
  100. '#fc8452',
  101. '#9a60b4',
  102. '#ea7ccc'
  103. ],
  104. tooltip: {
  105. trigger: 'item'
  106. },
  107. label: {
  108. position: 'inner',
  109. fontSize: 12
  110. },
  111. series: [
  112. {
  113. // name: '访问来源',
  114. type: 'pie',
  115. radius: '80%',
  116. data: this.pieData,
  117. emphasis: {
  118. itemStyle: {
  119. shadowBlur: 0,
  120. shadowOffsetX: 0,
  121. shadowColor: 'rgba(0, 0, 0, 0.5)'
  122. }
  123. }
  124. }
  125. ]
  126. }
  127. // console.log(this.tabData)
  128. // 基于准备好的dom,初始化echarts实例
  129. this.myChart = echarts.init(
  130. document.getElementById('a_tylo_oo_2ppmn_ayghs')
  131. )
  132. // 绘制图表
  133. this.myChart.setOption(this.option)
  134. this.myChart.on('click', (params) => {
  135. this.reportBizName = params.data.name
  136. })
  137. },
  138. tabChange(value) {
  139. this.active = value
  140. this.reportBizName = ''
  141. this.tabData = this.pageData.filter(
  142. (elm) => elm.clientType === this.active
  143. )[0]
  144. console.log(this.tabData)
  145. console.log(this.tabData.onlineProblemCopywriters)
  146. this.pieData = this.tabData.onlineProblemCopywriters.filter(elm => elm.total)
  147. this.option.series[0].data = this.pieData
  148. this.myChart.setOption(this.option)
  149. }
  150. }
  151. }
  152. </script>
  153. <style scoped lang="less">
  154. .echarts-wrapper {
  155. margin-top: -10px;
  156. font-size: 12px;
  157. display: flex;
  158. color: #333;
  159. position: relative;
  160. // font-size: 14px;
  161. .pie-wrapper {
  162. width: 50%;
  163. .total-wrapper {
  164. color: #666;
  165. margin-top: 10px;
  166. .total {
  167. color: #409eff;
  168. font-size: 16px;
  169. cursor: pointer;
  170. }
  171. }
  172. }
  173. .detail-wrapper {
  174. width: 50%;
  175. padding: 0px 10px;
  176. height: 225px;
  177. margin-top: 20px;
  178. // margin-bottom: 10px;
  179. overflow-y: scroll;
  180. }
  181. .fontWeight {
  182. color: #333;
  183. font-weight: 500;
  184. }
  185. .no-data {
  186. top: 50%;
  187. left: 0;
  188. right: 0;
  189. text-align: center;
  190. position:absolute;
  191. }
  192. }
  193. </style>