<!-- 基本信息-->
<template>

  <el-form label-position="left" ref="form" label-width="100px" :model="form" :size="defaultFormItemSize">
    <el-row class="title">基本信息</el-row>
    <el-form-item label="模型名称:">
    <span>{{ tableItem.modelName }}</span>
    </el-form-item>
    <el-form-item label="模型类型:">
      <span>{{ ModelType.getValue(tableItem.modelType) }}</span>
    </el-form-item>
    <el-form-item label="业务标签:">
      <span>{{ tableItem.businessLabel}}</span>
        </el-form-item>
    <el-row class="title">模型配置</el-row>
    <el-form-item label="模型版本:">
      V{{ form.modelVersionDto.modelVersion}}
    </el-form-item>
    <el-form-item label="模型版本描述:">
      <el-input v-model="form.modelVersionDto.versionDescribe" type="textarea" class="inputWidth" :rows="5" :size="defaultFormItemSize"></el-input>
    </el-form-item>

  <el-form-item label="模型训练方式:">
      <el-select v-model="form.modelVersionDto.modelTrainingMethod" placeholder="请选择">
        <el-option v-for="item in ModelTrainingMode.getList()" :key="item.id" :label="item.name" :value="item.id"></el-option>
      </el-select>
    </el-form-item>
    <el-form-item label="训练任务:">
      <el-select v-model="form.modelVersionDto.trainingTask" placeholder="请选择">
        <el-option v-for="item in  []" :key="item.value" :label="item.label" :value="item.value"></el-option>
      </el-select>
    </el-form-item>
    <el-form-item label="运行名称:">
      <el-select v-model="form.modelVersionDto.runName" placeholder="请选择">
        <el-option v-for="item in  []" :key="item.value" :label="item.label" :value="item.value"></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="onSubmit">确定</el-button>
    </el-row>
  </el-form>
</template>

<script>

import { ModelVersion } from '@/api/gptController.js';
export default {
  data () {
    return {
      form: {
        'modelVersionDto': {
          'modelId': '',
          'modelTrainingMethod': '', //
          'modelVersion': '', //
          'runName': '', //
          'trainingTask': '', //
          'versionDescribe': '' //

        }
      }

    };
  },
  props: ['tableItem', 'versionIndex'],
  components: {},

  computed: {

  },

  mounted () {
    this.intFrom()
    console.log(this.tableItem);
  },

  methods: {
    intFrom () {
      this.form.modelVersionDto.modelId = this.tableItem.modelId
      this.form.modelVersionDto.modelVersion = this.versionIndex + 1
    },
    onCancel (isSuccess) {
      if (this.observer != null) {
        this.observer.cancel(isSuccess);
      }
    },
    onSubmit () {
      return new Promise((resolve, reject) => {
        this.$refs['form'].validate((valid) => {
          if (valid) {
            let params = {};
            params = { ...this.form };

            if (this.isEdit) {
              ModelVersion.update(this, params).then(res => {
                resolve(res);
                this.$message.success('编辑成功');
                this.onCancel(true);
              }).catch(e => {
                reject(e);
              });
            } else {
              ModelVersion.add(this, params).then(res => {
                resolve(res);
                this.$message.success('添加成功');
                this.onCancel(true);
              }).catch(e => {
                reject(e);
              });
            }
          } else {
            reject();
          }
        });
      });
    }
  }
};
</script>
<style scoped>
.inputWidth {
  width: 600px;
}
.title {
  font-size: 20px;
  margin-bottom: 16px;
}
.introduce {
  font-size: 12px;
  color: #909399;
}
</style>
