<template>
|
<div class="tbl-container dialog-table"
|
v-loading="loading"
|
element-loading-text="拼命加载中"
|
element-loading-spinner="el-icon-loading"
|
element-loading-background="rgba(0, 0, 0, 0.2)">
|
<flex-layout no-bg>
|
<el-tabs type="border-card" name="resTabs" v-model="acTabs" class="flex-layout noborder">
|
<el-tab-pane name="line" label="曲线图">
|
<res-line-contrast :active="acTabs" :update-time="timeStamp" :list="tblData"></res-line-contrast>
|
</el-tab-pane>
|
<el-tab-pane name="tblData" label="数据表格">
|
<el-table :data="tblData" height="100%">
|
<el-table-column
|
v-for="item in tblHeader" :key="item.prop"
|
:label="item.label" :prop="item.prop"
|
align="center" :min-width="item.minWidth"></el-table-column>
|
<el-table-column
|
fixed="right"
|
label="操作"
|
width="120"
|
align="center">
|
<template slot-scope="scope">
|
<el-button @click="confirmUpdate(scope.row)" :type="scope.row.btnType" size="mini">{{ scope.row.isStandardText }}</el-button>
|
</template>
|
</el-table-column>
|
</el-table>
|
</el-tab-pane>
|
</el-tabs>
|
<div class="flex-page-footer" slot="footer">
|
<div class="el-pagination-btns">
|
<el-button type="primary" round size="mini" icon="el-icon-search" @click="searchData">查询</el-button>
|
<el-button type="primary" round size="mini" icon="el-icon-wallet" @click="ExportFile">导出</el-button>
|
</div>
|
</div>
|
</flex-layout>
|
</div>
|
</template>
|
|
<script>
|
import exportFile from '@/assets/js/tools/exportFile';
|
import ResLineContrast from "@/pages/dataTest/components/resLineContrast";
|
|
export default {
|
components: {ResLineContrast},
|
props: {
|
batt: {
|
type: Object,
|
default() {
|
return {}
|
}
|
},
|
},
|
data() {
|
return {
|
loading: false,
|
acTabs: "tblData",
|
timeStamp: 0,
|
tblHeader: [
|
{
|
label: '测试日期',
|
prop: 'time',
|
minWidth: 180
|
}
|
],
|
tblData: []
|
}
|
},
|
methods: {
|
historyResData(id) {
|
this.loading = true;
|
this.$apis.dataTest.history.historyResData(id).then(res=>{
|
let rs = JSON.parse(res.data.result);
|
this.loading = false;
|
let list = [];
|
if(rs.code == 1) {
|
let data = rs.data;
|
let time = "";
|
for(let i=0; i<data.length; i++) {
|
let item = data[i];
|
if(time == item.test_starttime) {
|
let tmp = list[list.length-1];
|
tmp.time = time;
|
tmp['mon'+item.mon_num] = item.mon_res;
|
tmp.data.push(item.mon_res);
|
}else {
|
time = item.test_starttime;
|
let tmp = {
|
data: []
|
};
|
tmp.time = time;
|
tmp['mon'+item.mon_num] = item.mon_res;
|
tmp.isStandard = item.isStandard;
|
tmp.isStandardText = tmp.isStandard?"标准内组值":"设置为标准";
|
tmp.btnType = tmp.isStandard?"primary":"success";
|
tmp.data.push(item.mon_res);
|
list.push(tmp);
|
}
|
}
|
}else {
|
this.$layer.msg(rs.msg);
|
}
|
this.tblData = list;
|
this.timeStamp = new Date().getTime();
|
}).catch(error=>{
|
this.loading = false;
|
console.log(error);
|
});
|
},
|
searchData() {
|
let batt = this.batt;
|
this.historyResData(batt.BattGroupId);
|
},
|
ExportFile() {
|
let batt = this.batt;
|
let text = batt.StationName+"-"+batt.BattGroupName+"-内阻信息";
|
exportFile(this.tblHeader, this.tblData, text);
|
},
|
confirmUpdate(data) {
|
this.$confirm('此操作将修改基础内阻值, 是否继续?', '提示', {
|
confirmButtonText: '确定',
|
cancelButtonText: '取消',
|
type: 'warning'
|
}).then(res=>{
|
this.updateStandardRes(data);
|
}).catch(error=>{});
|
},
|
// 更新标准内阻
|
updateStandardRes(data) {
|
let batt = this.batt;
|
let params = {
|
BattGroupId: batt.BattGroupId,
|
test_starttime: data.time
|
};
|
this.loading = true;
|
this.$apis.dataTest.history.updateStandardRes(params).then(res=>{
|
this.loading = false;
|
let rs = JSON.parse(res.data.result);
|
if(rs.code == 1) {
|
this.$layer.msg("设置成功!");
|
}else {
|
this.$layer.msg("设置失败!");
|
}
|
this.searchData();
|
}).catch(error=>{
|
this.$layer.msg("设置成功,请检测网络!");
|
this.loading = false;
|
});
|
}
|
},
|
mounted() {
|
let batt = this.batt;
|
let monCount = batt.MonCount?batt.MonCount:0;
|
for(let i=0; i<monCount; i++) {
|
let temp = {
|
label: '#'+(i+1),
|
prop: 'mon'+(i+1)+"1",
|
minWidth: 80
|
};
|
this.tblHeader.push(temp);
|
}
|
// 查询内容
|
this.searchData();
|
}
|
}
|
</script>
|
|
<style scoped>
|
.tbl-container {
|
height: 560px;
|
}
|
</style>
|