import BasicField from '../Basic' import { KMPopupSelect } from '@/components/ui' import { FormControl } from '../../form' import { STATUS_MAP } from '@/utils' import type { IStatusSelectProps, StatusSelectValueType } from '@/types' class StatusSelect extends BasicField { props: IStatusSelectProps constructor(props: IStatusSelectProps, form: FormControl) { super(props, form) this.props = props this.rules = this.getRules(props.componentConfig) } getRules(config: IStatusSelectProps['componentConfig']) { const rules = [] if (config.required) { rules.push({ required: true, message: `请选择${this.name}` }) } return rules } render() { return ( ) } } const FormElement = ({ onChange, name, workOrderComponentType, value = { status: '', reason: '' } }: { name: string workOrderComponentType: IStatusSelectProps['workOrderComponentType'] onChange?: (value: Partial) => void value?: StatusSelectValueType }) => { const triggerValue = (changedValue: Partial) => { onChange?.({ ...value, ...changedValue }) } const onStatusChange = (status: StatusSelectValueType['status']) => { triggerValue({ status, reason: status === STATUS_MAP[workOrderComponentType].failValue ? value.reason : '' }) } return ( <> ) } export default StatusSelect