优化导出

master
fanluyan 1 year ago
parent 00ef41ac2a
commit cbf3f163f5

@ -15,7 +15,7 @@
<h3 class="lableBox">装置列表</h3>
<el-input
type="textarea"
:rows="28"
:rows="22"
placeholder="请输入装置列表"
v-model="activityForm.cmdidArr"
@focus="textfocus"
@ -171,10 +171,11 @@ export default {
const columnData = this.termsData.map((row) => row[dataField]);
console.log(`当前列数据字段:${dataField}`);
console.log(`当前列数据值:${columnData}`);
this.copyToClipboard(columnData.join("\n"));
//this.copyToClipboard(columnData.join("\n"));
console.log(columnData);
this.activityForm.cmdidArr = columnData.join("\n");
this.activityForm.title = this.activityNameTitle;
this.termsShow = false;
},
copyToClipboard(text) {
const textArea = document.createElement("textarea");

@ -25,81 +25,132 @@
<el-table-column label="i1服务器">
<template slot-scope="scope">
{{ scope.row.raw_report.msgs.cma }}
<span v-if="scope.row.raw_report.hasOwnProperty('XyDev')">{{
scope.row.raw_report.cma
}}</span>
<span v-else>{{ scope.row.raw_report.msgs.cma }}</span>
</template>
</el-table-column>
<el-table-column label="心跳间隔" width="70">
<template slot-scope="scope">
{{ scope.row.raw_report.msgs.heartbeatDuration }}
<span v-if="scope.row.raw_report.hasOwnProperty('XyDev')">{{
scope.row.raw_report.heartbeatDuration
}}</span>
<span v-else>{{
scope.row.raw_report.msgs.heartbeatDuration
}}</span>
</template>
</el-table-column>
<el-table-column label="电池">
<template slot-scope="scope">
{{ scope.row.raw_report.msgs.battery }}
<span v-if="scope.row.raw_report.hasOwnProperty('XyDev')">{{
scope.row.raw_report.battary
}}</span>
<span v-else> {{ scope.row.raw_report.msgs.battery }}</span>
</template>
</el-table-column>
<el-table-column label="电池温度" width="70">
<template slot-scope="scope">
{{ scope.row.raw_report.msgs.batteryTmp }}
<span v-if="scope.row.raw_report.hasOwnProperty('XyDev')">{{
scope.row.raw_report.batteryTmp
}}</span>
<span v-else>{{ scope.row.raw_report.msgs.batteryTmp }}</span>
</template>
</el-table-column>
<el-table-column label="主板温度" width="70">
<template slot-scope="scope">
{{ scope.row.raw_report.msgs.mainBoardTmp }}
<span v-if="scope.row.raw_report.hasOwnProperty('XyDev')">{{
scope.row.raw_report.mainBoardTmp
}}</span>
<span v-else> {{ scope.row.raw_report.msgs.mainBoardTmp }}</span>
</template>
</el-table-column>
<el-table-column label="系统重启" width="70">
<template slot-scope="scope">
{{ scope.row.raw_report.msgs.rebootTimes }}
<span v-if="scope.row.raw_report.hasOwnProperty('XyDev')">{{
scope.row.raw_report.rebootTimes
}}</span>
<span v-else>{{ scope.row.raw_report.msgs.rebootTimes }}</span>
</template>
</el-table-column>
<el-table-column label="i1重启" width="70">
<template slot-scope="scope">
{{ scope.row.raw_report.msgs.i1RebootTimes }}
<span v-if="scope.row.raw_report.hasOwnProperty('XyDev')">{{
scope.row.raw_report.i1RebootTimes
}}</span>
<span v-else>{{ scope.row.raw_report.msgs.i1RebootTimes }}</span>
</template>
</el-table-column>
<el-table-column label="收" width="70">
<template slot-scope="scope">
{{ scope.row.raw_report.msgs.recv }}
<span v-if="scope.row.raw_report.hasOwnProperty('XyDev')">{{
scope.row.raw_report.recv
}}</span>
<span v-else> {{ scope.row.raw_report.msgs.recv }}</span>
</template>
</el-table-column>
<el-table-column label="传图" width="70">
<template slot-scope="scope">
{{ scope.row.raw_report.pic }}
<span v-if="scope.row.raw_report.hasOwnProperty('XyDev')">{{
scope.row.raw_report.pic
}}</span>
<span v-else> {{ scope.row.raw_report.pic }}</span>
</template>
</el-table-column>
<el-table-column label="拍" width="60">
<template slot-scope="scope">
{{ scope.row.raw_report.msgs.photoTimes }}
<span v-if="scope.row.raw_report.hasOwnProperty('XyDev')">{{
scope.row.raw_report.photoTimes
}}</span>
<span v-else> {{ scope.row.raw_report.msgs.photoTimes }}</span>
</template>
</el-table-column>
<el-table-column label="成/败/传" width="70">
<template slot-scope="scope">
{{ scope.row.raw_report.msgs.success }}/{{
scope.row.raw_report.msgs.failure
}}/{{ scope.row.raw_report.msgs.uploads }}
<span v-if="scope.row.raw_report.hasOwnProperty('XyDev')">
{{ scope.row.raw_report.success }}/{{
scope.row.raw_report.failure
}}/{{ scope.row.raw_report.uploads }}</span
>
<span v-else>
{{ scope.row.raw_report.msgs.success }}/{{
scope.row.raw_report.msgs.failure
}}/{{ scope.row.raw_report.msgs.uploads }}</span
>
</template>
</el-table-column>
<el-table-column label="心跳累计" width="80">
<template slot-scope="scope">
{{ scope.row.raw_report.msgs.numberOfHb }}
<span v-if="scope.row.raw_report.hasOwnProperty('XyDev')">{{
scope.row.raw_report.numberOfHb
}}</span>
<span v-else> {{ scope.row.raw_report.msgs.numberOfHb }}</span>
</template>
</el-table-column>
<el-table-column label="网络异常" width="80">
<template slot-scope="scope">
{{ scope.row.raw_report.msgs.networkError }}
<span v-if="scope.row.raw_report.hasOwnProperty('XyDev')">{{
scope.row.raw_report.networkError
}}</span>
<span v-else>{{ scope.row.raw_report.msgs.networkError }}</span>
</template>
</el-table-column>
<el-table-column label="信号1" width="60">
<template slot-scope="scope">
{{ scope.row.raw_report.msgs.signature1 }}
<span v-if="scope.row.raw_report.hasOwnProperty('XyDev')">{{
scope.row.raw_report.signature1
}}</span>
<span v-else>{{ scope.row.raw_report.msgs.signature1 }}</span>
</template>
</el-table-column>
<el-table-column label="信号2" width="60">
<template slot-scope="scope">
{{ scope.row.raw_report.msgs.signature2 }}
<span v-if="scope.row.raw_report.hasOwnProperty('XyDev')">{{
scope.row.raw_report.signature2
}}</span>
<span v-else> {{ scope.row.raw_report.msgs.signature2 }}</span>
</template>
</el-table-column>
<!-- <el-table-column label="其他">

@ -231,11 +231,14 @@
</u-table-column>
<u-table-column label="电池状态" width="138" key="dc" v-if="dccheck">
<template slot-scope="scope">
{{
<span v-if="scope.row.raw_report.hasOwnProperty('XyDev')">{{
scope.row.raw_report.battary
}}</span>
<span v-else>{{
scope.row.raw_report.hasOwnProperty("msgs")
? scope.row.raw_report.msgs.battery
: ""
}}
}}</span>
</template>
</u-table-column>
@ -247,29 +250,38 @@
:sort-method="sortnumberOfHb"
>
<template slot-scope="scope">
{{
<span v-if="scope.row.raw_report.hasOwnProperty('XyDev')">{{
scope.row.raw_report.numberOfHb
}}</span>
<span v-else>{{
scope.row.raw_report.msgs.hasOwnProperty("numberOfHb")
? Number(scope.row.raw_report.msgs.numberOfHb)
: ""
}}
}}</span>
</template>
</u-table-column>
<u-table-column label="周期" min-width="48">
<template slot-scope="scope">
{{
<span v-if="scope.row.raw_report.hasOwnProperty('XyDev')">{{
scope.row.raw_report.heartbeatDuration
}}</span>
<span v-else>{{
scope.row.raw_report.hasOwnProperty("msgs")
? scope.row.raw_report.msgs.heartbeatDuration
: ""
}}
}}</span>
</template>
</u-table-column>
<u-table-column label="CMA消息" min-width="60">
<template slot-scope="scope">
{{
<span v-if="scope.row.raw_report.hasOwnProperty('XyDev')">{{
scope.row.raw_report.recv
}}</span>
<span v-else>{{
scope.row.raw_report.hasOwnProperty("msgs")
? scope.row.raw_report.msgs.recv
: ""
}}
}}</span>
</template>
</u-table-column>
</u-table-column>
@ -277,11 +289,14 @@
<u-table-column label="拍照" v-if="pzcheck" key="pz">
<u-table-column label="计划/实际" min-width="60">
<template slot-scope="scope">
{{
<span v-if="scope.row.raw_report.hasOwnProperty('XyDev')">{{
scope.row.raw_report.photoTimes
}}</span>
<span v-else>{{
scope.row.raw_report.hasOwnProperty("msgs")
? scope.row.raw_report.msgs.photoTimes
: ""
}}
}}</span>
</template>
</u-table-column>
<u-table-column
@ -291,11 +306,14 @@
:sort-method="sortSuccess"
>
<template slot-scope="scope">
{{
<span v-if="scope.row.raw_report.hasOwnProperty('XyDev')">{{
scope.row.raw_report.success
}}</span>
<span v-else>{{
scope.row.raw_report.msgs.hasOwnProperty("success")
? Number(scope.row.raw_report.msgs.success)
: ""
}}
}}</span>
</template>
</u-table-column>
<u-table-column
@ -305,11 +323,14 @@
:sort-method="sortFailure"
>
<template slot-scope="scope">
{{
<span v-if="scope.row.raw_report.hasOwnProperty('XyDev')">{{
scope.row.raw_report.failure
}}</span>
<span v-else>{{
scope.row.raw_report.msgs.hasOwnProperty("failure")
? Number(scope.row.raw_report.msgs.failure)
: ""
}}
}}</span>
</template>
</u-table-column>
</u-table-column>
@ -333,18 +354,29 @@
</u-table-column>
<u-table-column label="卡2" min-width="60" prop="signature2">
<template slot-scope="scope">
<el-tooltip
class="item"
effect="dark"
:content="scope.row.raw_report.msgs.signature2"
placement="top"
<span v-if="scope.row.raw_report.hasOwnProperty('XyDev')">
<el-tooltip
class="item"
effect="dark"
:content="scope.row.raw_report.simcard2"
placement="top"
><span>{{ scope.row.raw_report.simcard2 }}</span></el-tooltip
></span
>
<span>{{
scope.row.raw_report.msgs.hasOwnProperty("signature2")
? scope.row.raw_report.msgs.signature2.split("/")[0]
: ""
}}</span>
</el-tooltip>
<span v-else>
<el-tooltip
class="item"
effect="dark"
:content="scope.row.raw_report.msgs.signature2"
placement="top"
>
<span>{{
scope.row.raw_report.msgs.hasOwnProperty("signature2")
? scope.row.raw_report.msgs.signature2.split("/")[0]
: ""
}}</span>
</el-tooltip>
</span>
<!-- {{
scope.row.raw_report.msgs.hasOwnProperty("signature2")
? scope.row.raw_report.msgs.signature2.split("/")[0]
@ -360,11 +392,14 @@
:sort-method="sortNumbersErr"
>
<template slot-scope="scope">
{{
<span v-if="scope.row.raw_report.hasOwnProperty('XyDev')">{{
scope.row.raw_report.networkError
}}</span>
<span v-else>{{
scope.row.raw_report.msgs.hasOwnProperty("networkError")
? Number(scope.row.raw_report.msgs.networkError)
: ""
}}
}}</span>
</template>
</u-table-column>
</u-table-column>
@ -378,11 +413,14 @@
:sort-method="sortNumbers"
>
<template slot-scope="scope">
{{
<span v-if="scope.row.raw_report.hasOwnProperty('XyDev')">{{
scope.row.raw_report.rebootTimes
}}</span>
<span v-else>{{
scope.row.raw_report.msgs.hasOwnProperty("rebootTimes")
? Number(scope.row.raw_report.msgs.rebootTimes)
: ""
}}
}}</span>
</template>
</u-table-column>
<u-table-column
@ -393,31 +431,44 @@
:sort-method="sortNumbers2"
>
<template slot-scope="scope">
{{
<span v-if="scope.row.raw_report.hasOwnProperty('XyDev')">{{
scope.row.raw_report.i1RebootTimes
}}</span>
<span v-else>{{
scope.row.raw_report.msgs.hasOwnProperty("i1RebootTimes")
? Number(scope.row.raw_report.msgs.i1RebootTimes)
: ""
}}
}}</span>
</template>
</u-table-column>
</u-table-column>
<u-table-column label="SIM卡" v-if="simcheck" min-width="160" key="sim">
<u-table-column label="卡1" width="158" prop="simcard1">
<template slot-scope="scope">
{{
scope.row.raw_report.msgs.hasOwnProperty("simcard1")
? scope.row.raw_report.msgs.simcard1
: ""
}}
<span v-if="scope.row.raw_report.hasOwnProperty('XyDev')">
{{ scope.row.raw_report.simcard1 }}</span
>
<span v-else>
{{
scope.row.raw_report.msgs.hasOwnProperty("simcard1")
? scope.row.raw_report.msgs.simcard1
: ""
}}</span
>
</template>
</u-table-column>
<u-table-column label="卡2" width="158" prop="simcard2">
<template slot-scope="scope">
{{
scope.row.raw_report.msgs.hasOwnProperty("simcard2")
? scope.row.raw_report.msgs.simcard2
: ""
}}
<span v-if="scope.row.raw_report.hasOwnProperty('XyDev')">
{{ scope.row.raw_report.simcard2 }}</span
>
<span v-else>
{{
scope.row.raw_report.msgs.hasOwnProperty("simcard2")
? scope.row.raw_report.msgs.simcard2
: ""
}}</span
>
</template>
</u-table-column>
</u-table-column>
@ -430,7 +481,10 @@
:sort-method="sortfreeNumbers"
>
<template slot-scope="scope">
<span>{{
<span v-if="scope.row.raw_report.hasOwnProperty('XyDev')">
{{ scope.row.raw_report.freeROM }}</span
>
<span v-else>{{
scope.row.raw_report.msgs.hasOwnProperty("freeROM")
? scope.row.raw_report.msgs.freeROM
: ""
@ -439,11 +493,14 @@
</u-table-column>
<u-table-column label="CMA服务器" v-if="cmacheck" width="160" key="cma">
<template slot-scope="scope">
{{
<span v-if="scope.row.raw_report.hasOwnProperty('XyDev')">
{{ scope.row.raw_report.cma }}</span
>
<span v-else>{{
scope.row.raw_report.hasOwnProperty("msgs")
? scope.row.raw_report.msgs.cma
: ""
}}
}}</span>
</template>
</u-table-column>
<u-table-column label="I1版本" v-if="i1check" min-width="160" key="I1">
@ -1133,8 +1190,89 @@ export default {
// ).length;
},
//
// handleExport() {
// htmlToExcel.getExcel("#ywTable", "");
// },
//
handleExport() {
htmlToExcel.getExcel("#ywTable", "设备运维信息");
// CSV
const headers = [
"出厂ID",
"装置编号",
"状态",
"最后心跳时间",
"传图",
"规约",
"电池状态",
"心跳次数",
"心跳周期",
"CMA消息",
"拍照计划/实际",
"拍照成功",
"拍照失败",
"卡1信号",
"卡2信号",
"网络错误",
"系统重启",
"I1重启",
"SIM卡1",
"SIM卡2",
"CMA服务器",
"磁盘剩余空间",
"I1版本",
"运维版本",
"camera版本",
"AI版本",
"MCU版本",
];
// CSV
let csvContent = headers.join(",") + "\n";
this.tableData.forEach((item) => {
const rawReport = item.raw_report;
const msgs = item.raw_report.msgs;
// raw_report
const rawReportData = [
item.oid,
item.cmdid,
this.nowTime - item.last_heartbeat_ts <= 720 ? "在线" : "离线",
item.last_heartbeat,
rawReport.pic || "",
this.protocolMap[item.protocol],
msgs.battery || "",
msgs.numberOfHb || "",
msgs.heartbeatDuration || "",
msgs.recv || "",
msgs.photoTimes || "",
msgs.success || "",
msgs.failure || "",
msgs.signature1 || "",
msgs.signature2 || "",
msgs.networkError || "",
msgs.rebootTimes || "",
msgs.i1RebootTimes || "",
msgs.simcard1 || "",
msgs.simcard2 || "",
msgs.freeROM || "",
msgs.cma || "",
msgs.i1Version || "",
msgs.maintainVersion || "",
msgs.cameraService || "",
msgs.aiVersion || "",
msgs.mcu || "",
];
// msgs
// CSV
csvContent += rawReportData.join(",") + "\n";
});
// Blob text/csv UTF-8
const blob = new Blob([csvContent], { type: "text/csv;charset=utf-8" });
// 使 FileSaver
saveAs(blob, "运维数据报表.csv");
},
// id,row-keykey
getRowKey(row) {
@ -1625,6 +1763,8 @@ export default {
return ` 0${minutes} : 0${seconds} `;
} else if (minutes < 10) {
return ` 0${minutes} : ${seconds} `;
} else if (seconds < 10) {
return ` ${minutes} : 0${seconds} `;
} else {
return ` ${minutes} : ${seconds} `;
}

Loading…
Cancel
Save