|
@@ -0,0 +1,111 @@
|
|
|
+<template>
|
|
|
+ <Card :title="title||'订单数据统计'">
|
|
|
+ <template #extra>
|
|
|
+ <condition @change="Search" @expor="expor" />
|
|
|
+ </template>
|
|
|
+ <div ref="chartRef" :style="{ height, width }"></div>
|
|
|
+ </Card>
|
|
|
+</template>
|
|
|
+<script lang="ts" setup>
|
|
|
+ import { basicProps } from './props';
|
|
|
+ import condition from './condition.vue';
|
|
|
+ import { Card, DatePicker } from 'ant-design-vue';
|
|
|
+ import { ref, Ref, watch, defineEmits } from 'vue';
|
|
|
+ import { useECharts } from '/@/hooks/web/useECharts';
|
|
|
+ const props = defineProps({
|
|
|
+ loading: Boolean,
|
|
|
+ ...basicProps,
|
|
|
+ });
|
|
|
+ const emit = defineEmits(["alertSome"])
|
|
|
+ const downOrderData = ref<number[]>([]);
|
|
|
+ const incrementOrderData = ref<number[]>([]);
|
|
|
+ const partsOrderData = ref<number[]>([]);
|
|
|
+ const yixStringData = ref<string[]>([]);
|
|
|
+ const echartTypr = ref('line')
|
|
|
+ const nameList = ref<string[]>(['下载订单','权益订单','配件订单']);
|
|
|
+ const maxSize = ref(0);
|
|
|
+ const chartRef = ref<HTMLDivElement | null>(null);
|
|
|
+ const { setOptions } = useECharts(chartRef as Ref<HTMLDivElement>)
|
|
|
+
|
|
|
+ function Search(val){
|
|
|
+ emit('change',val)
|
|
|
+ }
|
|
|
+ function expor(val){
|
|
|
+ emit('expor',val)
|
|
|
+ }
|
|
|
+ function handlesetOptions() {
|
|
|
+ console.log('handlesetOptions',downOrderData.value,partsOrderData.value,partsOrderData.value,yixStringData.value)
|
|
|
+ setOptions({
|
|
|
+ tooltip: {
|
|
|
+ trigger: 'axis',
|
|
|
+ axisPointer: {
|
|
|
+ lineStyle: {
|
|
|
+ width: 1,
|
|
|
+ color: '#019680',
|
|
|
+ },
|
|
|
+ },
|
|
|
+ },
|
|
|
+ legend: {
|
|
|
+ orient: 'horizontal',
|
|
|
+ bottom: 0,
|
|
|
+ },
|
|
|
+ // grid: { left: '2%', right: '2%', top: '10%', bottom: '10%', containLabel: true },
|
|
|
+ xAxis: {
|
|
|
+ type: 'category',
|
|
|
+ // data: [...new Array(30)].map((_item, index) => `${index + 1}日`),
|
|
|
+ data: yixStringData.value,
|
|
|
+ },
|
|
|
+ yAxis: {
|
|
|
+ type: 'value',
|
|
|
+ max: maxSize.value,
|
|
|
+ splitNumber: 4,
|
|
|
+ },
|
|
|
+ series: [
|
|
|
+ {
|
|
|
+ data: downOrderData.value,
|
|
|
+ type: echartTypr.value,
|
|
|
+ itemStyle: { color: '#38a0ff' },
|
|
|
+ barMaxWidth: 80,
|
|
|
+ name: nameList.value[0],
|
|
|
+ },
|
|
|
+ {
|
|
|
+ data: incrementOrderData.value,
|
|
|
+ type: echartTypr.value,
|
|
|
+ itemStyle: { color: '#4cca73' },
|
|
|
+ barMaxWidth: 80,
|
|
|
+ name: nameList.value[1],
|
|
|
+ },
|
|
|
+ {
|
|
|
+ data: partsOrderData.value,
|
|
|
+ type: echartTypr.value,
|
|
|
+ itemStyle: { color: '#FDD56A' },
|
|
|
+ barMaxWidth: 80,
|
|
|
+ name: nameList.value[2],
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ });
|
|
|
+ }
|
|
|
+ watch(
|
|
|
+ () => props.echartData,
|
|
|
+ (echartData) => {
|
|
|
+ downOrderData.value = echartData.downOrder ||[]
|
|
|
+ incrementOrderData.value = echartData.incrementOrder ||[]
|
|
|
+ partsOrderData.value = echartData.partOrder ||[]
|
|
|
+ yixStringData.value = echartData.xdata ||[]
|
|
|
+ if(echartData.nameList){
|
|
|
+ nameList.value = echartData.nameList
|
|
|
+ }
|
|
|
+ if(echartData.echartTypr){
|
|
|
+ echartTypr.value = echartData.echartTypr
|
|
|
+ }
|
|
|
+ const maxNumber = Math.max(...echartData.downOrder.concat(echartData.incrementOrder));
|
|
|
+ const pow = Math.pow(10, maxNumber.toString().length - 1);
|
|
|
+ maxSize.value = maxNumber > 10 ? Math.floor(maxNumber / 10) * 10 + pow * 2 : 10;
|
|
|
+ handlesetOptions();
|
|
|
+ },
|
|
|
+ {
|
|
|
+ immediate: true,
|
|
|
+ deep: true,
|
|
|
+ },
|
|
|
+ );
|
|
|
+</script>
|