rate.ts 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. import uniqueId from '@form-create/utils/lib/unique'
  2. import { localeProps, makeRequiredRule } from '../../utils/formCreateIndex'
  3. const label = '评分'
  4. const name = 'rate'
  5. export default {
  6. icon: 'icon-rate',
  7. label,
  8. name,
  9. rule({ t }) {
  10. return {
  11. type: name,
  12. field: uniqueId(),
  13. title: t('components.rate.name'),
  14. info: '',
  15. $required: false,
  16. props: {}
  17. }
  18. },
  19. props(_, { t }) {
  20. return localeProps(t, name + '.props', [
  21. makeRequiredRule(),
  22. { type: 'inputNumber', field: 'max', title: '最大分值', props: { min: 0 } },
  23. {
  24. type: 'switch',
  25. field: 'disabled',
  26. title: '是否为只读'
  27. },
  28. { type: 'switch', field: 'allowHalf', title: '是否允许半选' },
  29. {
  30. type: 'input',
  31. field: 'voidColor',
  32. title: '未选中 icon 的颜色'
  33. },
  34. { type: 'input', field: 'disabledVoidColor', title: '只读时未选中 icon 的颜色' },
  35. {
  36. type: 'input',
  37. field: 'voidIconClass',
  38. title: '未选中 icon 的类名'
  39. },
  40. { type: 'input', field: 'disabledVoidIconClass', title: '只读时未选中 icon 的类名' },
  41. {
  42. type: 'switch',
  43. field: 'showScore',
  44. title: '是否显示当前分数,show-score 和 show-text 不能同时为真'
  45. },
  46. { type: 'input', field: 'textColor', title: '辅助文字的颜色' },
  47. {
  48. type: 'input',
  49. field: 'scoreTemplate',
  50. title: '分数显示模板'
  51. }
  52. ])
  53. }
  54. }