独墅湖高教创新区危化品智慧管控平台(新危化品)
zhouwx
2025-04-17 a8593f5ca77a934b31bbdd3b919d8e41796cb920
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
<template>
  <div class="homePage">
    <el-row :gutter="20" justify="space-between" style="margin-bottom: 15px">
      <el-col :xl="6" :lg="6" :md="12" :sm="12" :xs="24" v-for="(item,index) in data.cardList" :key="index">
        <el-card style="margin-bottom: 5px">
          <div class="cardContent">
            <img :src='item.imgUrl' :class="index !== 3 ? 'imgW' :'imgT' " />
            <div class="cardRight">
              <span style="font-size: 17px">{{item.title}}</span>
              <countTo
                  style="font-weight: 700;font-size: 22px"
                  :startVal="item.startVal"
                  :endVal="item.endVal"
                  :duration="item.duration"
              >
              </countTo>
            </div>
          </div>
        </el-card>
      </el-col>
    </el-row>
    <div>
      <el-row :gutter="20" justify="space-between" style="margin-bottom: 15px">
        <el-col :xl="12" :lg="12" :md="24" :sm="24" :xs="24">
          <el-card style="margin-bottom: 5px">
            <div :id="pieChart" style="width: 100%;height: 300px"></div>
          </el-card>
        </el-col>
        <el-col :xl="12" :lg="12" :md="24" :sm="24" :xs="24">
          <el-card class="right">
            <div :id="barChart" style="width: 100%;height: 300px"></div>
          </el-card>
        </el-col>
      </el-row>
    </div>
    <div>
      <el-row :gutter="20" justify="space-between" style="margin-bottom: 15px">
        <el-col :xl="24" :lg="24" :md="24" :sm="24" :xs="24">
          <el-card style="margin-bottom: 5px">
            <div :id="lineChart" style="width: 100%;height: 300px"></div>
          </el-card>
        </el-col>
      </el-row>
    </div>
    <div>
      <el-row :gutter="20" justify="space-between" >
        <el-col :xl="12" :lg="12" :md="24" :sm="24" :xs="24" style="margin-bottom: 15px">
          <el-card style="height: 500px;overflow: auto">
              <span style="font-size: 18px;font-weight: 600;margin-bottom: -5px">危化品动态</span>
              <el-divider style="margin: 15px 0"></el-divider>
              <div style="padding: 10px;" v-if="data.hazmatData && data.hazmatData.length >0">
                <div v-for="(item,index) in data.hazmatData" :key="index" style="display: flex;flex-direction: column">
                  <div style="display: flex">
                    <img :src="avator" style="width: 25px;height: 25px" />
                    <div style="display: flex;flex-direction: column;margin-left: 20px">
                      <span style="font-size: 16px;font-weight: 600">{{item.description}}&nbsp;
                         <span style="color: #03752e;font-weight: 600" v-if="item.num > 0">{{item.stateName}}</span>&nbsp;
                         <span style="color: #f6828e;font-weight: 600" v-else>{{item.stateName}}</span>&nbsp;
                        <span style="color: #03752e" v-if="item.num > 0">{{item.num >0 ? '+' + item.num: item.num}}{{item.unit}}</span>
                        <span style="color: #f6828e" v-else>{{item.num}}{{item.unit}}</span>
                      </span>
                      <span style="font-size: 14px;color: #8a8f97;margin-top: 5px">{{item.updateTime}}</span>
                    </div>
                  </div>
                  <el-divider style="margin: 15px 0" v-if="index != data.hazmatData.length-1"></el-divider>
                </div>
              </div>
            <div v-else>
              <el-empty description="暂无数据" style="margin-top: 10%"></el-empty>
            </div>
          </el-card>
        </el-col>
        <el-col :xl="12" :lg="12" :md="24" :sm="24" :xs="24">
          <el-card style="height: 500px;overflow: auto">
            <span style="font-size: 18px;font-weight: 600;margin-bottom: -5px">超期预警</span>
            <el-divider style="margin: 15px 0"></el-divider>
            <div style="padding: 10px;" v-if="data.warningData && data.warningData.length >0">
              <div v-for="(item,index) in data.warningData" :key="index" style="display: flex;flex-direction: column">
                <div style="display: flex">
                  <img :src="avator" style="width: 25px;height: 25px" />
                  <div style="display: flex;flex-direction: column;margin-left: 20px">
                      <span style="font-size: 16px;font-weight: 600">{{item.description}}
                      </span>
                    <span style="font-size: 14px;color: #8a8f97;margin-top: 5px">{{item.createTime}}</span>
                  </div>
                </div>
                <el-divider style="margin: 15px 0" v-if="index != data.hazmatData.length-1"></el-divider>
              </div>
            </div>
            <div v-else>
              <el-empty description="暂无数据" style="margin-top: 10%"></el-empty>
            </div>
          </el-card>
        </el-col>
      </el-row>
    </div>
  </div>
