<template>
  <el-dialog class="api-edit" v-model="showDialog" :title="`${formData?.id ? '编辑模板' : '新增模板'}`" width="500px" :close-on-click-modal="false" :close-on-press-escape="false">
    <EditVue ref="editRef" v-if="showDialog" @getList="getList" @cancel="cancel"></EditVue>
  </el-dialog>
</template>

<script lang="ts" setup>
import { ref, nextTick } from 'vue';
import EditVue from './edit.vue'

const emit = defineEmits(['getList']);

const showDialog = ref(false);
const editRef = ref();
const formData = ref({ id: null });

function open(row?: any) {
  showDialog.value = true;
  formData.value = row;
  nextTick(() => {
    editRef.value.open(row)
  });
}

function getList() {
  emit('getList')
  showDialog.value = false;
}

function cancel() {
  showDialog.value = false;
}

defineExpose({ open });
</script>
