cascader.js 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. import uniqueId from '@form-create/utils/lib/unique';
  2. import {localeOptions, localeProps, makeTreeOptions, makeTreeOptionsRule} from '../../utils/index';
  3. const label = '级联选择器';
  4. const name = 'cascader';
  5. export default {
  6. menu: 'main',
  7. icon: 'icon-cascader',
  8. label,
  9. name,
  10. input: true,
  11. event: ['change', 'expandChange', 'blur', 'focus', 'visibleChange', 'removeTag'],
  12. validate: ['string', 'number', 'array'],
  13. rule({t}) {
  14. return {
  15. type: name,
  16. field: uniqueId(),
  17. title: t('com.cascader.name'),
  18. info: '',
  19. effect: {
  20. fetch: ''
  21. },
  22. $required: false,
  23. props: {
  24. options: makeTreeOptions(t('props.option'), {label: 'label', value: 'value'}, 3)
  25. }
  26. };
  27. },
  28. props(_, {t}) {
  29. return localeProps(t, name + '.props', [
  30. makeTreeOptionsRule(t, 'props.options'),
  31. ...[
  32. {
  33. type: 'switch',
  34. field: 'disabled'
  35. },
  36. {
  37. type: 'switch',
  38. field: 'clearable'
  39. },
  40. {
  41. type: 'input',
  42. field: 'placeholder'
  43. },
  44. {
  45. type: 'Object',
  46. field: 'props',
  47. props: {
  48. rule: localeProps(t, name + '.propsOpt', [{
  49. type: 'switch',
  50. field: 'multiple'
  51. }, {
  52. type: 'select',
  53. field: 'expandTrigger',
  54. options: localeOptions(t, [{label: 'click', value: 'click'}, {
  55. label: 'hover',
  56. value: 'hover'
  57. }])
  58. }, {
  59. type: 'switch',
  60. field: 'checkStrictly'
  61. }, {
  62. type: 'switch',
  63. field: 'emitPath',
  64. value: true
  65. }, {
  66. type: 'input',
  67. field: 'value',
  68. value: 'value'
  69. }, {
  70. type: 'input',
  71. field: 'label',
  72. value: 'label'
  73. }, {
  74. type: 'input',
  75. field: 'children',
  76. value: 'children'
  77. }, {
  78. type: 'input',
  79. field: 'disabled',
  80. value: 'disabled'
  81. }, {type: 'input', field: 'leaf'}])
  82. }
  83. },
  84. {
  85. type: 'switch',
  86. field: 'showAllLevels',
  87. value: true
  88. },
  89. {
  90. type: 'switch',
  91. field: 'collapseTags'
  92. },
  93. {
  94. type: 'switch',
  95. field: 'collapseTagsTooltip'
  96. },
  97. {
  98. type: 'input',
  99. field: 'separator'
  100. },
  101. {
  102. type: 'switch',
  103. field: 'filterable'
  104. },
  105. {
  106. type: 'select',
  107. field: 'tagType',
  108. options: [
  109. {label: 'success', value: 'success'},
  110. {label: 'info', value: 'info'},
  111. {label: 'warning', value: 'warning'},
  112. {label: 'danger', value: 'danger'},
  113. ]
  114. },
  115. ]
  116. ]);
  117. }
  118. };