<template>
  <el-dialog :title=" '数据预处理'" :close-on-click-modal="false" :visible.sync="visible">
    <el-form :model="dataForm" ref="dataForm" @keyup.enter.native="dataFormSubmit()"
      label-width="100px">
      <el-form-item label="数据集名称" prop="datasetName">
        <el-input v-model="dataForm.datasetName" placeholder="请输入数据集名称" :disabled=true></el-input>
      </el-form-item>
      <el-form-item label="缺失值处理" size="mini">
        <el-radio-group v-model="radio">
          <el-radio label="drop">删除缺失值所在行</el-radio>
          <el-radio label="median">填充中位数</el-radio>
          <el-radio label="mean">填充平均值</el-radio>
        </el-radio-group>
      </el-form-item>
      <el-form-item label="是否进行特征工程处理" size="mini">
        <el-radio-group v-model="mark">
          <el-radio label="yes">是</el-radio>
          <el-radio label="no">否</el-radio>
        </el-radio-group>
      </el-form-item>
      
    </el-form>
    <span slot="footer" class="dialog-footer">
      <el-button @click="visible = false">取消</el-button>
      <el-button type="primary" @click="dataPreProcess()">确定</el-button>
    </span>
  </el-dialog>
</template>

<script>
import { Message } from "element-ui"
export default {
  data() {
    return {
      visible: false,
      radio:'drop',
       mark:'yes',
      // 获取所有类别列表
      dataForm: {
        id: 0,
        datasetName: "",

      },
      
      
    };
  },
  methods: {
    init(filename) {
      this.dataForm.datasetName=filename+".csv";
      console.log(this.dataForm.datasetName);
      this.visible=true;
    },

    //执行数据预处理流程
    dataPreProcess(){

        this.$http({
          url:this.$http.adornUrl('/dataPreProcess/dataPreProcessByPython'),
          method:'get',
          params:this.$http.adornParams({
            datasetName:this.dataForm.datasetName,
            preProcessMethod:this.radio,
             featureMark:this.mark
          }),
        }).then(({data})=>{
          if(data&&data.code===0){
              Message({
              message: '操作成功',
              type: 'success',
              duration: 1500,
            });
            this.visible=false;
          }else{
              Message.error('失败');
          }
        });
    }
    
  },
};
</script>
