<!--导出 -->
<template>

  <el-form label-position="left" ref="form" label-width="100px" :model="form" :size="defaultFormItemSize">

    <el-form-item label="导出文件格式：">
      <el-select v-model="form.format" placeholder="请选择">
    <el-option
      v-for="item in ImportFormat.getList()"
      :key="item.id"
      :label="item.name"
      :value="item.symbol">
    </el-option>
  </el-select>
    </el-form-item>

    <el-row type="flex" justify="end" class="dialog-btn-layer mt20">
      <el-button :size="defaultFormItemSize" :plain="true" @click="onCancel(false)">取消</el-button>
      <el-button type="primary" :size="defaultFormItemSize" @click="downloadFile">开始导出</el-button>
    </el-row>
  </el-form>
</template>

<script>

// import { DatasetVersion } from '@/api/gptController.js';
export default {
  data () {
    return {
      form: {
        format: 'jsonl'
      }

    };
  },
  props: ['isEdit', 'row'],
  components: {},

  computed: {

  },

  mounted () {
  },

  methods: {

    onCancel (isSuccess) {
      if (this.observer != null) {
        this.observer.cancel(isSuccess);
      }
    },
    downloadFile () {
      let params = {
        versionId: this.row.versionId
      }
      
      this.download('/admin/app/datasetVersion/export', params, '下载文件.' + this.form.format, 'get').then(res => {
        // resolve(res);
        console.log(res);
        this.$message.success('下载成功');
        this.onCancel(true);
      }).catch(e => {
        // reject(e);
      });
    }
  }
};
</script>
<style scoped>
.inputWidth {
  width: 600px;
}
.title {
  font-size: 20px;
  margin-bottom: 16px;
}
.introduce {
  font-size: 12px;
  color: #909399;
}
</style>
