重点代码:
let params = new FormData();
for (let key in this.params) {
params.append(key, this.params[key]);
}
完整版
// 检查文件上传
// 入参 file:当前上传的文件,fileList:所有被上传的文件列表
checkFilesChange(file, fileList) {
if (!this.checkForm.checkFiles.length) {
this.$refs.checkFormRef.clearValidate("checkFiles");
}
this.checkForm.checkFiles = fileList;
},
// 检查是否合格
// 入参 flag:"0"为点击了检查合格,"1"为点击了检查不合格
check(flag) {
this.$refs.checkFormRef.validate((valid) => {
if (valid) {
let params = new FormData();
for (let key in this.params) {
params.append(key, this.params[key]);
}
params.append("isQualified", flag);
params.append("remark", this.checkForm.checkRemark);
this.checkForm.checkFiles.forEach((item) => {
params.append("files", item.raw);
});
this.$axios.defaults.withCredentials = true;
this.$axios
.post(this.$zjyhPath + "//upload/checkup*****", params)
.then((res) => {
let code = res.data.code;
if (code === 200) {
this.checkDialogVisible = false;
this.$message.success("检查完成!");
this.reLoad();
}
})
.catch((error) => {
console.log(error);
});
}
});
},