<template>
  <div>
    <el-dialog  :title="title" :visible.sync="showDialog" width="1000px" :close-on-click-modal="false"  :before-close="handleClose" append-to-body>
        <el-form :model="form"  ref="form" label-width="80px" label-position="left">
            <el-form-item label="特征内容" prop="featureText">
                <el-input type="textarea" autosize v-model="form.featureText" placeholder="请输入特征内容"></el-input>
            </el-form-item>
            <el-form-item label="说明" prop="common">
                <el-input type="textarea" autosize v-model="form.common" placeholder="请输入说明"></el-input>
            </el-form-item>
        </el-form>
        <span slot="footer" class="dialog-footer">
          <el-button @click="handleClose">取 消</el-button>
          <el-button type="primary" :loading="btnLoading" @click="submit" >确 定</el-button>
        </span>
    </el-dialog>
  </div>
</template>

<script>
export default {
  components: {},
  props: {
    projectId:{
        default:0
    },
    ifSecondInvalid:{
        default:false
    }
  },
  data() {
    return {
        title:'添加特征',
        showDialog:false,
        form:{},
        btnLoading:false
    };
  },
  watch: {},
  computed: {},
  created() {},
  mounted() {},
  methods: {
    open(form){
        this.form = form
        this.showDialog = true
    },
    handleClose(){
        this.showDialog = false
    },
    submit(){
        this.$refs.form.validate((valid) => {
          if (valid) {
            this.btnLoading = true
            this.form.gen = this.ifSecondInvalid?2:1,
            this.$api.addFeatureGroupBatch(this.form).then(response=>{
                if(response.code == 200){
                    this.$message.success('特征添加成功')
                    this.$emit('save',true)
                    this.handleClose()
                    this.btnLoading = false
                }
            }).catch(error=>{
                this.$message.error('特征添加失败')
                this.btnLoading = false
            })
          }
        })
    }
  },
};
</script>
<style lang="scss" scoped>
</style>