<tr style="height:200px">
<td style="text-align: center;color:#C00000">上传稿件</td>
<td colspan="8">
<el-upload
v-if="isNew8 "
ref="upload"
:action="getuploadurl()" //必选参数,上传的地址
drag //是否启用拖拽上传
limit="1" //最大允许上传个数
accept=".pdf, .doc, .docx" //接受上传的文件类型(thumbnail-mode 模式下此参数无效)
style="text-align:left"
:before-upload="beforeUpload" //上传文件之前的钩子,参数为上传的文件,若返回 false 或者返回 Promise 且被 reject,则停止上传。
:file-list="ruleForm.documentfilelist" //上传的文件列表, 例如: [{name: 'food.jpg', url: 'https://xxx.cdn.com/xxx.jpg'}]
:on-change="formalfileChange" //文件状态改变时的钩子,添加文件、上传成功和上传失败时都会被调用
>
<i class="el-icon-upload"></i>
<div class="el-upload__text">
将文件拖到此处,或
<em>点击上传</em>
</div>
<div class="el-upload__tip" slot="tip">只能上传1个pdf/word文件,且不超过5M</div>
</el-upload>
<div v-else>
<div v-for="(item, index) in ruleForm.documentfilelist" :key="index">
<el-tag
closable
@click.native="showDoc(item)"
style="cursor: pointer;"
:disable-transitions="false"
@close="formalClose"
>{{item.thename || item.name}}</el-tag>
</div>
</div>
</td>
</tr>
方法:
// 文件上传
getuploadurl() {
return (
"http://" +
util.getServerIP() +
"/Boflow/upload?busitype=incomingDocument"
);
},
beforeUpload: function(file) {
let FileExt = file.name.replace(/.+\./, "");
if (["pdf", "doc", "docx"].indexOf(FileExt.toLowerCase()) === -1) {
this.$alert("请上传后缀名为pdf、doc、docx的附件!", "提示");
return false;
}
formalfileChange: function(file, fileList) {
console.log(file);
this.ruleForm.documentfilelist = fileList.slice(-3);
this.ruleForm.documentfilelist.forEach(item => {
item.filetype = "1";
});
// console.log(this.form.formalfilelist)
},