<template>
  <div>
    <Modal v-model="showSampleModal" v-drag @on-visible-change="_visibleChange" width="1200"
           class="zIndex-900 modal-footer-none">
      <p slot="header">管理样品</p>
      <div>
        <el-tabs v-model="activeName" @tab-click="_changeTabs">
          <el-tab-pane label="样品管理" name="prepareManage">
            <SoilSampleManage ref="prepareManage"></SoilSampleManage>
          </el-tab-pane>
          <el-tab-pane label="原始记录填写" name="recordModal">
            <RecordWrite ref="recordModal"></RecordWrite>
          </el-tab-pane>
        </el-tabs>
<!--        <keep-alive>-->
<!--          &lt;!&ndash; eslint-disable-next-line vue/require-component-is &ndash;&gt;-->
<!--          <component ref="refModal" :is="currentComponent"></component>-->
<!--        </keep-alive>-->
      </div>
    </Modal>
  </div>
</template>
<script>
import SoilSampleManage from './SoilSampleManageHis'
import RecordWrite from './sample-preparation-record-his/RecordIndex'
export default {
  components: {
    SoilSampleManage,
    RecordWrite
  },
  data() {
    return {
      type: '',
      contractId: '', // 合同id
      entrustId: '',
      showSampleModal: false,
      modalTitle: '',
      selectIds: [],
      activeName: 'prepareManage',
      name: '',
      currentComponent: ''
    }
  },
  mounted() {},
  methods: {
    _open(entrustId, type, name) {
      this.type = type // 类型（采样或送样）
      this.name = name
      this.showSampleModal = true
      this.entrustId = entrustId // 委托id
      this.activeName = 'prepareManage'
      this.selectIds = []
      this._preparePage()
    },
    // 制备管理
    _preparePage() {
      this.$refs.prepareManage._open(this.entrustId)
    },
    // 原始记录填写
    _recordPage() {
      this.$refs.recordModal._open(this.entrustId)
    },
    _changeTabs(tab, event) {
      if (tab.name === 'prepareManage') {
        // this._issuedPage()
        this.$refs.prepareManage._open(this.entrustId)
        this.$refs.recordModal._clearTable()
      } else {
        this.$refs.recordModal._open(this.entrustId)
      }
    },
    // 关闭弹框的时候刷新上个界面
    _visibleChange(data) {
      this.$emit('on-result-change')
    }
  }
}
</script>
