123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202 |
- <template>
- <span>
- <a-empty
- v-show="!hasData | !selectYear | !selectUnidId"
- :class="$style.empty"
- :description="description"
- ></a-empty>
- <sd-echart
- v-show="hasData && selectYear && selectUnidId"
- :class="$style.onepieClass"
- :options="chartData"
- autoresize
- />
- </span>
- </template>
- <script>
- import 'echarts/lib/chart/line'
- import 'echarts/lib/component/polar'
- import 'echarts/lib/component/legend'
- import 'echarts/lib/component/tooltip'
- import 'echarts/lib/component/title'
- import iamAuditDscService from '../iam-audit-dsc-service'
- import components from './_import-components/iam-audit-twopie-import'
- export default {
- name: 'IamAuditTwopie',
- metaInfo: {
- title: 'IamAuditOnepie',
- },
- components,
- props: {
- /**
- * 统计的组织ID
- */
- unidId: {
- type: Array,
- default: () => {
- return []
- },
- },
- /**
- * 统计的年份
- */
- planYear: {
- type: String,
- default: null,
- },
- },
- data() {
- return {
- hasData: false, // 是否检查出数据
- chartData: {
- tooltip: {
- trigger: 'axis',
- formatter: function(params) {
- let res = params[0].name
- for (var i = 0, l = params.length; i < l; i++) {
- const seriesId = JSON.parse(params[i].seriesId)
- res +=
- '<br/>' +
- params[i].marker +
- seriesId.NAME +
- ' ' +
- seriesId.TYPE_CN +
- ' : ' +
- params[i].value
- }
- return res
- },
- },
- legend: {
- type: 'scroll',
- data: [],
- bottom: 0,
- },
- grid: {
- left: 20,
- right: 20,
- bottom: 30,
- top: 30,
- containLabel: true,
- },
- toolbox: {
- feature: {
- saveAsImage: {},
- },
- },
- xAxis: {
- type: 'category',
- boundaryGap: false,
- data: [],
- },
- yAxis: {
- type: 'value',
- },
- series: [],
- },
- }
- },
- computed: {
- // 因为props传值不会自动更新,使用计算值
- selectYear() {
- return this.planYear
- },
- // 因为props传值不会自动更新,使用计算值
- selectUnidId() {
- if (this.unidId.length > 0) {
- return this.unidId[0].name
- } else {
- return null
- }
- },
- description() {
- if (!this.selectYear | !this.selectUnidId) {
- return '未选择年份以及审计机构'
- } else {
- return '暂无数据'
- }
- },
- },
- created() {
- // 获取项目总览
- this.getData()
- },
- methods: {
- getData() {
- // 如果没有选时间或组织机构,则直接返回
- if (!this.selectYear | !this.selectUnidId) {
- return
- }
- // 获取项目总览
- const columns = ['0_NAME', '0_TYPE_CN']
- for (let i = parseFloat(this.selectYear) - 2; i < parseFloat(this.selectYear) + 3; i++) {
- columns.push(i + '')
- }
- const params = {
- columns: columns.join(','),
- maxResults: 9999,
- startPosition: 0,
- expressions: [],
- dateStart: parseFloat(this.selectYear) - 2 + '',
- dateEnd: parseFloat(this.selectYear) + 2 + '',
- unitNames: "'" + this.selectUnidId + "'",
- pageIndex: 0,
- pageSize: 9999,
- unitIds: "'" + this.unidId[0].id + "'",
- }
- iamAuditDscService.getProjectTrends(params).then((res) => {
- if (res.data.data.length === 0) {
- return
- }
- this.hasData = true
- const chartData = {
- legend: [],
- xAxis: [],
- series: [],
- }
- let startYear = parseFloat(this.selectYear) - 2
- const endYear = parseFloat(this.selectYear) + 2
- while (startYear <= endYear) {
- chartData.xAxis.push(startYear.toString())
- startYear++
- }
- res.data.data.forEach((item, index) => {
- chartData.legend.push(item['0_TYPE_CN'])
- const seriesData = chartData.xAxis.map((year) => {
- return item[year] ? item[year] : 0
- })
- chartData.series.push({
- name: item['0_TYPE_CN'],
- type: 'line',
- stack: index,
- data: seriesData,
- id: JSON.stringify({
- NAME: item['0_NAME'],
- TYPE_CN: item['0_TYPE_CN'],
- TYPE: item['0_TYPE'],
- }),
- })
- })
- this.chartData.legend.data = chartData.legend
- this.chartData.xAxis.data = chartData.xAxis
- this.chartData.series = chartData.series
- })
- },
- },
- }
- </script>
- <style module lang="scss">
- @use '@/common/design' as *;
- .onepie-class {
- width: 100%;
- height: 300px;
- }
- .empty {
- padding-top: 80px;
- margin: 0;
- }
- </style>
|