<template>
  <div>
    <el-drawer size="1200px" :visible.sync="drawer" direction="rtl">
      <div slot="title" class="title flex">
        <span
          >材料列表（共{{
            matterInfo.matterDatumList ? matterInfo.matterDatumList.length : 0
          }}个）</span
        >
        <span class="matter-name flex1 flexwrap"
          >事项全称：<span v-html="matterInfo.matterFullName"></span>
        </span>
      </div>
      <!-- 列表 -->
      <div
        class="matterDatumList-list flex flexwrap jcb"
        v-if="matterInfo.matterDatumList && matterInfo.matterDatumList.length"
      >
        <div
          class="matterDatumList-item flex flexc aic"
          v-for="v in matterInfo.matterDatumList"
          :key="v.id"
          @click="handleWrite"
        >
          <div class="pic-box">
            <div class="pic-img-box">
              <img class="pic" :src="api + v.preViewPath" />
            </div>
          </div>
          <div class="for-short">{{ v.materialName }}</div>
          <div class="matterDatumList-name">
            材料全称：{{ v.materiaFullName }}
          </div>
          <!-- <div class="check-btn" @click.stop>点击查看二维码</div> -->
        </div>
        <div
          class="list"
          v-for="item in row - (matterInfo.matterDatumList.length % row)"
          v-show="matterInfo.matterDatumList.length % row > 0"
          :key="'list' + item"
        ></div>
      </div>
      <el-empty class="empty" :image-size="200" v-else></el-empty>
    </el-drawer>
  </div>
</template>

<script>
import local from "@/utils/local";
export default {
  props: {
    visible: {
      type: Boolean,
      required: true,
      default: false,
    },
    matterInfo: {
      type: Object,
      required: true,
      default: () => {
        return {};
      },
    },
  },
  data() {
    return {
      api: local.getLocal("baseUrl")
        ? local.getLocal("baseUrl") + "/"
        : "http://192.168.0.98:11078/",
      row: 4,
    };
  },
  computed: {
    drawer: {
      get() {
        return this.visible;
      },
      set(val) {
        this.$emit("update:visible", val);
      },
    },
  },
  methods: {
    handleWrite() {
      this.$router.push({
        path: "/showMaterials",
        query: {
          matterName: this.matterInfo.matterName,
          matterId: this.matterInfo.id,
        },
      });
    },
  },
};
</script>

<style lang="less" scoped>
:deep(.el-drawer__header) {
  margin-bottom: 20px;
}
:deep(.el-drawer__body) {
  border-top: 1px solid #e0e0e0;
  padding: 40px;
  padding-top: 0px;
  position: relative;
  overflow-y: auto;
  &::-webkit-scrollbar {
    width: 12px;
    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;
  }
}
.empty {
  position: absolute;
  left: 0;
  top: 0;
  right: 0;
  bottom: 0;
}
.title {
  font-size: 28px;
  font-family: Source Han Sans CN;
  font-weight: 500;
  color: #333333;
  .matter-name {
    display: inline-block;
    // width: 1000px;
    font-size: 20px;
    font-family: Source Han Sans CN;
    line-height: 34px;
    color: #777777;
    // overflow: hidden;
    // text-overflow: ellipsis;
    // white-space: nowrap;
  }
}
.matterDatumList-list {
  width: 100%;
  height: 100%;
  align-content: flex-start;

  .list {
    content: "";
    width: 236px;
    border: 1px solid transparent;
    padding: 5px;
    overflow: hidden;
  }
}
.matterDatumList-item {
  width: 236px;
  margin-top: 40px;
  // height: 430px;
  .pic-box {
    width: 236px;
    height: 300px;
    padding: 16px 24px;
    background: #f4f6fc;
    border-radius: 16px;
    .pic-img-box {
      width: 100%;
      height: 100%;
      border-radius: 4px;
      overflow: hidden;
    }
    img {
      width: 100%;
      min-height: 100%;
      border-radius: inherit;
    }
  }
  .for-short {
    width: 100%;
    margin-top: 18px;
    margin-bottom: 8px;
    font-size: 24px;
    font-family: Source Han Sans CN;
    color: #333333;
    letter-spacing: 1px;
    overflow: hidden;
    text-align: center;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .matterDatumList-name {
    width: 100%;
    font-size: 18px;
    font-family: Source Han Sans CN;
    color: #777777;
    line-height: 30px;
    letter-spacing: 1px;
    text-align: left;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
  }
  .check-btn {
    width: 185px;
    height: 50px;
    margin-top: 18px;
    background-color: #e6effd;
    border-radius: 8px;
    font-size: 20px;
    font-family: Source Han Sans CN;
    color: var(--main-theme-color1);
    text-align: center;
    line-height: 50px;
    cursor: pointer;
  }
}
</style>