<template>
  <div class="bigBox">
    <img
      src="../../../../../assets/images/report01.png"
      alt=""
      class="sealImg"
    />
    <div class="top">
      <div class="topIcon">
        <img src="../../../../../assets/images/report03.png" alt="" />
        <div class="topIconDescribe">
          <div class="describeH">#铸坯编号</div>
          <div class="describeS">{{ data?.prdNo }}</div>
        </div>
      </div>
      <div class="topTitle">
        <div class="topTitleNumber">{{ data?.prdSection }}m²</div>
        <div class="topTitleName">
          <svg-icon icon-class="casting-4" />铸坯截面尺寸
        </div>
      </div>
      <div class="topTitle">
        <div class="topTitleNumber">{{ data?.prdThick }}mm</div>
        <div class="topTitleName">
          <svg-icon icon-class="casting-3" />铸坯直径
        </div>
      </div>
      <div class="topTitle">
        <div class="topTitleNumber">{{ data?.prdLength }}m</div>
        <div class="topTitleName">
          <svg-icon icon-class="casting-1" />铸坯长度
        </div>
      </div>
      <div class="topTitle">
        <div class="topTitleNumber">{{ data?.prdWeight }}t</div>
        <div class="topTitleName">
          <svg-icon icon-class="casting-2" />铸坯重量
        </div>
      </div>
    </div>
    <div v-if="pageType" class="slider-demo-block">
      <el-slider v-model="sliderValue" range :marks="marks" :max="sliderMax" />
    </div>
    <div class="bottom" v-else>
      <span>铸坯生产开始时间：</span><i>{{ data?.prdStartTime }}</i>
      <span>铸坯生产结束时间：</span><i>{{ data?.prdEndTime }}</i>
    </div>
  </div>
</template>

<script setup>
import { computed, watch } from 'vue';

const props = defineProps({
  pageType: {
    type: Boolean,
    default: true
  },
  sliderMax: {
    type: Number,
    default: 20
  },
  sliderVal: {
    type:Array,
    default: () => [0,0]
  },
  data: {
    type: Object,
    default: () => {
      return {}
    }
  }
});
const sliderValue = ref([])
watch(() => props.sliderVal, (val)=>{
  if (val && val.length == 2) {
    sliderValue.value = val
  } else {
    sliderValue.value = [null, null]
  }
},{deep:true, immediate:true})
// 动态设置铸坯条的刻度点
const marks = computed(()=>{
  let marks = {}
  for(let i = 0; i < props.sliderMax; i++){
    marks[i] = `${i}${i === 0 ? 'm' : ''}`
  }
  props.sliderVal.forEach(item => {
    marks[item] = {
      label:`${item}m`,
      style:{ color: 'var(--el-color-primary)', bottom: '-37px'}
    }
  })
  return marks
})
</script>

<style lang="scss" scoped>
.bigBox {
  width: 100%;
  // height: 192px;
  border-top: 3px solid #e83333;
  position: relative;
  margin: 20px 0 50px;
  border-radius: 8px;
  background-image: linear-gradient(rgba(249, 110, 110, 0.1), #fff);
  .sealImg {
    position: absolute;
    left: 3%;
    top: -7%;
  }
  .top {
    display: flex;
    justify-content: space-around;
    height: 96px;
    .topIcon {
      display: flex;
      justify-content: space-around;
      margin-right: 15%;
      height: 96px;
      align-items: center;
      img {
        vertical-align: middle;
        width: 70px;
        height: 70px;
        margin-right: 15px;
      }
      .topIconDescribe {
        vertical-align: middle;
        .describeH {
          font-size: 16px;
          font-weight: 600;
          height: 24px;
          line-height: 24px;
        }
        .describeS {
          color: #e83333;
          font-weight: 700;
          font-size: 24px;
          height: 32px;
          line-height: 32px;
        }
      }
    }
    .topTitle {
      width: 160px;
      text-align: center;
      margin-top: 20px;
      .topTitleNumber {
        font-weight: 700;
        font-size: 22px;
        height: 30px;
        line-height: 30px;
        color: #e83333;
        font-family: din;
      }
      .topTitleName {
        font-weight: 400;
        font-size: 14px;
        height: 22px;
        line-height: 22px;
        color: #7b828e;
        .svg-icon {
          font-size: 16px;
          margin-right: 4px;
        }
      }
    }
  }
  .slider-demo-block{
    margin-top: 20px;
    padding: 0 20px;
    height: 105px;
    .el-slider{
      height: 46px;
      :deep(.el-slider__runway){
        pointer-events: none;
        height: 46px;
        background: #EBEDEE;
        .el-slider__bar{
          height: 100%;
          background-image: linear-gradient(to right,  #e65c37, #C52B2B);
          border-radius: 4px;
        }
        .el-slider__marks-stop{
          bottom: -24px;
          background: #EBEDEE;
          height: 20px;
          border-radius: 0;
          width: 1px;
          border: none;
        }
        .el-slider__marks{
          bottom: -10px;
          .el-slider__marks-text{
            bottom: -50px;
          }
        }
        .el-slider__button-wrapper{
          display: none;
        }
      }
    }
  }
  .bottom {
    margin-top: 10px;
    padding-left: 35px;
    font-size: 14px;
    > span {
      color: #0b182d;
    }
    > i {
      font-style: normal;
      color: #7b828e;
      margin-right: 32px;
    }
  }
}
</style>
