yangyin
2024-11-20 190529c5038e81b2f5539d3ee9738274e7a63637
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
        <title>客户情况</title>
        <script src="/customer_list/ch/ai_html/views/demo/js/tailwind.js"></script>
        <script src="/customer_list/ch/ai_html/views/demo/js/vue.global.js"></script>
        <script src="/customer_list/ch/ai_html/views/demo/js/iframe-resizer/child-5.1.5.js" async></script>
        <script src="/customer_list/ch/ai_html/views/demo/js/index.full.js"></script>
        <script src="/customer_list/ch/ai_html/views/demo/js/customInstruction.js"></script>
        <link href="/customer_list/ch/static/fonts/iconfont/iconfont.css" rel="stylesheet" type="text/css" />
        <link href="/customer_list/ch/ai_html/views/demo/css/ele-index.css" rel="stylesheet" type="text/css" />
        <script src="/customer_list/ch/ai_html/views/demo/js/echarts.min.js"></script>
    </head>
 
    <body>
        <div class="w-full h-full bg-[#f2f4f8] px-[5px] py-[5px]" id="customerSituation">
            <div class="bg-[rgb(242,244,248)] space-y-1">
                <div v-resize="chartContainerResize" class="w-full h-full">
                    <div class="flex space-x-4 bg-white">
                        <div class="min-w-[300px] h-[320px] w-full">
                            <div class="text-[16px] my-5 text-center">新区服务部客户情况</div>
 
                            <div class="flex-row text-center grid grid-cols-3">
                                <div v-for="(item,index) in state.CustomerSituationList" :key="item.ID">
                                    <div class="text-[16px] text-[#000] ml-[10px] w-[200px]">{{ item.Name }}</div>
                                    <div class="text-[16px] text-[#000] ml-[10px] w-[200px] mb-[10px]">{{ item.Value }}户</div>
                                </div>
                            </div>
                        </div>
                        <div class="w-full h-[320px]" id="customerSituationBarChart"></div>
                    </div>
                </div>
            </div>
        </div>
    </body>
    <script>
        const { createApp, onMounted, ref, reactive } = Vue;
        const customerSituationBarChartDomRef = ref(null);
 
        const App = createApp({
            setup() {
                let state = reactive({
                    CustomerSituationList: [
                        {
                            ID: 1,
                            Name: '直营终端',
                            Value: 3,
                        },
                        {
                            ID: 2,
                            Name: '合作终端',
                            Value: 13,
                        },
                        {
                            ID: 3,
                            Name: '加盟终端',
                            Value: 2,
                        },
                        {
                            ID: 4,
                            Name: '新现代终端',
                            Value: 3,
                        },
                        {
                            ID: 5,
                            Name: '普通终端',
                            Value: 4,
                        },
                    ],
                    CustomerRateList: [
                        {
                            ID: 1,
                            Name: '现代终端月度户均会员消费笔数占比',
                            Value: '32%',
                        },
                        {
                            ID: 2,
                            Name: '现代终端日均营业额',
                            Value: '138.1万元',
                        },
                        {
                            ID: 3,
                            Name: '加盟终端',
                            Value: 22521.57,
                        },
                    ],
                });
                const initCustomerSituationBarChart = () => {
                    var chartDom = document.getElementById('customerSituationBarChart');
                    var customerSituationBarChartDom = echarts.init(chartDom);
                    customerSituationBarChartDomRef.value = customerSituationBarChartDom;
                    let option = {
                        legend: {
                            show: true, // 显示图例
                            orient: 'vertical',
                            x: 'left', // 图例水平位置
                            y: 'center', // 图例垂直位置
                            align: 'left',
                            left: '80%',
                            icon: 'square', // 图例形状
                            itemWidth: 10, // 图例项宽度
                            itemHeight: 10, // 图例项高度
                            itemGap: 20,
                            textStyle: {
                                opacity: 0.8,
                            },
                        },
                        series: [
                            {
                                name: 'Nightingale Chart',
                                type: 'pie',
                                radius: [50, 100],
                                center: ['50%', '50%'],
                                roseType: 'area',
                                itemStyle: {
                                    borderRadius: 8,
                                },
                                data: [
                                    { value: 40, name: '消费活动' },
                                    { value: 38, name: '产品测试' },
                                    { value: 32, name: '酒类活动' },
                                    { value: 30, name: '有问必答' },
                                ],
                            },
                        ],
                    };
 
                    option && customerSituationBarChartDom.setOption(option);
                };
                const chartContainerResize = ({ width, height }) => {
                    customerSituationBarChartDomRef.value.resize();
                };
                onMounted(() => {
                    initCustomerSituationBarChart();
                });
 
                return { state, chartContainerResize };
            },
        });
        App.use(ElementPlus);
        elementResizeDirective(App);
        App.mount('#customerSituation');
    </script>
</html>