<template>
  <div>
    <Modal v-model="nonConformModal" width="1200">
      <p slot="header">
        查看不符合项
      </p>
      <div class="layout-content-padding">
        <div class="layout-content-main">
          <el-tabs v-model="activeName" @tab-click="_changeTabs">
            <el-tab-pane label="不符合项" name="report">
              <nonConformItem ref="reportTabs" />
            </el-tab-pane>
            <el-tab-pane label="合格项" name="his">
              <conformItem ref="hisTabs" />
            </el-tab-pane>
          </el-tabs>
        </div>
      </div>
      <div slot="footer">
        <modal-footer ref="footerModal" :footer="footerList" @on-result-change="_footerResult" />
      </div>
    </Modal>
  </div>
</template>
<script>
import nonConformItem from './tabs/NotOkItem'
import conformItem from './tabs/OkItem'

export default {
  components: { nonConformItem, conformItem },
  data() {
    return {
      activeName: 'report',
      nonConformModal: false,
      footerList: [{ id: '', type: '', name: '关闭' }]
    }
  },
  methods: {
    _open(id) {
      this.activeName = 'report'
      this.$refs.footerModal._hideLoading()
      this.nonConformModal = true
      this.$refs.reportTabs.sampleId = id
      this.$refs.hisTabs.sampleId = id
      this._page()
    },
    _changeTabs(tab, event) {
      if (tab.name === 'report') {
        this._page()
      } else {
        // this.$refs.hisTabs._clearPage()
        this.$refs.hisTabs._page()
      }
    },
    _footerResult(msg) {
      switch (msg) {
        case '关闭':
          this.nonConformModal = false
          break
      }
    },
    _page() {
      // this.$refs.reportTabs._clearPage()
      this.$refs.reportTabs._page()
    }
  }
}
</script>
