ll
liukangdong
2024-10-25 f9fd7c038b6405a69c5d070febebab0a59eb821b
screen/src/views/LogisticsCenter.vue
@@ -140,7 +140,9 @@
              <span class="num">80%</span>
            </div>
          </div>
          <div class="center_box_two"></div>
          <div class="center_box_two">
            <div class="echart_map" ref="mapEchart" id="echart_map"></div>
          </div>
        </div>
        <div class="right_box">
          <div class="com_header">
@@ -223,12 +225,13 @@
</template>
<script setup>
import { ref, onMounted } from 'vue'
import { ref, onMounted, nextTick } from 'vue'
import VScaleScreen from 'v-scale-screen'
import Percent from '@/components/percent.vue'
import dayjs from 'dayjs'
import * as echarts from 'echarts'
import chinaJSON from '@/assets/china.json'
const weekMap = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六',]
const date = ref(dayjs().format('YYYY.MM.DD'))
const week = ref(weekMap[new Date().getDay()])
@@ -240,14 +243,15 @@
}, 1000)
const colors = ['#0193FE', '#FFB642', '#5fc6d5']
const colors = ['#0193FE', '#FFB642']
const StockOutData = ref([])
const getStockOut = () => {
  let arr = []
  arr.push({ name: '访客', value: 20 })
  arr.push({ name: '关方', value: 30 })
  arr.push({ name: '省内', value: 20 })
  arr.push({ name: '省外', value: 30 })
  arr.sort((a, b) => b.value - a.value)
  StockOutData.value = arr
  initEchart1()
}
const initEchart1 = () => {
@@ -269,6 +273,38 @@
          show: false
        },
        data: StockOutData.value
      }
    ]
  }
  myChart.setOption(option)
  window.addEventListener('resize', function () { // 执行
    myChart.resize()
  })
}
const initEchart2 = () => {
  const myChart = echarts.init(document.getElementById('echart1'))
  const option = {
    series: [
      {
        type: 'pie',
        radius: ['86%', '100%'],
        label: {
          show: false,
          position: 'center'
        },
        padAngle: 5,
        itemStyle: {
          borderRadius: 10
        },
        color: colors,
        labelLine: {
          show: false
        },
        data: [
          { value: 1048, name: 'Search Engine' },
          { value: 735, name: 'Direct' },
          { value: 580, name: 'Email' }
        ]
      }
    ]
  }
@@ -351,15 +387,25 @@
        splitNumber: 4
      }
    },
    legend: {
      itemGap: 24,
      icon: 'rect',
      right: '12px',
      top: '0',
      itemWidth: 16,
      itemHeight: 2,
      textStyle: {
        color: '#fff',
        borderColor: '#fff'
      },
      data: ['总入库量', '总出库量']
    },
    grid: {
      top: '18%',
      left: '0%',
      right: '2%',
      bottom: '2%',
      containLabel: true
    },
    legend: {
      data: ['总入库量', '总出库量']
    },
    series: [
      {
@@ -411,11 +457,11 @@
          width: 1.5, // 线条粗细
        },
        symbol: 'circle',
        symbolSize: 10,
        symbolSize: 6,
        itemStyle: {
          normal: {
            color: '#4191f6', //折线点的颜色
          },
          color: "#4190f4",
          borderColor: "rgba(255,255,255,.3)",
          borderWidth: 6,
        },
        smooth: true
      },
@@ -462,11 +508,11 @@
          width: 2, // 线条粗细
        },
        symbol: 'circle',
        symbolSize: 10,
        symbolSize: 6,
        itemStyle: {
          normal: {
            color: '#F3BD00', //折线点的颜色
          },
          color: "#F3BD00",
          borderColor: "rgba(255,255,255,.3)",
          borderWidth: 6,
        },
        smooth: true
      }
