Sfoglia il codice sorgente

fix property chart

张延森 6 anni fa
parent
commit
2a2714ef08

+ 1
- 0
VUECODE/smart-property-manage/package.json Vedi File

@@ -16,6 +16,7 @@
16 16
   "dependencies": {
17 17
     "add": "^2.0.6",
18 18
     "axios": "0.18.0",
19
+    "dayjs": "^1.8.14",
19 20
     "element-ui": "2.4.6",
20 21
     "file-saver": "^2.0.0-rc.4",
21 22
     "html2canvas": "^1.0.0-rc.1",

+ 108
- 0
VUECODE/smart-property-manage/src/components/chart/barChart.vue Vedi File

@@ -0,0 +1,108 @@
1
+<template>
2
+  <div :id="id"/>
3
+</template>
4
+
5
+<script>
6
+import G2 from "@antv/g2";
7
+
8
+export default {
9
+  name: 'BarChart',
10
+  props: [
11
+    'id',
12
+    'title',
13
+    'data',
14
+    'axisX',
15
+    'axisY'
16
+  ],
17
+  data () {
18
+    return {
19
+      chart: undefined,
20
+    }
21
+  },
22
+  mounted() {
23
+    this.rander();
24
+  },
25
+  watch: {
26
+    data() {
27
+      window.console.log(this.id, this.data)
28
+      this.rander()
29
+    }
30
+  },
31
+  methods: {
32
+    rander() {
33
+      const _self = this
34
+
35
+      if (this.chart) {
36
+        this.chart.clear();
37
+      } else {
38
+        this.chart = new G2.Chart({
39
+          container: _self.id,
40
+          forceFit: true,
41
+          height: 282,
42
+        padding: [80, 20, 30, 40]
43
+        });
44
+      }
45
+
46
+      const chart = this.chart;
47
+      chart.source(_self.data);
48
+
49
+
50
+      chart.axis("value", {
51
+        line: {
52
+          lineWidth: 1, // 设置线的宽度
53
+          stroke: "#a4b6c5" // 设置线的颜色
54
+        },
55
+        grid: null,
56
+        label: {
57
+          textStyle: {
58
+            textAlign: "end", // 文本对齐方向,可取值为: start middle end
59
+            fill: "#a4b6c5", // 文本的颜色
60
+            fontSize: "12", // 文本大小
61
+            textBaseline: "middle" // 文本基准线,可取 top middle bottom,默认为middle
62
+          }
63
+        }
64
+      });
65
+      chart.axis("item", {
66
+        line: {
67
+          lineWidth: 1, // 设置线的宽度
68
+          stroke: "#a4b6c5" // 设置线的颜色
69
+        },
70
+        grid: null,
71
+        label: {
72
+          textStyle: {
73
+            fill: "#a4b6c5", // 文本的颜色
74
+            fontSize: "12" // 文本大小
75
+          }
76
+        }
77
+      });
78
+      chart.tooltip({
79
+        crosshairs: true
80
+      });
81
+
82
+      chart.guide().html({
83
+        position: ["5%", "-35%"],
84
+        html: `<div class="line-chat"><p class="title">${_self.title}</p></div>`
85
+      });
86
+      chart.guide().html({
87
+        position: ["1%", "-22%"],
88
+        html: `<div class="line-chat"><p class="title">${_self.axisY}</p></div>`
89
+      });
90
+      chart.guide().html({
91
+        position: ["102%", "100%"],
92
+        html: `<div class="line-chat"><p class="title">${_self.axisX}</p></div>`
93
+      });
94
+
95
+      chart.render();
96
+    }
97
+  }
98
+};
99
+</script>
100
+<style lang="scss">
101
+.chart7-title {
102
+  .title {
103
+    font-size: 13px;
104
+    color: #a4b6c5;
105
+  }
106
+}
107
+</style>
108
+

+ 75
- 62
VUECODE/smart-property-manage/src/components/chart/chart1.vue Vedi File

@@ -5,82 +5,95 @@
5 5
 <script>
6 6
 import G2 from '@antv/g2'
7 7
 import DataSet from '@antv/data-set'
8
-import $ from 'jquery'
9 8
 
10
-export default {
9
+export default {  
10
+  props: [
11
+    'data',  // [ { item: '实例1', count: 210, percent: 0.21 } ]
12
+  ],
13
+  computed: {
14
+    total () {
15
+      return (this.data || []).reduce((acc, it) => (acc + it.count), 0) || 0
16
+    }
17
+  },
18
+  watch: {
19
+    data () {
20
+      this.rander()
21
+    }
22
+  },
11 23
   mounted() {
12 24
     this.rander()
13 25
   },
14 26
   methods: {
15 27
     rander() {
16
-      var data = [{
17
-        type: '未解决',
18
-        percent: 0.3
19
-      }, {
20
-        type: '已解决',
21
-        percent: 0.7
22
-      }]
23
-      var sum = 200
24
-      var ds = new DataSet()
25
-      var dv = ds.createView().source(data)
26
-      dv.transform({
27
-        type: 'map',
28
-        callback: function callback(row) {
29
-          row.value = parseInt(sum * row.percent)
30
-          return row
28
+      const _self = this
29
+      
30
+      if (this.chart) {
31
+        this.chart.clear();
32
+      } else {
33
+        this.chart = new G2.Chart({
34
+          container: 'node1',
35
+          forceFit: true,
36
+          height: 282,
37
+          animate: false,
38
+          padding: [40, 'auto', 'auto', 'auto']
39
+        });
40
+      }
41
+
42
+      var chart = this.chart
43
+
44
+      chart.source(_self.data, {
45
+        percent: {
46
+          formatter: function formatter(val) {
47
+            val = val * 100 + '%';
48
+            return val;
49
+          }
31 50
         }
32
-      })
33
-      var chart = new G2.Chart({
34
-        container: 'node1',
35
-        forceFit: true,
36
-        height: 282,
37
-        // height: window.innerHeight / 3 - 50,
38
-        padding: [30, 'auto', 'auto', 'auto']
39
-      })
40
-      chart.source(dv)
41
-      chart.tooltip(false)
42
-      // chart.legend({
43
-      //   position: 'right-center',
44
-      //   offsetX: -100
45
-      // })
51
+      });
52
+
46 53
       chart.coord('theta', {
47 54
         radius: 0.75,
48 55
         innerRadius: 0.6
49
-      })
50
-      chart.intervalStack().position('percent').color('type', ['#53F9FF', '#1A1E22']).opacity(1).label('percent', {
51
-        offset: -18,
52
-        textStyle: {
53
-          fill: 'white',
54
-          fontSize: 12,
55
-          shadowBlur: 2,
56
-          shadowColor: 'rgba(0, 0, 0, .45)'
57
-        },
58
-        rotate: 0,
59
-        autoRotate: false,
60
-        formatter: function formatter(text, item) {
61
-          return String(parseInt(item.point.percent * 100)) + '%'
62
-        }
63
-      })
56
+      });
57
+
58
+      chart.tooltip({
59
+        showTitle: false,
60
+        itemTpl: '<li><span style="background-color:{color};" class="g2-tooltip-marker"></span>{name}: {value}</li>'
61
+      });
62
+
63
+      chart.legend(false);
64
+
64 65
       chart.guide().html({
65
-        position: ['50%', '50%'],
66
-        html: '<div class="g2-guide-html"><p class="title">总计</p><p class="value">200</p></div>'
66
+        position: ['50%', '-15%'],
67
+        html: '<div class="chart2-title"><p class="title">历史工单</p></div>'
67 68
       })
69
+
70
+      // 辅助文本
68 71
       chart.guide().html({
69
-        position: ['50%', '-10%'],
70
-        html: '<div class="g2-guide-title"><p class="title">昨日工单解决情况200单</p></div>'
71
-      })
72
-      chart.on('interval:mouseenter', function(ev) {
73
-        var data = ev.data._origin
74
-        $('.g2-guide-html').css('opacity', 1)
75
-        $('.g2-guide-html .title').text(data.type)
76
-        $('.g2-guide-html .value').text(data.value)
77
-      })
72
+        position: ['50%', '50%'],
73
+        html: `<div style="color:#8c8c8c;font-size: 14px;text-align: center;width: 10em;">总计<br><span style="color:#8c8c8c;font-size:20px">${_self.total}</span>单</div>`,
74
+        alignX: 'middle',
75
+        alignY: 'middle'
76
+      });
78 77
 
79
-      chart.on('interval:mouseleave', function() {
80
-        $('.g2-guide-html .title').text('总计')
81
-        $('.g2-guide-html .value').text(200)
82
-      })
83
-      chart.render()
78
+      var interval = chart.intervalStack().position('percent').color('item').label('percent', {
79
+        formatter: function formatter(val, item) {
80
+          return item.point.item + ': ' + val;
81
+        },
82
+        textStyle: {
83
+          fill: '#a4b6c5', // 文本的颜色
84
+          fontSize: '12' // 文本大小
85
+        }
86
+      }).tooltip('item*percent', function(item, percent) {
87
+        // percent = percent * 100 + '%';
88
+        window.console.log('------>', _self.data, item)
89
+        return {
90
+          name: item,
91
+          value: _self.data.filter(({ item: it }) => (it == item))[0].count,
92
+        };
93
+      });
94
+
95
+      chart.render();
96
+      // interval.setSelected(this.data[0]);
84 97
     }
85 98
   }
