zxl
2026-03-20 d5f3ca51818d635d3c5be7f73984b0e592a23ed4
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
<template>
  <div style="margin-right: 30px" class="data-reMechanism">
    <div style="display: flex; align-items: center">
      <div style="margin-right:12px;font-size:16px;font-weight:bold">趋势分析</div>
      <a-radio-group v-model="trendAnalysisType" @change="trendAnalysisTypeChange">
        <a-radio-button :value="0"> 车流量 </a-radio-button>
        <a-radio-button :value="1"> 加油数 </a-radio-button>
        <a-radio-button :value="2"> 油品销量 </a-radio-button>
        <a-radio-button :value="3"> 通过率 </a-radio-button>
        <a-radio-button :value="4"> 客户 </a-radio-button>
        <a-radio-button :value="5"> 流失率 </a-radio-button>
      </a-radio-group>
    </div>
    <div>
      <div style="display: flex; align-items: flex-end; flex-direction: column">
        <a-radio-group
          style="margin: 20px 0"
          size="small"
          v-model="trendAnalysisUnit"
          @change="trendAnalysisTypeChange"
        >
          <a-radio-button value="HOURS" :disabled="trendAnalysisType == 4 || trendAnalysisType == 5">
            小时
          </a-radio-button>
          <a-radio-button value="DAYS"> 日期 </a-radio-button>
          <a-radio-button value="MONTHS"> 月份 </a-radio-button>
        </a-radio-group>
        <DataReLineChart
          domId="trendAnalysisLine"
          ref="trendAnalysisLineRef"
          :chartData="trendAnalysisData"
          style="width: 100%"
          :showpercent="trendAnalysisChartShowPercent"
        ></DataReLineChart>
      </div>
      <div id="trendAnalysisChartID"></div>
    </div>
    <!-- 操作按钮区域 -->
    <div class="table-operator">
      <a-select style="width: 200px" v-model="searchWay" @change="changeWay" placeholder="请选择">
        <a-select-option value="1"> 时间 </a-select-option>
        <a-select-option value="2"> 活动 </a-select-option>
      </a-select>
      <a-select
        v-if="searchWay == 2"
        style="width: 300px; margin: 0 12px"
        @change="activeTimeChange"
        v-model="activeTime"
        placeholder="请选择"
      >
        <a-select-option value=""> 全部 </a-select-option>
        <a-select-option v-for="item in activeOptions" :key="item.id" :value="item.id">
          {{ item.name }}
        </a-select-option>
      </a-select>
      <a-range-picker style="width: 300px; margin: 0 12px" v-if="searchWay == 1" @change="timeChange" />
      <a-button type="primary" @click="searchActive"> 搜索 </a-button>
    </div>
    <div class="fueling-overview-ct">
      <div class="block-title" style="display: flex; align-items: center">
        <div style="margin-right: 12px">加油概况</div>
        <a-switch v-model="isContrast" />
        <div style="font-size: 12px; font-weight: 100; margin-left: 8px; color: #5fa6f0">对照组</div>
        <a-range-picker style="width: 300px; margin: 0 12px" v-if="isContrast" @change="contrastTimeChange" />
      </div>
      <div class="fueling-overview-block">
        <div class="fueling-overview-item">
          <div class="fueling-overview-name">车流量</div>
          <div class="fueling-overview-num">
            <span style="margin-right: 24px">{{ statisTotalObj.carCount }}</span>
            <span style="color: #16b777" v-if="isContrast">{{ contrastObj.carCount }}</span>
          </div>
        </div>
        <div class="fueling-overview-item">
          <div class="fueling-overview-name">进站数</div>
          <div class="fueling-overview-num">
            <span style="margin-right: 24px">{{ statisTotalObj.appearCount }}</span>
            <span style="color: #16b777" v-if="isContrast">{{ contrastObj.appearCount }}</span>
          </div>
        </div>
        <div class="fueling-overview-item">
          <div class="fueling-overview-name">加油数</div>
          <div class="fueling-overview-num">
            <span style="margin-right: 24px">{{ statisTotalObj.oilCount }}</span>
            <span style="color: #16b777" v-if="isContrast">{{ contrastObj.oilCount }}</span>
          </div>
        </div>
        <div class="fueling-overview-item">
          <div class="fueling-overview-name">油品销量</div>
          <div class="fueling-overview-num">
            <span style="margin-right: 24px">{{ statisTotalObj.oilVolume }}</span>
            <span style="color: #16b777" v-if="isContrast">{{ contrastObj.oilVolume }}</span>
          </div>
        </div>
        <div class="fueling-overview-item">
          <div class="fueling-overview-name">通过率(分)</div>
          <div class="fueling-overview-num">
            <span style="margin-right: 24px">{{ statisTotalObj.spandAvg }}</span>
            <span style="color: #16b777" v-if="isContrast">{{ contrastObj.spandAvg }}</span>
          </div>
        </div>
        <div class="fueling-overview-item">
          <div class="fueling-overview-name">拐入率</div>
          <div class="fueling-overview-num">
            <span style="margin-right: 24px">{{ statisTotalObj.entryRate }}%</span>
            <span style="color: #16b777" v-if="isContrast">{{ contrastObj.entryRate }}%</span>
          </div>
        </div>
        <div class="fueling-overview-item">
          <div class="fueling-overview-name">加油率</div>
          <div class="fueling-overview-num">
            <span style="margin-right: 24px">{{ statisTotalObj.oilRate }}%</span>
            <span style="color: #16b777" v-if="isContrast">{{ contrastObj.oilRate }}%</span>
          </div>
        </div>
        <div class="fueling-overview-item">
          <div class="fueling-overview-name">回头率</div>
          <div class="fueling-overview-num">
            <span style="margin-right: 24px">{{ statisTotalObj.rebackRate }}%</span>
            <span style="color: #16b777" v-if="isContrast">{{ contrastObj.rebackRate }}%</span>
          </div>
        </div>
      </div>
    </div>
    <div>
      <div class="block-title">车型分析</div>
      <div style="display: flex">
        <DataReLineChart
          domId="vehicleTypeLine"
          ref="statModelBarRef"
          :chartData="vehicleTypeLineData"
          style="width: 70%"
          :showpercent="false"
        ></DataReLineChart>
        <div style="width: 30%">
          <a-radio-group v-model="vehicleTypeSpecies" size="small" @change="vehicleTypeSpeciesChange">
            <a-radio-button :value="1"> 加油数 </a-radio-button>
            <a-radio-button :value="3"> 油品销量 </a-radio-button>
          </a-radio-group>
          <DataRePieChart
            style="width: 100%"
            domId="vehicleTypePie"
            ref="vehicleTypePieRef"
            :chartData="vehicleTypePieData"
          ></DataRePieChart>
        </div>
      </div>
    </div>
    <div>
      <div class="block-title">加油位分析</div>
      <div style="display: flex">
        <DataReLineChart
          style="width: 70%"
          domId="fuelLevelLine"
          ref="statPositionBarRef"
          :chartData="fuelLevelLineData"
        ></DataReLineChart>
 
        <div style="width: 30%">
          <a-radio-group v-model="fuelingStationSpecies" size="small" @change="fuelingStationSpeciesChange">
            <a-radio-button :value="2"> 加油数 </a-radio-button>
            <a-radio-button :value="4"> 油品销量 </a-radio-button>
          </a-radio-group>
          <DataRePieChart
            style="width: 100%"
            domId="fuelLevelPie"
            ref="fuelLevelPieRef"
            :chartData="fuelLevelPieData"
          ></DataRePieChart>
        </div>
      </div>
    </div>
    <TopTenCustomers
      :customerData="customerObj"
      :typeOneTotal="customerOneTotal"
      :typeTwoTotal="customerTwoTotal"
    ></TopTenCustomers>
  </div>