</template>
<script setup>
import { CountTo } from 'vue3-count-to'
import avator from '@/assets/images/avator.png'
import hazmat from '@/assets/logo/hazmat.png'
import warehouse from '@/assets/logo/warehouse.png'
import warning from '@/assets/logo/warning1.png'
import used from '@/assets/logo/used.png'
import * as echarts from 'echarts';
import {nextTick, onMounted, onUnmounted, reactive, ref, shallowRef} from "vue";
import {getFinishBasicList} from "@/api/hazardousChemicals/finishedBasicInfo";
import {ElMessage} from "element-plus";
import {getEntryData, getHazmatUseList, getHoData, getMaxUseData, getUseData} from "@/api/hazardousChemicals/count";
import {getWarning} from "@/api/hazardousChemicals/warning";
import {getRawFlow} from "@/api/hazardousChemicals/rawRecord";
const data = reactive({
  cardList: [
    {
      title: '危化品数量',
      imgUrl: hazmat,
      startVal: 0,
      endVal: null,
      duration: 1500
    },
    {
      title: '使用量',
      imgUrl: used,
      startVal: 0,
      endVal: null,
      duration: 1500
    },
    {
      title: '仓库数量',
      imgUrl: warehouse,
      startVal: 0,
      endVal: null,
      duration: 1500
    },
    {
      title: '预警量',
      imgUrl: warning,
      startVal: 0,
      endVal: null,
      duration: 1500
    },
  ],
  maxUseList: [],
  maxUseName: [],
  useXData: [],
  useYData: [],
  entryXData: [],
  entryYData: [],
  warningData: [],
  warningQueryParams: {
    pageNum: 1,
    pageSize: 10
  },
  wTotal: 0,
  wloading: false,
  hTotal: 0,
  hloading: false,
  hazmatQueryParams: {
    pageNum: 1,
    pageSize: 10
  },
  hazmatData: [],
 
});
const myChart = shallowRef(null)
const pieChart = ref("eChartPieN" + Date .now() + Math .random())
const myBarChart = shallowRef(null)
const barChart = ref("eChartBarN" + Date .now() + Math .random())
const myLineChart = shallowRef(null)
const lineChart = ref("eChartBarN" + Date .now() + Math .random())
 
onMounted(async () => {
  await getHomeData()
  await entryData()
  await useData()
  await maxUseData()
  await getWarningData()
  await getHazmatFlowData()
});
const getWarningData = async () => {
  data.wloading = true
  const res = await getWarning(data.warningQueryParams)
  if(res.code == 200){
    data.warningData =res.data.list.map(item => {
      return {
        ...item,
        description: `${item.createName} 领用了 ${item.hazmatBasic.name} 状态:${item.state ==0?'未处理':'已处理' }`
      }
    })
    data.warningData = data.warningData.filter(item => item.state === 0)
  }else{
    ElMessage.warning(res.message)
  }
  data.wloading = false
}
const getHazmatFlowData = async () => {
  data.hloading = true
  const res = await getRawFlow(data.hazmatQueryParams)
  if(res.code == 200){
    data.hazmatData =res.data.list.map(item => {
      return {
        ...item,
        unit:item.hazmatBasic.unit,
        stateName: item.state ==0 ?'入库': item.state ==1 ? '取用' :item.state ==2 ? '归还': item.state ==3 ? '标签作废' : item.state ==4 ? '用尽登记':item.state ==5 ? '销售' : '',
        description: `${item.user.departName ? item.user.departName +'部门' : ''}   ${item.user.name}  进行了  `
      }
    })
    console.log('data.hazmatData',data.hazmatData)
  }else{
    ElMessage.warning(res.message)
  }
  data.hloading = false
}
const getHomeData = async () => {
  const res = await getHoData(data.queryParams)
  if(res.code == 200){
    data.cardList[0].endVal = res.data.hazmatCount
    data.cardList[1].endVal = res.data.usedCount
    data.cardList[2].endVal = res.data.warehouseCount
    data.cardList[3].endVal = res.data.warningCount
  }else{
    ElMessage.warning(res.message)
  }
}
const entryData = async () => {
  const res = await getEntryData()
  if(res.code == 200){
    data.entryXData = res.data.map(item => item.month+'月' + item.day+'日')
    data.entryYData = res.data.map(item =>item.count)
    await getLineChart()
  }else{
    ElMessage.warning(res.message)
  }
}
const useData = async () => {
  const res = await getUseData()
  if(res.code == 200){
    data.useXData = res.data.map(item => item.day+'日')
    data.useYData = res.data.map(item =>item.count)
    await getBarChart()
  }else{
    ElMessage.warning(res.message)
  }
}
const maxUseData = async () => {
  const res = await getMaxUseData()
  if(res.code == 200){
    data.maxUseList = res.data.map(item => {
      return{
        value: item.count,
        name: item.name
      }
    })
    data.maxUseName = res.data.map(item => item.name)
    await getPieChart()
  }else{
    ElMessage.warning(res.message)
  }
}
const getPieChart = () => {
  if (myChart.value != null && myChart.value != "" && myChart.value != undefined) {
    myChart.value.dispose();
  }
  myChart.value = echarts.init(document.getElementById(pieChart.value));
  let option;
    option = {
      title: {
        text: '近一周频繁使用的危化品量',
        left: 'center'
      },
      tooltip: {
        trigger: 'item'
      },
      legend: {
        orient: 'vertical',
        left: 'left'
      },
      series: [
        {
          name: '',
          type: 'pie',
          radius: '50%',
          data: data.maxUseList,
          emphasis: {
            itemStyle: {
              shadowBlur: 10,
              shadowOffsetX: 0,
              shadowColor: 'rgba(0, 0, 0, 0.5)'
            }
          },
          // showEmptyCircle: false,
        }
      ]
    };
 
 
 
  // 使用刚指定的配置项和数据显示图表。
  myChart.value.setOption(option,true);
  //自适应宽度
  window.addEventListener('resize',function () {
    myChart.value.resize();
  })
}
 
