<template>
  <div class="aqdt-show-container">
    <div class="aqdt-show-content">
      <div style="text-align: center;font-size: 30px;font-weight: bolder;padding-bottom: 10px;">{{ row.name }}</div>
      <div class="aqdt-divider"></div>

      <div class="content-other-info">
        <span>
          <span>发布时间：{{ row.time }}</span>
        </span>
      </div>

      <!-- 内容 -->
      <div class="aqdt-content-txt" v-html="row.content">

      </div>
      <div v-if="imgList && imgList.length > 0" class="aqdt-pic">
        <div v-for="item in imgList">
          <!-- <el-image style="width: 80%;" :src="item.url" fit="contain"></el-image> -->
          <img style="height: 400px;margin-top: 20px;" :src="item.url" alt="无图片" />
        </div>
      </div>
      <div v-if="titleFile && titleFile.length > 0" class="aqdt-pic">
        <div v-for="item in titleFile">
          <!-- <el-image style="width: 80%;" :src="item.url" fit="contain"></el-image> -->
          <img style="height: 400px;margin-top: 20px;" :src="item.url" alt="无图片" />
        </div>
      </div>
    </div>
  </div>
</template>

<script setup>
import { ref, onMounted } from "vue";
import { useRoute, useRouter } from "vue-router";
import { getApi } from '@/api/tobAcco_api.js';
const route = useRoute();

const row = ref({});
const imgList = ref([]);
/** 其他图片 */
const titleFile = ref([]);

/** 设置图片 */
const setPic = (res) => {
  // 动态标题图片
  imgList.value = []
  let imgIds = res.titleFile?.length > 0 ? res.titleFile.split(',') : [];
  imgIds.forEach(imgId => {
    getApi({}, `/mosty-base/minio/file/download/${imgId}`).then((res) => {
      if (res?.url) imgList.value.push({ url: res.url });
    })
  });
  // 其他动态图片
  let imgIds2 = res.otherFile?.length > 0 ? res.otherFile.split(',') : [];
  imgIds2.forEach(imgId => {
    getApi({}, `/mosty-base/minio/file/download/${imgId}`).then((res) => {
      if (res?.url) titleFile.value.push({ url: res.url });
    })
  });
}
// 查询详情
const queryDetail = (params) => {
  getApi({ id: params.id }, "/mosty-jcgl/securityDynamics/selectOne").then((res) => {
    res = res || {}
    row.value = {
      name: res.name,
      time: res.time,
      content: res.content,
      // otherFile
    }
    setPic(res);
  })
}
onMounted(() => {
  const { query, params } = route;

  try {
    let currRow = JSON.parse(params.row);
    currRow = currRow || {};
    queryDetail(params);
  } catch (error) {
    console.error(error);
  }
})
</script>

<style lang="scss" scoped>
.aqdt-show-container {
  background-color: #fff;
  color: #000;
  padding: 10px;

  .aqdt-show-content {
    height: calc(100vh - 155px);
    padding: 15px;
    border: 1px solid #ebeef5;
    overflow-y: auto;

    .aqdt-divider {
      height: 4px;
      width: 100%;
      background-color: var(--el-color-primary);
    }

    .content-other-info {
      margin-top: 10px;
      color: #666;
    }

    .aqdt-pic {
      text-align: center;
      margin-top: 20px;

      ::v-deep .el-image {
        background-color: initial;
      }
    }
  }
}
</style>
