multilevelClass.js 1.7 KB

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