satisfactionJS.js 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. import { datasetTypeOptions } from '@/business/platform/data/constants/index'
  2. import echarts from 'echarts'
  3. const radius = window.innerWidth > 1600 ? '55%' : '45%'
  4. export default {
  5. data () {
  6. return {
  7. show1: true,
  8. show2: true,
  9. show3: true,
  10. show4: true
  11. }
  12. },
  13. created () {
  14. this.id = this.generalList[0].id_
  15. this.getManYiDuZiBiao(this.id)
  16. },
  17. methods: {
  18. getManYIDuPeiZhi () {
  19. const second = this.$store.getters.level.second
  20. return new Promise((resolve, reject) => {
  21. const sql = `select * from t_myddcpzb where di_dian_ = '${second}' order by create_time_ desc LIMIT 1`
  22. this.$common.request('sql', sql).then(res => {
  23. const { data = [] } = res.variables || {}
  24. if (data.length > 0) {
  25. const list = []
  26. list.push('1.' + data[0].pei_zhi_1_)
  27. list.push('2.' + data[0].pei_zhi_2_)
  28. list.push('3.' + data[0].pei_zhi_3_)
  29. list.push('4.' + data[0].pei_zhi_4_)
  30. list.push('5.' + data[0].pei_zhi_5_)
  31. resolve(list)
  32. } else {
  33. const list = ['1.服务态度', '2.检验服务能力', '3.检验报告及时性', '4.检验结果准确率', '5.工作规范性']
  34. resolve(list)
  35. }
  36. })
  37. })
  38. },
  39. getManYiDuZiBiao (id) {
  40. this.getManYIDuPeiZhi().then(resData => {
  41. const legendData = []
  42. resData.forEach(item => {
  43. const obj = {
  44. name: item
  45. }
  46. legendData.push(obj)
  47. })
  48. const sql = `select * from t_yhmyddctjzb where parent_id_ = '${id}' order by xu_hao_`
  49. this.$common.request('sql', sql).then((res) => {
  50. const { data = [] } = res.variables || {}
  51. if (data.length > 0) {
  52. const list = []
  53. const list1 = []
  54. const list2 = []
  55. const list3 = []
  56. const list4 = []
  57. const titleData = {
  58. title: '总计',
  59. color: '#ff6347'
  60. }
  61. const titleData1 = {
  62. title: '住院患者',
  63. color: '#00c16e'
  64. }
  65. const titleData2 = {
  66. title: '门诊患者',
  67. color: '#d20962'
  68. }
  69. const titleData3 = {
  70. title: '医务人员',
  71. color: '#0cb9c1'
  72. }
  73. const titleData4 = {
  74. title: '员工',
  75. color: '#7552cc'
  76. }
  77. data.forEach((item, index) => {
  78. const obj = {
  79. name: resData[index],
  80. value: item.xiao_ji_
  81. }
  82. list.push(obj)
  83. const obj1 = {
  84. name: resData[index],
  85. value: item.fen_shu_1_
  86. }
  87. list1.push(obj1)
  88. const obj2 = {
  89. name: resData[index],
  90. value: item.fen_shu_2_
  91. }
  92. list2.push(obj2)
  93. const obj3 = {
  94. name: resData[index],
  95. value: item.fen_shu_3_
  96. }
  97. list3.push(obj3)
  98. const obj4 = {
  99. name: resData[index],
  100. value: item.fen_shu_4_
  101. }
  102. list4.push(obj4)
  103. })
  104. const accept = echarts.init(this.$refs.Echart)
  105. accept.setOption(JSON.parse(JSON.stringify(this.barData(legendData, list, titleData))))
  106. this.show1 = list1.every(item => item.value !== '0')
  107. if (this.show1) {
  108. const accept1 = echarts.init(this.$refs.Echart1)
  109. accept1.setOption(JSON.parse(JSON.stringify(this.barData(legendData, list1, titleData1))))
  110. }
  111. this.show2 = list2.every(item => item.value !== '0')
  112. console.log(this.show2,list2)
  113. if (this.show2) {
  114. const accept2 = echarts.init(this.$refs.Echart2)
  115. accept2.setOption(JSON.parse(JSON.stringify(this.barData(legendData, list2, titleData2))))
  116. }
  117. this.show3 = list3.every(item => item.value !== '0')
  118. if (this.show3) {
  119. const accept3 = echarts.init(this.$refs.Echart3)
  120. accept3.setOption(JSON.parse(JSON.stringify(this.barData(legendData, list3, titleData3))))
  121. }
  122. this.show4 = list4.every(item => item.value !== '0')
  123. if (this.show4) {
  124. const accept4 = echarts.init(this.$refs.Echart4)
  125. accept4.setOption(JSON.parse(JSON.stringify(this.barData(legendData, list4, titleData4))))
  126. }
  127. } else {
  128. this.close()
  129. this.$message.error('统计的数据已经被清除,请检查数据是否被清除')
  130. }
  131. })
  132. })
  133. },
  134. barData (legendData, seriesData, titleData) {
  135. const barData = {
  136. title: {
  137. show: true,
  138. text: titleData.title,
  139. textStyle: {
  140. color: titleData.color,
  141. fontSize: 20,
  142. fontWeight: '600'
  143. },
  144. textAlign: 'center',
  145. left: '50%',
  146. top: '10px'
  147. },
  148. legend: {
  149. orient: 'horizontal',
  150. show: true,
  151. left: 'center',
  152. bottom: 10,
  153. z: 3,
  154. // itemWidth: 25,
  155. // itemHeight: 14,
  156. // itemGap: 10,
  157. data: legendData
  158. },
  159. series: [
  160. {
  161. name: '任务完成情况',
  162. stillShowZeroSum: false,
  163. type: 'pie',
  164. radius,
  165. center: ['50%', '50%'],
  166. data: seriesData,
  167. itemStyle: {
  168. emphasis: {
  169. shadowBlur: 10,
  170. shadowOffsetX: 0,
  171. shadowColor: 'rgba(0, 0, 0, 0.5)'
  172. },
  173. normal: {
  174. label: {
  175. show: true,
  176. position: 'outer',
  177. // formatter: `占比:{d}%\n\n\r{b}:{c}`,
  178. formatter: `{b}(分数):{c}\n占比:{d}%`,
  179. fontSize: 14
  180. },
  181. labelLine: {
  182. show: true
  183. }
  184. }
  185. },
  186. startAngle: 10
  187. }
  188. ],
  189. color: ['#f85a40',
  190. '#00c16e',
  191. '#d20962',
  192. '#0cb9c1',
  193. '#7552cc'],
  194. tooltip: {
  195. show: true,
  196. trigger: 'item',
  197. formatter: '评价内容<br/>{b}:{c}<br/>占比:{d}%'
  198. }
  199. }
  200. return barData
  201. }
  202. }
  203. }