Commit 02c7ed03 authored by renjintao's avatar renjintao

input

parent 0c62226b
<!--一次只能上传一个文件 -->
<template> <template>
<div> <div>
<div> <Input v-model="newName" style="height:28px;width:400px;float:left;margin-top:2px;">
<Input <Button slot="prepend" icon="ios-eye" title="查看" @click="downFile(newName)"></Button>
v-model="newName" </Input>
style="height:30px;width:240px;float:left;" <Upload
placeholder="请选择上传文件" v-model="name"
disabled :action="postUrl"
/> :on-success="uploadSuccess"
<Upload :on-error="uploadError"
v-model="name" :on-remove="removeFile"
:action="postUrl" :format="formatList"
:on-success="uploadSuccess" :max-size="maxSize"
:on-error="uploadError" :on-exceeded-size="onExceededSize"
:on-remove="removeFile" :on-format-error="onFormatError"
:format="formatList" :show-upload-list="false"
:max-size="maxSize" :files="files"
:on-exceeded-size="onExceededSize" :on-progress="onProgress"
:on-format-error="onFormatError" >
:show-upload-list="false" <Button icon="ios-cloud-upload-outline">上传文件</Button>
:files="files" </Upload>
:on-progress="onProgress"
style="width:120px;float:left"
>
<Button icon="ios-cloud-upload-outline">上传文件</Button>
</Upload>
<a v-show="newName.length>2&&showButton" :href="fileUrlPath" @click="downFile(newPath)" target="_blank" style="float:left">查看</a>
</div>
<Progress :percent="per" :stroke-width="5" v-show="vshowPro" /> <Progress :percent="per" :stroke-width="5" v-show="vshowPro" />
</div> </div>
</template> </template>
...@@ -52,7 +44,7 @@ export default { ...@@ -52,7 +44,7 @@ export default {
this.parms, this.parms,
formatList: ["png", "jpg", "gif"], formatList: ["png", "jpg", "gif"],
newName: "", newName: "",
newPath:'', newPath: "",
per: 0, per: 0,
vshowPro: false vshowPro: false
}; };
...@@ -72,9 +64,9 @@ export default { ...@@ -72,9 +64,9 @@ export default {
type: String, type: String,
default: "" default: ""
}, },
showButton:{ showButton: {
type:Boolean, type: Boolean,
default:true, default: true
} }
}, },
methods: { methods: {
...@@ -96,8 +88,8 @@ export default { ...@@ -96,8 +88,8 @@ export default {
objImag.fileName = file.response.data.fileName; objImag.fileName = file.response.data.fileName;
objImag.filePath = file.response.data.downloadPath; objImag.filePath = file.response.data.downloadPath;
filesList.push(objImag); filesList.push(objImag);
this.newName = file.response.data.fileName; this.newName = file.response.data.downloadPath;
this.newPath=file.response.data.downloadPath this.newPath = file.response.data.downloadPath;
this.$emit("on-change", JSON.stringify(filesList)); this.$emit("on-change", JSON.stringify(filesList));
this.per = 100; this.per = 100;
setTimeout(() => { setTimeout(() => {
...@@ -146,9 +138,20 @@ export default { ...@@ -146,9 +138,20 @@ export default {
} }
return this.formatList; return this.formatList;
}, },
downFile(path) { downFile(path) {
this.fileUrlPath = this.downUrl + path; let truePath = path.trim();
}, if (truePath.length > 2) {
if (
truePath.substring(0, 7).toLowerCase() == "http://" ||
truePath.substring(0, 8).toLowerCase() == "https://"
) {
window.open(truePath, "_blank");
} else {
this.fileUrlPath = this.downUrl + path;
window.open(this.fileUrlPath, "_blank");
}
}
}
}, },
mounted() { mounted() {
this.formatL(); this.formatL();
...@@ -166,5 +169,4 @@ export default { ...@@ -166,5 +169,4 @@ export default {
}; };
</script> </script>
<style lang="less"> <style lang="less">
</style> </style>
\ No newline at end of file
...@@ -126,7 +126,7 @@ export default { ...@@ -126,7 +126,7 @@ export default {
load(v) { load(v) {
Api.get({ id: v }).then(r => { Api.get({ id: v }).then(r => {
this.entity = r.result; this.entity = r.result;
this.$refs.inputfile.newName = this.entity.qualityTemplateName; this.$refs.inputfile.newName = this.entity.qualityTemplate;
this.$refs.inputfile.newPath = this.entity.qualityTemplate; this.$refs.inputfile.newPath = this.entity.qualityTemplate;
}); });
......
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