From da98d2a8a686cde09b20345e4a2b55a85410fde4 Mon Sep 17 00:00:00 2001 From: hanbaoshan <hanbaoshan@aiotlink.com> Date: 星期二, 27 十月 2020 11:31:05 +0800 Subject: [PATCH] 数据栈文件上传动态限制类型调试,标注切换摄像机获取底图 --- src/components/subComponents/FileUpload/uploader.vue | 80 +++++++++++++++++++++++++++++++--------- 1 files changed, 62 insertions(+), 18 deletions(-) diff --git a/src/components/subComponents/FileUpload/uploader.vue b/src/components/subComponents/FileUpload/uploader.vue index 2df8221..41fb54c 100644 --- a/src/components/subComponents/FileUpload/uploader.vue +++ b/src/components/subComponents/FileUpload/uploader.vue @@ -5,8 +5,8 @@ <uploader-unsupport></uploader-unsupport> <uploader-drop> <!-- <p>鎷栧姩鏂囦欢鍒拌鍖哄煙涓婁紶</p> --> - <uploader-btn>閫夋嫨鏂囦欢</uploader-btn> - <uploader-btn :directory="true">閫夋嫨鏂囦欢澶�</uploader-btn> + <uploader-btn :attrs="attrs">閫夋嫨鏂囦欢</uploader-btn> + <uploader-btn :directory="true" :attrs="attrs">閫夋嫨鏂囦欢澶�</uploader-btn> </uploader-drop> <uploader-list></uploader-list> </slot> @@ -33,7 +33,26 @@ uploader: this } }, + watch:{ + attrs:{ + handler(n,o){ + console.log('uploader attrs update',n) + this.$nextTick(()=>{ + //this.unBindUploader(); + this.bindUploader(); + }) + }, + deep: true + }, + + }, props: { + attrs: { + type: Object, + default() { + return {} + } + }, options: { type: Object, default() { @@ -94,6 +113,7 @@ } }, allEvent(...args) { + console.log(args) const name = args[0] const EVENTSMAP = { [FILE_ADDED_EVENT]: true, @@ -112,27 +132,51 @@ }, closeHandle() { this.$emit("close") + }, + bindUploader(){ + console.log('new Uploader') + this.options.initialPaused = !this.autoStart + const uploader = new Uploader(this.options) + this.uploader = uploader + this.uploader.fileStatusText = this.fileStatusText + uploader.on('catchAll', this.allEvent) + uploader.on(FILE_ADDED_EVENT, this.fileAdded) + uploader.on(FILES_ADDED_EVENT, this.filesAdded) + uploader.on('fileRemoved', this.fileRemoved) + uploader.on('filesSubmitted', this.filesSubmitted) + }, + unBindUploader(){ + const uploader = this.uploader + uploader.off('catchAll', this.allEvent) + uploader.off(FILE_ADDED_EVENT, this.fileAdded) + uploader.off(FILES_ADDED_EVENT, this.filesAdded) + uploader.off('fileRemoved', this.fileRemoved) + uploader.off('filesSubmitted', this.filesSubmitted) + this.uploader = null } }, created() { - this.options.initialPaused = !this.autoStart - const uploader = new Uploader(this.options) - this.uploader = uploader - this.uploader.fileStatusText = this.fileStatusText - uploader.on('catchAll', this.allEvent) - uploader.on(FILE_ADDED_EVENT, this.fileAdded) - uploader.on(FILES_ADDED_EVENT, this.filesAdded) - uploader.on('fileRemoved', this.fileRemoved) - uploader.on('filesSubmitted', this.filesSubmitted) + console.log('uploader attrs',this.attrs); + this.bindUploader(); + // this.options.initialPaused = !this.autoStart + // const uploader = new Uploader(this.options) + // this.uploader = uploader + // this.uploader.fileStatusText = this.fileStatusText + // uploader.on('catchAll', this.allEvent) + // uploader.on(FILE_ADDED_EVENT, this.fileAdded) + // uploader.on(FILES_ADDED_EVENT, this.filesAdded) + // uploader.on('fileRemoved', this.fileRemoved) + // uploader.on('filesSubmitted', this.filesSubmitted) }, destroyed() { - const uploader = this.uploader - uploader.off('catchAll', this.allEvent) - uploader.off(FILE_ADDED_EVENT, this.fileAdded) - uploader.off(FILES_ADDED_EVENT, this.filesAdded) - uploader.off('fileRemoved', this.fileRemoved) - uploader.off('filesSubmitted', this.filesSubmitted) - this.uploader = null + this.unBindUploader(); + // const uploader = this.uploader + // uploader.off('catchAll', this.allEvent) + // uploader.off(FILE_ADDED_EVENT, this.fileAdded) + // uploader.off(FILES_ADDED_EVENT, this.filesAdded) + // uploader.off('fileRemoved', this.fileRemoved) + // uploader.off('filesSubmitted', this.filesSubmitted) + // this.uploader = null }, components: { UploaderBtn, -- Gitblit v1.8.0