<template>
  <div class="record_detail">
    <div class="title">
      <p class="data_detail">数据详情</p>
    </div>
    <div class="content">
      <div class="content_datail" v-if="status">
        <div class="detail">
          <span>资料名称：</span>
          <span>{{ detailData[nowIndex].informationName }}</span>
        </div>
        <div class="detail">
          <span>上传时间：</span>
          <span>{{ detailData[nowIndex].fileUploadDate }}</span>
        </div>
        <!--  <div class="multiDetail">
          <div class="firstColumn">
            <span>车系：</span>
            <span>{{
              detailData[nowIndex].spread
            }}</span>
          </div>
          <div class="secondColumn">
            <span>车型：</span>
            <span>
              {{ detailData[nowIndex].spread }}
            </span>
          </div>
        </div> -->
        <div class="multiDetail">
          <div class="firstColumn">
            <span>素材时间：</span>
            <span>{{ detailData[nowIndex].filePulishTime }}</span>
          </div>
          <div class="secondColumn">
            <span>经销商范围：</span>
            <span>
              {{ detailData[nowIndex].accountScope === 1 ? "共通" : "部分" }}
            </span>
          </div>
        </div>
        <div class="detail">
          <span>资料描述：</span>
          <span>{{ detailData[nowIndex].fileDiscription }}</span>
        </div>
        <div class="filesStyle multiDetail">
          <span>附件：</span>
          <div class="filesName">
            <p
              v-for="(item, index) in fileData"
              :key="index"
              @click="downloadFile(index)"
            >
              {{ item.fileName || "附件附件" }}
            </p>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    /*     detailData: {
      type: Array,
      default: () => {
        return [];
      },
    }, */
    /*     fileData: {
      type: Array,
      default: () => {
        return [];
      },
    }, */
    /*     nowIndex: {
      type: Number,
      default: -1,
    }, */
  },
  components: {},
  data() {
    return {
      status: false,
      dataObj: {},
      onlineUrl: "http://8.136.230.133:8080",
      informationId: this.$route.query.informationId || "",
      nowIndex: this.$route.query.nowIndex || "",

      rows: this.$route.query.Rows || 20,
      page: this.$route.query.Page || 1,
      agentId: (this.$route.query && this.$route.query.agentId) || "",

      detailData: [
        {
          accountScope: '',
          agentId: "",
          asc: '',
          download: "",
          downloadCount: null,
          fileDiscription: "",
          filePulishTime: "",
          fileUploadCreator: "",
          fileUploadDate: "",
          fileUploadDateLt: null,
          id: "",
          informationName: "1234",
          report: "",
          reportId: "",
          totalCount: null,
        },
      ],
      fileData: [],
    };
  },
  computed: {},
  methods: {
    // 下载附件
    downloadFile: function (index) {
      let config =
        "informationId=" +
        this.fileData[index].informationId +
        "&" +
        "fileId=" +
        this.fileData[index].id;
      let url = this.onlineUrl + "/dealerDownload?" + config;
      console.log("下载附件:", config, url);
      window.open(url);
    },

    //查看详情
    showDetail: function () {
      //获取附件数据
      this.$http({
        url: "/selectInformationFileList",
        method: "post",
        data: {
          informationId: this.informationId,
        },
      })
        .then((res) => {
          if (res.data.code === 200) {
            this.fileData = res.data.data;
          }
        })
        .catch((err) => {
          console.log(err);
        });
    },

    //分页 获取资料列表
    getDataListPage: function () {
      this.$http({
        url: "/firmsUploadListByAgent",
        method: "post",
        data: {
          agentId: this.agentId,
          Page: this.page,
          Rows: this.rows,
        },
      })
        .then((res) => {
          if (res.data.code === 200) {
            this.detailData = res.data.data;
            console.log(this.detailData);
            this.showDetail();
            this.status = true;
          }
        })
        .catch((err) => {
          console.log(err);
        });
    },
  },
  mounted() {
    this.getDataListPage();
    console.log(this.detailData);
  },
};
</script>

<style scoped lang="less">
.record_detail {
  .title {
    border: 1px solid #ccc;
    border-bottom: 0px;
    .data_detail {
      padding-left: 22px;
      font-size: 14px;
      font-weight: bolder;
      height: 46.8px;
      display: flex;
      align-items: center;
    }
  }
  .content {
    display: flex;
    border: 1px solid #ccc;
    padding: 20px;
    .content_datail {
      width: 100%;
      padding: 20px 50px 0;
      .detail {
        width: 100%;
        height: 50px;
        display: flex;
        align-items: center;
      }
    }
  }
}
.multiDetail {
  width: 100%;
  height: 50px;
  display: flex;
  align-items: center;
}
.firstColumn,
.secondColumn {
  display: flex;
  align-items: center;
}
.firstColumn span:nth-child(1) {
  /*  width: 80px; */
  display: block;
  margin-right: 16px;
}
.secondColumn span:nth-child(1) {
  /*   width: 80px; */
  display: block;
  margin-left: 40px;
  margin-right: 16px;
}
.detail span:nth-child(1) {
  /* width: 80px; */
  margin-right: 16px;
}
.filesStyle span:nth-child(1) {
  /* width: 80px; */
  margin-right: 16px;
}
.filesStyle {
  margin-right: 16px;
}

.filesName p {
  color: #4b8ec7;
  margin: 4px;
}
</style>
