<template>
  <div>
    <el-drawer size="70%" :visible.sync="drawer" direction="rtl">
      <div slot="title" class="title flex aic">
        <span
          >材料列表（共{{
            matterInfo.materals ? matterInfo.materals.length : 0
          }}个）</span
        >
        <span class="matter-name">事项名称：{{ matterInfo.matterName }}</span>
      </div>
      <!-- 列表 -->
      <div
        class="materals-list flex flexwrap jcb"
        v-if="matterInfo.materals && matterInfo.materals.length"
      >
        <div
          class="materals-item flex flexc aic"
          v-for="v in matterInfo.materals"
          :key="v.id"
          @click="handleWrite"
        >
          <div class="pic-box">
            <img :src="api + v.preViewPath" />
          </div>
          <div class="for-short">{{ v.materialName }}</div>
          <div class="materals-name">
            {{ v.materiaFullName }}
          </div>
          <!-- <div class="check-btn" @click.stop>点击查看二维码</div> -->
        </div>
        <div
          class="list"
          v-for="item in row - (matterInfo.materals.length % row)"
          v-show="matterInfo.materals.length % row > 0"
          :key="'list' + item"
        ></div>
      </div>
      <el-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:11074/",
      row: 5,
    };
  },
  computed: {
    drawer: {
      get() {
        return this.visible;
      },
      set(val) {
        this.$emit("update:visible", val);
      },
    },
  },
  methods: {
    handleWrite() {
      this.$router.push({
        path: "/writepage",
        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;
}
.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;
    font-weight: 400;
    color: #777777;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}
.materals-list {
  width: 100%;
  height: 100%;
  align-content: flex-start;
  overflow-y: auto;
  .list {
    content: "";
    width: 19%;
    border: 1px solid transparent;
    padding: 5px;
    overflow: hidden;
  }
}
.materals-item {
  width: 19%;
  margin-top: 40px;
  // height: 430px;
  .pic-box {
    width: 207px;
    height: 256px;
    padding: 16px 24px;
    background: #f4f6fc;
    border-radius: 16px;
    img {
      width: 100%;
      height: 100%;
    }
  }
  .for-short {
    margin-top: 18px;
    margin-bottom: 8px;
    font-size: 24px;
    font-family: Source Han Sans CN;
    color: #333333;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .materals-name {
    font-size: 18px;
    font-family: Source Han Sans CN;
    color: #777777;
    line-height: 30px;
    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>