86 99
 }

+ 24
- 35
VUECODE/smart-property-manage/src/components/chart/chart2.vue Vedi File

@@ -1,40 +1,35 @@
1 1
 <template>
2
-  <div id="node2"/>
2
+  <div id="node2" />
3 3
 </template>
4 4
 
5 5
 <script>
6 6
 import G2 from '@antv/g2'
7 7
 
8 8
 export default {
9
+  props: [
10
+    'data',
11
+  ],
9 12
   mounted() {
10 13
     this.rander()
11 14
   },
15
+  watch: {
16
+    data() {
17
+      this.rander()
18
+    }
19
+  },
12 20
   methods: {
13 21
     rander() {
14
-      var data = [{
15
-        item: '报修单一',
16
-        count: 40,
17
-        percent: 0.4
18
-      }, {
19
-        item: '报修单二',
20
-        count: 21,
21
-        percent: 0.21
22
-      }, {
23
-        item: '报修单三',
24
-        count: 17,
25
-        percent: 0.17
26
-      }, {
27
-        item: '报修单四',
28
-        count: 13,
29
-        percent: 0.13
30
-      }]
22
+
23
+      const _self = this
24
+
31 25
       var chart = new G2.Chart({
32 26
         container: 'node2',
33 27
         forceFit: true,
34 28
         height: 282,
35 29
         padding: [40, 'auto', 'auto', 'auto']
36 30
       })
37
-      chart.source(data, {
31
+
32
+      chart.source(this.data, {
38 33
         percent: {
39 34
           formatter: function formatter(val) {
40 35
             val = val * 100 + '%'
@@ -42,28 +37,24 @@ export default {
42 37
           }
43 38
         }
44 39
       })
40
+
45 41
       chart.coord('theta', {
46 42
         radius: 0.75
47 43
       })
44
+
48 45
       chart.guide().html({
49 46
         position: ['50%', '-15%'],
50 47
         html: '<div class="chart2-title"><p class="title">今日新增工单</p></div>'
51 48
       })
49
+
52 50
       chart.tooltip({
53 51
         showTitle: false,
54 52
         itemTpl: '<li><span style="background-color:{color}" class="g2-tooltip-marker"></span>{name}: {value}</li>'
55 53
       })
56
-      chart.intervalStack().position('percent').color('item', function(val) {
57
-        if (val === '报修单一') {
58
-          return '#53F9FF'
59
-        } else if (val === '报修单二') {
60
-          return '#83BB41'
61
-        } else if (val === '报修单三') {
62
-          return '#FFC400'
63
-        } else if (val === '报修单四') {
64
-          return '#454D54'
65
-        }
66
-      }).label('percent', {
54
+      
55
+      chart.legend(false);
56
+
57
+      chart.intervalStack().position('percent').color('item').label('percent', {
67 58
         formatter: function formatter(val, item) {
68 59
           return item._origin.item + ': ' + val
69 60
         },
@@ -72,15 +63,13 @@ export default {
72 63
           fontSize: '12' // 文本大小
73 64
         }
74 65
       }).tooltip('item*percent', function(item, percent) {
75
-        percent = percent * 100 + '%'
66
+        // percent = percent * 100 + '%'
76 67
         return {
77 68
           name: item,
78
-          value: percent
69
+          value: _self.data.filter(({ item: it }) => (it == item))[0].count,
79 70
         }
80
-      }).style({
81
-        lineWidth: 1,
82
-        stroke: '#fff'
83 71
       })
72
+
84 73
       chart.render()
85 74
     }
86 75
   }

+ 19
- 20
VUECODE/smart-property-manage/src/components/chart/chart4.vue Vedi File

@@ -7,32 +7,32 @@ import G2 from "@antv/g2";
7 7
 import DataSet from "@antv/data-set";
8 8
 
9 9
 export default {
10
+  props: [
11
+    'data',
12
+  ],
13
+  data () {
14
+    return {}
15
+  },
10 16
   mounted() {
11 17
     this.rander();
12 18
     console.log(this.invoicelist,"chart4")
13 19
   },
14
- props:['invoicelist'],
20
+  watch: {
21
+    data() {
22
+      this.rander()
23
+    }
24
+  },
15 25
   methods: {
16 26
     rander() {
17
-      var data = this.invoicelist;
18
-      var dv = new DataSet.View().source(data);
19 27
       var chart = new G2.Chart({
20 28
         container: "node4",
21 29
         forceFit: true,
22 30
         height: 282,
23 31
         padding: [80, 40, 30, 50]
24 32
       });
25
-      chart.source(dv, {
26
-        priceTotal: {
27
-          formatter: function formatter(val) {
28
-            return val;
29
-          }
30
-        },
31
-        createDate: {
32
-        }
33
-      });
33
+      chart.source(this.data);
34 34
 
35
-      chart.axis("priceTotal", {
35
+      chart.axis("value", {
36 36
         line: {
37 37
           lineWidth: 1, // 设置线的宽度
38 38
           stroke: "#a4b6c5" // 设置线的颜色
@@ -47,7 +47,7 @@ export default {
47 47
           }
48 48
         }
49 49
       });
50
-      chart.axis("createDate", {
50
+      chart.axis("day", {
51 51
         line: {
52 52
           lineWidth: 1, // 设置线的宽度
53 53
           stroke: "#a4b6c5" // 设置线的颜色
@@ -66,7 +66,7 @@ export default {
66 66
 
67 67
       chart
68 68
         .line()
69
-        .position("createDate*priceTotal")
69
+        .position("day*value")
70 70
         .color("priceTotal", function(val) {
71 71
           return "#83BB41";
72 72
         })
@@ -74,13 +74,12 @@ export default {
74 74
         .shape("smooth");
75 75
       chart
76 76
         .point()
77
-        .position("createDate*priceTotal")
77
+        .position("day*value")
78 78
         .size(3)
79 79
         .shape("circle")
80
-        .label(
81
-          "createDate*priceTotal",
82
-          function(createDate, priceTotal) {
83
-            return priceTotal;
80
+        .label("day*value",
81
+          function(day, value) {
82
+            return value;
84 83
           },
85 84
           {
86 85
             textStyle: {

+ 17
- 56
VUECODE/smart-property-manage/src/components/chart/chart5.vue Vedi File

@@ -1,72 +1,33 @@
1 1
 <template>
2
-  <div id="node5"/>
2
+  <div id="node5" />
3 3
 </template>
4 4
 
5 5
 <script>
6 6
 import G2 from "@antv/g2";
7 7
 import DataSet from "@antv/data-set";
8 8
 export default {
9
+  data () {
10
+    return {}
11
+  },
9 12
   mounted() {
10 13
     this.rander();
11
-     console.log(this.invoicelist,"chart4")
12 14
   },
13
-  props:['usercountList'],
15
+  props:['data'],
16
+  watch: {
17
+    data() {
18
+      this.rander();
19
+    }
20
+  },
14 21
   methods: {
15 22
     rander() {
16
-      var data = [
17
-        {
18
-          year: "11.17",
19
-          ACME: 300
20
-        },
21
-        {
22
-          year: "11.18",
23
-          ACME: 280
24
-        },
25
-        {
26
-          year: "11.19",
27
-          ACME: 320
28
-        },
29
-        {
30
-          year: "11.20",
31
-          ACME: 250
32
-        },
33
-        {
34
-          year: "11.21",
35
-          ACME: 310
36
-        },
37
-        {
38
-          year: "11.22",
39
-          ACME: 323
40
-        },
41
-        {
42
-          year: "11.23",
43
-          ACME: 350
44
-        }
45
-      ];
46
-      var dv = new DataSet.View().source(data);
47
-      dv.transform({
48
-        type: "fold",
49
-        fields: ["ACME"],
50
-        key: "type",
51
-        value: "value"
52
-      });
53 23
       var chart = new G2.Chart({
54 24
         container: "node5",
55 25
         forceFit: true,
56 26
         height: 282,
57 27
         padding: [80, 40, 30, 40]
58 28
       });
59
-      chart.source(dv, {
60
-        value: {
61
-          alias: "The Share Price in Dollars",
62
-          formatter: function formatter(val) {
63
-            return val;
64
-          }
65
-        },
66
-        year: {
67
-          // range: [0, 1]
68
-        }
69
-      });
29
+      chart.source(this.data);
30
+
70 31
       chart.axis("value", {
71 32
         line: {
72 33
           lineWidth: 1, // 设置线的宽度
@@ -82,7 +43,7 @@ export default {
82 43
           }
83 44
         }
84 45
       });
85
-      chart.axis("year", {
46
+      chart.axis("day", {
86 47
         line: {
87 48
           lineWidth: 1, // 设置线的宽度
88 49
           stroke: "#a4b6c5" // 设置线的颜色
@@ -102,7 +63,7 @@ export default {
102 63
 
103 64
       chart
104 65
         .line()
105
-        .position("year*value")
66
+        .position("day*value")
106 67
         .color("type", function(val) {
107 68
           return "#da70d6";
108 69
         })
@@ -110,12 +71,12 @@ export default {
110 71
         .shape("smooth");
111 72
       chart
112 73
         .point()
113
-        .position("year*value")
74
+        .position("day*value")
114 75
         .size(3)
115 76
         .shape("circle")
116 77
         .label(
117
-          "year*value",
118
-          function(year, value) {
78
+          "day*value",
79
+          function(day, value) {
119 80
             return value;
120 81
           },
121 82
           {

+ 136
- 0
VUECODE/smart-property-manage/src/components/chart/lineChart.vue Vedi File

@@ -0,0 +1,136 @@
1
+<template>
2
+  <div :id="id"/>
3
+</template>
4
+
5
+<script>
6
+import G2 from "@antv/g2";
7
+import DataSet from "@antv/data-set";
8
+
9
+export default {
10
+  name: 'LineChart',
11
+  props: [
12
+    'id',
13
+    'title',
14
+    'data',
15
+    'axisX',
16
+    'axisY'
17
+  ],
18
+  data () {
19
+    return {
20
+      chart: undefined,
21
+    }
22
+  },
23
+  mounted() {
24
+    this.rander();
25
+  },
26
+  watch: {
27
+    data() {
28
+      window.console.log(this.id, this.data)
29
+      this.rander()
30
+    }
31
+  },
32
+  methods: {
33
+    rander() {
34
+      const _self = this
35
+
36
+      if (this.chart) {
37
+        this.chart.clear();
38
+      } else {
39
+        this.chart = new G2.Chart({
40
+          container: _self.id,
41
+          forceFit: true,
42
+          height: 282,
43
+          padding: [80, 40, 30, 50]
44
+        });
45
+      }
46
+
47
+      const chart = this.chart;
48
+      chart.source(_self.data);
49
+
50
+      chart.axis("value", {
51
+        line: {
52
+          lineWidth: 1, // 设置线的宽度
53
+          stroke: "#a4b6c5" // 设置线的颜色
54
+        },
55
+        grid: null,
56
+        label: {
57
+          textStyle: {
58
+            textAlign: "end", // 文本对齐方向,可取值为: start middle end
59
+            fill: "#a4b6c5", // 文本的颜色
60
+            fontSize: "12", // 文本大小
61
+            textBaseline: "middle" // 文本基准线,可取 top middle bottom,默认为middle
62
+          }
63
+        }
64
+      });
65
+      chart.axis("item", {
66
+        line: {
67
+          lineWidth: 1, // 设置线的宽度
68
+          stroke: "#a4b6c5" // 设置线的颜色
69
+        },
70
+        grid: null,
71
+        label: {
72
+          textStyle: {
73
+            fill: "#a4b6c5", // 文本的颜色
74
+            fontSize: "12" // 文本大小
75
+          }
76
+        }
77
+      });
78
+      chart.tooltip({
79
+        crosshairs: true
80
+      });
81
+
82
+      chart
83
+        .line()
84
+        .position("item*value")
85
+        .color("value", () => '#83BB41')
86
+        .size(2)
87
+        .shape("smooth");
88
+      chart
89
+        .point()
90
+        .position("item*value")
91
+        .size(3)
92
+        .shape("circle")
93
+        .label("item*value",
94
+          function(item, value) {
95
+            return value;
96
+          },
97
+          {
98
+            textStyle: {
99
+              fill: "#fff",
100
+              fontSize: 12,
101
+              textAlign:'left',
102
+            }
103
+          }
104
+        )
105
+        .style({
106
+          fill: "#eee",
107
+          fontSize: 12,
108
+          stroke: "#83BB41",
109
+          lineWidth: 1
110
+        });
111
+      chart.guide().html({
112
+        position: ["5%", "-35%"],
113
+        html: `<div class="line-chat"><p class="title">${_self.title}</p></div>`
114
+      });
115
+      chart.guide().html({
116
+        position: ["1%", "-22%"],
117
+        html: `<div class="line-chat"><p class="title">${_self.axisY}</p></div>`
118
+      });
119
+      chart.guide().html({
120
+        position: ["102%", "100%"],
121
+        html: `<div class="line-chat"><p class="title">${_self.axisX}</p></div>`
122
+      });
123
+      chart.render();
124
+    }
125
+  }
126
+};
127
+</script>
128
+
129
+<style lang="scss">
130
+.line-chat {
131
+  .title {
132
+    font-size: 13px;
133
+    color: #a4b6c5;
134
+  }
135
+}
136
+</style>

+ 108
- 18
VUECODE/smart-property-manage/src/views/index/index.vue Vedi File

@@ -1,33 +1,31 @@
1 1
 <template>
2 2
   <div class="main">
3 3
     <div class="left">
4
-      <chart1/>
5
-      <chart2/>
4
+      <chart1 :data="data1" />
5
+      <chart2 :data="data2" />
6 6
       <chart3 :hardwaremap="hardwaremap"/>
7 7
     </div>
8 8
     <div class="middle">
9
-      <chart4 :invoicelist="invoicelist"/>
10
-      <chart5 :usercountlist="usercountlist"/>
11
-      <chart6 :temporarylist="temporarylist"/>
9
+      <line-chart id="chat4" :data="data4" title="收费组总缴费统计" axis-x="日期" axis-y="金额(元)" />
10
+      <line-chart id="chat5" :data="data5" title="月租车总缴费统计" axis-x="日期" axis-y="金额(元)" />
11
+      <line-chart id="chat6" :data="data6" title="临时车总缴费统计" axis-x="日期" axis-y="金额(元)" />
12 12
     </div>
13 13
     <div class="right">
14 14
       <chart7/>
15
-      <chart8/>
15
+      <line-chart id="chat8" :data="data8" title="日活跃用户" axis-x="日期" axis-y="数量(个)" />
16 16
       <chart9/>
17 17
     </div>
18 18
   </div>
19 19
 </template>
20 20
 
21 21
 <script>
22
+import dayjs from 'dayjs';
22 23
 import { mapState, mapActions } from "vuex";
23 24
 import chart1 from "@/components/chart/chart1.vue";
25
+import LineChart from "@/components/chart/lineChart.vue";
24 26
 import chart2 from "@/components/chart/chart2.vue";
25 27
 import chart3 from "@/components/chart/chart3.vue";
26
-import chart4 from "@/components/chart/chart4.vue";
27
-import chart5 from "@/components/chart/chart5.vue";
28
-import chart6 from "@/components/chart/chart6.vue";
29 28
 import chart7 from "@/components/chart/chart7.vue";
30
-import chart8 from "@/components/chart/chart8.vue";
31 29
 import chart9 from "@/components/chart/chart9.vue";
32 30
 
33 31
 export default {
@@ -43,17 +41,112 @@ export default {
43 41
     chart1,
44 42
     chart2,
45 43
     chart3,
46
-    chart4,
47
-    chart5,
48
-    chart6,
44
+    LineChart,
49 45
     chart7,
50
-    chart8,
51 46
     chart9
52 47
   },
53 48
   computed: {
54 49
     ...mapState("trunkIndex", {
55 50
       IndexInfo: item => item.trunkIndex.IndexInfo
56
-    })
51
+    }),
52
+    data1 () {
53
+      // 总单, 没有使用返回值
54
+      const { solvedTicket = 0, unsolvedTicket = 0 } = (this.IndexInfo || {}).historyMap || {}
55
+      const total = solvedTicket + unsolvedTicket
56
+
57
+      if (!total) return [ { item: '无数据', count: 1, percent: 1 } ]
58
+
59
+      const solvedPercent = Number(solvedTicket / total).toFixed(2) - 0
60
+
61
+      return [
62
+        {
63
+          item: '已解决',
64
+          count: solvedTicket,
65
+          percent: solvedPercent
66
+        },
67
+        {
68
+          item: '未解决',
69
+          count: unsolvedTicket,
70
+          percent: Number(1 - solvedPercent).toFixed(2) - 0
71
+        },
72
+      ]
73
+    },
74
+    data2 () {
75
+      // 总单, 没有使用返回值
76
+      let { todayComplaintTicket = 0, todayRepairTicket = 0, todayContactTicket = 0 } = (this.IndexInfo || {}).todayMap || {}
77
+      
78
+      if (process.env.NODE_ENV == 'development') {
79
+        todayComplaintTicket = 10
80
+        todayRepairTicket = 20
81
+        todayContactTicket = 30
82
+      }
83
+
84
+      const total = todayComplaintTicket + todayRepairTicket + todayContactTicket
85
+
86
+      if (!total) return [ { item: '无数据', count: 1, percent: 1 } ]
87
+
88
+      const p1 = Number(todayComplaintTicket / total).toFixed(2) - 0
89
+      const p2 = Number(todayRepairTicket / total).toFixed(2) - 0
90
+      const p3 = Number(1 - p1 - p2).toFixed(2) - 0
91
+
92
+      return [
93
+        {
94
+          item: '投诉',
95
+          count: todayComplaintTicket,
96
+          percent: p1
97
+        },
98
+        {
99
+          item: '报修',
100
+          count: todayRepairTicket,
101
+          percent: p2
102
+        },
103
+        {
104
+          item: '联系',
105
+          count: todayContactTicket,
106
+          percent: p3
107
+        },
108
+      ]
109
+    },
110
+    data4 () {
111
+      let billList = (this.IndexInfo || {}).billInvoiceCountList || []
112
+
113
+      return billList.map(({ createDate, priceTotal }) => {
114
+        return ({
115
+          item: dayjs(createDate).format('M.D'),
116
+          value: priceTotal,
117
+        })
118
+      })
119
+    },
120
+    data5 () {
121
+      let billList = (this.IndexInfo || {}).taUserLicenseCountList || []
122
+
123
+      return billList.map(({ createDate, priceTotal }) => {
124
+        return ({
125
+          item: dayjs(createDate).format('M.D'),
126
+          value: priceTotal,
127
+        })
128
+      })
129
+    },
130
+    data6 () {
131
+      let billList = (this.IndexInfo || {}).taTemporaryLicenseCountList || []
132
+
133
+      return billList.map(({ createDate, priceTotal }) => {
134
+        return ({
135
+          item: dayjs(createDate).format('M.D'),
136
+          value: priceTotal,
137
+        })
138
+      })
139
+    },
140
+    data8 () {
141
+      let billList = (this.IndexInfo || {}).taBriskUserList || []
142
+
143
+      return billList.map(({ createDate, briskCount }) => {
144
+        return ({
145
+          item: dayjs(createDate).format('M.D'),
146
+          value: briskCount,
147
+        })
148
+      })
149
+    },
57 150
   },
58 151
   methods: {
59 152
     ...mapActions("trunkIndex", ["getIndexCount"])
@@ -63,9 +156,6 @@ export default {
63 156
       console.log(this.IndexInfo);
64 157
 
65 158
       this.hardwaremap = this.IndexInfo.hardwareMap; //chart3
66
-      this.invoicelist = this.IndexInfo.billInvoiceCountList; //chart4
67
-      this.usercountlist = this.IndexInfo.taUserLicenseCountList; //chart5
68
-      this.temporarylist = this.IndexInfo.taTemporaryLicenseCountList; //chart6
69 159
     });
70 160
   }
71 161
 };