Commit 66f76808 authored by linhuandong's avatar linhuandong

上传控件列表可以修改文件名称

parent 8efa184c
{"1.4.13":"1.4","2.0.11":"2.0","2.1.0":"2.1","2.2.2":"2.2","2.3.9":"2.3","2.4.11":"2.4","2.5.4":"2.5","2.6.3":"2.6","2.7.2":"2.7","2.8.2":"2.8","2.9.2":"2.9","2.10.1":"2.10","2.11.1":"2.11","2.12.0":"2.12","2.13.2":"2.13","2.14.1":"2.14","2.15.7675":"2.15"} {"1.4.13":"1.4","2.0.11":"2.0","2.1.0":"2.1","2.2.2":"2.2","2.3.9":"2.3","2.4.11":"2.4","2.5.4":"2.5","2.6.3":"2.6","2.7.2":"2.7","2.8.2":"2.8","2.9.2":"2.9","2.10.1":"2.10","2.11.1":"2.11","2.12.0":"2.12","2.13.2":"2.13","2.14.1":"2.14","2.15.7678":"2.15"}
\ No newline at end of file \ No newline at end of file
{ {
"name": "element-ui", "name": "element-ui",
"version": "2.15.7675", "version": "2.15.7678",
"description": "A Component Library for Vue.js.", "description": "A Component Library for Vue.js.",
"main": "lib/element-ui.common.js", "main": "lib/element-ui.common.js",
"files": [ "files": [
......
...@@ -52,8 +52,9 @@ export default function upload(option) { ...@@ -52,8 +52,9 @@ export default function upload(option) {
formData.append(key, option.data[key]); formData.append(key, option.data[key]);
}); });
} }
formData.append('filename', option.filename);
formData.append(option.filename, option.file, option.file.name); formData.append(option.name, option.file, option.file.name);
xhr.onerror = function error(e) { xhr.onerror = function error(e) {
option.onError(e); option.onError(e);
......
...@@ -13,7 +13,6 @@ ...@@ -13,7 +13,6 @@
:class="['el-upload-list__item', 'is-' + file.status, focusing ? 'focusing' : '']" :class="['el-upload-list__item', 'is-' + file.status, focusing ? 'focusing' : '']"
:key="file.uid" :key="file.uid"
tabindex="0" tabindex="0"
@keydown.delete="!disabled && $emit('remove', file)"
@focus="focusing = true" @focus="focusing = true"
@blur="focusing = false" @blur="focusing = false"
@click="focusing = false" @click="focusing = false"
...@@ -24,8 +23,9 @@ ...@@ -24,8 +23,9 @@
v-if="file.status !== 'uploading' && ['picture-card', 'picture'].indexOf(listType) > -1" v-if="file.status !== 'uploading' && ['picture-card', 'picture'].indexOf(listType) > -1"
:src="file.url" alt="" :src="file.url" alt=""
> >
<a class="el-upload-list__item-name" @click="handleClick(file)"> <a @click="handleClick(file)">
<i class="el-icon-document"></i>{{file.name}} <i class="el-icon-document"></i>
<el-input v-model="file.name" @focus="inputFocus" @blur="inputBlur" style="display: inline-block;width: 80%;padding:10px 10px 0 0;"></el-input>
</a> </a>
<label class="el-upload-list__item-status-label"> <label class="el-upload-list__item-status-label">
<i :class="{ <i :class="{
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
}"></i> }"></i>
</label> </label>
<i class="el-icon-close" v-if="!disabled" @click="$emit('remove', file)"></i> <i class="el-icon-close" v-if="!disabled" @click="$emit('remove', file)"></i>
<i class="el-icon-close-tip" v-if="!disabled">{{ t('el.upload.deleteTip') }}</i> <!--因为close按钮只在li:focus的时候 display, li blur后就不存在了,所以键盘导航时永远无法 focus到 close按钮上--> <!-- <i class="el-icon-close-tip" v-if="!disabled">{{ t('el.upload.deleteTip') }}</i> 因为close按钮只在li:focus的时候 display, li blur后就不存在了,所以键盘导航时永远无法 focus到 close按钮上-->
<el-progress <el-progress
v-if="file.status === 'uploading'" v-if="file.status === 'uploading'"
:type="listType === 'picture-card' ? 'circle' : 'line'" :type="listType === 'picture-card' ? 'circle' : 'line'"
...@@ -74,7 +74,9 @@ ...@@ -74,7 +74,9 @@
data() { data() {
return { return {
focusing: false focusing: false,
tempValue: '',
orgValue: ''
}; };
}, },
components: { ElProgress }, components: { ElProgress },
...@@ -99,6 +101,20 @@ ...@@ -99,6 +101,20 @@
}, },
handleClick(file) { handleClick(file) {
this.handlePreview && this.handlePreview(file); this.handlePreview && this.handlePreview(file);
},
inputFocus(event) {
let val = event.target.value;
this.orgValue = val;
this.tempValue = val.substring(val.lastIndexOf('.'));
event.target.value = val.substring(0, val.lastIndexOf('.'));
},
inputBlur(event) {
if (event.target.value === '') {
event.target.value = this.orgValue;
return;
}
let val = event.target.value + this.tempValue;
event.target.value = val;
} }
} }
}; };
......
...@@ -85,7 +85,9 @@ export default { ...@@ -85,7 +85,9 @@ export default {
this.$refs.input.value = null; this.$refs.input.value = null;
if (!this.beforeUpload) { if (!this.beforeUpload) {
return this.post(rawFile); let file = this.fileList.find(o => o.uid === rawFile.uid);
let filename = file.name + rawFile.name.substring(rawFile.name.lastIndexOf('.'));
return this.post(rawFile, filename);
} }
const before = this.beforeUpload(rawFile); const before = this.beforeUpload(rawFile);
...@@ -132,14 +134,15 @@ export default { ...@@ -132,14 +134,15 @@ export default {
}); });
} }
}, },
post(rawFile) { post(rawFile, filename) {
const { uid } = rawFile; const { uid } = rawFile;
const options = { const options = {
headers: this.headers, headers: this.headers,
withCredentials: this.withCredentials, withCredentials: this.withCredentials,
file: rawFile, file: rawFile,
data: this.data, data: this.data,
filename: this.name, filename: filename,
name: this.name,
action: this.action, action: this.action,
onProgress: e => { onProgress: e => {
this.onProgress(e, rawFile); this.onProgress(e, rawFile);
......
...@@ -210,7 +210,7 @@ if (typeof window !== 'undefined' && window.Vue) { ...@@ -210,7 +210,7 @@ if (typeof window !== 'undefined' && window.Vue) {
} }
export default { export default {
version: '2.15.7675', version: '2.15.7678',
locale: locale.use, locale: locale.use,
i18n: locale.i18n, i18n: locale.i18n,
install, install,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment