<!--
 * @Description: 创业指引详情
 * @Author: 空白格
 * @Date: 2022-08-25 13:30:07
 * @LastEditors: 空白格
 * @LastEditTime: 2022-08-29 13:55:28
 * @FilePath: \veterans_client_web\src\views\WorkGuide\WorkGuideDetails\WorkGuideDetailsIndex.vue
 * @Copyright: Copyright (c) 2016~2022 by 空白格, All Rights Reserved.
-->
<template>
  <div class="app-main details">
    <BannerBreadcrumb title="创业指引" :isRouter="true" />
    <div class="app-main-box details-box">
      <div class="app-main-box-content details-box-content">
        <div class="details-box-content-title">
          {{ detainsInfo.title || "-" }}
        </div>
        <div class="details-box-content-subtitle">
          <span>{{ detainsInfo.createTime }}提交</span>
          <span class="no-reply" v-if="detainsInfo.replyStatus === 0"
            >待专家回复</span
          >
          <span class="has-reply" v-else>专家已回复</span>
        </div>
        <div class="details-box-content-des">
          <div class="dbcd-label">描述</div>
          <div class="dbcd-content ql-editor" v-html="detainsInfo.description"></div>
        </div>
        <div class="details-box-content-pdf" v-if="detainsInfo.planBookName">
          <div class="btn" @click="previewPdf(detainsInfo.planBookUrl)">{{ detainsInfo.planBookName }}</div>
          <view-pdf ref="viewPdf"/>
        </div>
        <div
          class="details-box-content-reply"
          v-if="detainsInfo.replyStatus === 1"
        >
          <div class="dbcr-label">专家建议</div>
          <div class="dbcr-content" v-html="detainsInfo.replyContent"></div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import BannerBreadcrumb from "@/components/BannerBreadcrumb";
import ViewPdf from '@/components/ViewPdf'
import { getWorkGuideDetails } from "@/api/WorkGuide";
export default {
  name: "WorkGuideDetailsIndex",
  components: {
    BannerBreadcrumb,
    ViewPdf
  },
  data() {
    return {
      detainsInfo: {},
      id: undefined,
    };
  },
  created() {
    const { id } = this.$route.query;
    if (id) {
      this.id = id;
      this.getDetails();
    }
  },
  methods: {
    /**
     * 获取详情
     * @date 2022-08-25
     * @returns {any}
     */
    getDetails() {
      getWorkGuideDetails({ id: this.id }).then((res) => {
        if (res.code === 200) {
          this.detainsInfo = res?.data;
        }
      });
    },
    /**
     * 预览pdf
     * @date 2022-08-25
     * @param {any} pdfUrl
     * @returns {any}
     */
    previewPdf(pdfUrl) {
      if (pdfUrl) {
        // window.open('http://www.gjtool.cn/pdfh5/pdf.html?file=' + pdfUrl)
        this.$refs['viewPdf'].openDialog(pdfUrl)
      }
    }
  },
};
</script>

<style lang="scss" scoped>
.details {
  &-box {
    margin: 0 auto;
    &-content {
      &-title {
        padding: 10px 0;
        text-align: center;
        font-size: 24px;
        color: #1a1a1a;
        border-bottom: 1px solid #d5d5d5;
      }
      &-subtitle {
        text-align: center;
        margin: 20px 0 40px;
        font-size: 14px;
        color: #999999;
        span {
          &:last-child {
            margin-left: 40px;
          }
        }
        .no-reply {
          color: #ef6622;
        }
        .has-reply {
          color: #3ca7fe;
        }
      }
      &-des {
        .dbcd-label {
          font-size: 20px;
          color: #1a1a1a;
          margin-bottom: 20px;
          font-family: SourceHanSansCN;
        }
        .dbcd-content {
          color: #666666;
          font-size: 14px;
        }
      }
      &-pdf {
        text-align: center;
        margin: 20px auto 30px;
        .btn {
          display: inline-block;
          padding: 0 100px;
          max-width: 700px;
          cursor: pointer;
          height: 50px;
          line-height: 50px;
          text-align: center;
          font-size: 14px;
          color: #008fff;
          border: dashed 1px #0091ff;
          border-radius: 5px;
          white-space: nowrap;
          overflow: hidden;
          text-overflow: ellipsis;
          word-break: break-all;
        }
      }
      &-reply {
        .dbcr-label {
          font-size: 20px;
          color: #1a1a1a;
          margin-bottom: 20px;
          font-family: SourceHanSansCN;
        }
        .dbcr-content {
          color: #666666;
          font-size: 14px;
        }
      }
    }
  }
}
</style>
