<!-- 选择关联问题 -->
<template>
  <div>
    <dialog-edit :appendToBody="appendToBody" :visible.sync="dialogVisible" :editModel="editModel" :form="form" :title="$t('effectDealFeedBackMain.selectAssociated')">
      <el-tabs class="relationeltab" type="card" v-model="relationTabNum">
        <el-tab-pane class="relationeltabpane" v-for="item in relationTab" :key="item.index" :label="item.label" :name="item.index">
        </el-tab-pane>
      </el-tabs>
          <keep-alive>
            <component :is="components.filter(res => res.index === relationTabNum)[0].name" :form="form" :qustData.sync="qustData" :editModel="editModel" :code="code"></component>
          </keep-alive>
    </dialog-edit>
  </div>
</template>

<script>
import relationQustTableSame from '@/pages/assetoutfeedback/effectDealFeedBack/effectDealFeedBackCom/relationQustTableSame'
import relationQustTableCom from '@/pages/assetoutfeedback/effectDealFeedBack/effectDealFeedBackCom/relationQustTableCom'
import effectDealFeedBackApi from '@/api/assetoutfeedback/effectDealFeedBack/effectDealFeedBackApi'
import { DialogEdit, DataTable, authButton } from 'newepoch-components'
import BasePage from '@/pages/baseEditPage'
export default {
  components: { DialogEdit, DataTable, authButton, relationQustTableSame, relationQustTableCom },
  extends: new BasePage(),
  props: {
    form: {
      type: Object,
      default () {
        return {}
      }
    },
    code: {
      type: String,
      default () {
        return ''
      }
    },
    editModel: {
      type: String,
      default () {
        return 'V'
      }
    }
  },
  computed: {
    // 关联问题
    api () {
      return effectDealFeedBackApi.getRelationQust
    }
  },
  data () {
    return {
      qustData: {},
      components: [
        {
          index: '1',
          name: 'relationQustTableSame'
        }, {
          index: '2',
          name: 'relationQustTableCom'
        }
      ],
      appendToBody: true,
      relationTabNum: '1',
      tyindex: 0,
      relationTab: [{
        index: '1',
        label: this.$i18n.messages[this.$i18n.locale].effectDealFeedBackMain.associatedGeneral
      }, {
        index: '2',
        label: this.$i18n.messages[this.$i18n.locale].effectDealFeedBackMain.associatedUniversal
      }]
    }
  },
  watch: {
    qustData: {
      handler (newName, oldName) {
        this.close(newName)
      }
    }
  },
  methods: {
    // 更新表数据
    myhandleFilter () {
      this.loadCount = this.loadCount + 1
    },
    // 关闭画面，传递数据
    close (value) {
      this.dialogVisible = false
      this.$emit('qustData', value, this.form.index, this.form.code)
    }
  }
}
</script>

<style lang="scss" scoped>
/deep/ .relationdatatable > div:first-of-type {
  margin-bottom: 0px !important
}
</style>
