Event.js 931 Bytes
Newer Older
wangdanlei's avatar
wangdanlei committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
export default {
  props: {},
  data() {
    return {
      outputEvent: []
    }
  },
  created() {
    this.getEvent()
  },
  computed: {
    inputEvent() {
      if (!this.pageData || !this.config || !this.config.name) {
        return null
      }
      return this.pageData[this.config.name]
    }
  },
  methods: {
    getEvent() {
      if (this.config && this.config.componentInfo) {
        if (typeof this.config.componentInfo === 'string') {
          this.config.componentInfo = JSON.parse(this.config.componentInfo)
        }
        const Event = this.config.componentInfo
        if (Event) {
          this.outputEvent = Event.bindEvent
        }
      }
    },
    outEvent(Event, params) {
      if (Event.length) {
        Event.forEach(event => {
          const data = {}
          data[event.inputEvent] = { ...params }
          this.$set(this.pageData, event.component, data)
        })
      }
    }
  }
}