import type { VbenFormProps } from '#/adapter/form';

import { STATUS_OPTIONS, THEME_OPTIONS } from './constants';

/**
 * 小程序工作台功能入口新增/编辑表单
 * theme_color 是表单虚拟字段：选主色，提交时由 modal 组装成 {bg,color} JSON 存 theme 列
 */
export const modalFormProps: VbenFormProps = {
  wrapperClass: 'grid-cols-12',
  commonConfig: {
    formItemClass: 'col-span-12',
    componentProps: { class: 'w-full' },
  },
  layout: 'horizontal',
  schema: [
    {
      component: 'VbenInput',
      fieldName: 'id',
      label: 'ID',
      dependencies: { show: false, triggerFields: ['id'] },
    },
    {
      component: 'VbenInput',
      fieldName: 'code',
      label: '入口编码',
      rules: 'required',
      componentProps: {
        placeholder: 'snake_case 全局唯一，按端加前缀：clinic_admin_ / platform_ / sp_ / cs_',
      },
    },
    {
      component: 'VbenInput',
      fieldName: 'name',
      label: '入口名称',
      rules: 'required',
      componentProps: { placeholder: '卡片标题，如：提现管理' },
    },
    {
      component: 'VbenInput',
      fieldName: 'description',
      label: '入口描述',
      componentProps: { placeholder: '卡片副标题，如：提现流水查询' },
      defaultValue: '',
    },
    {
      component: 'VbenInput',
      fieldName: 'group_name',
      label: '分组标题',
      rules: 'required',
      componentProps: { placeholder: '首页分区块标题，如：财务管理' },
    },
    {
      component: 'VbenInput',
      fieldName: 'icon',
      label: '图标',
      componentProps: { placeholder: 'uView 图标名，如 red-packet-fill' },
      defaultValue: 'grid-fill',
    },
    {
      component: 'VbenSelect',
      fieldName: 'theme_color',
      label: '主题配色',
      formItemClass: 'col-span-6',
      componentProps: { options: THEME_OPTIONS, allowClear: true },
    },
    {
      component: 'InputNumber',
      fieldName: 'sort',
      label: '排序',
      formItemClass: 'col-span-6',
      componentProps: { min: 0 },
      defaultValue: 0,
    },
    {
      component: 'VbenInput',
      fieldName: 'path',
      label: '跳转路径',
      componentProps: {
        placeholder: '小程序页面路径；留空表示前端按编码特殊处理（如传方弹窗）',
      },
      defaultValue: '',
    },
    {
      component: 'VbenSelect',
      fieldName: 'status',
      label: '状态',
      componentProps: { options: STATUS_OPTIONS },
      defaultValue: 1,
    },
  ],
  showDefaultActions: false,
};
