<template>
  <el-card>
    <div slot="header">
      <span class="card-title">
        工厂公告
        {{ noticeTitle }}
      </span>
    </div>
    <el-scrollbar class="article">
      <div v-if="noticeContent" v-html="noticeContent" />
      <el-empty v-else description="暂无公告" :image-size="120" />
    </el-scrollbar>
  </el-card>
</template>

<script>
import { listNotice } from '@/api/system/notice'

export default {
  data() {
    return {
      queryParams: {
        page: 1,
        pageSize: 1,
        type: 2
      },
      loading: false,
      noticeContent: '',
      noticeTitle: ''
    }
  },
  created() {
    this.queryDetails()
  },
  methods: {
    queryDetails() {
      this.loading = true
      listNotice(this.queryParams).then(res => {
        const { data = {}} = res
        const { list = [] } = data
        if (list.length > 0) {
          const { content, title } = list[0]
          this.noticeContent = content
          this.noticeTitle = `【${title}】`
        }
      }).finally(() => {
        this.loading = false
      })
    }
  }
}
</script>

<style lang="scss" scoped>
.card-title {
  font-size: 14px;
}
.article {
  height: 300px;
  p {
    font-size: 13px;
    line-height: 1.5;
  }
}
</style>
