iam-audit-onepie.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. <template>
  2. <sd-echart :options="onepie" autoresize :class="$style.onepieClass" />
  3. </template>
  4. <script>
  5. import 'echarts/lib/chart/pie'
  6. import 'echarts/lib/component/legend'
  7. import 'echarts/lib/component/tooltip'
  8. import iamAuditDscService from '../iam-audit-dsc-service'
  9. import components from './_import-components/iam-audit-onepie-import'
  10. export default {
  11. name: 'IamAuditOnepie',
  12. metaInfo: {
  13. title: 'IamAuditOnepie',
  14. },
  15. components,
  16. props: {
  17. /**
  18. * 统计的组织ID
  19. */
  20. unidId: {
  21. type: Array,
  22. default: () => {
  23. return []
  24. },
  25. },
  26. /**
  27. * 统计的年份
  28. */
  29. planYear: {
  30. type: String,
  31. default: null,
  32. },
  33. },
  34. data() {
  35. return {
  36. leftactiveKey: '1',
  37. rightactiveKey: '1',
  38. onepie: {
  39. color: ['#bb7ec4', '#ffb74a', '#ff4a55', '#54c5eb', '#8675ff', '#dce0fa'],
  40. textStyle: {
  41. color: '#8a8a8a',
  42. fontSize: 13,
  43. },
  44. tooltip: {
  45. trigger: 'item',
  46. },
  47. legend: {
  48. orient: 'vertical',
  49. right: '150px',
  50. icon: 'circle',
  51. top: 50,
  52. textStyle: {
  53. color: '#8a8a8a',
  54. lineHeight: 18,
  55. },
  56. },
  57. series: [
  58. {
  59. type: 'pie',
  60. left: '-300px',
  61. top: 15,
  62. radius: [60, 90],
  63. data: [],
  64. avoidLabelOverlap: true,
  65. emphasis: {
  66. itemStyle: {
  67. shadowBlur: 10,
  68. shadowOffsetX: 0,
  69. shadowColor: 'rgba(0, 0, 0, 0.5)',
  70. },
  71. },
  72. label: {
  73. minMargin: 5,
  74. edgeDistance: 10,
  75. lineHeight: 15,
  76. padding: [0, -50],
  77. formatter: '{b}\n',
  78. },
  79. labelLine: {
  80. length2: '70px',
  81. },
  82. },
  83. ],
  84. },
  85. }
  86. },
  87. computed: {
  88. // 因为props传值不会自动更新,使用计算值
  89. selectYear() {
  90. return this.planYear
  91. },
  92. // 因为props传值不会自动更新,使用计算值
  93. selectUnidId() {
  94. if (this.unidId.length > 0) {
  95. return this.unidId[0].id
  96. } else {
  97. return null
  98. }
  99. },
  100. description() {
  101. if (!this.selectYear | !this.selectUnidId) {
  102. return '未选择年份以及审计机构'
  103. } else {
  104. return '暂无数据'
  105. }
  106. },
  107. },
  108. created() {
  109. // 获取项目总览
  110. this.getData()
  111. },
  112. methods: {
  113. getData() {
  114. // 获取项目总览
  115. const params = {
  116. unitId: this.selectUnidId,
  117. planYear: this.selectYear,
  118. }
  119. iamAuditDscService.getOverallResult(params).then((res) => {
  120. // { value: 1048, name: 'Search Engine' }
  121. // 准备
  122. this.onepie.series[0].data.push({
  123. value: parseFloat(res.data.PREPARE_NUM),
  124. name: '准备 ' + res.data.PREPARE_NUM,
  125. tooltip: {
  126. formatter: () => {
  127. return res.data.PREPARE_PERCENT
  128. },
  129. },
  130. })
  131. // 实施
  132. this.onepie.series[0].data.push({
  133. value: parseFloat(res.data.EXEC_NUM),
  134. name: '实施 ' + res.data.EXEC_NUM,
  135. tooltip: {
  136. formatter: () => {
  137. return res.data.EXEC_PERCENT
  138. },
  139. },
  140. })
  141. // 报告
  142. this.onepie.series[0].data.push({
  143. value: parseFloat(res.data.REPORT_NUM),
  144. name: '报告 ' + res.data.REPORT_NUM,
  145. tooltip: {
  146. formatter: () => {
  147. return res.data.REPORT_PERCENT
  148. },
  149. },
  150. })
  151. // 关闭
  152. this.onepie.series[0].data.push({
  153. value: parseFloat(res.data.CLOSED_NUM),
  154. name: '关闭 ' + res.data.CLOSED_NUM,
  155. tooltip: {
  156. formatter: () => {
  157. return res.data.CLOSED_PERCENT
  158. },
  159. },
  160. })
  161. // 归档
  162. this.onepie.series[0].data.push({
  163. value: parseFloat(res.data.ARCHIVE_NUM),
  164. name: '归档 ' + res.data.ARCHIVE_NUM,
  165. tooltip: {
  166. formatter: () => {
  167. return res.data.ARCHIVE_PERCENT
  168. },
  169. },
  170. })
  171. // 未启动
  172. this.onepie.series[0].data.push({
  173. value: parseFloat(res.data.TODO_NUM),
  174. name: '未启动 ' + res.data.TODO_NUM,
  175. tooltip: {
  176. formatter: () => {
  177. return res.data.TODO_PERCENT
  178. },
  179. },
  180. label: {
  181. padding: [0, -70],
  182. },
  183. })
  184. })
  185. },
  186. },
  187. }
  188. </script>
  189. <style module lang="scss">
  190. @use '@/common/design' as *;
  191. .onepie-class {
  192. width: 100%;
  193. height: 320px;
  194. }
  195. </style>