Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

index.tsx 4.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. import { useTranslate } from '@/hooks/common-hooks';
  2. import { Form, Input, Select } from 'antd';
  3. import { useMemo } from 'react';
  4. import {
  5. Jin10CalendarDatashapeOptions,
  6. Jin10CalendarTypeOptions,
  7. Jin10FlashTypeOptions,
  8. Jin10SymbolsDatatypeOptions,
  9. Jin10SymbolsTypeOptions,
  10. Jin10TypeOptions,
  11. } from '../../constant';
  12. import { IOperatorForm } from '../../interface';
  13. import DynamicInputVariable from '../components/dynamic-input-variable';
  14. const Jin10Form = ({ onValuesChange, form, node }: IOperatorForm) => {
  15. const { t } = useTranslate('flow');
  16. const jin10TypeOptions = useMemo(() => {
  17. return Jin10TypeOptions.map((x) => ({
  18. value: x,
  19. label: t(`jin10TypeOptions.${x}`),
  20. }));
  21. }, [t]);
  22. const jin10FlashTypeOptions = useMemo(() => {
  23. return Jin10FlashTypeOptions.map((x) => ({
  24. value: x,
  25. label: t(`jin10FlashTypeOptions.${x}`),
  26. }));
  27. }, [t]);
  28. const jin10CalendarTypeOptions = useMemo(() => {
  29. return Jin10CalendarTypeOptions.map((x) => ({
  30. value: x,
  31. label: t(`jin10CalendarTypeOptions.${x}`),
  32. }));
  33. }, [t]);
  34. const jin10CalendarDatashapeOptions = useMemo(() => {
  35. return Jin10CalendarDatashapeOptions.map((x) => ({
  36. value: x,
  37. label: t(`jin10CalendarDatashapeOptions.${x}`),
  38. }));
  39. }, [t]);
  40. const jin10SymbolsTypeOptions = useMemo(() => {
  41. return Jin10SymbolsTypeOptions.map((x) => ({
  42. value: x,
  43. label: t(`jin10SymbolsTypeOptions.${x}`),
  44. }));
  45. }, [t]);
  46. const jin10SymbolsDatatypeOptions = useMemo(() => {
  47. return Jin10SymbolsDatatypeOptions.map((x) => ({
  48. value: x,
  49. label: t(`jin10SymbolsDatatypeOptions.${x}`),
  50. }));
  51. }, [t]);
  52. return (
  53. <Form
  54. name="basic"
  55. autoComplete="off"
  56. form={form}
  57. onValuesChange={onValuesChange}
  58. layout={'vertical'}
  59. >
  60. <DynamicInputVariable nodeId={node?.id}></DynamicInputVariable>
  61. <Form.Item label={t('type')} name={'type'} initialValue={'flash'}>
  62. <Select options={jin10TypeOptions}></Select>
  63. </Form.Item>
  64. <Form.Item label={t('secretKey')} name={'secret_key'}>
  65. <Input></Input>
  66. </Form.Item>
  67. <Form.Item noStyle dependencies={['type']}>
  68. {({ getFieldValue }) => {
  69. const type = getFieldValue('type');
  70. switch (type) {
  71. case 'flash':
  72. return (
  73. <>
  74. <Form.Item label={t('flashType')} name={'flash_type'}>
  75. <Select options={jin10FlashTypeOptions}></Select>
  76. </Form.Item>
  77. <Form.Item label={t('contain')} name={'contain'}>
  78. <Input></Input>
  79. </Form.Item>
  80. <Form.Item label={t('filter')} name={'filter'}>
  81. <Input></Input>
  82. </Form.Item>
  83. </>
  84. );
  85. case 'calendar':
  86. return (
  87. <>
  88. <Form.Item label={t('calendarType')} name={'calendar_type'}>
  89. <Select options={jin10CalendarTypeOptions}></Select>
  90. </Form.Item>
  91. <Form.Item
  92. label={t('calendarDatashape')}
  93. name={'calendar_datashape'}
  94. >
  95. <Select options={jin10CalendarDatashapeOptions}></Select>
  96. </Form.Item>
  97. </>
  98. );
  99. case 'symbols':
  100. return (
  101. <>
  102. <Form.Item label={t('symbolsType')} name={'symbols_type'}>
  103. <Select options={jin10SymbolsTypeOptions}></Select>
  104. </Form.Item>
  105. <Form.Item
  106. label={t('symbolsDatatype')}
  107. name={'symbols_datatype'}
  108. >
  109. <Select options={jin10SymbolsDatatypeOptions}></Select>
  110. </Form.Item>
  111. </>
  112. );
  113. case 'news':
  114. return (
  115. <>
  116. <Form.Item label={t('contain')} name={'contain'}>
  117. <Input></Input>
  118. </Form.Item>
  119. <Form.Item label={t('filter')} name={'filter'}>
  120. <Input></Input>
  121. </Form.Item>
  122. </>
  123. );
  124. default:
  125. return <></>;
  126. }
  127. }}
  128. </Form.Item>
  129. </Form>
  130. );
  131. };
  132. export default Jin10Form;