<template>
|
|
<CardBox
|
|
class="card-page"
|
|
:showTitle="false"
|
|
>
|
|
<div class="page-container">
|
|
<div class="table-card" ref="tableCardRef">
|
|
<el-table
|
|
v-loading="loading"
|
|
:data="dataList"
|
|
class="card-table"
|
|
ref="tableRef"
|
|
border
|
|
stripe
|
|
:height="tableHeight"
|
|
>
|
|
<el-table-column
|
|
label="序号"
|
|
type="index"
|
|
width="60"
|
|
align="center"
|
|
:index="table_index"
|
|
/>
|
|
<el-table-column label="区域" align="center" prop="areaName" />
|
|
<el-table-column label="点位" align="center" prop="pointName" />
|
|
<el-table-column label="采集时间" align="center" prop="patrolTime" />
|
|
<el-table-column label="缺陷照片" align="center">
|
|
<template slot-scope="scope">
|
|
<AsyncImage
|
|
v-if="scope.row.imgAnalyse"
|
|
class="table-img"
|
|
:src="scope.row.imgAnalyse"
|
|
@load="onImageLoad"
|
|
@click="lookImageDetail(scope.row.imgAnalyse)"
|
|
>
|
|
</AsyncImage>
|
|
<span v-else>--</span>
|
|
</template>
|
|
</el-table-column>
|
|
<el-table-column label="缺陷结果" align="center" prop="desc" />
|
|
</el-table>
|
|
<CardPagination
|
|
ref="paginationRef"
|
|
v-show="total > 0"
|
|
:total="total"
|
|
:page.sync="queryParams.pageNum"
|
|
:limit.sync="queryParams.pageSize"
|
|
@pagination="getList"
|
|
/>
|
|
</div>
|
|
</div>
|
|
<el-dialog
|
|
title="图片预览"
|
|
:visible.sync="showPreviewImages"
|
|
:close-on-click-modal="false"
|
|
:close-on-press-escape="false"
|
|
:destroy-on-close="true"
|
|
custom-class="card-dialog card-page"
|
|
width="70%"
|
|
append-to-body
|
|
>
|
|
<ImagePreview
|
|
v-if="showPreviewImages"
|
|
:imageUrls="showImgesUrls"
|
|
:selectImgPosition="previewImagePos"
|
|
:showTemperatureTool="false"
|
|
/>
|
|
</el-dialog>
|
|
</CardBox>
|
|
</template>
|
|
|
|
<script>
|
|
import CardBox from "../components/cardBox.vue";
|
|
import CardPagination from "../components/CardPagination/index.vue";
|
|
import { defectRecordList } from "@/api/videosMonitor/index";
|
|
import ImagePreview from "@/views/cards/components/ImagePreview/index.vue";
|
|
import AsyncImage from "@/components/AsyncImage/index.vue";
|
|
export default {
|
|
name: "DefectRecord",
|
|
components: { CardBox, CardPagination, ImagePreview, AsyncImage },
|
|
data() {
|
|
return {
|
|
queryParams: { pageNum: 1, pageSize: 20 },
|
|
dataList: [],
|
|
loading: false,
|
|
total: 0,
|
|
tableHeight: null,
|
|
addShow: false,
|
|
dialogTitle: "新建日常维护",
|
|
defaultProps: {
|
|
children: "children",
|
|
label: "label",
|
|
},
|
|
dateRange: [],
|
|
dateRangePickerOptions: {
|
|
disabledDate(selectDate) {
|
|
return new Date().getTime() < selectDate.getTime();
|
|
},
|
|
},
|
|
// 图片加载计数器
|
|
imageLoadCount: 0,
|
|
expectedImageCount: 0,
|
|
layoutRefreshTimer: null,
|
|
showPreviewImages: false,
|
|
showImgesUrls: [],
|
|
previewImagePos: 0,
|
|
};
|
|
},
|
|
created() {
|
|
this.getList();
|
|
window.addEventListener("resize", this.setTableHeight);
|
|
},
|
|
mounted() {
|
|
this.setTableHeight();
|
|
},
|
|
beforeDestroy() {
|
|
// 清理定时器
|
|
if (this.layoutRefreshTimer) {
|
|
clearTimeout(this.layoutRefreshTimer);
|
|
}
|
|
window.removeEventListener("resize", this.setTableHeight);
|
|
},
|
|
methods: {
|
|
setTableHeight() {
|
|
if (!this.$refs.tableCardRef) return;
|
|
const pagination = this.$refs.paginationRef;
|
|
const paginationHeight =
|
|
pagination && pagination.$el ? pagination.$el.offsetHeight : 0;
|
|
this.tableHeight = Math.max(
|
|
this.$refs.tableCardRef.clientHeight - paginationHeight,
|
|
160
|
|
);
|
|
},
|
|
// 序号计算
|
|
table_index(index) {
|
|
const { pageNum, pageSize } = this.queryParams;
|
|
return (pageNum - 1) * pageSize + index + 1;
|
|
},
|
|
|
|
handleQuery() {
|
|
this.queryParams.pageNum = 1;
|
|
this.getList();
|
|
},
|
|
|
|
linkUrl() {
|
|
this.addShow = true;
|
|
this.dialogTitle = "新建日常维护";
|
|
},
|
|
|
|
controlChange() {},
|
|
|
|
editClick() {
|
|
this.addShow = true;
|
|
this.dialogTitle = "编辑日常维护";
|
|
},
|
|
|
|
delClick() {},
|
|
|
|
// 图片加载完成回调
|
|
onImageLoad() {
|
|
this.imageLoadCount++;
|
|
// 当所有图片加载完成后刷新表格布局
|
|
if (
|
|
this.imageLoadCount === this.expectedImageCount &&
|
|
this.expectedImageCount > 0
|
|
) {
|
|
this.refreshTableLayout();
|
|
}
|
|
},
|
|
lookImageDetail(imgUrl) {
|
|
this.previewImagePos = 0;
|
|
this.showImgesUrls = [imgUrl];
|
|
this.showPreviewImages = true;
|
|
},
|
|
// 刷新表格布局
|
|
refreshTableLayout() {
|
|
this.$nextTick(() => {
|
|
if (this.layoutRefreshTimer) {
|
|
clearTimeout(this.layoutRefreshTimer);
|
|
}
|
|
// 延迟执行,确保DOM完全更新
|
|
this.layoutRefreshTimer = setTimeout(() => {
|
|
if (this.$refs.tableRef && this.$refs.tableRef.doLayout) {
|
|
this.$refs.tableRef.doLayout();
|
|
}
|
|
// 重置计数器
|
|
this.imageLoadCount = 0;
|
|
this.expectedImageCount = 0;
|
|
}, 50);
|
|
});
|
|
},
|
|
|
|
// 强制刷新表格(用于没有图片的情况)
|
|
forceRefreshTable() {
|
|
this.$nextTick(() => {
|
|
setTimeout(() => {
|
|
if (this.$refs.tableRef && this.$refs.tableRef.doLayout) {
|
|
this.$refs.tableRef.doLayout();
|
|
}
|
|
}, 100);
|
|
});
|
|
},
|
|
|
|
getList() {
|
|
this.loading = true;
|
|
// 重置图片计数器
|
|
this.imageLoadCount = 0;
|
|
this.expectedImageCount = 0;
|
|
|
|
const params = { ...this.queryParams };
|
|
if (this.dateRange && this.dateRange.length === 2) {
|
|
params.beginTime = this.dateRange[0];
|
|
params.endTime = this.dateRange[1];
|
|
}
|
|
|
|
defectRecordList(params)
|
|
.then((res) => {
|
|
this.dataList = res.rows || [];
|
|
this.total = res.total || 0;
|
|
this.$nextTick(this.setTableHeight);
|
|
|
|
// 计算需要加载的图片数量
|
|
this.expectedImageCount = this.dataList.filter(
|
|
(item) => item.imgAnalyse
|
|
).length;
|
|
|
|
// 如果没有图片需要加载,直接刷新表格
|
|
if (this.expectedImageCount === 0) {
|
|
this.forceRefreshTable();
|
|
}
|
|
})
|
|
.catch((error) => {
|
|
console.error("获取缺陷记录失败:", error);
|
|
this.dataList = [];
|
|
this.total = 0;
|
|
})
|
|
.finally(() => {
|
|
this.loading = false;
|
|
});
|
|
},
|
|
|
|
onSubmit() {
|
|
this.addShow = false;
|
|
},
|
|
},
|
|
};
|
|
</script>
|
|
|
|
<style lang="scss" scoped>
|
|
.page-container {
|
|
height: 100%;
|
|
display: flex;
|
|
flex-direction: column;
|
|
}
|
|
.card-page {
|
|
height: 100%;
|
|
min-height: 0;
|
|
overflow: hidden;
|
|
}
|
|
.fss {
|
|
font-size: 20px;
|
|
margin: 0 15px;
|
|
cursor: pointer;
|
|
}
|
|
.table-card {
|
|
flex: 1;
|
|
height: 0;
|
|
|
|
::v-deep .el-card__body {
|
|
height: 100%;
|
|
}
|
|
}
|
|
.tree-container {
|
|
display: flex;
|
|
}
|
|
.tree-box {
|
|
width: 45%;
|
|
}
|
|
|
|
// 给表格图片设置固定尺寸,避免高度变化过大
|
|
.table-img {
|
|
::v-deep img {
|
|
width: 80px;
|
|
height: 60px;
|
|
object-fit: cover;
|
|
display: block;
|
|
margin: 0 auto;
|
|
}
|
|
}
|
|
|
|
.card-page ::v-deep .el-table {
|
|
width: 100% !important;
|
|
color: #17345f;
|
|
background: transparent !important;
|
|
border-color: #6f9ed8 !important;
|
|
}
|
|
|
|
.card-page ::v-deep .el-table::before,
|
|
.card-page ::v-deep .el-table::after,
|
|
.card-page ::v-deep .el-table--border::after,
|
|
.card-page ::v-deep .el-table--group::after {
|
|
background-color: #6f9ed8 !important;
|
|
}
|
|
|
|
.card-page ::v-deep .el-table th.el-table__cell {
|
|
color: #ffffff !important;
|
|
background: #012773 !important;
|
|
border-color: #6f9ed8 !important;
|
|
}
|
|
|
|
.card-page ::v-deep .el-table th.el-table__cell .cell {
|
|
color: #ffffff !important;
|
|
}
|
|
|
|
.card-page ::v-deep .el-table__body-wrapper,
|
|
.card-page ::v-deep .el-table__empty-block,
|
|
.card-page ::v-deep .el-table__fixed,
|
|
.card-page ::v-deep .el-table__fixed-right {
|
|
background: #0f124a !important;
|
|
}
|
|
|
|
.card-page ::v-deep .el-table__empty-text {
|
|
color: #9fc4ee !important;
|
|
}
|
|
|
|
.card-page ::v-deep .el-table__body .el-table__row,
|
|
.card-page ::v-deep .el-table__body .el-table__row td.el-table__cell {
|
|
color: #17345f !important;
|
|
background: #edf4ff !important;
|
|
border-color: #a9c4e8 !important;
|
|
}
|
|
|
|
.card-page ::v-deep .el-table__body .el-table__row td.el-table__cell .cell,
|
|
.card-page ::v-deep .el-table__body .el-table__row td.el-table__cell .cell span {
|
|
color: #17345f !important;
|
|
}
|
|
|
|
.card-page ::v-deep .el-table__body .el-table__row--striped,
|
|
.card-page ::v-deep .el-table__body .el-table__row--striped td.el-table__cell {
|
|
background: #dce9fa !important;
|
|
}
|
|
|
|
.card-page ::v-deep .el-table__body tr:hover > td.el-table__cell {
|
|
background: #c8dcf5 !important;
|
|
}
|
|
</style>
|