123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198 |
- <template>
- <sd-echart :options="onepie" autoresize :class="$style.onepieClass" />
- </template>
- <script>
- import 'echarts/lib/chart/pie'
- import 'echarts/lib/component/legend'
- import 'echarts/lib/component/tooltip'
- import iamAuditDscService from '../iam-audit-dsc-service'
- import components from './_import-components/iam-audit-onepie-import'
- export default {
- name: 'IamAuditOnepie',
- metaInfo: {
- title: 'IamAuditOnepie',
- },
- components,
- props: {
- /**
- * 统计的组织ID
- */
- unidId: {
- type: Array,
- default: () => {
- return []
- },
- },
- /**
- * 统计的年份
- */
- planYear: {
- type: String,
- default: null,
- },
- },
- data() {
- return {
- leftactiveKey: '1',
- rightactiveKey: '1',
- onepie: {
- color: ['#bb7ec4', '#ffb74a', '#ff4a55', '#54c5eb', '#8675ff', '#dce0fa'],
- textStyle: {
- color: '#8a8a8a',
- fontSize: 13,
- },
- tooltip: {
- trigger: 'item',
- },
- legend: {
- orient: 'vertical',
- right: '150px',
- icon: 'circle',
- top: 50,
- textStyle: {
- color: '#8a8a8a',
- lineHeight: 18,
- },
- },
- series: [
- {
- type: 'pie',
- left: '-300px',
- top: 15,
- radius: [60, 90],
- data: [],
- avoidLabelOverlap: true,
- emphasis: {
- itemStyle: {
- shadowBlur: 10,
- shadowOffsetX: 0,
- shadowColor: 'rgba(0, 0, 0, 0.5)',
- },
- },
- label: {
- minMargin: 5,
- edgeDistance: 10,
- lineHeight: 15,
- padding: [0, -50],
- formatter: '{b}\n',
- },
- labelLine: {
- length2: '70px',
- },
- },
- ],
- },
- }
- },
- computed: {
- // 因为props传值不会自动更新,使用计算值
- selectYear() {
- return this.planYear
- },
- // 因为props传值不会自动更新,使用计算值
- selectUnidId() {
- if (this.unidId.length > 0) {
- return this.unidId[0].id
- } else {
- return null
- }
- },
- description() {
- if (!this.selectYear | !this.selectUnidId) {
- return '未选择年份以及审计机构'
- } else {
- return '暂无数据'
- }
- },
- },
- created() {
- // 获取项目总览
- this.getData()
- },
- methods: {
- getData() {
- // 获取项目总览
- const params = {
- unitId: this.selectUnidId,
- planYear: this.selectYear,
- }
- iamAuditDscService.getOverallResult(params).then((res) => {
- // { value: 1048, name: 'Search Engine' }
- // 准备
- this.onepie.series[0].data.push({
- value: parseFloat(res.data.PREPARE_NUM),
- name: '准备 ' + res.data.PREPARE_NUM,
- tooltip: {
- formatter: () => {
- return res.data.PREPARE_PERCENT
- },
- },
- })
- // 实施
- this.onepie.series[0].data.push({
- value: parseFloat(res.data.EXEC_NUM),
- name: '实施 ' + res.data.EXEC_NUM,
- tooltip: {
- formatter: () => {
- return res.data.EXEC_PERCENT
- },
- },
- })
- // 报告
- this.onepie.series[0].data.push({
- value: parseFloat(res.data.REPORT_NUM),
- name: '报告 ' + res.data.REPORT_NUM,
- tooltip: {
- formatter: () => {
- return res.data.REPORT_PERCENT
- },
- },
- })
- // 关闭
- this.onepie.series[0].data.push({
- value: parseFloat(res.data.CLOSED_NUM),
- name: '关闭 ' + res.data.CLOSED_NUM,
- tooltip: {
- formatter: () => {
- return res.data.CLOSED_PERCENT
- },
- },
- })
- // 归档
- this.onepie.series[0].data.push({
- value: parseFloat(res.data.ARCHIVE_NUM),
- name: '归档 ' + res.data.ARCHIVE_NUM,
- tooltip: {
- formatter: () => {
- return res.data.ARCHIVE_PERCENT
- },
- },
- })
- // 未启动
- this.onepie.series[0].data.push({
- value: parseFloat(res.data.TODO_NUM),
- name: '未启动 ' + res.data.TODO_NUM,
- tooltip: {
- formatter: () => {
- return res.data.TODO_PERCENT
- },
- },
- label: {
- padding: [0, -70],
- },
- })
- })
- },
- },
- }
- </script>
- <style module lang="scss">
- @use '@/common/design' as *;
- .onepie-class {
- width: 100%;
- height: 320px;
- }
- </style>
|