</template>
 
<script>
import TopTenCustomers from './TopTenCustomers'
import DataReLineChart from './DataReLineChart'
import DataRePieChart from './DataRePieChart'
import { getAction, postAction } from '@tievd/cube-block/lib/api/manage'
export default {
  name: 'DataReMechanism',
  components: {
    TopTenCustomers,
    DataReLineChart,
    DataRePieChart,
  },
  props: {
    selectTreeObj: {
      default: () => {
        return JSON.parse(localStorage.getItem('userDepartInfo'))
      },
    },
  },
  watch: {
    isContrast() {
      this.contrastObj = {}
    },
  },
  data() {
    return {
      trendAnalysisChartShowPercent: true,
      loading: false,
      description: '数据报表(加油站)',
      vehicleTypeSpecies: 1,
      fuelingStationSpecies: 2,
      searchWay: '1',
      isContrast: false,
      activeTime: '',
      customerObj: {}, //TOP10客户数据
      customerOneTotal: 0,
      customerTwoTotal: 0,
      statisTotalObj: {},
      contrastObj: {},
      startTime: '',
      endTime: '',
      activeOptions: [],
      vehicleTypePieData: {}, //车型分析饼图数据
      fuelLevelLineData: {}, //加油位分析折线图数据
      fuelLevelPieData: {}, //加油位分析饼图数据
      vehicleTypeLineData: {}, //车型分析折线图数据
      trendAnalysisType: 0, //趋势分析选择类型
      trendAnalysisUnit: 'DAYS', //趋势分析选择时间
      trendAnalysisData: {}, //趋势分析数据
      trendAnalysisChart: null, //趋势分析图表
    }
  },
 
  methods: {
    //获取车型/加油位折线图数据
    getVehicleTypeLineData() {
      postAction('/jyz/dataTable/statisMidTable', {
        orgCode: this.selectTreeObj.orgCode,
        startTime: this.startTime,
        endTime: this.endTime,
      }).then((res) => {
        console.log(res)
        this.vehicleTypeLineData = res.result.statModelBar
        this.fuelLevelLineData = res.result.statPositionBar
        this.$nextTick(() => {
          this.$refs.statModelBarRef.setChart()
          this.$refs.statPositionBarRef.setChart()
        })
      })
    },
    //获取车型饼图数据
    getVehicleStationPieData() {
      postAction('/jyz/dataTable/statFan', {
        orgCode: this.selectTreeObj.orgCode,
        startTime: this.startTime,
        endTime: this.endTime,
        type: this.vehicleTypeSpecies,
      }).then((res) => {
        console.log(res)
        this.vehicleTypePieData = res.result
        this.$nextTick(() => {
          this.$refs.vehicleTypePieRef.setChart()
        })
      })
    },
    vehicleTypeSpeciesChange(e) {
      this.vehicleTypeSpecies = e.target.value
      this.getVehicleStationPieData()
    },
    //获取加油位饼图数据
    getFuelingStationPieData() {
      postAction('/jyz/dataTable/statFan', {
        orgCode: this.selectTreeObj.orgCode,
        startTime: this.startTime,
        endTime: this.endTime,
        type: this.fuelingStationSpecies,
      }).then((res) => {
        console.log(res)
        this.fuelLevelPieData = res.result
        this.$nextTick(() => {
          this.$refs.fuelLevelPieRef.setChart()
        })
      })
    },
    fuelingStationSpeciesChange(e, val) {
      console.log(e, val)
      this.fuelingStationSpecies = e.target.value
      this.getFuelingStationPieData()
    },
    //趋势分析类型切换
    trendAnalysisTypeChange(e) {
      let val = e.target.value
      if (val == 0 || val == 2 || val == 3 || val == 5) {
        this.trendAnalysisChartShowPercent = true
      } else {
        this.trendAnalysisChartShowPercent = false
      }
      if (val == 4 || val == 5) {
        this.trendAnalysisUnit = 'DAYS'
      }
      this.getTrendAnalysis()
    },
    //获取趋势分析数据
    getTrendAnalysis() {
      postAction('/jyz/dataTable/statTrend', {
        orgCode: this.selectTreeObj.orgCode,
        startTime: this.startTime,
        endTime: this.endTime,
        trendType: this.trendAnalysisType,
        timeUnit: this.trendAnalysisUnit,
      }).then((res) => {
        console.log(res)
        this.trendAnalysisData = res.result
        this.$nextTick(() => {
          if (this.trendAnalysisType == 4) {
            this.$refs.trendAnalysisLineRef.setPieUpChart()
          } else if (this.trendAnalysisType == 5) {
            this.$refs.trendAnalysisLineRef.setOnlyLineChart()
          } else {
            this.$refs.trendAnalysisLineRef.setChart()
          }
        })
      })
    },
    changeWay() {
      this.startTime = ''
      this.endTime = ''
    },
    timeChange(e, t) {
      console.log(e, t)
      this.startTime = t[0]
      this.endTime = t[1]
    },
    contrastTimeChange(e, t) {
      postAction('/jyz/dataTable/statisTotal', {
        orgCode: this.selectTreeObj.orgCode,
        startTime: t[0],
        endTime: t[1],
      }).then((res) => {
        this.contrastObj = res.result
      })
    },
    activeTimeChange(e) {
      console.log(e)
      if (e) {
        let item = this.activeOptions.find((el) => el.id == e)
        this.startTime = item.startTime
        this.endTime = item.endTime
      } else {
        this.startTime = ''
        this.endTime = ''
      }
    },
    activeChange() {},
    //获取统计总数
    getStatisTotal() {
      postAction('/jyz/dataTable/statisTotal', {
        orgCode: this.selectTreeObj.orgCode,
        startTime: this.startTime,
        endTime: this.endTime,
      }).then((res) => {
        this.statisTotalObj = res.result
      })
    },
    getCustomerData() {
      getAction('/jyz/dataTable/clientTop', {
        orgCode: this.selectTreeObj.orgCode,
      }).then((res) => {
        this.customerObj = res.result
        this.customerOneTotal = 0
        this.customerTwoTotal = 0
        this.customerObj.type1.map((el) => {
          this.customerOneTotal += el.oilCount
        })
        this.customerObj.type2.map((el) => {
          this.customerTwoTotal += el.oilCount
        })
      })
    },
    getActiveListAll() {
      getAction('/jyz/activity/listAll', {
        orgCode: this.selectTreeObj.orgCode,
      }).then((res) => {
        this.activeOptions = res.result
      })
    },
    searchActive() {
      this.getStatisTotal()
      this.getVehicleTypeLineData()
      this.getVehicleStationPieData()
      this.getFuelingStationPieData()
      this.getTrendAnalysis()
    },
    initData() {
      this.getCustomerData()
      this.getActiveListAll()
      this.getStatisTotal()
      this.getVehicleTypeLineData()
      this.getVehicleStationPieData()
      this.getFuelingStationPieData()
      this.getTrendAnalysis()
    },
  },
 
  created() {
    this.initData()
  },
}
</script>
<style scoped lang="less">
@import '~@assets/less/common.less';
/deep/ .ant-table-content {
  height: 500px;
  .ant-table-placeholder {
    background: none;
    border: none;
  }
}
.ant-switch::after {
  background: #fff;
}
.data-reMechanism {
  .table-operator {
    margin: 24px 0 0 0;
  }
  .block-title {
    font-weight: bold;
    font-size: 16px;
  }
  .fueling-overview-ct {
    // margin: 0 12px;
    .fueling-overview-block {
      display: flex;
      .fueling-overview-item {
        border: 1px solid #343a44;
        padding: 12px 80px 12px 12px;
        margin: 12px;
        white-space: nowrap;
        .fueling-overview-num {
          color: #5b81f9;
          font-size: 16px;
        }
      }
    }
  }
}
</style>