<!-- 标注 -->
<template>
  <div>
    <vxe-table border show-header-overflow show-overflow :row-config="{ isHover: true ,height: 260}" :data="[form.data]" min-height="96">
      <!-- <vxe-column field="index" title="序号"></vxe-column> -->
      <vxe-column field="data.instruction" title="问题">
        <template slot-scope="scope">
          <el-input v-if="isEdit===true" style="height: 100%;" type="textarea" placeholder="请输入内容" v-model="scope.row.instruction" :rows="10">
          </el-input>
          <div class="text" v-else>{{ scope.row.instruction }}</div>
        </template>
      </vxe-column>
      <vxe-column field="data.output" title="回答">
        <template slot-scope="scope">
          <el-input v-if="isEdit===true" style="height: 100%;" type="textarea" placeholder="请输入内容" v-model="scope.row.output" :rows="10">
          </el-input>
          <div class="text" v-else>{{ scope.row.output }}</div>
        </template>
      </vxe-column>

    </vxe-table>
    <el-row type="flex" justify="end" class="dialog-btn-layer mt20" v-if="isEdit">
      <el-button :size="defaultFormItemSize" :plain="true" @click="onCancel(false)">取消</el-button>
      <el-button type="primary" :size="defaultFormItemSize" @click="onSubmit">确定</el-button>
    </el-row>
  </div>
</template>

<script>
import { DatasetData } from '@/api/gptController.js'
export default {
  data() {
    return {
      form: JSON.parse(JSON.stringify(this.row))
    }
  },
  props: ['row', 'columnList', 'refresh', 'isEdit'],
  components: {},

  computed: {},

  mounted() {},

  methods: {
    onCancel(isSuccess) {
      if (this.observer != null) {
        this.observer.cancel(isSuccess)
      }
    },
    onSubmit() {
      let params = {}
      params.datasetMongoDto = this.form
      DatasetData.update(this, params)
        .then((res) => {
          this.$message.success('编辑成功')
          this.onCancel(true)
        })
        .catch((e) => {})
    }
  }
}
</script>
<style scoped>
.text {
  white-space: break-spaces;
  height: 260px;
  overflow: auto;
}
</style>
