<template>
  <a-form v-model="computedModelValue" :config="config" :disabled="disabled" :span="24"> </a-form>
</template>

<script setup lang="ts">
import AForm from '@/components/AForm/index.vue'
import { StrAnyObj } from '@/typings'
import { FormConfigType } from '@/components/AForm/type'

const props = withDefaults(
  defineProps<{
    modelValue: StrAnyObj
    disabled: boolean
  }>(),
  {
    disabled: false
  }
)

const emits = defineEmits(['update:modelValue'])

const computedModelValue = computed({
  get() {
    return props.modelValue
  },
  set(newValue) {
    emits('update:modelValue', newValue)
  }
})

const config: FormConfigType[] = [
  {
    type: 'input',
    prop: 'nodeCode',
    label: '节点编码'
  },
  {
    type: 'input',
    prop: 'nodeName',
    label: '节点名称'
  },
  {
    type: 'select',
    prop: 'listenerTypeArr',
    label: '监听器类型',
    multiple: true,
    option: [
      { key: 'create', label: '创建' },
      { key: 'start', label: '开始' },
      { key: 'assignment', label: '分派' },
      { key: 'finish', label: '完成' }
    ]
  },
  {
    type: 'input',
    itemType: 'textarea',
    prop: 'listenerPath',
    label: '监听器路径',
    rows: 8
  }
]
</script>
