选煤厂生产管理平台前端代码
dongyukun
2024-12-10 5cc1d92af645c2f8f4f6d1d3777283b70df78ccd
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
<template>
  <!-- 搜索 -->
  <ContentWrap>
    <el-form
      class="-mb-15px"
      :model="queryParams"
      ref="queryFormRef"
      :inline="true"
      label-width="68px"
    >
      <el-form-item label="开始时间">
        <el-date-picker
          size="mini"
          v-model="queryParams.startTime"
          format="YYYY-MM-DD HH:mm:00"
          value-format="YYYY-MM-DD HH:mm:00"
          type="datetime"
          :clearable="false"
          placeholder="选择日期时间"/>
      </el-form-item>
      <el-form-item label="结束时间">
        <el-date-picker
          size="mini"
          v-model="queryParams.endTime"
          format="YYYY-MM-DD HH:mm:00"
          value-format="YYYY-MM-DD HH:mm:00"
          type="datetime"
          :clearable="false"
          placeholder="选择日期时间"/>
      </el-form-item>
      <el-form-item label="调度指标" prop="ddzb">
        <el-select
          v-model="queryParams.ddbz"
          class="!w-240px"
          clearable
          placeholder="请选择调度指标"
        >
          <el-option
            v-for="dict in getIntDictOptions(DICT_TYPE.PMS_DDZB)"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button @click="handleQuery">
          <Icon icon="ep:search" class="mr-5px"/>
          搜索
        </el-button>
      </el-form-item>
    </el-form>
    <div :loading="loading" style="height: 400px; width: 100%;">
      <bar-line :option="chartOption"/>
    </div>
  </ContentWrap>
</template>
<script lang="ts" setup>
  import {ref} from "vue"
  import {getYMD} from "@/utils/dateUtil"
  import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
  defineOptions({name: 'Analysis'})
 
  const loading = ref(false)
  const chartOption = {}
  const queryParams = reactive({
    startTime:getYMD(new Date().getTime() - 3600 * 1000 * 24 * 30),
    endTime:getYMD(new Date()),
    groupType: 'day',
    index: ''
  })
 
 
  const queryChart = async () => {
 
    this.loading = true
    this.$http.post(`/iailab-iems-coal-proddisp/analysis/index/chart`, queryParams).then(({data: res}) => {
      this.loading = false
      if (res.code !== 0) {
        return this.$message.error(res.msg)
      }
      let series = []
      if (res.data.series) {
        res.data.series.forEach(function (item) {
          series.push(
            {
              name: item.name,
              data: item.data,
              type: 'line',
              smooth: false
            }
          )
        })
      }
 
      this.chartOption = {
        title: {
          text: res.data.valueName,
          textStyle: {
            fontSize: 14
          }
        },
        tooltip: {
          trigger: 'axis'
        },
        grid: {
          top: '10%',
          right: '10%',
          bottom: '10%',
          left: '5%'
        },
        legend: {
          type: 'scroll',
          data: res.data.legend
        },
        toolbox: {
          show: true,
          top: 0,
          right: '10%',
          feature: {
            dataView: {readOnly: false},
            magicType: {type: ['line', 'bar']},
            saveAsImage: {}
          }
        },
        xAxis: {
          type: 'category',
          data: res.data.categories
        },
        yAxis: {
          type: 'value',
          //name: res.data.valueName,
          nameTextStyle: {
            fontWeight: 'bold'
          },
          axisLine: {
            show: true
          }
        },
        series: series
      }
 
    }).catch(() => {
      this.loading = false
    })
  }
  /** 初始化 **/
  onMounted(async () => {
    await queryChart()
  })
</script>