// REQ-USR-001 / REQ-USR-002: 用户单据表单网格(3 列布局,8 字段 + 员工联动 + 前置校验,BR1-BR9) import { Form, Input, Select, Checkbox, type FormInstance } from 'antd'; import type { EmployeeOption } from '../../../api/types'; import { USER_TYPE_OPTIONS, LANGUAGE_OPTIONS, USERNAME_PATTERN, LABEL_CREATE_TIME, LABEL_CREATOR, LABEL_EMPLOYEE, LABEL_USERNAME, LABEL_USER_TYPE, LABEL_LANGUAGE, LABEL_USER_NO, LABEL_CAN_MODIFY_BILL, TEXT_CREATOR_PLACEHOLDER, MSG_USERNAME_FORMAT, MSG_USERNAME_REQUIRED, MSG_USERNO_REQUIRED, MSG_USERTYPE_REQUIRED, MSG_LANGUAGE_REQUIRED, type UserFormValues, } from './constants'; import styles from './UserDetail.module.css'; export interface UserBasicFormProps { form: FormInstance; mode: 'create' | 'edit'; employees: EmployeeOption[]; readonlyCreateTime?: string; readonlyCreator?: string; onSelectEmployee(value: number | null): void; } const toEnumOptions = (arr: readonly string[]) => arr.map((v) => ({ value: v, label: v })); export default function UserBasicForm({ form, mode, employees, readonlyCreateTime, readonlyCreator, onSelectEmployee, }: UserBasicFormProps) { void form; // 表单由父级 Form 实例驱动(受控 initialValues / validate / submit) const creatorText = mode === 'edit' ? readonlyCreator || '' : TEXT_CREATOR_PLACEHOLDER; const createTimeText = mode === 'edit' ? readonlyCreateTime || '' : ''; return (
{/* 创建时间(只读,BR1) */}
{createTimeText}
{/* 制单人(只读,BR2) */}
{creatorText}
{/* 员工名(Select,选中联动带出用户名/用户号,BR5) */} {/* 类型(Select 枚举,create 默认普通用户,BR6) */} {/* 用户号(必填,BR4,可由员工名联动带出,BR5) */} {/* 单据修改权限(Checkbox,默认否,BR8) */}
); }