|
@@ -19,9 +19,7 @@
|
|
<!-- <el-table-column label="文件大小(kb)" align="center" prop="wSize" /> -->
|
|
<!-- <el-table-column label="文件大小(kb)" align="center" prop="wSize" /> -->
|
|
<el-table-column label="上传时间" align="center" prop="wUploadTime" width="180">
|
|
<el-table-column label="上传时间" align="center" prop="wUploadTime" width="180">
|
|
<template slot-scope="scope">
|
|
<template slot-scope="scope">
|
|
- <span>{{
|
|
|
|
- parseTime(scope.row.wUploadTime, "{y}-{m}-{d}")
|
|
|
|
- }}</span>
|
|
|
|
|
|
+ <span>{{ parseTime(scope.row.wUploadTime, "{y}-{m}-{d}") }}</span>
|
|
</template>
|
|
</template>
|
|
</el-table-column>
|
|
</el-table-column>
|
|
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
|
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
|
@@ -29,7 +27,6 @@
|
|
<a :href="scope.row.url" target="_blank">
|
|
<a :href="scope.row.url" target="_blank">
|
|
<el-button size="mini" type="text" icon="el-icon-download">下载</el-button>
|
|
<el-button size="mini" type="text" icon="el-icon-download">下载</el-button>
|
|
</a>
|
|
</a>
|
|
-
|
|
|
|
<el-button style="margin-left: 10px" size="mini" type="text" icon="el-icon-edit"
|
|
<el-button style="margin-left: 10px" size="mini" type="text" icon="el-icon-edit"
|
|
@click="handleUpdate(scope.row)">修改</el-button>
|
|
@click="handleUpdate(scope.row)">修改</el-button>
|
|
<el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)"
|
|
<el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)"
|
|
@@ -54,14 +51,16 @@
|
|
<el-input v-model="form.wSize" placeholder="请输入文件大小" />
|
|
<el-input v-model="form.wSize" placeholder="请输入文件大小" />
|
|
</el-form-item> -->
|
|
</el-form-item> -->
|
|
<el-form-item label="附件">
|
|
<el-form-item label="附件">
|
|
- <el-upload ref="upload" class="upload-demo" :limit="1" accept=".doc, .docx, .rar, .txt, .png, .jpg" multiple
|
|
|
|
|
|
+ <el-upload ref="upload" class="upload-demo" :limit="1" multiple
|
|
:action="upload.url" :data="upload" :on-change="changeFileLength" :headers="upload.headers"
|
|
:action="upload.url" :data="upload" :on-change="changeFileLength" :headers="upload.headers"
|
|
- :file-list="upload.fileList" :before-remove="beforeRemove" :on-progress="handleFileUploadProgress"
|
|
|
|
- :on-success="handleFileSuccess" :auto-upload="false">
|
|
|
|
|
|
+ :file-list="upload.fileList" :on-progress="handleFileUploadProgress"
|
|
|
|
+ :on-success="handleFileSuccess" :auto-upload="false" :before-upload="handleBeforeUpload">
|
|
<el-button slot="trigger" size="small" type="primary">选取文件</el-button>
|
|
<el-button slot="trigger" size="small" type="primary">选取文件</el-button>
|
|
- <div slot="tip" class="el-upload__tip">
|
|
|
|
- 只能上传.doc, .docx, .rar, .txt, .png,
|
|
|
|
- .jpg文件,且不超过500MB
|
|
|
|
|
|
+ <div class="el-upload__tip" slot="tip">
|
|
|
|
+ 请上传
|
|
|
|
+ <template v-if="fileSize"> 大小不超过 <b style="color: #f56c6c">{{ fileSize }}MB</b> </template>
|
|
|
|
+ <template v-if="fileType"> 格式为 <b style="color: #f56c6c">{{ fileType.join("/") }}</b> </template>
|
|
|
|
+ 的文件
|
|
</div>
|
|
</div>
|
|
</el-upload>
|
|
</el-upload>
|
|
</el-form-item>
|
|
</el-form-item>
|
|
@@ -151,6 +150,10 @@ export default {
|
|
uploadFiles: [],
|
|
uploadFiles: [],
|
|
// 收集——上传文件的个数
|
|
// 收集——上传文件的个数
|
|
filesLength: 0,
|
|
filesLength: 0,
|
|
|
|
+ // 大小限制(MB)
|
|
|
|
+ fileSize: 500,
|
|
|
|
+ // 文件类型, 例如['png', 'jpg', 'jpeg']
|
|
|
|
+ fileType: ["doc", "docx", "rar", "txt", "pdf"],
|
|
// 上传参数
|
|
// 上传参数
|
|
upload: {
|
|
upload: {
|
|
sid: this.$route.query.sid,
|
|
sid: this.$route.query.sid,
|
|
@@ -294,6 +297,33 @@ export default {
|
|
}
|
|
}
|
|
});
|
|
});
|
|
},
|
|
},
|
|
|
|
+ // 上传前校检格式和大小
|
|
|
|
+ handleBeforeUpload (file) {
|
|
|
|
+ if (file.name.indexOf('#') > -1) {
|
|
|
|
+ this.$modal.msgError(`上传文件名不得带有#等特殊字符`);
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+ // 校检文件类型
|
|
|
|
+ if (this.fileType) {
|
|
|
|
+ const fileName = file.name.split('.');
|
|
|
|
+ const fileExt = fileName[fileName.length - 1];
|
|
|
|
+ const isTypeOk = this.fileType.indexOf(fileExt) >= 0;
|
|
|
|
+ if (!isTypeOk) {
|
|
|
|
+ this.$modal.msgError(`文件格式不正确, 请上传${this.fileType.join("/")}格式文件!`);
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ // 校检文件大小
|
|
|
|
+ if (this.fileSize) {
|
|
|
|
+ const isLt = file.size / 1024 / 1024 < this.fileSize;
|
|
|
|
+ if (!isLt) {
|
|
|
|
+ this.$modal.msgError(`上传文件大小不能超过 ${this.fileSize} MB!`);
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return true;
|
|
|
|
+ },
|
|
// 文件提交处理
|
|
// 文件提交处理
|
|
submitUpload () {
|
|
submitUpload () {
|
|
this.$refs.upload.submit();
|
|
this.$refs.upload.submit();
|
|
@@ -341,10 +371,6 @@ export default {
|
|
}
|
|
}
|
|
this.upload.isUploading = false;
|
|
this.upload.isUploading = false;
|
|
},
|
|
},
|
|
- beforeRemove (file, fileList) {
|
|
|
|
- this.upload.fileList = [];
|
|
|
|
- return this.$confirm(`确定移除 ${file.name}?`);
|
|
|
|
- },
|
|
|
|
beforeUpload (file) {
|
|
beforeUpload (file) {
|
|
const isLt5M = file.size / 1024 / 1024 < 500;
|
|
const isLt5M = file.size / 1024 / 1024 < 500;
|
|
|
|
|