Commit b6ba5a82 by 莫晓莉

热热热

parent 6ccf3f6a
...@@ -185,7 +185,7 @@ ...@@ -185,7 +185,7 @@
> >
<!-- <div class="eladmin-upload"><i class="el-icon-upload" /> 添加文件</div> --> <!-- <div class="eladmin-upload"><i class="el-icon-upload" /> 添加文件</div> -->
<el-button size="small" type="primary">点击上传</el-button> <el-button size="small" type="primary">点击上传</el-button>
<div slot="tip" class="el-upload__tip">可上传任意格式文件,且不超过100M</div> <div slot="tip" class="el-upload__tip">可上传任意格式文件,且不超过500M</div>
</el-upload> </el-upload>
</el-form-item> </el-form-item>
<el-form-item prop="name" label="作业名称:"> <el-form-item prop="name" label="作业名称:">
...@@ -554,7 +554,7 @@ export default { ...@@ -554,7 +554,7 @@ export default {
params.type=type; params.type=type;
this.$refs[formName].validate((valid) => { this.$refs[formName].validate((valid) => {
if (valid) { if (valid) {
if(type==2 && params.path==''){ if(type==2 && params.path==undefined){
this.$message.error("请上传一个文件!"); this.$message.error("请上传一个文件!");
return; return;
} }
...@@ -723,9 +723,56 @@ export default { ...@@ -723,9 +723,56 @@ export default {
}) })
}, },
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// acceptFile(e) {
// const allowHook = {
// video: '.mp4, .ogv, .ogg, .webm',
// audio: '.wav, .mp3, .ogg, .acc, .webm, .amr',
// file: 'doc,.docx,.xlsx,.xls,.pdf',
// excel: 'xlsx,.xls',
// img: '.jpg, .jpeg, .png, .gif'
// }
// if (e) {
// return allowHook[e];
// }
// let srt = null
// for (const k in allowHook) {
// srt += allowHook[k]
// }
// return srt
// },
beforeAvatarUpload(file) {
console.log('上传的文件===:',file);
// console.log('上传的文件类型===:',file.type);
// const isJPG = file.type === 'image/jpeg';
// const isLt2M = file.size / 1024 / 1024 < 500;
// if (!isJPG) {
// this.$message.error('上传头像图片只能是 JPG 格式!');
// }
// if (!isLt2M) {
// this.$message.error('上传头像图片大小不能超过 500MB!');
// }
// return isJPG && isLt2M;
var testmsg=file.name.substring(file.name.lastIndexOf('.')+1)
const extension = testmsg === 'xls'
const extension2 = testmsg === 'xlsx'
const isLt2M = file.size / 1024 / 1024 < 500
if(!extension && !extension2) {
this.$message.error('该文件类型不支持!');
}
if(!isLt2M) {
this.$message.error('上传文件大小不能超过 500MB!');
}
return extension || extension2 && isLt2M
},
// 上传资源文件成功 // 上传资源文件成功
uplodSuccess(response, file, fileList) { uplodSuccess(response, file, fileList) {
console.log(response, file, fileList); console.log(response, file, fileList);
if (response.success !== true) { if (response.success !== true) {
this.$message.error("上传失败!"); this.$message.error("上传失败!");
return; return;
...@@ -942,7 +989,6 @@ export default { ...@@ -942,7 +989,6 @@ export default {
// if (this.$refs['formNameOne']!==undefined) { // if (this.$refs['formNameOne']!==undefined) {
// this.$refs['formNameOne'].resetFields();//对该表单项进行重置,将其值重置为初始值并移除校验结果 // this.$refs['formNameOne'].resetFields();//对该表单项进行重置,将其值重置为初始值并移除校验结果
// } // }
// }, // },
......
...@@ -534,6 +534,10 @@ export default { ...@@ -534,6 +534,10 @@ export default {
this.$refs[formName].validate((valid) => { this.$refs[formName].validate((valid) => {
if (valid) { if (valid) {
// this.formOne.id=1; // this.formOne.id=1;
if(type==2 && params.path==undefined){
this.$message.error("请上传一个文件!");
return;
}
insert(params).then(res=>{ insert(params).then(res=>{
console.log('提交新增数据:',res); console.log('提交新增数据:',res);
if (res.success) { if (res.success) {
......
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