Commit f466da55 by 前端

Merge branch 'wuwx-v1.13.0' into 'v1.13.0'

信息解析按钮

See merge request !54
2 parents fc0deba6 ff27c2c1
<template>
<div>
<glsx-dialog :show="showDialog" :title="!showResult?'批量操作':'提示'" width="560px" @close="closeDialog()">
<div>
<div class="upload_box" v-show="!showResult">
<div class="input_box">
<el-input v-model="uploadFile.name" placeholder="未选择任何文件..." class="a_input" size="small" readonly></el-input>
<el-upload ref="elUpload" :action="IMPORT_FAKEOFFLINE_FILES" :headers="uploadHeaders" :accept="acceptFile" :show-file-list="false" :auto-upload="false" :file-list="fileList" :on-change="onFileChange" :on-success="onSuccess">
<el-button size="small" type="primary">浏览</el-button>
</el-upload>
</div>
<div class="tips">*请选择需要导入的条件模板*</div>
<div>
<el-button type="primary" size="small" v-if="!showResult" @click="downloadTemplate()">SN号导入模板</el-button>
<el-button type="primary" size="small" v-if="!showResult" @click="downloadTemplate()">工单号导入模板</el-button>
<el-button type="primary" size="small" v-if="!showResult" @click="downloadTemplate()">车架号导入模板</el-button>
</div>
</div>
<div class="upload_result" v-show="showResult && !exportDialog">
<div class="cell">
<span class="num">{{uploadResult.succNum}}</span>
<span>成功记录</span>
</div>
<div class="cell">
<span class="num cred">{{uploadResult.failNum}}</span>
<span>失败记录</span>
</div>
</div>
<div class="upload_result" v-show="exportDialog">
<el-alert
type="warning"
description="请等待解析结果,解析完成后将自动为您下载,请勿关闭当前浏览器!"
:closable="false"
show-icon>
</el-alert>
</div>
</div>
<div slot="footer">
<div class="dialog_links">
<div>
<el-button type="primary" size="small" v-if="showResult && uploadResult.failFile" @click="downloadFail()">导出失败记录</el-button>
</div>
<div>
<el-button type="primary" size="small" :loading="aloading" :disabled="!uploadFile.name" v-if="!showResult" @click="saveFile()">确认</el-button>
<el-button type="default" size="small" @click="closeDialog()" v-if="!exportDialog">{{!showResult?'取消':'关闭'}}</el-button>
<el-button type="default" size="small" @click="closeDialog()" v-if="exportDialog"><i class="el-icon-loading" v-show="exportDialog"></i>完成</el-button>
</div>
</div>
</div>
</glsx-dialog>
</div>
</template>
<script>
import { IMPORT_FAKEOFFLINE_FILES } from "services/report";
import GlsxDialog from "@/components/dialog";
export default {
name:"informationDialog",
components: {
GlsxDialog
},
data() {
return {
showDialog: false,
showResult: false,
uploadFile: {},
IMPORT_FAKEOFFLINE_FILES,
acceptFile: ".xlsx,.xls",
fileList: [],
uploadResult: {},
aloading: false,
}
},
props: {
uploadHeaders: Object,
// 导出按钮互动参数
exportDialog: {
type: Boolean,
default: false
}
},
methods: {
openDialog() {
this.showDialog = true
},
// 监听文件导入
onFileChange(file, fileList) {
console.log(file);
if (!file.response) {
this.uploadFile = file;
this.fileList = [file];
}
},
// 监听文件上传成功
onSuccess(response, file, fileList) {
this.aloading = false;
if (response.code != 200) {
showToast({
message: response.message,
});
this.uploadFile = {};
this.$refs.elUpload.clearFiles();
return false;
}
this.uploadResult = response.data;
this.showResult = true;
// this.getList(); 刷新表格
this.$emit("successData", true)
},
// 确认上传文件
saveFile() {
let o = this.uploadFile;
console.log(o);
if (!this.uploadFile.name) {
showToast({
message: "请选择上传文件",
});
return false;
}
let list = o.name.split(".");
let acceptFile = this.acceptFile;
let _type = list[list.length - 1];
console.log(_type);
let idx = acceptFile.includes(_type);
if (!idx) {
showToast({
message: `导入文件只支持${acceptFile}`,
});
return false;
}
this.aloading = true;
this.$refs.elUpload.submit();
},
// 下载失败模板
downloadFail() {
let o = this.uploadResult;
window.open(o.failFile);
},
// 关闭弹框
closeDialog() {
this.showDialog = false;
this.uploadFile = {};
this.uploadResult = {};
this.showResult = false;
},
}
}
</script>
<style lang="scss" scoped>
@import "@/styles/offline.scss";
.upload_result ::v-deep.el-alert .el-alert__description {
margin: 0;
}
</style>
\ No newline at end of file
......@@ -4,6 +4,7 @@
<div class="page_head_title">
<h2 class="h2">运营统计报表</h2>
<h3 class="h3">通过车辆或设备纬度,统计系统内设备数据,并支持宽表输出</h3>
<!-- <el-button class="informationBtn" type="primary" size="mini" @click="informationClick">信息解析</el-button> -->
</div>
<el-tabs v-model="tabActive">
......@@ -14,7 +15,7 @@
<statistics-device></statistics-device>
</el-tab-pane>
</el-tabs>
<informationDialog ref="informationDialog" :uploadHeaders="uploadHeaders" @successData="successData" />
</div>
</template>
......@@ -22,22 +23,41 @@
import {} from "services/report";
import StatisticsCar from './statistics_car'
import StatisticsDevice from './statistics_device'
import informationDialog from './informationDialog'
export default {
components: {
StatisticsCar,
StatisticsDevice
StatisticsDevice,
informationDialog
},
data() {
return {
tabActive: "car",
uploadHeaders: {}
};
},
mounted() {},
methods: {},
mounted() {
let token = localStorage.getItem("token");
this.uploadHeaders = { Authorization: token };
},
methods: {
informationClick() {
this.$refs.informationDialog.openDialog()
// this.$refs.informationDialog.showResult = true
},
successData(val) {
console.log('val', val);
}
},
};
</script>
<style lang="scss" scoped>
@import "@/styles/common.scss";
.informationBtn {
position: absolute;
right: 24px;
z-index: 2;
}
</style>>
\ No newline at end of file
......@@ -77,7 +77,7 @@
</div>
</el-form-item>
</el-form>
<span v-if="tenantFlag">提示:每周五晚,系统自动恢复无线设备调频状态</span>
<span v-if="tenantFlag">* 提示:每周五晚,系统自动恢复无线设备调频状态</span>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm" :loading="loading" size="small">确认</el-button>
<el-button @click="$emit('onFreqModalChange', false)" size="small">取消</el-button>
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!