1、增加获取附件函数
computed: {
fileCount(){
//return this.fileList.length
return this.form.fileNum
},
...
}
2、Dialog 界面修改
<span v-if="crud.status.cu == 3&&fileCount>1" >
<el-row v-for="(cols, rx) in crud.getNewArray(fileList,1)" >
<el-col :span="24" v-for="(item, index) in cols" :key="item.storageId" >
<el-card style="padding :20px;margin:10px;" :body-style="{ padding: '5px' }"> <i class="el-icon-folder-opened"></i>
<span @click="filePreview(item)"><el-link href="#" >{{item.name}}</el-link></span><p/>
<span class="time">日期:{{ formatDate(item.createTime,'yyyy-MM-dd') }}</span> <span class="time">大小:{{item.size}}</span>
<span style="float: right"><el-button type="text" class="button el-icon--right" @click="filePreview(item)">点击查看</el-button></span>
</el-card>
</el-col>
</el-row>
</span>
<span v-else-if="crud.status.cu == 3&&fileCount == 1">
<span class="fontsize-ensurer">正在打开文件...</span>
</span>
<span v-else-if="crud.status.cu > 0">
...
</span>
...
<div slot="footer" class="dialog-footer" v-if="crud.status.cu !==3">
...
</div>
3、打开前Dialog事件函数修改
async initFileName() {
...
await getFileUuid(this.form.uuid).then(data => {
if (data.content.length > 0) {
this.fileList = data.content
this.form.fileNum = this.fileList.length
//附件数量为1,并且是查看事件,则直接打开pdf
if(this.crud.status.cu==3 &&this.form.fileNum === 1){
this.handlePreview(this.fileList[0])
this.crud.status.view = 0
}
}
})
},
4、文件上传判断
beforeUpload(file) {
if(!this.crud.allowUploadFile(file)){
this.loading = false
this.$message.error('不支持此文件类型!')
return false
}