<template>
  <!-- 文物基本信息 -->
  <div>
    <el-card shadow="hover">
      <el-descriptions title="文物基本详情" :column="1" labelClassName="label">
        <el-descriptions-item
          :label="item.label"
          v-for="(item, index) in crTabletitle"
          :key="index"
        >
          <div v-if="item.prop == 'faceImagePressUrl'">
            <el-image
              v-if="info['faceImagePressUrl']"
              class="image"
              :src="info['faceImagePressUrl']"
              fit="contain"
              :preview-src-list="[info['faceImageUrl']]"
            >
            </el-image>
            <span v-else>无</span>
          </div>
          <div v-else-if="item.prop == 'imagesVo'">
            <el-image
              v-for="(v, i) in info['imagesVo']"
              :key="i"
              class="image"
              :src="v.pressUrl"
              fit="contain"
              :preview-src-list="imgsList"
            >
            </el-image>
            <span v-if="info['imagesVo'].length == 0">无</span>
          </div>
          <div v-else-if="item.prop == 'videosVo'">
            <VideoPlayer
              class="video"
              v-for="(v, i) in info['videosVo']"
              :key="i"
              :src="v.url"
            />
            <span v-if="info['videosVo'].length == 0">无</span>
          </div>
          <div v-else-if="item.prop == 'audiosVo'">
            <AudioPlayer
              v-for="(v, i) in info['audiosVo']"
              :key="i"
              :url="v.url"
              ref="AudioPlayer"
            />
            <span v-if="info['audiosVo'].length == 0">无</span>
          </div>
          <div v-else-if="item.prop == 'literatureVo'">
            <el-table
              stripe
              border
              :data="info['literatureVo']"
              v-if="info['literatureVo'].length > 0"
            >
              <el-table-column prop="name" label="名称"></el-table-column>
              <el-table-column prop="authors" label="作者"></el-table-column>
              <el-table-column prop="source" label="来源"></el-table-column>
              <el-table-column prop="source" label="操作">
                <template slot-scope="scope">
                  <el-button type="text">预览</el-button>
                </template>
              </el-table-column>
            </el-table>
            <span v-if="info['literatureVo'].length == 0">无</span>
          </div>
          <div v-else-if="item.prop === 'intro'" v-html="info['intro']"></div>
          <span v-else>{{ info[item.prop] || "无" }}</span>
        </el-descriptions-item>
      </el-descriptions>
    </el-card>
  </div>
</template>

<script>
import { crTabletitle } from "../../config";
import VideoPlayer from "@/components/VideoPlayer";
import AudioPlayer from "@/components/AudioPlayer";
export default {
  components: {
    VideoPlayer,
    AudioPlayer,
  },
  props: {
    info: {
      type: Object,
      default: () => ({}),
    },
  },
  computed: {
    // 大图预览的
    imgsList() {
      return this.info.imagesVo.map((item) => {
        return item.url;
      });
    },
  },
  data() {
    return {
      crTabletitle,
    };
  },
};
</script>

<style lang="scss" scoped>
::v-deep .el-descriptions-item__label {
  width: 90px;
  display: inline-block;
}
::v-deep .el-descriptions-item__content {
  flex: 1;
}

.image {
  margin-right: 20px;
  width: 200px;
  height: 200px;
  border: 1px solid #dadada;
  border-radius: 4px;
}
.video {
  width: 400px;
  height: 400px;
  border: 1px solid #dadada;
  border-radius: 4px;
}
</style>
