multilevelClass.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. Component({
  2. properties: {
  3. item: Object
  4. },
  5. data: {
  6. active: {}
  7. },
  8. methods: {
  9. onSelect(e) {
  10. const {
  11. i,
  12. item
  13. } = e.currentTarget.dataset;
  14. if (this.data.item.index == i) {
  15. getApp().globalData.temporaryId = this.data.item.id || "";
  16. this.setData({
  17. "item.index": null,
  18. childClass: null
  19. });
  20. } else {
  21. getApp().globalData.temporaryId = this.data.item.selectKey ? item[this.data.item.selectKey] : JSON.parse(JSON.stringify(item));
  22. this.setData({
  23. "item.index": i,
  24. childClass: item.subdep.length ? {
  25. index: null,
  26. label: item.itemclassname + '的下级分类',
  27. list: item.subdep,
  28. selectKey: this.data.item.selectKey,
  29. showName: this.data.item.showName,
  30. type: this.data.item.type,
  31. value: "",
  32. valueKey: this.data.item.valueKey,
  33. id: getApp().globalData.temporaryId
  34. } : null
  35. });
  36. };
  37. }
  38. }
  39. })