|
@@ -37,24 +37,15 @@
|
|
|
:on-exceed="handleExceed"
|
|
:on-exceed="handleExceed"
|
|
|
:before-upload="beforeUpload"
|
|
:before-upload="beforeUpload"
|
|
|
:file-list="fileList"
|
|
:file-list="fileList"
|
|
|
|
|
+ :auto-upload="false"
|
|
|
|
|
+ accept=".xls,.xlsx"
|
|
|
>
|
|
>
|
|
|
- <el-button slot="trigger" size="small" type="primary"
|
|
|
|
|
- >点击上传</el-button
|
|
|
|
|
|
|
+ <el-button style="width: 200px;" slot="trigger" size="small" type=""
|
|
|
|
|
+ >点击选择</el-button
|
|
|
>
|
|
>
|
|
|
- <!-- <div class="el-upload__text">
|
|
|
|
|
- <el-button
|
|
|
|
|
- type="primary"
|
|
|
|
|
- size="small"
|
|
|
|
|
- >点击选择</el-button
|
|
|
|
|
- >
|
|
|
|
|
-
|
|
|
|
|
- </div> -->
|
|
|
|
|
</el-upload>
|
|
</el-upload>
|
|
|
</el-form-item>
|
|
</el-form-item>
|
|
|
</el-form>
|
|
</el-form>
|
|
|
-
|
|
|
|
|
- <!-- 点击确定上传文件 -->
|
|
|
|
|
-
|
|
|
|
|
<template #footer>
|
|
<template #footer>
|
|
|
<div class="dialog-footer">
|
|
<div class="dialog-footer">
|
|
|
<el-button type="primary" @click="onSubmit" :loading="loading"
|
|
<el-button type="primary" @click="onSubmit" :loading="loading"
|
|
@@ -72,7 +63,7 @@ export default {
|
|
|
data() {
|
|
data() {
|
|
|
return {
|
|
return {
|
|
|
loading: false,
|
|
loading: false,
|
|
|
- fileList: [], //深拷贝,判断重名及第一步时的文件信息展示f
|
|
|
|
|
|
|
+ fileList: [],
|
|
|
form: {
|
|
form: {
|
|
|
compNm: "",
|
|
compNm: "",
|
|
|
fileInfo: undefined,
|
|
fileInfo: undefined,
|
|
@@ -81,6 +72,7 @@ export default {
|
|
|
compList: [],
|
|
compList: [],
|
|
|
};
|
|
};
|
|
|
},
|
|
},
|
|
|
|
|
+ props: ["parent"],
|
|
|
methods: {
|
|
methods: {
|
|
|
// 获取公司列表
|
|
// 获取公司列表
|
|
|
async getCompList() {
|
|
async getCompList() {
|
|
@@ -130,14 +122,12 @@ export default {
|
|
|
},
|
|
},
|
|
|
// 处理文件选择操作
|
|
// 处理文件选择操作
|
|
|
handleFileChange(file, fileList) {
|
|
handleFileChange(file, fileList) {
|
|
|
- console.log(file, "file");
|
|
|
|
|
this.form.fileInfo = file;
|
|
this.form.fileInfo = file;
|
|
|
},
|
|
},
|
|
|
// 处理文件上传操作
|
|
// 处理文件上传操作
|
|
|
handleFileUpload() {
|
|
handleFileUpload() {
|
|
|
- console.log(this.form.fileInfo, "sss");
|
|
|
|
|
const formData = new FormData();
|
|
const formData = new FormData();
|
|
|
- formData.append("file", this.form.fileInfo);
|
|
|
|
|
|
|
+ formData.append("file", this.form.fileInfo.raw);
|
|
|
formData.append("compNm", this.form.compNm);
|
|
formData.append("compNm", this.form.compNm);
|
|
|
this.loading = true;
|
|
this.loading = true;
|
|
|
// 调用后端服务器的接口
|
|
// 调用后端服务器的接口
|
|
@@ -150,9 +140,16 @@ export default {
|
|
|
data: formData,
|
|
data: formData,
|
|
|
})
|
|
})
|
|
|
.then((resp) => {
|
|
.then((resp) => {
|
|
|
- this.$message.success("文件上传成功");
|
|
|
|
|
- this.$refs.upload.clearFiles();
|
|
|
|
|
- this.cancel();
|
|
|
|
|
|
|
+ if (resp.data.code === 0) {
|
|
|
|
|
+ this.$message.success("文件上传成功");
|
|
|
|
|
+ this.$refs.upload.clearFiles();
|
|
|
|
|
+ // 上传成功后,刷新数据列表
|
|
|
|
|
+ this.parent.search();
|
|
|
|
|
+ this.cancel();
|
|
|
|
|
+ } else {
|
|
|
|
|
+ this.$message.error(resp.data.msg);
|
|
|
|
|
+ this.$refs.upload.clearFiles();
|
|
|
|
|
+ }
|
|
|
})
|
|
})
|
|
|
.catch((e) => {
|
|
.catch((e) => {
|
|
|
this.$message.error(e.message);
|
|
this.$message.error(e.message);
|
|
@@ -165,14 +162,11 @@ export default {
|
|
|
// 提交表单
|
|
// 提交表单
|
|
|
onSubmit() {
|
|
onSubmit() {
|
|
|
this.$refs.ruleForm.validate((valid) => {
|
|
this.$refs.ruleForm.validate((valid) => {
|
|
|
- if (valid) {
|
|
|
|
|
- if (this.form.fileInfo) {
|
|
|
|
|
- this.handleFileUpload();
|
|
|
|
|
- } else {
|
|
|
|
|
- this.$message.error("请选择文件");
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ if (!valid) return;
|
|
|
|
|
+ if (this.form.fileInfo) {
|
|
|
|
|
+ this.handleFileUpload();
|
|
|
} else {
|
|
} else {
|
|
|
- this.$message.error("请选择归属县旗");
|
|
|
|
|
|
|
+ this.$message.error("请选择文件");
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
},
|
|
},
|