zhangyanpeng
2024-05-29 1f227a1cf627526701c652ba84bae3e430bba8d3
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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8"><meta http-equiv="Expires" content="0"><meta http-equiv="Pragma" content="no-cache"><meta http-equiv="Cache-control" content="no-cache"><meta http-equiv="Cache" content="no-cache">
        <title>纯销计划汇总</title>
        <script src="https://cdn.jsdelivr.net/npm/echarts@5.3.3/dist/echarts.min.js"></script>
 
        <script type="text/javascript">
            // var setting = getSetting("puresaleplan_list");
            var initlized = false;
 
            var pageVue = null;
            function loadJsCss(callback) {
                var jscss_urls = [
                    {
                        id: "css1",
                        type: "css",
                        url: "//at.alicdn.com/t/font_2374495_13ltsxm2eor.css"
                    }
                ];
                window.top.initJsCss(document, jscss_urls, callback);
            }
 
            function initVue() {
                new ListVue({
                    el: "#vbody",
                    data: {
                        dataname: "plan_sales_year",
                        title: "年销售计划",
                        orderby :"update_time desc",
                        
                        pageAttr: {
                            heightType: "table"
                        },
 
                        filterfieldClick: {},
                        tablefieldClick: {},
                        formfieldClick: {},
                        form:{
                            region: 'A药',
                        },
                        cbuttons_r: {},
                        ctabs_r: {},
                    },
                    
                    created() {
                        this.fieldsToFieldsObj();
                    },
 
                    mounted() {
                        var me = this;
                        if (window.top.tab.selected.option.page_id) {
                            getPageByPageId(window.top.tab.selected.option.page_id, function(result){
                                me.cbuttons_r = result.buttons_r;
                                me.ctabs_r = result.tabs_r;
                                
                                me.initData();
                                me.$nextTick(() => {
                                    // 以服务的方式调用的 Loading 需要异步关闭
                                    hideLoading();
                                });
                                
                                me.plan();
                                me.percent();
                            })
                        }
                    },
                    
                    methods: {    
                        initData() {
                            var me = this;
                            this.onQuery(function(result, callback) {//查询后的回调,用于获取字段的
                                if (result.meta && result.meta[me.dataname] && result.meta[me.dataname].fields) {
                                    var metas = clone(result.meta[me.dataname].fields);
                                    var filterFields_ = [];
                                    var tableFields_ = [];
                                    
                                    metas.map(f=>{
                                        f.isshow = "T";
                                        
                                        if (f.isfilter) {
                                            filterFields_.push(clone(f));
                                        }
                                        else {
                                            var filter_f = clone(f);
                                            filter_f.isshow = "F";
                                            filterFields_.push(filter_f);
                                        }
                                        
                                        tableFields_.push(clone(f));
                                    })
                                    if (!me.filterFields || (me.filterFields && me.filterFields.length == 0)) {
                                        me.filterFields = clone(filterFields_);
                                        me.tableFields = clone(tableFields_);
                                        
                                        //字段数组转字段obj,目的为了筛选时获取字段属性
                                        me.fieldsToFieldsObj();
                                        
                                        //设置字段事件
                                        me.tableFieldClick();
                                    }
                                }
                                
                                if (callback) {
                                    callback();
                                }
                            });
                        },
 
                        tableFieldClick() {
                            var me = this;
                            
                            //筛选字段事件设置
                            this.filterfieldClick = {};
                            
                            me.filterFields.map(f=>{
                                if(!this.filterfieldClick[f.field]) {
                                    this.filterfieldClick[f.field] = {}
                                }
                                this.filterfieldClick[f.field].input = {
                                    onchange: function(obj) {//输入更改事件
                                        me.onQuery();
                                    }
                                }
                            })
                            
                            //表格字段事件设置
                            this.tablefieldClick = {
                                
                            };
                        },
                        
                        //pie
                        percent(){
                            var me = this;
                            var percentDom = document.getElementById("percent");
                            var percentChart = echarts.init(percentDom);
                            
                            const data1 = [
                                { value: 6960, name: "已完成", label: { show: true } },
                                { value: 4600, name: "未完成" },
                            ];
                            const data2 = [
                                { value: 4655, name: "已完成", label: { show: true } },
                                { value: 2940, name: "未完成" },
                            ];
                            const data3 = [
                                { value: 10140, name: "已完成", label: { show: true } },
                                { value: 5520, name: "未完成" },
                            ];
                            
                            var data = data1;
                            switch(me.form.region)
                            {
                                case "A药":data = data1;
                                break;
                                case "B药":data = data2;
                                break;
                                case "C药":data = data3;
                                break;
                            }
                            
                            var percentOption = {
                                color: ["#3c8dbc", "Gainsboro"],
                                tooltip: {
                                  trigger: "item",
                                  formatter: "{a}<br/>{b} : {c} ({d}%)",
                                },
                                // grid: {
                                //     left: "3%",
                                //     right: "4%",
                                //     bottom: "7%",
                                //     containLabel: true,
                                // },
                                // legend: {
                                //   left: "center",
                                //   top: "90%",
                                // },
                                // dataset: [
                                //   {
                                //     source: [
                                //       ["Type", "Amount", "Product"],
                                //       ["已完成", 6960, "A药"],
                                //       ["未完成", 4600, "A药"],
                                //       ["已完成", 4655, "B药"],
                                //       ["未完成", 2940, "B药"],
                                //       ["已完成", 10140, "C药"],
                                //       ["未完成", 5520, "C药"],
                                //     ],
                                //   },
                                //   {
                                //     transform: {
                                //       type: "filter",
                                //       config: { dimension: "Product", "=": "A药" },
                                //       // 这个筛选条件表示,遍历数据,筛选出维度( dimension )
                                //     },
                                //   },
                                // ],
                                series: [
                                  {
                                    name: "进度",
                                    type: "pie",
                                    radius: ["45%", "60%"],
                                    data: data,
                                    avoidLabelOverlap: false,
                                    label: {
                                      normal: {
                                        show: false,
                                        formatter: "{b}\n\n{d}%",
                                        position: "center",
                                        lineHeight: 25,
                                        fontSize: "30",
                                        fontWeight: "bold",
                                      },
                                    },
                                    labelLine: {
                                      show: false,
                                    },
                                  },
                                ],
                              };
                        
                            percentChart.setOption(percentOption);
                        },
                        
                        //双折线
                        plan(){
                            var me = this;
                            var planDom = document.getElementById("plan");
                            var planChart = echarts.init(planDom);
                            
                            var planOption = {
                                color: ["IndianRed", "green"],
                                title: {
                                    text: "Plan",
                                    left:'center',
                                    show: false,
                                },
                                tooltip: {
                                    trigger: "axis",
                                },
                                legend: {
                                    top:'bottom',
                                },
                                grid: {
                                    left: "3%",
                                    right: "4%",
                                    bottom: "7%",
                                    containLabel: true,
                                },
                                toolbox: {
                                    right:"5%",
                                    feature: {
                                        saveAsImage: {},
                                        magicType: { type: ['line', 'bar'] },
                                    },
                                },
                                dataset: [
                                    {
                                        source: [
                                            ["Type", "Amount", "Month", "Product"],
                                            ["Goal", 900, "1月", "A药"],
                                            ["Goal", 930, "2月", "A药"],
                                            ["Goal", 935, "3月", "A药"],
                                            ["Goal", 950, "4月", "A药"],
                                            ["Goal", 950, "5月", "A药"],
                                            ["Goal", 970, "6月", "A药"],
                                            ["Goal", 975, "7月", "A药"],
                                            ["Goal", 980, "8月", "A药"],
                                            ["Goal", 980, "9月", "A药"],
                                            ["Goal", 990, "10月", "A药"],
                                            ["Goal", 1000, "11月", "A药"],
                                            ["Goal", 1000, "12月", "A药"],
                                            ["Goal", 600, "1月", "B药"],
                                            ["Goal", 610, "2月", "B药"],
                                            ["Goal", 625, "3月", "B药"],
                                            ["Goal", 630, "4月", "B药"],
                                            ["Goal", 630, "5月", "B药"],
                                            ["Goal", 620, "6月", "B药"],
                                            ["Goal", 625, "7月", "B药"],
                                            ["Goal", 630, "8月", "B药"],
                                            ["Goal", 650, "9月", "B药"],
                                            ["Goal", 660, "10月", "B药"],
                                            ["Goal", 655, "11月", "B药"],
                                            ["Goal", 660, "12月", "B药"],
                                            ["Goal", 1200, "1月", "C药"],
                                            ["Goal", 1250, "2月", "C药"],
                                            ["Goal", 1250, "3月", "C药"],
                                            ["Goal", 1300, "4月", "C药"],
                                            ["Goal", 1320, "5月", "C药"],
                                            ["Goal", 1340, "6月", "C药"],
                                            ["Goal", 1400, "7月", "C药"],
                                            ["Goal", 1400, "8月", "C药"],
                                            ["Goal", 1300, "9月", "C药"],
                                            ["Goal", 1350, "10月", "C药"],
                                            ["Goal", 1300, "11月", "C药"],
                                            ["Goal", 1250, "12月", "C药"],
                                            ["Now", 750, "1月", "A药"],
                                            ["Now", 830, "2月", "A药"],
                                            ["Now", 850, "3月", "A药"],
                                            ["Now", 870, "4月", "A药"],
                                            ["Now", 850, "5月", "A药"],
                                            ["Now", 900, "6月", "A药"],
                                            ["Now", 950, "7月", "A药"],
                                            ["Now", 960, "8月", "A药"],
                                            ["Now", 530, "1月", "B药"],
                                            ["Now", 540, "2月", "B药"],
                                            ["Now", 555, "3月", "B药"],
                                            ["Now", 570, "4月", "B药"],
                                            ["Now", 590, "5月", "B药"],
                                            ["Now", 600, "6月", "B药"],
                                            ["Now", 620, "7月", "B药"],
                                            ["Now", 650, "8月", "B药"],
                                            ["Now", 1000, "1月", "C药"],
                                            ["Now", 1100, "2月", "C药"],
                                            ["Now", 1200, "3月", "C药"],
                                            ["Now", 1350, "4月", "C药"],
                                            ["Now", 1320, "5月", "C药"],
                                            ["Now", 1350, "6月", "C药"],
                                            ["Now", 1370, "7月", "C药"],
                                            ["Now", 1450, "8月", "C药"],
                                        ],
                                    },
                                    {
                                        transform: {
                                            type: "filter",
                                            config: {
                                                and: [
                                                    { dimension: "Type", "=": "Goal" },
                                                    { dimension: "Product", "=": me.form.region },
                                                ], // 这个筛选条件表示,遍历数据,筛选出维度( dimension )
                                            },
                                        },
                                    },
                                    {
                                        transform: {
                                            type: "filter",
                                            config: {
                                                and: [
                                                    { dimension: "Type", "=": "Now" },
                                                    { dimension: "Product", "=": me.form.region },
                                                ], // 这个筛选条件表示,遍历数据,筛选出维度( dimension )
                                            },
                                        },
                                    },
                                ],
                                xAxis: { type: "category" },
                                yAxis: {
                                    min:500,
                                },
                                series: [
                                    {
                                        name: "Goal",
                                        type: "line",
                                        datasetIndex: 1,
                                        label: {
                                          show: true,
                                        },
                                        encode: {
                                          x: "Month",
                                          y: "Amount",
                                        },
                                         itemStyle:{
                                            normal:{
                                                lineStyle:{
                                                    //'dotted','solid',dashed''
                                                    type:'dashed',
                                                    // type: [5, 10],
                                                    // dashOffset: 5
                                                }
                                            }
                                        },           
                                    },
                                    {
                                        name: "Now",
                                        type: "line",
                                        datasetIndex: 2,
                                        label: {
                                          show: true,
                                        },
                                        encode: {
                                          x: "Month",
                                          y: "Amount",
                                        },
                                    },
                                ],
                            };
                            
                            planChart.setOption(planOption);
                        },
                        
                        select(){
                            this.plan();
                            this.percent();
                        },
                    },
                });
            }
 
            loadJsCss(function() {
                initVue();
            });
        </script>
 
        <style>
            /* 在vue.js中 v-cloak 这个指令是防止页面加载时出现 vuejs 的变量名而设计的 */
            [v-cloak] {
                display: none !important;
            }
        </style>
    </head>
 
    <body style="margin: 0px;">
        <div v-cloak id="vbody">
            <div id="vbody">
                <div style="width: 100%;height: 400px;display: flex;">
                    <div id="pie" style="width: 35%;height: 100%;background-color: white;">
                        <h3 style="font-weight: 600;color: black;text-align: center;width: 100%;height: 10%;">整体销售进度</h3>
                        <div id="percent" style="width: 100%;height: 90%;background-color: white;margin-top: -30px;"></div>
                    </div>
                    <div id = "chart" style="width: 63%;height: 100%;display: flex;flex-direction:column;">
                        <div id="filter" style="width: 100%;height: 20%;background-color: white;">
                            <h3 style="font-weight: 600;color: black;text-align: center;margin-bottom: 15px;">月份销售进度</h3>
                                <div class="block" style="margin-top: -5px;margin-left: 30px;display: flex;">
                                    <span class="demonstration">切换产品</span>
                                    <el-form ref="form" :model="form" style="margin-left: 10px;margin-top: -10px;">
                                        <el-form-item>
                                            <el-select @change="select" v-model="form.region" placeholder="请选择产品">
                                              <el-option label="A药" value="A药"></el-option>
                                              <el-option label="B药" value="B药"></el-option>
                                              <el-option label="C药" value="C药"></el-option>
                                            </el-select>
                                          </el-form-item>
                                    </el-form>
                                       <!-- <el-radio @change="qiehuan" v-model="radio" label="A药">A药</el-radio>
                                        <el-radio @change="qiehuan" v-model="radio" label="B药">B药</el-radio>
                                        <el-radio @change="qiehuan" v-model="radio" label="C药">C药</el-radio> -->
                                        <!-- <el-date-picker
                                        v-model="value2"
                                        type="month"
                                        @change="changemon"
                                        placeholder="选择产品">
                                        </el-date-picker> -->
                                </div>
                        </div>
                        <div id="plan" style="width: 100%;height: 80%;background-color: white;"></div>
                    </div>
                    
                </div>
                <div id="page_root">
                    <div class="topbar">
                        <span>{{title}}</span>
                        <div style="float: right; margin-right: 18px">
                            <el-button-group style="margin-left: 3px">
                                <el-button @click="":icon="buttonsconfig.import.icon">{{buttonsconfig.import.name}}</el-button>
                                <el-button @click="download()":icon="buttonsconfig.export.icon">{{buttonsconfig.export.name}}</el-button>
                            </el-button-group>
                        </div>
                    </div>
 
                    <!-- 查询条件 -->
                    <div class="topbar-line">
                        <div class="query-bar">
                            <h-form-filter ref="form1" 
                                :form-attr="filterAttr" 
                                :table-fields="filterFields"
                                :form-data="filterObj" 
                                :table-field-click="filterfieldClick"
                                :isdraggableorder="true"
                                
                                v-on:on-query="onQuery"
                                v-on:on-init-query="onInitFilter" 
                                v-on:on-edit-query="onEditFilter"
                                v-on:order-fields="orderFilterFields">
                            </h-form-filter>
                        </div>
                    </div>
 
                    <div class="h_dialog__body">
                        <h-table 
                            v-if="isRefresh" 
                            ref="table1" 
                            :table-fields="tableFields" 
                            :table-data="tableData"
                            :pagesize="pagesize" 
                            :pagenum="pagenum" 
                            :total="total" 
                            :table-height="tableHeight"
                            :is-highlight-row="true" 
                            :table-field-click="tablefieldClick"
                            :isdraggableorder="true"
                            
                            v-on:get-data="getData"
                            v-on:order-fields="orderTableFields">
                        </h-table>
                    </div>
                </div>
            </div>
        </div>
        <div id="page_loading" style="position: absolute; top: 0px; width: 100vw; height: 50vh">
            <div class="spinner">
                <div class="cube1"></div>
                <div class="cube2"></div>
            </div>
        </div>
    </body>
</html>