cascader.ts 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. import uniqueId from '@form-create/utils/lib/unique'
  2. import { localeProps, makeOptionsRule, makeRequiredRule } from '../../utils/formCreateIndex'
  3. const label = '级联选择器'
  4. const name = 'cascader'
  5. export default {
  6. icon: 'icon-cascader',
  7. label,
  8. name,
  9. rule({ t }) {
  10. const opt = t('props.option')
  11. return {
  12. type: name,
  13. field: uniqueId(),
  14. title: t('components.cascader.name'),
  15. info: '',
  16. effect: {
  17. fetch: ''
  18. },
  19. $required: false,
  20. props: {
  21. options: [1, 2].map(value => {
  22. return {
  23. label: opt + value,
  24. value,
  25. children: []
  26. }
  27. })
  28. }
  29. }
  30. },
  31. props(_, { t }) {
  32. return localeProps(t, name + '.props', [
  33. makeRequiredRule(),
  34. makeOptionsRule(t, 'props.options', false),
  35. {
  36. type: 'Object',
  37. field: 'props',
  38. title: '配置选项',
  39. props: {
  40. rule: localeProps(t, name + '.propsOpt', [
  41. {
  42. type: 'select',
  43. field: 'expandTrigger',
  44. title: '次级菜单的展开方式',
  45. options: [
  46. { label: 'click', value: 'click' },
  47. { label: 'hover', value: 'hover' }
  48. ]
  49. },
  50. { type: 'switch', field: 'multiple', title: '是否多选' },
  51. {
  52. type: 'switch',
  53. field: 'checkStrictly',
  54. title: '是否严格的遵守父子节点不互相关联'
  55. },
  56. {
  57. type: 'switch',
  58. field: 'emitPath',
  59. title: '在选中节点改变时,是否返回由该节点所在的各级菜单的值所组成的数组,若设置 false,则只返回该节点的值',
  60. value: true
  61. },
  62. { type: 'input', field: 'value', title: '指定选项的值为选项对象的某个属性值', value: 'value' },
  63. {
  64. type: 'input',
  65. field: 'label',
  66. title: '指定选项标签为选项对象的某个属性值',
  67. value: 'label'
  68. },
  69. { type: 'input', field: 'children', title: '指定选项的子选项为选项对象的某个属性值', value: 'children' },
  70. {
  71. type: 'input',
  72. field: 'disabled',
  73. title: '指定选项的禁用为选项对象的某个属性值',
  74. value: 'disabled'
  75. },
  76. { type: 'input', field: 'leaf', title: '指定选项的叶子节点的标志位为选项对象的某个属性值' }
  77. ])
  78. }
  79. },
  80. {
  81. type: 'select',
  82. field: 'size',
  83. title: '尺寸',
  84. options: [
  85. { label: 'large', value: 'large' },
  86. { label: 'default', value: 'default' },
  87. {
  88. label: 'small',
  89. value: 'small'
  90. }
  91. ]
  92. },
  93. { type: 'input', field: 'placeholder', title: '输入框占位文本' },
  94. {
  95. type: 'switch',
  96. field: 'disabled',
  97. title: '是否禁用'
  98. },
  99. { type: 'switch', field: 'clearable', title: '是否支持清空选项' },
  100. {
  101. type: 'switch',
  102. field: 'showAllLevels',
  103. title: '输入框中是否显示选中值的完整路径',
  104. value: true
  105. },
  106. { type: 'switch', field: 'collapseTags', title: '多选模式下是否折叠Tag' },
  107. {
  108. type: 'input',
  109. field: 'separator',
  110. title: '选项分隔符'
  111. }
  112. ])
  113. }
  114. }