<template>
  <div>
    <component :is="componentName" :config.sync="workflowStore.selectedNode" />
  </div>
</template>

<script>
import Root from './RootNodeConfig.vue';
import Approval from './ApprovalNodeConfig.vue';
import Cc from './CcNodeConfig.vue';
import Condition from './ConditionNodeConfig.vue';

import { mapState } from 'vuex';

export default {
  name: 'NodeConfig',
  components: {
    Root,
    Approval,
    Cc,
    Condition
  },
  computed: {
    ...mapState('workflow', ['selectedNode']),
    componentName() {
      switch (this.selectedNode.type) {
        case 0:
          return 'Root';
        case 1:
          return 'Approval';
        case 2:
          return 'Cc';
        case 3:
          return 'Condition';
        default:
          return null;
      }
    },
    workflowStore() {
      // 保留原始调用语义
      return this.$store.state.workflow;
    }
  }
};
</script>

<style scoped lang="less"></style>
