| | |
| | | ref="uploader"
|
| | | :options="options"
|
| | | :file-status-text="statusText"
|
| | | :attrs="attrs"
|
| | | class="uploader-single"
|
| | | @file-added="onFileAdded"
|
| | | @complete="onComplete"
|
| | |
| | | <uploader
|
| | | v-else
|
| | | ref="uploader"
|
| | | :attrs="attrs"
|
| | | :options="options"
|
| | | :file-status-text="statusText"
|
| | | class="uploader-example"
|
| | |
| | | @complete="onComplete"
|
| | | @close="closeHandle"
|
| | | >
|
| | | <uploader-btn ref="button" :attrs="attrs">
|
| | | <uploader-btn ref="button" :sourceType="sourceType">
|
| | | <i class="el-icon-upload2" style="font-size:18px; color:#0088ff"></i>
|
| | | 上传
|
| | | </uploader-btn>
|
| | |
| | | UploaderList
|
| | | },
|
| | | props: {
|
| | | acptTypes: {
|
| | | type: String,
|
| | | default: ''
|
| | | sourceType: {
|
| | | type: Number,
|
| | | },
|
| | | tip: {
|
| | | type: Boolean,
|
| | |
| | | },
|
| | | attrs: {
|
| | | type: Object,
|
| | | // default () {
|
| | | // return {
|
| | | default () {
|
| | | return {
|
| | |
|
| | | // }
|
| | | // }
|
| | | }
|
| | | }
|
| | | }
|
| | | },
|
| | | data () {
|
| | | data() {
|
| | | return {
|
| | | fileName: "",
|
| | | fileMd5: "",
|
| | |
| | | }
|
| | | },
|
| | | computed: {
|
| | | uploader () {
|
| | | uploader() {
|
| | | return this.$refs.uploader.uploader;
|
| | | },
|
| | | options () {
|
| | | options() {
|
| | | return {
|
| | | target: this.url,
|
| | | testChunks: true,
|
| | |
| | | }
|
| | | },
|
| | | methods: {
|
| | | onFileAdded (file) {
|
| | | onFileAdded(file) {
|
| | | if (this.single) {
|
| | | this.uploader.fileList = this.uploader.fileList.slice([-1]);
|
| | | this.$emit("file-added")
|
| | | }
|
| | | this.computeMD5(file);
|
| | | },
|
| | | computeMD5 (file) {
|
| | | computeMD5(file) {
|
| | | let fileReader = new FileReader();
|
| | | let time = new Date().getTime();
|
| | | let blobSlice = File.prototype.slice || File.prototype.mozSlice || File.prototype.webkitSlice;
|
| | |
| | | this.error(`文件${file.name}读取出错,请检查该文件`)
|
| | | file.cancel();
|
| | | };
|
| | | function loadNext () {
|
| | | function loadNext() {
|
| | | let start = currentChunk * chunkSize;
|
| | | let end = ((start + chunkSize) >= file.size) ? file.size : start + chunkSize;
|
| | | fileReader.readAsArrayBuffer(blobSlice.call(file.file, start, end));
|
| | | }
|
| | | },
|
| | | computeMD5Success (md5, file) {
|
| | | // 将自定义参数直接加载uploader实例的opts上
|
| | | // if (this.$route.path.indexOf("VideoManage") >= 0) {
|
| | | // Object.assign(this.uploader.opts, {
|
| | | // query: {
|
| | | // stackId: this.DataStackPool.selectedDir.id
|
| | | // // ...this.params,
|
| | | // }
|
| | | // })
|
| | | // }
|
| | | computeMD5Success(md5, file) {
|
| | | //将自定义参数直接加载uploader实例的opts上
|
| | | if (location.href.indexOf("dataStack") >= 0) {
|
| | | Object.assign(this.uploader.opts, {
|
| | |
| | | file.resume();
|
| | | this.statusText.paused = "暂停中";
|
| | | },
|
| | | onComplete () {
|
| | | debugger
|
| | | onComplete() {
|
| | | this.$emit("complete", { filename: this.fileName, identifier: this.fileMd5 });
|
| | | },
|
| | | fileComplete () {
|
| | | fileComplete() {
|
| | | // console.log('file complete', arguments)
|
| | | },
|
| | | closeHandle () {
|
| | | closeHandle() {
|
| | | this.$emit("close")
|
| | | }
|
| | | },
|
| | | mounted () {
|
| | | mounted() {
|
| | | this.$nextTick(() => {
|
| | | console.log(this.acptTypes)
|
| | | console.log(this.sourceType)
|
| | | window.uploader = this.$refs.uploader.uploader
|
| | | })
|
| | | }
|