eventBus.js 745 B

1234567891011121314151617181920212223242526
  1. import Vue from 'vue'
  2. export const EventBus = new Vue()
  3. export function dataInit (_this) {
  4. EventBus.$on('dataInit', (formData, bindComponents) => {
  5. // eslint-disable-next-line no-unused-expressions
  6. bindComponents?.forEach(com => {
  7. const maps = com.maps
  8. const filterList = maps?.map(param => ({
  9. column: param.targetField,
  10. operator: param.queryRule,
  11. value: formData[param.sourceField]
  12. }))
  13. _this.$nextTick(() => {
  14. if (_this.$refs[com.componentKey]) {
  15. if (_this.$refs[com.componentKey].dataInit) {
  16. _this.$refs[com.componentKey].dataInit(filterList)
  17. }
  18. }
  19. })
  20. })
  21. })
  22. }
  23. export function destroyedEvent () {
  24. EventBus.$off('dataInit')
  25. }