Commit b7eb250b by 张杰

v1.5.0版本需求

1 parent 6ef9d21b
...@@ -4,10 +4,10 @@ ...@@ -4,10 +4,10 @@
<div class="choose_box"> <div class="choose_box">
<div class="upload_wrap"> <div class="upload_wrap">
<el-input placeholder="请选择需要导入的车辆表格" v-model="uploadFile.name" readonly> <el-input placeholder="请选择需要导入的车辆表格" v-model="uploadFile.name" readonly>
<el-button slot="append" @click="chooseFiles">选择文件</el-button> <el-button slot="append">选择文件</el-button>
</el-input> </el-input>
<!-- 隐藏上传文件按钮 开始 --> <!-- 隐藏上传文件按钮 开始 -->
<el-upload ref="uploadBox" class="upload_box" :auto-upload="false" :headers="uploadHead" :data="uploadParams" :action="uploadPath" multiple :limit="1" :show-file-list="false" :on-change="onChange" :on-success="onSuccess"> <el-upload ref="uploadBox" class="upload_box" :auto-upload="false" :headers="uploadHead" :accept="acceptFile" :data="uploadParams" :action="uploadPath" multiple :limit="1" :show-file-list="false" :on-change="onChange" :on-success="onSuccess" :before-upload="beforeUpload">
<el-button type="primary">点击上传</el-button> <el-button type="primary">点击上传</el-button>
</el-upload> </el-upload>
<!-- 隐藏上传文件按钮 end --> <!-- 隐藏上传文件按钮 end -->
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
</div> --> </div> -->
<!-- 导入结果 开始 --> <!-- 导入结果 开始 -->
<div class="upload_result"> <div class="upload_result" v-if="uploadResult && uploadResult.total">
<h2 class="title">导入结果</h2> <h2 class="title">导入结果</h2>
<div class="result_box"> <div class="result_box">
<div class="cell"> <div class="cell">
...@@ -48,7 +48,7 @@ import { ...@@ -48,7 +48,7 @@ import {
IMPORT_VEHICLE_TEMPLATE, IMPORT_VEHICLE_TEMPLATE,
DOWNLOAD_ASSIGNPERMIT_TEMPLATE_FILE, DOWNLOAD_ASSIGNPERMIT_TEMPLATE_FILE,
} from "@/services/user"; } from "@/services/user";
import { showToast,broadcast } from "@/utils/util"; import { showToast, broadcast } from "@/utils/util";
export default { export default {
name: "ImportVehicle", name: "ImportVehicle",
props: { props: {
...@@ -65,6 +65,7 @@ export default { ...@@ -65,6 +65,7 @@ export default {
uploadFile: {}, uploadFile: {},
uploadParams: {}, uploadParams: {},
uploadResult: {}, uploadResult: {},
acceptFile: ".xlsx,.xls",
}; };
}, },
mounted() { mounted() {
...@@ -76,15 +77,9 @@ export default { ...@@ -76,15 +77,9 @@ export default {
this.uploadParams = { receiverId: id }; this.uploadParams = { receiverId: id };
}, },
methods: { methods: {
// 选择文件
chooseFiles() {
console.log(this.$refs.uploadBox.$el);
this.$refs.uploadBox.$el.click();
},
// 监听文件选择 // 监听文件选择
onChange(file) { onChange(file) {
console.log(file); console.log("文件:", file);
this.uploadFile = file; this.uploadFile = file;
}, },
...@@ -94,10 +89,23 @@ export default { ...@@ -94,10 +89,23 @@ export default {
window.open(o.failFile); window.open(o.failFile);
}, },
// 文件上传前
beforeUpload() {
this.uploadResult = {};
},
// 监听文件上传成功 // 监听文件上传成功
onSuccess(response, file, fileList) { onSuccess(response, file, fileList) {
console.log(response); console.log(response);
let _this = this;
broadcast("cancel-loading"); broadcast("cancel-loading");
_this.$refs.uploadBox.clearFiles();
if (response.code != 200) {
showToast({
message: response.message,
});
return false;
}
this.uploadResult = response.data; this.uploadResult = response.data;
}, },
...@@ -108,7 +116,7 @@ export default { ...@@ -108,7 +116,7 @@ export default {
showToast({ showToast({
message: "请选择文件", message: "请选择文件",
}); });
console.log('7777777777777') console.log("7777777777777");
broadcast("cancel-loading"); broadcast("cancel-loading");
return false; return false;
} }
......
...@@ -400,13 +400,13 @@ export default { ...@@ -400,13 +400,13 @@ export default {
let txt = this.checkSearchText; let txt = this.checkSearchText;
let list = deepClone(this.checkList); let list = deepClone(this.checkList);
let result = list; let result = list;
if (txt) { //if (txt) {
result = list.filter((k) => { result = list.filter((k) => {
let isTrue = let isTrue =
(k.label || "").includes(txt) || (k.label1 || "").includes(txt); (k.label || "").includes(txt) || (k.label1 || "").includes(txt);
return isTrue; return isTrue;
}); });
} ///}
console.log(result); console.log(result);
return result; return result;
}, },
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!