<script setup lang="ts">
import { TableProperties } from '@vben/icons';
import { $t } from '@vben/locales';

import BaseNode from './BaseNode.vue';

defineProps(['selected', 'data', 'id']);
</script>

<template>
  <BaseNode
    :selected="selected"
    :execution-status="data.executionStatus"
    :execution-result="data.executionResult"
    :label="
      data.label || $t('ai-platform.workflow.nodes.form_list_design.label')
    "
    :inputs="[{ id: 'target' }]"
    :outputs="[{ id: 'source' }]"
    :node-id="id"
    node-type="form_list_design"
  >
    <template #icon><TableProperties class="size-5" /></template>
    <template #desc>
      {{ $t('ai-platform.workflow.nodes.form_list_design.desc') }}
    </template>

    <div class="space-y-2">
      <div
        class="flex items-center justify-between rounded bg-indigo-50 px-2 py-1 text-indigo-700 dark:bg-indigo-950 dark:text-indigo-300"
      >
        <span class="font-medium">{{
          $t('ai-platform.workflow.nodes.form_list_design.containerType')
        }}</span>
        <span>{{
          data.container_type === 'drawer'
            ? $t('ai-platform.workflow.nodes.form_list_design.drawer')
            : data.container_type === 'dialog'
              ? $t('ai-platform.workflow.nodes.form_list_design.dialog')
              : data.container_type === 'page'
                ? $t('ai-platform.workflow.nodes.form_list_design.page')
                : $t('ai-platform.workflow.nodes.form_list_design.drawer')
        }}</span>
      </div>

      <div class="text-muted-foreground space-y-1 text-xs">
        <div class="flex justify-between">
          <span>{{
            $t('ai-platform.workflow.nodes.form_list_design.pageSize')
          }}</span>
          <span>{{ data.page_size || 20 }}</span>
        </div>
        <div class="flex justify-between">
          <span>{{
            $t('ai-platform.workflow.nodes.form_list_design.autoQueryFields')
          }}</span>
          <span>{{
            data.auto_query_fields !== false
              ? $t('ai-platform.workflow.nodes.common.yes')
              : $t('ai-platform.workflow.nodes.common.no')
          }}</span>
        </div>
        <div class="flex justify-between">
          <span>{{
            $t('ai-platform.workflow.nodes.form_list_design.autoColumns')
          }}</span>
          <span>{{
            data.auto_columns !== false
              ? $t('ai-platform.workflow.nodes.common.yes')
              : $t('ai-platform.workflow.nodes.common.no')
          }}</span>
        </div>
      </div>

      <!-- 输出变量 -->
      <div class="rounded bg-green-50 px-2 py-1 text-xs dark:bg-green-950">
        <div
          class="flex items-center justify-between text-green-700 dark:text-green-300"
        >
          <span>{{ $t('ai-platform.workflow.nodes.common.output') }}</span>
          <span class="font-mono">list_config</span>
        </div>
      </div>
    </div>
  </BaseNode>
</template>
