<template>
  <div>
    <xy-dialog ref="dialog" :width="60" :is-show.sync="isShow" :type="'normal'" :title="form.title">
      <template v-slot:default>
        <div class="article">
          <div class="article-title">{{form.title}}</div>
          <div v-if="form.tag_ids">
            <!-- <el-tag></el-tag> -->
          </div>
          <div class="article-time">
            <div v-if="form.date">发布时间：{{form.date}}</div>
            <div v-if="form.catalog_name">所属目录：{{form.catalog_name}}</div>
            <div v-if="form.area_ids">所属区域：

            </div>
          </div>
          <div class="article-files" v-if="form.files_upload_details && form.files_upload_details.length>0">
            <div v-for="(item,index) in form.files_upload_details">
              附件{{index+1}}：
              <a :href="item.url" target="_blank">{{item.original_name}}</a>
              <el-link target="_blank" style="margin:0 10px;" @click="toshowFile(item.url)" type="primary">
                预览
              </el-link>

            </div>
          </div>
          <div class="article-html" v-if="form.content">
            <div v-html="form.content"></div>
          </div>
        </div>
      </template>
      <template v-slot:footerContent>
        <Button ghost type="primary" @click='isShow=false'>关闭</Button>
      </template>
    </xy-dialog>
    <viewFile ref="viewFile"></viewFile>
  </div>
</template>

<script>
  import {
    show
  } from "@/api/system/baseForm.js"
  import viewFile from '@/components/viewFile/viewFile.vue'
  export default {
    components: {
      viewFile
    },
    data() {
      return {
        isShow: false,
        id: '',
        table_name: 'records',
        form: {}
      }
    },
    created() {

    },
    methods: {
      getDetail() {
        show({
          id: this.id,
          table_name: this.table_name,
        }).then(res => {
          this.form = this.base.deepCopy(res)
          console.log("this.form",this.form)
        })
      },
      toshowFile(url) {
        this.$refs.viewFile.url = url
        this.$refs.viewFile.diaShow = true
      },
    },
    watch: {
      isShow(newVal) {
        if (newVal) {
          this.getDetail()

        } else {
          this.id = ''
          this.form = {}
        }
      },
    }

  }
</script>

<style scoped lang="scss">
  .article {
    &>div {
      margin: 10px;
    }

    &-title {
      font-size: 24px;
      text-align: center;
      font-weight: bold;
      color: #000;
    }

    &-time {
      display: flex;
      justify-content: center;
      font-size: 20px;
      color: rgba(0, 0, 0, 0.6);

      &>div {
        margin: 0 10px;
      }
    }

    &-files {
      color: blue;
      cursor: pointer;
      text-decoration: underline;
      text-indent: 2em;
    }

    &-html {
      line-height: 1.5;
      font-size: 20px;
    }
  }
</style>
