useUserSelectRule.ts 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. import { generateUUID } from '@/utils'
  2. import { localeProps, makeRequiredRule } from '@/components/FormCreate/src/utils'
  3. export const useUserSelectRule = () => {
  4. const label = '用户选择器'
  5. const name = 'UserSelect'
  6. return {
  7. icon: 'icon-select',
  8. label,
  9. name,
  10. rule() {
  11. return {
  12. type: name,
  13. field: generateUUID(),
  14. title: label,
  15. info: '',
  16. $required: false
  17. }
  18. },
  19. props(_, { t }) {
  20. return localeProps(t, name + '.props', [
  21. makeRequiredRule(),
  22. { type: 'switch', field: 'multiple', title: '是否多选' },
  23. {
  24. type: 'switch',
  25. field: 'disabled',
  26. title: '是否禁用'
  27. },
  28. { type: 'switch', field: 'clearable', title: '是否可以清空选项' },
  29. {
  30. type: 'switch',
  31. field: 'collapseTags',
  32. title: '多选时是否将选中值按文字的形式展示'
  33. },
  34. {
  35. type: 'inputNumber',
  36. field: 'multipleLimit',
  37. title: '多选时用户最多可以选择的项目数,为 0 则不限制',
  38. props: { min: 0 }
  39. },
  40. {
  41. type: 'input',
  42. field: 'autocomplete',
  43. title: 'autocomplete 属性'
  44. },
  45. { type: 'input', field: 'placeholder', title: '占位符' },
  46. {
  47. type: 'switch',
  48. field: 'filterable',
  49. title: '是否可搜索'
  50. },
  51. { type: 'switch', field: 'allowCreate', title: '是否允许用户创建新条目' },
  52. {
  53. type: 'input',
  54. field: 'noMatchText',
  55. title: '搜索条件无匹配时显示的文字'
  56. },
  57. {
  58. type: 'switch',
  59. field: 'remote',
  60. title: '其中的选项是否从服务器远程加载'
  61. },
  62. {
  63. type: 'Struct',
  64. field: 'remoteMethod',
  65. title: '自定义远程搜索方法'
  66. },
  67. { type: 'input', field: 'noDataText', title: '选项为空时显示的文字' },
  68. {
  69. type: 'switch',
  70. field: 'reserveKeyword',
  71. title: '多选且可搜索时,是否在选中一个选项后保留当前的搜索关键词'
  72. },
  73. {
  74. type: 'switch',
  75. field: 'defaultFirstOption',
  76. title: '在输入框按下回车,选择第一个匹配项'
  77. },
  78. {
  79. type: 'switch',
  80. field: 'popperAppendToBody',
  81. title: '是否将弹出框插入至 body 元素',
  82. value: true
  83. },
  84. {
  85. type: 'switch',
  86. field: 'automaticDropdown',
  87. title: '对于不可搜索的 Select,是否在输入框获得焦点后自动弹出选项菜单'
  88. }
  89. ])
  90. }
  91. }
  92. }