diff --git a/src/components/charts/pie-legend/index.js b/src/components/charts/pie-legend/index.js index 9c9d5e2..8d3e6a8 100644 --- a/src/components/charts/pie-legend/index.js +++ b/src/components/charts/pie-legend/index.js @@ -2,6 +2,9 @@ import * as echarts from 'echarts'; import elementResizeDetectorMaker from 'element-resize-detector'; export default { props: { + titleStr: { + + }, id: { type: String, default: 'pie' @@ -121,8 +124,8 @@ export default { }, }, { - text: "1000 万元", - left: "20%", + text: this.titleStr, + left: "22%", top: "50%", padding: [0, 0], textStyle: { @@ -152,13 +155,14 @@ export default { var itemvalue = 0 let index = 0 echartData.forEach((value, i, array) => { + total += value.value; if (value.name === params) { index = i itemvalue = value.value } }); - percent = ((itemvalue / total) * 100).toFixed(1); + percent = itemvalue === 0 ? 0 : ((itemvalue / total) * 100).toFixed(1); return ( '{blue|' + params + '}\n{hr|}' + '\n' + `{color${index}|` + percent + '%' + '}' + '' diff --git a/src/views/property/comps/left/middle/2/index.html b/src/views/property/comps/left/middle/2/index.html index 4821347..6223471 100644 --- a/src/views/property/comps/left/middle/2/index.html +++ b/src/views/property/comps/left/middle/2/index.html @@ -1,3 +1,8 @@ - - + + \ No newline at end of file diff --git a/src/views/property/comps/left/middle/2/index.js b/src/views/property/comps/left/middle/2/index.js index 8672d80..ed56a49 100644 --- a/src/views/property/comps/left/middle/2/index.js +++ b/src/views/property/comps/left/middle/2/index.js @@ -27,18 +27,26 @@ export default { data () { return { isLoad: false, + total: 0, data: [] }; }, methods: { getData () { if (this.year, this.deptId) { + this.total = 0 this.isLoad = false; debtCategoryAnalysis(this.deptId, this.year).then(res => { - console.log('debtCategoryAnalysis', res); - let data = res.data.map(item => { - return [item.name, item.resourceSort, item.resourceType, item.deptName] + // console.log('debtCategoryAnalysis', res); + let total = 0 + let data = res.data.list.map(item => { + total += item.value + return { + ...item, + unit: '万元' + } }) + this.total = total + '万元' this.data = data; this.isLoad = true; })