<template>
  <Dialog
    v-model="visible"
    show-footer
    diaTitle="新增参数库"
    :width="400"
    @close="closeFun"
  >
    <template #default>
      <el-form :model="formData" labelWidth="auto">
        <el-form-item label="参数库名称" prop="parameterLibraryName">
          <el-input v-model="formData.parameterLibraryName"></el-input>
        </el-form-item>
      </el-form>
    </template>
    <template #footer>
      <div class="dialog-footer">
        <el-button @click="closeFun">取消</el-button>
        <el-button type="primary" @click="onConfirmFun">确定</el-button>
      </div>
    </template>
  </Dialog>
</template>

<script setup lang="ts">
import { ref } from 'vue';
import Dialog from '@/components/common/dialog/index.vue';
import { ElMessage } from 'element-plus';

const emits = defineEmits(['close', 'createFun']);

const visible = ref(true);

const formData = ref({
  parameterLibraryName: '',
});

const closeFun = () => {
  emits('close');
};

const onConfirmFun = () => {
  if (!formData.value.parameterLibraryName) {
    ElMessage.warning('请输入参数库名称！');
    return;
  } else {
    emits('createFun', formData.value);
  }
};
</script>
<style lang="scss" scoped>
.upload {
  width: 100%;
}
</style>
