<template>
  <div>
    <el-dialog title="材料预览" :visible.sync="Visible" width="50%" top="2vh">
      <div class="main flex flexc aic">
        <div class="header tac mb20">
          <div class="materals-name mb10">{{ materialsInfo.materialName }}</div>
          <p class="abbreviation">
            材料全称：{{ materialsInfo.materiaFullName }}
          </p>
        </div>
        <div class="preview-box">
          <img class="sample-sheet-img" :src="api + materialsPreview" />
        </div>
      </div>
    </el-dialog>
  </div>
</template>

<script>
export default {
  props: {
    materialsInfo: {
      type: Object,
      required: true,
      default: () => {
        return {};
      },
    },
    previewVisible: {
      type: Boolean,
      required: true,
      default: false,
    },
  },
  computed: {
    Visible: {
      get() {
        return this.previewVisible;
      },
      set(val) {
        this.$emit("update:previewVisible", val);
      },
    },
    materialsPreview() {
      return this.materialsInfo.preViewPath;
    },
  },
  data() {
    return {
      api: process.env.VUE_APP_API_BASE_URL + "/",
      val: "",
    };
  },
};
</script>

<style lang="less" scoped>
/deep/.el-dialog__body {
  max-height: 86vh;
  overflow-y: auto;
  &::-webkit-scrollbar {
    width: 6px;
    overflow-y: auto;
  }

  &::-webkit-scrollbar-thumb {
    border-radius: 6px;
    background-color: rgba(144, 147, 153, 0.5);
  }

  &::-webkit-scrollbar-track {
    border-radius: 6px;
    background: #fff;
  }
}
.main {
  width: 100%;
  .materals-name {
    font-size: 18px;
  }
  .abbreviation {
    font-size: 14px;
    color: #999;
  }

  .preview-box {
    width: 80%;
    // box-shadow: 2px 2px 8px 8px #ccc;
    .sample-sheet-img {
      width: 100%;
    }
  }
}
</style>