<template>
  <ProForm ref="formRef" :items-options="items" :model="model" :form-options="_formOptions"> </ProForm>
</template>
<script lang="ts" name="GenBasicInfo" setup>
import { defineProps, ref } from 'vue'
import ProForm from '@/components/ProForm/index.vue'
const formRef = ref<InstanceType<typeof ProForm> | null>(null)
export interface InfoProps {
  tables: any[] // 表格数据
  menus: any[] // 菜单
  model: any // 详情数据
}

const prop = withDefaults(defineProps<InfoProps>(), {
  tables: () => [],
  menus: () => [],
  model: () => null
})
const tplData = [
  {
    label: '单表（增删改查）',
    value: 'crud'
  },
  {
    label: '树表（增删改查）',
    value: 'tree'
  },
  {
    label: '主子表（增删改查）',
    value: 'sub'
  }
]
const genTypeData = [
  {
    label: 'zip压缩包',
    value: '0'
  },
  {
    label: '自定义路径',
    value: '1'
  }
]
const _formOptions = {
  hasFooter: false
}
let items: ProForm.ItemsOptions[] = []
const setItem = () => {
  items = [
    {
      label: '生成模板',
      prop: 'tplCategory',
      span: 12,
      rules: [{ required: true, message: '生成模板不能为空', trigger: 'change' }],
      compOptions: {
        elTagName: 'select',
        clearable: true,
        style: 'width: 80%',
        enum: tplData,
        placeholder: '请输入生成模板'
      }
    },
    {
      label: '生成包路径',
      prop: 'packageName',
      tooltip: '生成在哪个java包下，例如 com.km.system',
      span: 12,
      rules: [{ required: true, message: '生成包路径不能为空', trigger: 'blur' }],
      compOptions: {
        elTagName: 'input',
        clearable: true,
        placeholder: '请输入生成包路径'
      }
    },
    {
      label: '生成模块名',
      prop: 'moduleName',
      span: 12,
      tooltip: '可理解为子系统名，例如 system',
      rules: [{ required: true, message: '生成模块名不能为空', trigger: 'blur' }],
      compOptions: {
        elTagName: 'input',
        clearable: true,
        placeholder: '请输入生成模块名'
      }
    },
    {
      label: '生成业务名',
      prop: 'businessName',
      tooltip: '可理解为功能英文名，例如 user',
      span: 12,
      rules: [{ required: true, message: '生成业务名不能为空', trigger: 'blur' }],
      compOptions: {
        elTagName: 'input',
        clearable: true,
        placeholder: '请输入生成业务名'
      }
    },
    {
      label: '生成功能名',
      prop: 'functionName',
      tooltip: '用作类描述，例如 用户',
      span: 12,
      rules: [{ required: true, message: '生成功能名不能为空', trigger: 'blur' }],
      compOptions: {
        elTagName: 'input',
        clearable: true,
        placeholder: '请输入生成功能名'
      }
    },
    {
      label: '上级菜单',
      prop: 'parentMenuId',
      span: 10,
      tooltip: '分配到指定菜单下，例如 系统管理',
      compOptions: {
        elTagName: 'tree-select',
        clearable: true,
        valueKey: 'menuId',
        placeholder: '请选择上级菜单',
        appendToBody: true,
        checkStrictly: true,
        enum: prop.menus,
        filterable: true,
        props: {
          value: 'menuId',
          label: 'menuName',
          children: 'children'
        }
      }
    },
    {
      label: '生成方式',
      prop: 'functionAuthor',
      tooltip: '默认为zip压缩包下载，也可以自定义生成路径',
      span: 12,
      compOptions: {
        elTagName: 'radio-group',
        enum: genTypeData,
        clearable: true,
        placeholder: '请输入作者'
      }
    }
  ]
}
setItem()
defineExpose({
  formRef
})
</script>
