select-good-popup-host.vue 886 B

123456789101112131415161718192021222324252627282930313233
  1. <template>
  2. <select-good-popup ref="popup" @notice-change="onNoticeChange" />
  3. </template>
  4. <script>
  5. import SelectGoodPopup from '@/pages-sell/components/select-good-popup/index.vue'
  6. import { eventBus } from '@/utils/event-bus'
  7. export default {
  8. name: 'SelectGoodPopupHost',
  9. components: {
  10. SelectGoodPopup,
  11. },
  12. mounted() {
  13. this.openHandler = (payload = {}) => {
  14. const { product, sourceFrom } = payload
  15. if (!product) return
  16. this.$refs.popup?.open(product, sourceFrom)
  17. }
  18. eventBus.on('openSelectGoodPopup', this.openHandler)
  19. },
  20. beforeDestroy() {
  21. if (this.openHandler) {
  22. eventBus.off('openSelectGoodPopup', this.openHandler)
  23. }
  24. },
  25. methods: {
  26. onNoticeChange(value) {
  27. eventBus.emit('selectGoodNoticeChange', value)
  28. },
  29. },
  30. }
  31. </script>