<template>
  <div>
    <tools-page :need-back='false' title="通知公告"></tools-page>
    <http-busy>
      <list :model="model">
        <div partial>
          <div class=" col-md-12 col-lg-12 ">
            <table class="table">
              <tbody>
                <tr class="h5">
                  <td>标题：</td>
                  <td>{{row.f_title}}</td>
                </tr>
                <tr class="h5">
                  <td>时间：</td>
                  <td>{{row.f_time}}</td>
                </tr>
                <tr class="h5">
                  <td>分公司：</td>
                  <td>{{row.f_subcompany}}</td>
                </tr>
                <tr>
                  <td colspan="2">{{row.f_content}}</td>
                </tr>
              </tbody>
            </table>
            <hr class="bg" />
          </div>
        </div>
      </list>
    </http-busy>
    <div style="height:50px;"></div>
  </div>
</template>

<script>
import Vue from 'vue'

export default {
  title: '安检通知',
  data() {
    return {
      model: {},
      timerEnabled: true,
      timer: null,
    }
  },
  methods: {
    getNotice() {
      console.log(Vue.user.f_subcompany)
      console.log('Vue.android',Vue.android)

      if (Vue.android) {
        this.model = this.$androidUtil.bzLogic('提取安检通知', {f_subcompany: Vue.user.f_subcompany}).data
      } else {
        this.$resetpost('AndroidRest/api/af-safecheck/sql/提取通知', {data: {f_subcompany: Vue.user.f_subcompany}}, {
          resolveMsg: null,
          rejectMsg: null
        }).then(
          (response) => {
            this.$set('model', {rows: response.data})
          }
        ).catch(
          (response) => {
            HostApp.alert('提取数据失败。')
          }
        )
      }
    },
    freshNotice(){
      if (!this.timerEnabled) {
        return
      }
      //this.timer = window.setInterval(this.getNotice, Vue.interval)
    },
    },
  ready() {
      this.getNotice()
      this.freshNotice()
  },
  destroyed() {
    this.timerEnabled = false
    if(this.timer) {
      console.log('destroying timer...')
      window.clearInterval(this.timer)
    }
  },
}
</script>
