radio.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import uniqueId from '@form-create/utils/lib/unique';
  2. import {localeProps, makeOptionsRule, makeTreeOptions} from '../../utils/index';
  3. const label = '单选框';
  4. const name = 'radio';
  5. export default {
  6. menu: 'main',
  7. icon: 'icon-radio',
  8. label,
  9. name,
  10. input: true,
  11. event: ['change'],
  12. validate: ['string', 'number'],
  13. rule({t}) {
  14. return {
  15. type: name,
  16. field: uniqueId(),
  17. title: t('com.radio.name'),
  18. info: '',
  19. effect: {
  20. fetch: ''
  21. },
  22. $required: false,
  23. props: {},
  24. options: makeTreeOptions(t('props.option'), {label: 'label', value: 'value'}, 1)
  25. };
  26. },
  27. props(_, {t}) {
  28. return localeProps(t, name + '.props', [
  29. makeOptionsRule(t, 'options'),
  30. {type: 'switch', field: 'disabled'},
  31. {type: 'switch', field: 'input'},
  32. {
  33. type: 'switch',
  34. field: 'type',
  35. props: {activeValue: 'button', inactiveValue: 'default'}
  36. }, {type: 'ColorInput', field: 'textColor'}, {
  37. type: 'ColorInput',
  38. field: 'fill'
  39. }]);
  40. }
  41. };