index.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. import baseComponent from '../helpers/baseComponent'
  2. import classNames from '../helpers/classNames'
  3. baseComponent({
  4. relations: {
  5. '../cell/index': {
  6. type: 'child',
  7. observer() {
  8. this.debounce(this.updateIsLastElement)
  9. },
  10. },
  11. },
  12. properties: {
  13. prefixCls: {
  14. type: String,
  15. value: 'wux-cell-group',
  16. },
  17. title: {
  18. type: String,
  19. value: '',
  20. },
  21. label: {
  22. type: String,
  23. value: '',
  24. },
  25. },
  26. computed: {
  27. classes() {
  28. const { prefixCls } = this.data
  29. const wrap = classNames(prefixCls)
  30. const hd = `${prefixCls}__hd`
  31. const bd = `${prefixCls}__bd`
  32. const ft = `${prefixCls}__ft`
  33. return {
  34. wrap,
  35. hd,
  36. bd,
  37. ft,
  38. }
  39. },
  40. },
  41. methods: {
  42. updateIsLastElement() {
  43. const elements = this.getRelationNodes('../cell/index')
  44. if (elements.length > 0) {
  45. const lastIndex = elements.length - 1
  46. elements.forEach((element, index) => {
  47. element.updateIsLastElement(index === lastIndex)
  48. })
  49. }
  50. },
  51. },
  52. })