<template>
  <div class="outlist">
    <div v-for="(item, index) in list_arr" :key="index + 1100" class="list">
      <span :class="item.prop && item.prop == 'title' ? 'service_title' : ''">
        <span class="line" v-if="item.prop && item.prop == 'title'"></span>
        {{ item.title }}
      </span>
      <span v-if="!(item.prop && item.prop == 'title')">
        <span v-if="item.type == 'url'" style="white-space: pre-wrap">
          访问地址:
          <a :href="item.info" target="_blank">{{ item.info }}</a>
        </span>
        <span v-else-if="item.type == 'time'">{{
          dateStringTransform(item.info)
        }}</span>
        <span
          v-else-if="item.type == 'explain'"
          v-html="item.info"
          style="white-space: pre-wrap"
        ></span>
        <span v-else-if="item.type == 'downArr' && item.info && item.info.length > 0">
          <div v-for="(e,i) in item.info" :key="'file' + i" class="file_box">
            <span>{{downloadFileFormat(e)}}</span>
            <span
              class="filebtn"
              @click="download(item.url[i])"
            >
            <span>下载文件</span>
          </span>
          </div>
        </span>
        <span v-else v-html="item.info" style="white-space: pre-wrap"></span>
        <span
          v-if="item.type && item.type == 'down' && item.url != ''"
          class="filebtn"
          @click="download(item.url)"
          >下载文件</span
        >
      </span>
      <slot
        v-if="item.type && item.type == 'solt'"
        :name="item.solt_name"
      ></slot>
    </div>
  </div>
</template>
<script>
import { downloadFileFormat,dateStringTransform } from "@/services/helper.js";
export default {
  data() {
    return {
      // helper: helper,
      dateStringTransform,
      downloadFileFormat
    };
  },
  props: ["list_arr"],
  mounted() {},
  methods: {
    download(val) {
      const a = document.createElement("a"); // 创建a标签
      a.setAttribute("download", ""); // download属性
      a.setAttribute("href", val); // href链接
      a.click(); // 自执行点击事件
    },
  },
};
</script>

<style scoped>
a {
  text-decoration: none;
}
.list span {
  line-height: 28px;
  color: #242c43;
  word-wrap: break-word;
}

.list span:nth-of-type(2) {
  color: #242c43;
}
.outlist .list:nth-last-of-type(1) {
  margin: 0;
}
.list .service_title {
  font-size: 16px;
  font-weight: bold;
  color: #58617a;
  text-align: left;
  height: 40px;
  line-height: 34px;
  margin-top: -10px;
  margin-bottom: 20px;
  margin-left: -10px;
}
.service_title span {
  display: inline-block;
  width: 4px;
  height: 16px;
  background-color: #515fe7;
  border-radius: 2px;
  float: left;
  margin-top: 9px;
  margin-right: 15px;
}
.filebtn {
  width: 76px;
  height: 32px;
  line-height: 32px;
  text-align: center;
  color: #e6ebfe;
  background-color: #515fe7;
  border-radius: 6px;
  display: inline-block;
  font-size: 14px;
  margin-left: 8px;
  cursor: pointer;
}
.file_box {
  height: 40px;
  line-height: 40px;
  padding: 4px 0;
}
</style>
