<template>
  <el-form
    class="code-gen-save-dataset-form"
    :model="$store.currentDataSet"
    ref="form"
  >
    <pro-input
      v-model="$store.currentDataSet.name"
      prop="name"
      :rules="$store.vStrRequired"
    />
    <div class="el-dialog__footer">
      <pro-action @handler="$emit('customerClose', form)" text="取 消" />
      <pro-action @asyncHandler="handlerSave" text="保存新增" type="primary" />
    </div>
  </el-form>
</template>

<script>
import { post } from "mars-pro/src/pro/request";
export default {
  data() {
    return {
      form: {},
    };
  },
  methods: {
    async handlerSave() {
      try {
        await this.$refs.form.validate();
        await post("/mock/api/code-gen/data-set/save", {
          data: {
            name: this.$store.currentDataSet.name,
            datas: this.$store.currentDataSet.datas,
            _id: this.$store.currentDataSet._id,
          },
        }).done();
        this.$emit('customerClose', this.form)
        this.$store.dataSet.loadDatas()
        this.$message.success('保存成功')
      } catch (error) {}
    },
  },
};
</script>

<style>
</style>