<!--节点标题编辑-->
<template>
  <a-modal
    :width="800"
    :visible="visible"
    title="修改节点标题"
    :body-style="{ paddingBottom: '8px' }"
    @update:visible="updateVisible"
    @close="updateVisible(false)"
    :maskClosable="true"
    @ok="save"
  >
    <a-input type="text" allow-clear v-model:value="nodeTitle" autofocus="autofocus" />
  </a-modal>
</template>

<script setup name="NodeTitleEdit">
import { onMounted, ref } from 'vue';

const emits = defineEmits(['done', 'update:visible']);
const props = defineProps({
  visible: {
    type: Boolean
  },
  nodeTitleNodeIdObj: {
    type: Object,
    default: () => {
      return {
        nodeName: '',
        nodeId: ''
      };
    }
  }
});

// 节点标题
const nodeTitle = ref('');

onMounted(() => {
  nodeTitle.value = props.nodeTitleNodeIdObj.nodeName;
});

const save = () => {
  emits('done', {
    nodeId: props.nodeTitleNodeIdObj.nodeId,
    nodeName: nodeTitle.value
  });
  updateVisible(false);
};

const updateVisible = value => {
  emits('update:visible', value);
};
</script>

<style scoped></style>
