MediaDialog.vue 871 Bytes
Newer Older
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 42 43 44 45 46
<script>
import ImageAndVideoUpload from '@/components/ImageAndVideoUpload'

export default {
  components: {ImageAndVideoUpload},
  props:{
    value:{
      type:Array,
      default:() => []
    },
    readonly: Boolean
  },
  data(){
    return {
      show: false,
      pictureUrls:[]
    }
  },
  watch:{
    show(){
      if(!this.show){
        this.$emit('close', this.pictureUrls)
      }
    },
    pictureUrls(){
      if(this.value == this.pictureUrls) return
      this.$emit('input', this.pictureUrls)
    }
  },
  created() {
    this.pictureUrls = this.value
    this.show = true
  },
  methods:{
    onBeforeClose(){
      this.show = false
    }
  }
}
</script>

<template>
  <el-dialog :visible.sync="show" :before-close="onBeforeClose">
    <image-and-video-upload v-model="pictureUrls" readonly></image-and-video-upload>
  </el-dialog>
</template>