<template>
  <el-dialog
    :title="topTitle"
    :visible.sync="show"
    width="70%"
    :close-on-click-modal="false"
    :before-close="handleClose" append-to-body>

    <goods-edit ref="editContent" :id="id" />

  </el-dialog>
</template>

<script>

  export default {
    props: {
      show: Boolean,
      id: [String, Number],
    },
    components: {
      'goods-edit': () => import('./goods_edit.vue')
    },
    computed: {
      topTitle() {
        if(this.id>=0&&this.id!=undefined){
          return "编辑商品"
        }
        return "新增商品"
      }
    },
    watch: {
      show(n, o) {
        if(n) {
          this.$nextTick(() => {
            this.$refs['editContent'].reload(this.id)
          })
        }
      }
    },
    methods: {
      handleClose() {
        this.$emit('close')
      }
    }
  }

</script>

<style scoped>



</style>