const getBarChart = () => {
  if (myBarChart.value != null && myBarChart.value != "" && myBarChart.value != undefined) {
    myChart.value.dispose();
  }
  myBarChart.value = echarts.init(document.getElementById(barChart.value));
  const option = {
    title: {
      text: '近一周使用量',
      left: 'center'
    },
    tooltip: {
      trigger: 'axis',
      axisPointer: {
        type: 'shadow'
      }
    },
    grid: {
      left: '3%',
      right: '4%',
      bottom: '3%',
      containLabel: true
    },
    xAxis: {
      type: 'category',
      data: data.useXData,
      axisTick: {
        alignWithLabel: true
      }
    },
    yAxis: {
      type: 'value'
    },
    series: [
      {
        data: data.useYData,
        type: 'bar',
        barWidth: '60%',
      }
    ]
  };
  // 使用刚指定的配置项和数据显示图表。
  myBarChart.value.setOption(option,true);
  //自适应宽度
  window.addEventListener('resize',function () {
    myBarChart.value.resize();
  })
}
 
 
const getLineChart = () => {
  if (myLineChart.value != null && myLineChart.value != "" && myLineChart.value != undefined) {
    myLineChart.value.dispose();
  }
  myLineChart.value = echarts.init(document.getElementById(lineChart.value));
  const option = {
    tooltip: {
      trigger: 'axis'
    },
    title: {
      text: '近30天入库量',
      left: 'center'
    },
    grid: {
      left: '3%',
      right: '4%',
      bottom: '3%',
      top: '150px',
      containLabel: true
    },
    xAxis: {
      type: 'category',
      data: data.entryXData
    },
    yAxis: {
      type: 'value'
    },
    series: [
      {
        data: data.entryYData,
        type: 'line',
        smooth: true
      }
    ]
  };
  // 使用刚指定的配置项和数据显示图表。
  myLineChart.value.setOption(option,true);
  //自适应宽度
  window.addEventListener('resize',function () {
    myLineChart.value.resize();
  })
}
 
 
</script>
<style scoped lang="scss">
.homePage{
  padding: 20px;
  background-color: white;
  .imgW{
      width: 50px;
      height: 50px;
    }
  .imgT{
    width: 70px;
    height: 70px;
  }
    .cardContent{
      display: flex;
      align-items: center;
      justify-content: space-between;
      .cardRight{
        display: flex;
        flex-direction: column;
        align-items: center;
        line-height: 35px
      }
    }
 
  .content{
    display: flex;
    flex-wrap: wrap;
    .right{
      flex: 1;
    }
 
  }
  ::-webkit-scrollbar {
    width: 5px;
    height: 5px;
    background-color: #ffffff;
    opacity: 0;
  }
  ::-webkit-scrollbar-track {
    border-radius: 10px;
    background-color: #ffffff;
  }
  ::-webkit-scrollbar-thumb {
    border-radius: 10px;
    /*-webkit-box-shadow: inset 0 0 6px rgba(154,154,154,.3);*/
    background-color: #ffffff;
  }
}
 
</style>