<template>
  <div>
    <data-table class="relationdatatable" :sourceData.sync="tytable" :columns="tycolumns" :loadCount="loadCount"
     :queryParas.sync="queryParas" :api="api" v-bind="{maxHeight:400}" :loadPage="'getDefaultCommom'">
      <el-table-column :label="$t('common.operate')" align="center" width="100px">
        <template slot-scope="scope">
          <auth-button size="small" class="iconCircle"
                      :title="$t('effectDealFeedBackMain.select')" icon="iconfont iconxuanze" @click="select(scope.row)"></auth-button>
        </template>
      </el-table-column>
      <template #commonQuestionContent="scope">
        <span-plus :index="scope.data.$index" :text="scope.data.row.commonQuestionContent"></span-plus>
      </template>
    </data-table>
  </div>
</template>

<script>
import effectDealFeedBackApi from '@/api/assetoutfeedback/effectDealFeedBack/effectDealFeedBackApi'
import { DataTable, authButton, SpanPlus } from 'newepoch-components'
import { mapGetters } from 'vuex'
export default {
  components: { DataTable, authButton, SpanPlus },
  props: {
    form: {
      type: Object,
      default () {
        return {}
      }
    }
  },
  computed: {
    // 关联问题
    api () {
      return effectDealFeedBackApi.getRelationQust
    },
    ...mapGetters(['userId'])
  },
  data () {
    return {
      queryParas: {
        pageIndex: 1,
        pageSize: 10
      },
      tytable: [],
      loadCount: 0,
      tycolumns: [
        {
          // 通用问题
          prop: 'commonQuestionContent',
          align: 'left',
          slot: true,
          width: '160px',
          label: this.$i18n.messages[this.$i18n.locale].effectDealFeedBackMain.commonQuestionContent
        }, {
          // 跟进人
          prop: 'traceUserName',
          align: 'left',
          width: '60px',
          label: this.$i18n.messages[this.$i18n.locale].effectDealFeedBackMain.traceUserName
        }
      ]
    }
  },
  mounted () {
    this.queryParas = Object.assign(this.queryParas, this.form)
    this.queryParas = Object.assign(this.queryParas, { 'userId': this.userId })
    this.$nextTick(() => {
      this.myhandleFilter()
    })
  },
  methods: {
    // 更新表数据
    myhandleFilter () {
      this.loadCount = this.loadCount + 1
    },
    // 选择
    select (row) {
      this.success('关联问题选择成功')
      row = Object.assign(row, { 'relationQuestionType': '0' })
      this.$emit('update:qustData', row)
    }
  }
}
</script>

<style>

</style>
