create.config.ts
1.16 KB
import { ScopeEnum } from '../../../enum/form';
import { useRuleChainI18n } from '../../../hook/useRuleChainI18n';
import { FormSchema } from '/@/components/Form';
const { tLabel, tPlaceholder, t } = useRuleChainI18n('action', 'saveAttributes');
export enum SaveAttributesFieldsEnum {
NOTIFY_DEVICE = 'notifyDevice',
SCOPE = 'scope',
}
export const formSchemas: FormSchema[] = [
{
field: SaveAttributesFieldsEnum.SCOPE,
component: 'Select',
label: tLabel(SaveAttributesFieldsEnum.SCOPE),
required: true,
componentProps: {
options: Object.keys(ScopeEnum).map((value) => ({ label: t(`enum.scope.${value}`), value })),
getPopupContainer: () => document.body,
placeholder: tPlaceholder(SaveAttributesFieldsEnum.SCOPE, 'choose'),
},
},
{
field: SaveAttributesFieldsEnum.NOTIFY_DEVICE,
component: 'Checkbox',
label: tLabel(SaveAttributesFieldsEnum.NOTIFY_DEVICE),
ifShow: ({ model }) => model[SaveAttributesFieldsEnum.SCOPE] === ScopeEnum.SHARED_SCOPE,
renderComponentContent: () => ({
default: () =>
'If the message arrives from the device, we will push it back to the device by default.',
}),
},
];