<template>
  <div class="video-form">
    <div class="form" ref="form">
      <Form :label-width="86">
        <FormItem label="视频简介">
          <Input type="text" size="large" v-model="form.introduceVideoDesc" :disabled="isDetail" />
        </FormItem>
        <FormItem label="上传视频">
          <videoUpload :hideUpload="isDetail" tips="只能上传mp4/mov文件，且不超过10mb" ref="videoUpload" :hasUploads="hasUploads" :preUploads="preUploads" />
        </FormItem>
      </Form>
    </div>
  </div>
</template>

<script>
import videoUpload from '@/components/upload/video'

export default {
  props: {
    form: Object,
    isDetail: Boolean
  },
  data () {
    return {
      hasUploads: [],
      preUploads: []
    }
  },
  components: {
    videoUpload
  },
  mounted () {
    this.$watch('form.introduceVideo', function (newVal) {
      console.log(newVal, 'new')
      if (this.isDetail) {
        this.hasUploads = [{img: `${newVal}?x-oss-process=video/snapshot,t_7000,f_jpg,w_800,h_600,m_fast`, url: newVal}]
      }
    }, {
      immediate: true
    })
  },
  methods: {
    async validate () {
      // const valid = await this.$refs['form'].validate()
      return true
    },
    async submit () {
      let res = await this.$refs['videoUpload'].uploadfiles()
      console.log(res, 'res')
      if (res[0]) {
        this.form.introduceVideo = res[0].data.url
      }
      
    },
  }
}
</script>