index.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. import baseComponent from '../helpers/baseComponent'
  2. import classNames from '../helpers/classNames'
  3. baseComponent({
  4. useField: true,
  5. relations: {
  6. '../radio/index': {
  7. type: 'child',
  8. observer() {
  9. this.debounce(this.changeValue)
  10. },
  11. },
  12. },
  13. properties: {
  14. prefixCls: {
  15. type: String,
  16. value: 'wux-radio-group',
  17. },
  18. cellGroupPrefixCls: {
  19. type: String,
  20. value: 'wux-cell-group',
  21. },
  22. value: {
  23. type: String,
  24. value: '',
  25. observer: 'changeValue',
  26. },
  27. title: {
  28. type: String,
  29. value: '',
  30. },
  31. label: {
  32. type: String,
  33. value: '',
  34. },
  35. },
  36. methods: {
  37. changeValue(value = this.data.value) {
  38. const elements = this.getRelationNodes('../radio/index')
  39. if (elements.length > 0) {
  40. elements.forEach((element, index) => {
  41. element.changeValue(value === element.data.value, index)
  42. })
  43. }
  44. },
  45. emitEvent(item) {
  46. this.triggerEvent('change', { ...item, name: this.data.name })
  47. },
  48. },
  49. })