<template>
  <Node
    :title="config.nodeName"
    :is-root="true"
    :content="content"
    placeholder="所有人"
    :header-bgc="headerBgc"
    header-icon="x-icon-user"
    @insertNode="handleInsertNode"
    @selected="onSelectedNode"
  />
</template>

<script>
import Node from '@views/workFlow/designer/common/process/nodes/Node.vue'
//根节点
export default {
  name: 'RootNode',
  components: { Node },
  props: {
    config: {
      type: Object,
      default: function () {
        return {};
      }
    }
  },
  computed: {
    content() {
      if (this.config.nodeAssigneeList && this.config.nodeAssigneeList.length > 0) {
        const texts = this.config.nodeAssigneeList.map(org => org.name);
        return texts.join('、');
      }
      return '所有人';
    },
    headerBgc() {
      const workflowStore = this.$store.state.workflow;
      if (workflowStore.diagramMode === 'viewer') {
        return this.config.headerBgc;
      }
      return '#576a95';
    },

  },
  methods: {
    onSelectedNode() {
      this.$emit('selected');
    },
    handleInsertNode(type) {
      this.$emit('insertNode', type)
    }
  }
};
</script>