@@ -482,197 +528,514 @@
  const myChart = echarts.init(document.getElementById('echart5'))
  // 绘制图表
  myChart.setOption({
    tooltip: {
      trigger: 'axis',
      axisPointer: {
        type: 'cross',
        crossStyle: {
          color: '#999'
        }
      }
    },
    toolbox: {
      feature: {
        dataView: { show: true, readOnly: false },
        magicType: { show: true, type: ['line', 'bar'] },
        restore: { show: true },
        saveAsImage: { show: true }
      }
    },
    legend: {
      data: ['Evaporation', 'Precipitation', 'Temperature']
      itemGap: 12,
      // icon: 'circle',
      right: '12px',
      top: '0',
      data: ['总库存', '当前库存', '库存利用率'],
      itemWidth: 20,
      itemHeight: 10,
      textStyle: {
        color: '#fff',
        borderColor: '#fff'
      },
    },
    xAxis: [
      {
        type: 'category',
        data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'],
        axisPointer: {
          type: 'shadow'
        }
      }
    ],
    yAxis: [
      {
        type: 'value',
        name: 'Precipitation',
        min: 0,
        max: 250,
        interval: 50,
        axisLabel: {
          formatter: '{value} ml'
        }
      },
      {
        type: 'value',
        name: 'Temperature',
        min: 0,
        max: 25,
        interval: 5,
        axisLabel: {
          formatter: '{value} °C'
        }
      }
    ],
    series: [
      {
        name: 'Evaporation',
        type: 'bar',
        tooltip: {
          valueFormatter: function (value) {
            return value + ' ml'
          }
        },
        data: [
          2.0, 4.9, 7.0, 23.2, 25.6, 76.7, 135.6, 162.2, 32.6, 20.0, 6.4, 3.3
        ]
      },
      {
        name: 'Precipitation',
        type: 'bar',
        tooltip: {
          valueFormatter: function (value) {
            return value + ' ml'
          }
        },
        data: [
          2.6, 5.9, 9.0, 26.4, 28.7, 70.7, 175.6, 182.2, 48.7, 18.8, 6.0, 2.3
        ]
      },
      {
        name: 'Temperature',
        type: 'line',
        yAxisIndex: 1,
        tooltip: {
          valueFormatter: function (value) {
            return value + ' °C'
          }
        },
        data: [2.0, 2.2, 3.3, 4.5, 6.3, 10.2, 20.3, 23.4, 23.0, 16.5, 12.0, 6.2]
      }
    ]
  })
  window.addEventListener('resize', function () {//执行
    myChart.resize()
  })
}
const arr = ['#68e2e3', '#50afd3', '#377cdb', '#d5ae3a']
const initEnergy = () => {
  var myChart = echarts.init(document.querySelector('.energyRef'))
  // 绘制图表
  const arr = ['#68e2e3', '#50afd3', '#377cdb', '#d5ae3a']
  myChart.setOption({
    grid: {
      top: '20%',
      left: '2%',
      right: '2%',
      bottom: '4%',
      left: '3%',
      right: '4%',
      bottom: '3%',
      top: '16%',
      containLabel: true
    },
    tooltip: {
      trigger: 'axis',
      axisPointer: {
        type: 'line'
      },
      trigger: 'axis'
    },
    xAxis: {
    xAxis: [{
      nameGap: 5,
      type: 'category',
      data: [1, 2, 3, 4, 4, 5]
    },
    yAxis: {
      type: 'value',
      name: 'kw·h',
      nameTextStyle: {
        padding: [0, 0, 4, -30]    // 四个数字分别为上右下左与原位置距离
      },
      splitLine: {
      axisLine: {
        show: true,
        lineStyle: {
          //这里输入线条的样式
          color: 'rgba(255,255,255,0.14)',
        }
          color: '#999'
        },
      },
      axisLabel: {
        color: '#869CC9'
        // fontSize: 24,
      },
      axisTick: {
        show: false,
      },
      data: ['合肥', '滁州', '芜湖', '蚌埠', '阜阳'],
    }],
    yAxis: [
      {
        nameTextStyle: {
          color: '#869CC9',
        },
        offset: 0,
        name: '万支',
        type: 'value',
        axisLabel: {
          show: true,
          color: "#869CC9",
        },
        axisLine: {
          show: true,
        },
        splitLine: {
          show: true,
          lineStyle: {
            width: 1,
            color: "rgba(49,105,129,0.4)",
            type: 'dashed'
          }
        },
      },
      {
        type: 'value',
        name: '%',
        min: 0,
        max: 100,
        // interval: 5,
        axisLabel: {
          formatter: '{value}%'
        },
        splitLine: false
      }
    },
    ],
    series: [
      {
        data: [1, 2, 3, 4, 5],
        name: '总库存',
        type: 'bar',
        barWidth: 10,
        barWidth: 8,
        barGap: '60%',
        label: {
          show: false,
          position: 'top',
          color: '#fff',
        },
        itemStyle: {
          normal: {
            color: new echarts.graphic.LinearGradient(
              0, 0, 0, 1,
              [
                { offset: 0, color: arr[1] },
                { offset: 1, color: '#080807' }
              ]
            ),
            barBorderRadius: [10, 10, 0, 0]
          }
        }
          color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
            {
              offset: 0,
              color: '#5bc7d5'
            },
            {
              offset: 1,
              color: '#1a3f55'
            }
          ], false),
          lineStyle: {
            width: 1,
            type: 'solid'
          },
          barBorderRadius: [30, 30, 0, 0],
        },
        data: [900, 438, 485, 631, 689]
      },
      {
        name: '当前库存',
        type: 'bar',
        barWidth: 8,
        label: {
          show: false,
          position: 'top',
          color: '#fff',
        },
        itemStyle: {
          color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
            {
              offset: 0,
              color: '#edaf3d'
            },
            {
              offset: 1,
              color: '#323522'
            }
          ], false),
          lineStyle: {
            width: 1,
            type: 'solid'
          },
          barBorderRadius: [30, 30, 0, 0],
        },
        data: [438, 485, 631, 689, 900]
      },
      {
        name: '库存利用率',
        type: 'line',
        smooth: true,
        showAllSymbol: true,
        symbol: 'none',
        lineStyle: {
          color: "#3d87e5"
        },
        label: {
          show: false,
          position: 'top',
          color: '#fff',
        },
        data: [485, 631, 389, 224, 287]
      }
    ]
  })
  window.addEventListener('resize', function () {//执行
    myChart.resize()
  })
}
const initEchart2 = () => {
  const myChart = echarts.init(document.getElementById('echart1'))
const mapEchart = ref()
const initMap = () => {
  var myChart = echarts.init(mapEchart.value)
  echarts.registerMap('china', chinaJSON)
  var points = [
    // 点坐标
    { value: [110.81, 33.40], itemStyle: { color: '#c1bb1f' }, name: '11', total: 0, bj: 0, yj: 0, yx: 0, tj: 0, dw: 0 },
    { value: [116.55, 40.01], itemStyle: { color: '#3eef1d' }, name: '北京', total: 0, bj: 0, yj: 0, yx: 0, tj: 0, dw: 0 },
    { value: [113.11, 28.40], itemStyle: { color: '#3eef1d' }, name: '22', total: 5, bj: 0, yj: 0, yx: 5, tj: 0, dw: 0 },
    { value: [106.44, 29.50], itemStyle: { color: '#3eef1d' }, name: '33', total: 10, bj: 0, yj: 0, yx: 10, tj: 0, dw: 0 },
    { value: [112.85, 38.95], itemStyle: { color: '#3eef1d' }, name: '44', total: 8, bj: 0, yj: 0, yx: 8, tj: 0, dw: 0 },
    { value: [82.78, 43.27], itemStyle: { color: '#3eef1d' }, name: '55', total: 18, bj: 0, yj: 0, yx: 18, tj: 0, dw: 0 }
  ]
  var lineToLf = [
    { name: '11', coords: [[110.81, 33.40], [116.55, 40.01]], lineStyle: { color: '#c1bb1f' } },
    { name: '22', coords: [[113.11, 28.40], [116.55, 40.01]], lineStyle: { color: '#3eef1d' } },
    { name: '33', coords: [[106.44, 29.50], [116.55, 40.01]], lineStyle: { color: '#3eef1d' } },
    { name: '44', coords: [[112.85, 38.95], [116.55, 40.01]], lineStyle: { color: '#3eef1d' } },
    { name: '55', coords: [[82.78, 43.27], [116.55, 40.01]], lineStyle: { color: '#3eef1d' } }
  ]
  const option = {
    series: [
      {
        type: 'pie',
        radius: ['86%', '100%'],
        label: {
          show: false,
          position: 'center'
    backgroundColor: 'transparent', // 设置背景色透明
    // 必须设置
    tooltip: {
      show: false
    },
    // 地图阴影配置
    geo: {
      map: 'china',
      // 这里必须定义,不然后面series里面不生效
      tooltip: {
        show: false
      },
      label: {
        show: false
      },
      zoom: 1.5,
      silent: true, // 不响应鼠标时间
      show: true,
      roam: false, // 地图缩放和平移
      aspectScale: 0.75, // scale 地图的长宽比
      itemStyle: {
        borderColor: '#2d5f9c',
        borderWidth: 1,
        areaColor: '#2d5f9c',
        shadowColor: 'rgba(1,34,73,0.48)',
        shadowBlur: 10,
        shadowOffsetX: -10, //
        shadowOffsetY: 10
      },
      select: {
        disabled: true
      },
      emphasis: {
        disabled: true,
        areaColor: '#00F1FF'
      },
      // 地图区域的多边形 图形样式 阴影效果
      // z值小的图形会被z值大的图形覆盖
      top: '30.2%',
      left: 'center',
      // 去除南海诸岛阴影 series map里面没有此属性
      regions: [{
        name: '南海诸岛',
        selected: false,
        emphasis: {
          disabled: true
        },
        padAngle: 5,
        itemStyle: {
          borderRadius: 10
        },
        color: colors,
        labelLine: {
          areaColor: '#00000000',
          borderColor: '#00000000'
        }
      }],
      z: 1
    },
    series: [
      // 地图配置
      {
        type: 'map',
        map: 'china',
        zoom: 1.5,
        tooltip: {
          show: false
        },
        data: [
          { value: 1048, name: 'Search Engine' },
          { value: 735, name: 'Direct' },
          { value: 580, name: 'Email' }
        ]
        label: {
          show: true, // 显示省份名称
          color: '#fff',
          fontSize: 13,
          shadowColor: '#fff',
          shadowBlur: 10,
          shadowOffsetX: 2,
          shadowOffsetY: 2,
          textBorderColor: '#fff',
          // rotate: 90,
          align: 'center'
        },
        top: '28%',
        left: 'center',
        aspectScale: 0.75,
        roam: false, // 地图缩放和平移
        itemStyle: {
          borderColor: '#4278a3', // 省分界线颜色  阴影效果的
          borderWidth: 1,
          areaColor: '#1d3f71',
          opacity: 1
        },
        // 去除选中状态
        select: {
          disabled: true
        },
        emphasis: { // 聚焦后颜色
          disabled: false, // 开启高亮
          label: {
            align: 'center',
            color: '#04CFF5'
          },
          itemStyle: {
            color: '#ffffff',
            areaColor: '#3c87b2'// 阴影效果 鼠标移动上去的颜色
          }
        },
        z: 2
      },
      // 点
      {
        name: 'companyPoint',
        type: 'effectScatter',
        coordinateSystem: 'geo',
        showEffectOn: 'render',
        // zlevel: 2, // zlevel用于 Canvas 分层 相同的绘制在同一个canvas上
        rippleEffect: {
          number: 5, // 波纹数量
          period: 4, // 动画周期 数值越大,波动越慢
          scale: 3.5, // 动画中波纹的最大缩放比例
          brushType: 'stroke' // 波纹的绘制方式 stroke fill
        },
        label: {
          show: false,
          position: 'right',
          formatter: '{b}',
          color: '#97e9e1',
          fontSize: 14
        },
        symbol: 'circle',
        symbolSize: 8,
        data: points,
        tooltip: {
          show: true,
          backgroundColor: 'rgba(0,0,0,0)',
          padding: 0,
          borderWidth: 0,
          extraCssText: 'box-shadow: 0 0 0 rgba(0, 0, 0, 0);', // 去除box-shadow阴影
          formatter: (params) => {
            return `<div class="map-tip-box">
                        <div class="company-name">${params.name}</div>
                        <div class="monitor-total">监测总数:${params.data.total}台</div>
                        <div class="item-state-con">
                          <span class="dot bj"></span>
                          <span class="item-state-num">
                           <span class="num">${params.data.bj}台</span>
                           <span class="text">报警</span>
                          </span>
                        </div>
                         <div class="item-state-con">
                          <span class="dot yj"></span>
                          <span class="item-state-num">
                           <span class="num">${params.data.yj}台</span>
                           <span class="text">预警</span>
                          </span>
                        </div>
                         <div class="item-state-con">
                          <span class="dot yx"></span>
                          <span class="item-state-num">
                           <span class="num">${params.data.yx}台</span>
                           <span class="text">运行</span>
                          </span>
                        </div>
                         <div class="item-state-con">
                          <span class="dot tj"></span>
                          <span class="item-state-num">
                           <span class="num">${params.data.tj}台</span>
                           <span class="text">停机</span>
                          </span>
                        </div>
                         <div class="item-state-con">
                          <span class="dot dw"></span>
                          <span class="item-state-num">
                           <span class="num">${params.data.dw}台</span>
                           <span class="text">断网</span>
                          </span>
                        </div>
                       </div>`
          }
        },
        z: 4
      },
      // 地图线的动画效果
      {
        name: 'arrowline',
        type: 'lines',
        // zlevel: 1,
        effect: {
          show: true,
          period: 3, // 箭头指向速度,值越小速度越快
          trailLength: 0.1, // 特效尾迹长度[0,1]值越大,尾迹越长重
          symbol: 'arrow', // 箭头图标
          symbolSize: 6 // 图标大小
        },
        lineStyle: {
          color: '#1DE9B6',
          width: 2, // 线条宽度
          opacity: 0.1, // 尾迹线条透明度
          curveness: 0.2 // 尾迹线条曲直度
        },
        data: lineToLf,
        z: 3
      }
    ]
  }
  myChart.setOption(option)
  window.addEventListener('resize', function () { // 执行
  window.addEventListener('resize', function () {//执行
    myChart.resize()
  })
}
const initEnergy = () => {
  var myChart = echarts.init(document.querySelector('.energyRef'))
  // 绘制图表
  myChart.setOption({
    tooltip: {
      trigger: 'axis',
      axisPointer: {
        // Use axis to trigger tooltip
        type: 'shadow' // 'shadow' as default; can also be 'line' or 'shadow'
      }
    },
    legend: {
      itemGap: 24,
      // icon: 'circle',
      right: '12px',
      top: '16px',
      itemWidth: 28,
      itemHeight: 14,
      textStyle: {
        color: '#fff',
        borderColor: '#fff'
      },
    },
    grid: {
      left: '3%',
      right: '4%',
      bottom: '3%',
      top: '15%',
      containLabel: true
    },
    xAxis: {
      type: 'value',
      splitLine: {
        show: true,
        lineStyle: {
          //这里输入线条的样式
          color: 'rgba(255,255,255,0.14)'
        },
        splitNumber: 4
      }
    },
    yAxis: {
      axisTick: {
        show: false,
      },
      type: 'category',
      axisLine: {
        show: false
      },
      data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
    },
    series: [
      {
        name: '在途',
        type: 'bar',
        stack: 'total',
        barWidth: 14,
        label: {
          show: true
        },
        emphasis: {
          focus: 'series'
        },
        data: [320, 302, 301, 334, 390, 330, 320],
        itemStyle: {
          normal: {
            color: {
              type: 'linear',
              x: 0,
              y: 0,
              x2: 1,
              y2: 0,
              colorStops: [{
                offset: 0,
                color: '#204d75'
              }, {
                offset: 1,
                color: '#2f6eae'
              }]
            }
          }
        },
      },
      {
        name: '到货',
        type: 'bar',
        barWidth: 14,
        stack: 'total',
        label: {
          show: true
        },
        itemStyle: {
          normal: {
            color: {
              type: 'linear',
              x: 0,
              y: 0,
              x2: 1,
              y2: 0,
              colorStops: [{
                offset: 0,
                color: '#3e8593'
              }, {
                offset: 1,
                color: '#5cc2d2'
              }]
            }
          }
        },
        emphasis: {
          focus: 'series'
        },
        data: [120, 132, 101, 134, 90, 230, 210]
      }
    ]
  })
  window.addEventListener('resize', function () {//执行
    myChart.resize()
  })
}
onMounted(() => {
  initEnergy()
  initMap()
  getStockOut()
  initEchart2()
  initEchart3()
@@ -683,11 +1046,16 @@
</script>
<style>
.map-tip-box{
  background-color: #1f3b57;
  color: #fff;
}
</style>
<style lang="scss" scoped>
div {
  box-sizing: border-box;
}
.main_content {
  display: flex;
  padding: 20px 25px 0;
@@ -786,11 +1154,17 @@
    .left_box_two {
      margin-bottom: 20px;
      border: 1px solid;
      position: relative;
      .second_title {
        position: absolute;
        top: 14px;
        left: 20px;
      }
      .energy_wrap {
        width: 100%;
        height: 250px;
        height: 300px;
        .energyRef {
          width: 100%;
@@ -840,6 +1214,8 @@
    flex: 1;
    padding: 0 20px;
    margin: 0 40px;
    display: flex;
    flex-direction: column;
    .center_box_one {
      background: rgba(255, 255, 255, 0.02);
@@ -964,7 +1340,15 @@
    .center_box_two {
      width: 100%;
      border: 1px solid;
      flex: 1;
      /* border: 1px solid; */
      .echart_map {
        width: 100%;
        height: 100%;
        border: 1px solid;
        /* transform: scale(.2); */
      }
    }
  }