187 lines
7.7 KiB
Vue
187 lines
7.7 KiB
Vue
<template>
|
|
<div class="data-center-report-history">
|
|
<el-card>
|
|
<!-- 筛选栏 -->
|
|
<el-form :model="queryParams" ref="queryForm" :inline="true" size="mini" label-width="80px" @submit.native.prevent>
|
|
<el-form-item label="关键字" prop="keyword">
|
|
<el-input
|
|
v-model="queryParams.keyword"
|
|
placeholder="报告编号 / 设备名称"
|
|
clearable
|
|
style="width: 220px"
|
|
@keyup.enter.native="handleQuery"
|
|
/>
|
|
</el-form-item>
|
|
<el-form-item label="周期" prop="period">
|
|
<el-select v-model="queryParams.period" placeholder="全部" clearable style="width: 130px">
|
|
<el-option v-for="item in periodOptions" :key="item.value" :label="item.label" :value="item.value" />
|
|
</el-select>
|
|
</el-form-item>
|
|
<el-form-item label="状态" prop="status">
|
|
<el-select v-model="queryParams.status" placeholder="全部" clearable style="width: 130px">
|
|
<el-option v-for="item in statusOptions" :key="item.value" :label="item.label" :value="item.value" />
|
|
</el-select>
|
|
</el-form-item>
|
|
<el-form-item style="float: right">
|
|
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">查询</el-button>
|
|
<el-button icon="el-icon-refresh" size="mini" @click="handleResetQuery">重置</el-button>
|
|
</el-form-item>
|
|
</el-form>
|
|
|
|
<!-- 报表列表 -->
|
|
<el-table v-loading="loading" :data="reportList" style="width: 100%">
|
|
<el-table-column label="报告编号" prop="reportNo" min-width="220" show-overflow-tooltip />
|
|
<el-table-column label="设备名称" prop="deviceName" min-width="140" show-overflow-tooltip />
|
|
<el-table-column label="监测分类" min-width="110" align="center">
|
|
<template slot-scope="scope">{{ categoryText(scope.row.monitorCategoryCode) }}</template>
|
|
</el-table-column>
|
|
<el-table-column label="周期" min-width="90" align="center">
|
|
<template slot-scope="scope">{{ periodText(scope.row.period) }}</template>
|
|
</el-table-column>
|
|
<el-table-column label="时间范围" min-width="240" align="center">
|
|
<template slot-scope="scope">{{ scope.row.startTime }} ~ {{ scope.row.endTime }}</template>
|
|
</el-table-column>
|
|
<el-table-column label="生成时间" prop="createTime" width="160" align="center" />
|
|
<el-table-column label="过期时间" prop="expireTime" width="160" align="center" />
|
|
<el-table-column label="状态" min-width="90" align="center">
|
|
<template slot-scope="scope">
|
|
<el-tag :type="statusType(scope.row.status)" size="mini">{{ statusText(scope.row.status) }}</el-tag>
|
|
</template>
|
|
</el-table-column>
|
|
<el-table-column label="操作" width="100" align="center" fixed="right">
|
|
<template slot-scope="scope">
|
|
<el-button
|
|
type="success"
|
|
icon="el-icon-download"
|
|
size="mini"
|
|
:disabled="scope.row.status !== 'SUCCESS' || isExpired(scope.row)"
|
|
@click="handleDownload(scope.row)"
|
|
>下载</el-button>
|
|
</template>
|
|
</el-table-column>
|
|
</el-table>
|
|
|
|
<pagination
|
|
v-show="total > 0"
|
|
:total="total"
|
|
:page.sync="queryParams.pageNum"
|
|
:limit.sync="queryParams.pageSize"
|
|
@pagination="getList"
|
|
/>
|
|
</el-card>
|
|
</div>
|
|
</template>
|
|
|
|
<script>
|
|
import { saveAs } from 'file-saver';
|
|
import { listReportRecords, downloadReportRecord } from '@/api/iot/report';
|
|
import { blobValidate } from '@/utils/ruoyi';
|
|
|
|
export default {
|
|
name: 'ReportHistory',
|
|
data() {
|
|
return {
|
|
loading: false,
|
|
reportList: [],
|
|
total: 0,
|
|
queryParams: {
|
|
pageNum: 1,
|
|
pageSize: 10,
|
|
keyword: null,
|
|
period: null,
|
|
status: null,
|
|
},
|
|
periodOptions: [
|
|
{ value: 'DAY', label: '日报' },
|
|
{ value: 'WEEK', label: '周报' },
|
|
{ value: 'HALF_MONTH', label: '半月报' },
|
|
{ value: 'MONTH', label: '月报' },
|
|
{ value: 'CUSTOM', label: '自定义' },
|
|
],
|
|
statusOptions: [
|
|
{ value: 'CREATING', label: '生成中' },
|
|
{ value: 'SUCCESS', label: '成功' },
|
|
{ value: 'FAILED', label: '失败' },
|
|
],
|
|
};
|
|
},
|
|
mounted() {
|
|
this.getList();
|
|
},
|
|
methods: {
|
|
getList() {
|
|
this.loading = true;
|
|
listReportRecords(this.queryParams)
|
|
.then((res) => {
|
|
this.reportList = res.rows || [];
|
|
this.total = res.total || 0;
|
|
})
|
|
.finally(() => {
|
|
this.loading = false;
|
|
});
|
|
},
|
|
handleQuery() {
|
|
this.queryParams.pageNum = 1;
|
|
this.getList();
|
|
},
|
|
handleResetQuery() {
|
|
this.resetForm('queryForm');
|
|
this.handleQuery();
|
|
},
|
|
handleDownload(row) {
|
|
if (this.isExpired(row)) {
|
|
this.$message.warning('报告已过期');
|
|
return;
|
|
}
|
|
downloadReportRecord(row.reportNo)
|
|
.then(async (data) => {
|
|
const isBlob = await blobValidate(data);
|
|
if (isBlob) {
|
|
const blob = new Blob([data]);
|
|
saveAs(blob, row.fileName || row.reportNo + '.docx');
|
|
} else {
|
|
const resText = await data.text();
|
|
const rspObj = JSON.parse(resText);
|
|
this.$message.error((rspObj && rspObj.msg) || '下载失败');
|
|
}
|
|
})
|
|
.catch(() => {
|
|
this.$message.error('下载失败,请稍后重试');
|
|
});
|
|
},
|
|
isExpired(row) {
|
|
return !!row.expireTime && new Date(row.expireTime.replace(/-/g, '/')).getTime() < Date.now();
|
|
},
|
|
categoryText(code) {
|
|
const map = {
|
|
CRACK_METER: '裂缝计',
|
|
DEEP_DISPLACEMENT: '深部位移',
|
|
AXIAL_FORCE: '轴力/应力',
|
|
STATIC_LEVEL: '静力水准',
|
|
VIBRATING_WIRE: '振弦',
|
|
};
|
|
return map[code] || code || '-';
|
|
},
|
|
periodText(code) {
|
|
const item = this.periodOptions.find((i) => i.value === code);
|
|
return item ? item.label : code || '-';
|
|
},
|
|
statusText(code) {
|
|
const item = this.statusOptions.find((i) => i.value === code);
|
|
return item ? item.label : code || '-';
|
|
},
|
|
statusType(code) {
|
|
if (code === 'SUCCESS') return 'success';
|
|
if (code === 'FAILED') return 'danger';
|
|
return 'warning';
|
|
},
|
|
},
|
|
};
|
|
</script>
|
|
|
|
<style scoped>
|
|
.data-center-report-history .el-card {
|
|
min-height: calc(100vh - 110px);
|
|
}
|
|
</style>
|