<template>
  <div v-if="visible">
    <el-dialog id="reviseplanDialog" title="修改计划" :destroy-on-close="true" :visible.sync="visible" :close-on-click-modal="false" append-to-body :before-close="closeDialog" width="90%">
      <el-row class="dialogMinHeight">
        <el-button class="successBorder" size="medium" style="position: absolute;z-index: 1;right: 2px;top: 2px;" @click="saveData()">应用</el-button>
        <el-tabs v-model="parentActiveName" type="border-card">
          <el-tab-pane label="栏舍配方" name="栏舍配方">
            <DhedFormula :parent-date="date" />
          </el-tab-pane>
          <el-tab-pane label="撒料计划" name="撒料计划">
            <MaterialIssuancePlan :parent-date="date" />
          </el-tab-pane>
          <el-tab-pane label="预混计划" name="预混计划">
            <PremixedPlan :parent-date="date" />
          </el-tab-pane>
        </el-tabs>
      </el-row>
      <div slot="footer" class="dialog-footer" style="bottom: 10px;">
        <el-button class="cancelClose" @click="closeDialog()">关闭</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import DhedFormula from './typePage/dhedFormula.vue'
import MaterialIssuancePlan from './typePage/materialIssuancePlan.vue'
import PremixedPlan from './typePage/premixedPlan.vue'
export default {
  name: 'RevisePlan',
  components: {
    DhedFormula, MaterialIssuancePlan, PremixedPlan
  },
  props: {
    show: { type: Boolean, default: false }, // 弹框可见标志
    parentActiveName: { type: String, defalut: '栏舍配方' },
    parentDate: { type: String, defalut: '' }
  },
  data() {
    return {
      typeList: [{ id: '1', effect: 'dark', label: '栏舍配方' }, { id: '2', effect: 'plain', label: '撒料计划' }, { id: '3', effect: 'plain', label: '预混计划' }],
      visible: this.show,
      dialogFormVisible: false,
      dialogStatus: '',
      rules: {},
      date: '',
      parentActiveName: '',
      temp: {},

      isDhedFormula: true,
      isMaterialIssuancePlan: false,
      isPremixedPlan: false,

      textMap: {
        revisePlan: '修改计划'
      },
      isokDisable: false
    }
  },
  watch: {
    // 监听show,visible 随着show变化而变化
    show: {
      immediate: true,
      handler(show) {
        this.visible = show
      }
    },
    parentDate: {
      immediate: true,
      handler(newVal, oldVal) {
        console.log('newVal-date', newVal)
        this.date = newVal
      }
    },
    parentActiveName: {
      immediate: true,
      handler(newVal, oldVal) {
        console.log('newVal===', newVal)
        console.log('oldVal', oldVal)
        this.parentActiveName = newVal
      }
    }
  },
  created() {

  },
  methods: {
    closeDialog() {
      this.$emit('update:show', false) // 子组件更新弹框隐藏
      this.$emit('activeName', '栏舍配方')
    },
    saveData() {

    }
  }
}
</script>

<style lang="scss" scoped>
  #reviseplanDialog {
      margin-top: -10vh !important
  }
</style>