index.js 1.2 KB

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