123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206 |
- <template>
- <moduleEnclosure title="近30日订单金额趋势">
- <div class="all-container">
- <div id="orderEcharts2" style="width: 100%; height: 100%"></div>
- </div>
- </moduleEnclosure>
- </template>
- <script>
- import * as echarts from 'echarts';
- import moduleEnclosure from '@/components/moduleEnclosure.vue';
- import { getOrderTrend } from '@/api/bigView.js';
- import { csize } from '@/utils/const.js';
- export default {
- components: {
- moduleEnclosure,
- },
- data() {
- return {
-
- };
- },
- async mounted() {
- getOrderTrend().then(res => {
- this.initEcharts(res.data);
- })
- },
- beforeUnmount() {
-
- },
- methods: {
- getDate() {
- const today = new Date();
- const dates = [];
-
- for (let i = 0; i < 30; i++) {
- const d = new Date();
- d.setDate(today.getDate() - i);
- dates.unshift(d.toISOString().split('T')[0].slice(5, 11));
- }
-
- return dates;
- },
- initEcharts(data) {
- var chartDom = document.getElementById('orderEcharts2');
- var myChart = echarts.init(chartDom);
- var option;
- option = {
- title: {
- text: ''
- },
- tooltip: {
- confine: true,
- trigger: 'axis',
- transitionDuration: 0,
- backgroundColor: '#092a66',
- borderColor: '#0462b5',
- borderRadius: 8,
- borderWidth: 2,
- padding: [5, 10],
- axisPointer: {
- type: 'line',
- lineStyle: {
- type: 'dashed',
- color: '#8AB1DC',
- },
- },
- textStyle: {
- color: '#ffffff'
- }
- },
- legend: {
- icon: 'circle',
- itemWidth: 8,
- itemHeight: 8,
- itemGap: 10,
- top: '16',
- right: '10',
- textStyle: {
- color: '#A9BBCC'
- },
- data: ['新增销售金额', '新增辅材金额', '新增配件金额', '新增增值金额'],
-
- },
- grid: {
- x: csize(40),
- y: csize(40),
- x2: csize(20),
- y2: csize(20),
- },
- toolbox: {
- // feature: {
- // saveAsImage: {}
- // }
- },
- xAxis: {
- type: 'category',
- boundaryGap: false,
- axisLabel: {
- fontSize: csize(12),
- },
- axisLine: {
- lineStyle: {
- color: '#8AB1DC', // x轴文字颜色
- }
- },
- splitLine: {
- show: true,
- lineStyle: {
- color: '#364D95', // x轴辅助线颜色
- }
- },
- data: this.getDate()
- },
- yAxis: {
- type: 'value',
- name: "(元)",
- nameTextStyle: {
- color: "#aaa",
- nameLocation: "start",
- align: 'right'
- },
- axisLabel: {
- fontSize: csize(12),
- },
- axisLine: {
- lineStyle: {
- color: '#8AB1DC', // y轴文字颜色
- }
- },
- splitLine: {
- show: true,
- lineStyle: {
- color: '#364D95', // y轴辅助线颜色
- }
- }
- },
- series: [
- {
- name: '新增销售金额',
- type: 'line',
- stack: 'Total',
- itemStyle: {
- normal: {
- color: '#FDFE02',
- },
- },
- data: data.map(o => o.sxddje)
- },
- {
- name: '新增辅材金额',
- type: 'line',
- stack: 'Total',
- itemStyle: {
- normal: {
- color: '#44E28F',
- },
- },
- data: data.map(o => o.fcddje)
- },
- {
- name: '新增配件金额',
- type: 'line',
- stack: 'Total',
- itemStyle: {
- normal: {
- color: '#41C5E2',
- },
- },
- data: data.map(o => o.pjddje)
- },
- {
- name: '新增增值金额',
- type: 'line',
- stack: 'Total',
- itemStyle: {
- normal: {
- color: '#D73A79',
- },
- },
- data: data.map(o => o.zzddje)
- }
- ]
- };
- option && myChart.setOption(option);
- }
- },
- };
- </script>
- <style scoped lang="scss">
- .all-container {
- width: 100%;
- height: 100%;
- box-sizing: border-box;
- padding-top: 16px;
- }
- </style>
|