<template>
  <div>
    <p-card :title="title" style="width: 100%">
      <p-tabs default-active-key="1" tab-position="left">
        <p-tab-pane key="1" tab="策略定义">
          <main-table v-if="hide" @back="back" :strategyType="strategyType"></main-table>
          <edit-tabl
            v-if="!hide"
            :rule="rule"
            :strategy="strategy"
            @back="back"
            :strategyType="strategyType"
          ></edit-tabl>
        </p-tab-pane>

        <p-tab-pane key="2" tab="规则因子">
          <fact-or :strategyType="strategyType"></fact-or>
        </p-tab-pane>
      </p-tabs>
    </p-card>
  </div>
</template>
<script>
import EditTabl from './components/edittable'
import MainTable from './components/maintable'
import factor from '../factor'
export default {
  name: 'StrategyView',
  data() {
    return {
      hide: true,
      rule: {},
      strategy: {}
    }
  },
  components: {
    MainTable,
    EditTabl,
    FactOr: factor
  },
  props: {
    strategyType: {
      type: String,
      default: 'OutStock'
    },
    title: {
      type: String,
      default: ''
    }
  },
  mounted() {},
  methods: {
    back(value, data) {
      console.log(value, data)
      if (data) {
        this.rule = data.rule
        this.strategy = data.strategy
      }

      this.hide = value
    }
  }
}
</script>
