support Progress & Upload
support Progress & Upload
This commit is contained in:
parent
c97c42ab2e
commit
5d08ddf27c
10 changed files with 137 additions and 63 deletions
|
@ -45,13 +45,18 @@
|
|||
default: 10
|
||||
}
|
||||
},
|
||||
data () {
|
||||
return {
|
||||
currentStatus: this.status
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
isStatus () {
|
||||
return this.status == 'wrong' || this.status == 'success';
|
||||
return this.currentStatus == 'wrong' || this.currentStatus == 'success';
|
||||
},
|
||||
statusIcon () {
|
||||
let type = '';
|
||||
switch (this.status) {
|
||||
switch (this.currentStatus) {
|
||||
case 'wrong':
|
||||
type = 'ios-close';
|
||||
break;
|
||||
|
@ -71,9 +76,9 @@
|
|||
wrapClasses () {
|
||||
return [
|
||||
`${prefixCls}`,
|
||||
`${prefixCls}-${this.status}`,
|
||||
`${prefixCls}-${this.currentStatus}`,
|
||||
{
|
||||
[`${prefixCls}-show-info`]: !this.hideInfo,
|
||||
[`${prefixCls}-show-info`]: !this.hideInfo
|
||||
|
||||
}
|
||||
];
|
||||
|
@ -94,16 +99,18 @@
|
|||
return `${prefixCls}-bg`;
|
||||
}
|
||||
},
|
||||
compiled () {
|
||||
created () {
|
||||
this.handleStatus();
|
||||
},
|
||||
methods: {
|
||||
handleStatus (isDown) {
|
||||
if (isDown) {
|
||||
this.status = 'normal';
|
||||
this.currentStatus = 'normal';
|
||||
this.$emit('on-status-change', 'normal');
|
||||
} else {
|
||||
if (parseInt(this.percent, 10) == 100) {
|
||||
this.status = 'success';
|
||||
this.currentStatus = 'success';
|
||||
this.$emit('on-status-change', 'success');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -115,6 +122,9 @@
|
|||
} else {
|
||||
this.handleStatus();
|
||||
}
|
||||
},
|
||||
status (val) {
|
||||
this.currentStatus = val;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -11,13 +11,14 @@
|
|||
type="ios-close-empty"
|
||||
:class="[prefixCls + '-list-remove']"
|
||||
v-show="file.status === 'finished'"
|
||||
@click="handleRemove(file)"></Icon>
|
||||
<Progress
|
||||
v-if="file.showProgress"
|
||||
:stroke-width="2"
|
||||
:percent="parsePercentage(file.percentage)"
|
||||
:status="file.status === 'finished' && file.showProgress ? 'success' : 'normal'"
|
||||
transition="fade"></Progress>
|
||||
@click.native="handleRemove(file)"></Icon>
|
||||
<transition name="fade">
|
||||
<Progress
|
||||
v-if="file.showProgress"
|
||||
:stroke-width="2"
|
||||
:percent="parsePercentage(file.percentage)"
|
||||
:status="file.status === 'finished' && file.showProgress ? 'success' : 'normal'"></Progress>
|
||||
</transition>
|
||||
</li>
|
||||
</ul>
|
||||
</template>
|
||||
|
@ -41,7 +42,6 @@
|
|||
prefixCls: prefixCls
|
||||
};
|
||||
},
|
||||
computed: {},
|
||||
methods: {
|
||||
fileCls (file) {
|
||||
return [
|
||||
|
|
|
@ -7,9 +7,9 @@
|
|||
@dragover.prevent="dragOver = true"
|
||||
@dragleave.prevent="dragOver = false">
|
||||
<input
|
||||
v-el:input
|
||||
:class="[prefixCls + '-input']"
|
||||
ref="input"
|
||||
type="file"
|
||||
:class="[prefixCls + '-input']"
|
||||
@change="handleChange"
|
||||
:multiple="multiple"
|
||||
:accept="accept">
|
||||
|
@ -154,7 +154,7 @@
|
|||
},
|
||||
methods: {
|
||||
handleClick () {
|
||||
this.$els.input.click();
|
||||
this.$refs.input.click();
|
||||
},
|
||||
handleChange (e) {
|
||||
const files = e.target.files;
|
||||
|
@ -163,7 +163,7 @@
|
|||
return;
|
||||
}
|
||||
this.uploadFiles(files);
|
||||
this.$els.input.value = null;
|
||||
this.$refs.input.value = null;
|
||||
},
|
||||
onDrop (e) {
|
||||
this.dragOver = false;
|
||||
|
@ -276,7 +276,8 @@
|
|||
_file.status = 'finished';
|
||||
_file.response = res;
|
||||
|
||||
this.$dispatch('on-form-change', _file);
|
||||
// todo 事件
|
||||
// this.$dispatch('on-form-change', _file);
|
||||
this.onSuccess(res, _file, this.fileList);
|
||||
|
||||
setTimeout(() => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue