<template />

<script>
import ApDevBase from './ApDevBase'
import { deepClone } from 'ap-util/util/ObjectUtil'

export default {
  name: 'ApDevPropBase',
  extends: ApDevBase,
  props: {
    // ref属性
    options: {
      type: String,
      required: true
    }
  },
  data() {
    return {
      opts: {}
    }
  },
  watch: {
    options: {
      handler(value) {
        // 点击不同的item，重新初始化数据
        this.initData()
      },
      deep: true
    },
    opts: {
      handler(value) {
        this.$store.commit('propUpdateItemOptions', {
          ref: this.$store.state.currentComps.ref,
          obj: value
        })
      },
      deep: true
    }
  },
  created() {
    this.initData()
  },
  methods: {
    initData() {
      const itemObj = this.$store.getters.getItem(this.options)
      const tempOpts = deepClone(itemObj.options)
      this.opts = tempOpts
    }
  }
}
</script>

<style scoped>

</style>
