默认判断文件类型

main
MY-SH\lenovo 12 months ago
parent 16e5c64ae0
commit 2a9053ef8b

@ -20,7 +20,7 @@
<div class="el-upload__tip" slot="tip" v-if="showTip"> <div class="el-upload__tip" slot="tip" v-if="showTip">
请上传 请上传
<template v-if="fileSize"> <b style="color: #f56c6c">{{ fileSize }}MB</b> </template> <template v-if="fileSize"> <b style="color: #f56c6c">{{ fileSize }}MB</b> </template>
<template v-if="fileType"> <b style="color: #f56c6c">{{ fileType.join("/") }}</b> </template> <template v-if="fileType && noFileType==false "> 格式为 <b style="color: #f56c6c">{{ fileType.join("/") }}</b> </template>
的文件 的文件
</div> </div>
</el-upload> </el-upload>
@ -66,6 +66,11 @@ export default {
isShowTip: { isShowTip: {
type: Boolean, type: Boolean,
default: true default: true
},
//
noFileType: {
type: Boolean,
default: false
} }
}, },
data() { data() {
@ -113,14 +118,17 @@ export default {
methods: { methods: {
// //
handleBeforeUpload(file) { handleBeforeUpload(file) {
// //
if (this.fileType) { if(!this.noFileType){
const fileName = file.name.split('.'); //
const fileExt = fileName[fileName.length - 1]; if (this.fileType) {
const isTypeOk = this.fileType.indexOf(fileExt) >= 0; const fileName = file.name.split('.');
if (!isTypeOk) { const fileExt = fileName[fileName.length - 1];
this.$modal.msgError(`文件格式不正确, 请上传${this.fileType.join("/")}格式文件!`); const isTypeOk = this.fileType.indexOf(fileExt) >= 0;
return false; if (!isTypeOk) {
this.$modal.msgError(`文件格式不正确, 请上传${this.fileType.join("/")}格式文件!`);
return false;
}
} }
} }
// //

@ -138,7 +138,7 @@
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label="上报模板" v-if="taskShow"> <el-form-item label="上报模板" v-if="taskShow">
<file-upload v-model="form.fileTempName" :fileType="['md']"/> <file-upload v-model="form.fileTempName" :noFileType="true" />
</el-form-item> </el-form-item>
<el-form-item label="内容"> <el-form-item label="内容">
<editor v-model="form.displayContent" :min-height="192"/> <editor v-model="form.displayContent" :min-height="192"/>
@ -157,11 +157,16 @@
</el-dialog> </el-dialog>
<!-- 上报企业统计 --> <!-- 上报企业统计 -->
<el-dialog :title="title" :visible.sync="openFile" width="500px" append-to-body> <el-dialog :title="title" :visible.sync="openFile" width="500px" append-to-body>
<el-table v-loading="loading" :data="ehsNoticeMessageFileList" @selection-change="handleSelectionChange" @cell-click="dload"> <el-table v-loading="loading" :data="ehsNoticeMessageFileList" @selection-change="handleSelectionChange">
<el-table-column label="部门名称" align="center" prop="deptName" /> <el-table-column label="部门名称" align="center" prop="deptName" />
<el-table-column label="上报情况" align="center" prop="originalName" > <el-table-column label="上报情况" align="center" prop="originalName" >
<template slot-scope="scope"> <template slot-scope="scope">
<span> {{scope.row.originalName==null?"未上报":scope.row.originalName}}</span> <span v-if="scope.row.originalName==null"></span>
<span v-else>
<el-tooltip class="item" effect="dark" content="点击下载文件" placement="right">
<el-link type="primary" @click="dload(scope.row)">{{scope.row.originalName}}</el-link>
</el-tooltip>
</span>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
@ -170,7 +175,7 @@
small small
:page.sync="pageNum" :page.sync="pageNum"
:limit.sync="pageSize" :limit.sync="pageSize"
@pagination="handleListFile" @pagination="diloagListFile"
:hide-on-single-page="true" :hide-on-single-page="true"
:total="total1"> :total="total1">
</el-pagination> </el-pagination>
@ -413,7 +418,7 @@ export default {
}, },
// //
handleListFile(row){ diloagListFile(row){
this.loading = true; this.loading = true;
this.openFile = true; this.openFile = true;
let data = { pageNum : this.pageNum, pageSize: this.pageSize, "noticeMessageId":row.noticeMessageId} let data = { pageNum : this.pageNum, pageSize: this.pageSize, "noticeMessageId":row.noticeMessageId}

Loading…
Cancel
Save