961 lines
24 KiB
Vue
Raw Normal View History

2024-10-12 14:35:31 +08:00
<!--
* @Author: SunTao 328867980@qq.com
* @Date: 2024-10-11 15:14:16
* @LastEditors: SunTao 328867980@qq.com
* @LastEditTime: 2025-01-21 10:48:28
2024-10-12 14:35:31 +08:00
* @FilePath: \znxjxt-ui\src\views\xj\inspection\road-management\index.vue
* @Description: 巡检信息-路产管理
-->
<template>
<div class="app-container">
<!-- 搜索表单 -->
<el-form
:model="queryParams"
ref="queryForm"
size="small"
:inline="true"
label-width="100px"
>
<el-form-item label="道路名称" prop="segmentId">
2024-10-12 14:35:31 +08:00
<el-select
v-model="queryParams.segmentId"
2024-10-12 14:35:31 +08:00
placeholder="请选择道路名称"
filterable
2024-10-12 14:35:31 +08:00
clearable
>
<el-option
v-for="item in segmentList"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-select>
</el-form-item>
<el-form-item label="采集时间" prop="dateTime">
<el-date-picker
v-model="dateTime"
type="daterange"
start-placeholder="开始日期"
end-placeholder="结束日期"
format="yyyy-MM-dd"
value-format="yyyy-MM-dd"
clearable
/>
</el-form-item>
2024-11-04 10:38:06 +08:00
<el-form-item label="路产类型" prop="equipmentType">
2024-10-12 14:35:31 +08:00
<el-select
2024-11-04 10:38:06 +08:00
v-model="queryParams.equipmentType"
2024-10-12 14:35:31 +08:00
placeholder="请选择路产类型"
clearable
>
<el-option
v-for="item in roadType"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-select>
</el-form-item>
<el-form-item label="校验状态" prop="dataStatus">
<el-select
v-model="queryParams.dataStatus"
placeholder="请选择校验状态"
clearable
>
<el-option
v-for="item in verifyStatus"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-select>
</el-form-item>
<el-form-item label="上下行" prop="inspectDirection">
<el-select
v-model="queryParams.inspectDirection"
placeholder="请选择"
clearable
>
<el-option label="上行" value="0" />
<el-option label="下行" value="1" />
</el-select>
</el-form-item>
<el-form-item label="公里桩" prop="stakeRange">
<el-input
v-model="queryParams.stakeStart"
placeholder="起始公里桩"
style="width: 10rem"
clearable
/>
<span style="margin: 0 5px">-</span>
<el-input
v-model="queryParams.stakeEnd"
placeholder="终止公里桩"
style="width: 10rem"
clearable
/>
<el-tooltip
class="item"
effect="dark"
content="格式为K0000+000"
placement="top"
>
<i class="el-icon-info"></i>
</el-tooltip>
</el-form-item>
2024-11-25 15:40:46 +08:00
<el-form-item label="巡检任务" prop="taskId">
2024-10-12 14:35:31 +08:00
<el-select
2024-11-25 15:40:46 +08:00
v-model="queryParams.taskId"
2024-10-12 14:35:31 +08:00
placeholder="请选择巡检任务"
2024-11-25 15:40:46 +08:00
filterable
2024-10-12 14:35:31 +08:00
clearable
>
<el-option
2024-11-25 15:40:46 +08:00
v-for="item in taskList"
2024-10-12 14:35:31 +08:00
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-select>
</el-form-item>
<el-form-item label="路产状态" prop="state">
<el-select
v-model="queryParams.state"
placeholder="请选择路产状态"
clearable
>
<el-option
v-for="item in defectStatus"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-select>
</el-form-item>
<el-form-item label="路产id" prop="id">
<el-input
v-model="queryParams.id"
placeholder="请填写路产id"
clearable=""
></el-input>
</el-form-item>
<el-form-item>
<el-button
type="primary"
icon="el-icon-search"
size="mini"
@click="handleQuery"
>搜索</el-button
>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
>重置</el-button
>
</el-form-item>
</el-form>
<!-- 操作按钮 -->
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button
type="primary"
plain
icon="el-icon-plus"
size="mini"
@click="handleAdd"
2025-01-15 17:01:25 +08:00
v-hasPermi="['xj_equipment_edit']"
2024-10-12 14:35:31 +08:00
>新增
</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="danger"
plain
icon="el-icon-delete"
size="mini"
:disabled="multiple"
2024-10-16 09:39:01 +08:00
@click="handleDelete(null)"
2025-01-15 17:01:25 +08:00
v-hasPermi="['xj_equipment_edit']"
2024-10-12 14:35:31 +08:00
>删除
</el-button>
</el-col>
2025-01-15 17:01:25 +08:00
<el-col :span="1.5">
<el-button
type="success"
plain
icon="el-icon-top-right"
size="mini"
@click="handleExport"
>导出
</el-button>
</el-col>
2024-10-12 14:35:31 +08:00
</el-row>
<!-- 列表 -->
<el-table
ref="roadTable"
v-loading="loading"
:data="roadList"
@selection-change="handleSelectionChange"
style="width: 100%"
>
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="道路名称" align="center" prop="segmentName" />
<el-table-column label="采集时间" align="center" prop="createdTime">
<template slot-scope="scope">
<span>{{ new Date(scope.row.createdTime).toLocaleString() }}</span>
</template>
</el-table-column>
<el-table-column label="路产类型" align="center" prop="equipmentType">
<template slot-scope="scope">
<span>{{ filterDefect(scope.row.equipmentType) }}</span>
</template>
</el-table-column>
<el-table-column label="路产状态" align="center" prop="state">
<template slot-scope="scope">
<span>{{ filterState(scope.row.state) }}</span>
</template>
</el-table-column>
2024-10-12 17:25:56 +08:00
<el-table-column label="校验状态" align="center" prop="dataStatus">
<template slot-scope="scope">
<span>{{
scope.row.dataStatus
? scope.row.dataStatus === 1
? "未校验"
: "已校验"
: ""
}}</span>
</template>
</el-table-column>
2024-10-12 14:35:31 +08:00
<el-table-column label="开始桩号" align="center" prop="stakeStart" />
<el-table-column label="结束桩号" align="center" prop="stakeEnd" />
2024-10-12 17:25:56 +08:00
<el-table-column label="路产图片" align="center" prop="media">
2024-10-12 14:35:31 +08:00
<template slot-scope="scope">
2024-11-04 10:38:06 +08:00
<img
@click="showScreenImg(scope.row)"
height="50"
:src="scope.row.mediaUrl"
2024-10-25 17:29:08 +08:00
/>
2024-10-12 14:35:31 +08:00
</template>
</el-table-column>
2024-11-25 15:40:46 +08:00
<el-table-column label="巡检任务" align="center" prop="taskId" />
2024-10-12 14:35:31 +08:00
<!-- <el-table-column label="校验状态" align="center" prop="datastatus">
<template slot-scope="scope">
<span>{{ scope.row.datastatus === "1" ? "未校验" : "已校验" }}</span>
</template>
</el-table-column> -->
<el-table-column label="道路方向" align="center" prop="inspectDirection">
<template slot-scope="scope">
<span>{{
scope.row.inspectDirection === "0" ? "上行" : "下行"
}}</span>
</template>
</el-table-column>
<el-table-column label="路产id" align="center" prop="id" />
<el-table-column
label="操作"
align="center"
class-name="small-padding fixed-width"
>
<template slot-scope="scope">
<el-button
size="mini"
type="text"
icon="el-icon-view"
2024-10-12 14:35:31 +08:00
@click="viewDefect(scope.row)"
>查看
</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-edit"
@click="handleUpdate(scope.row)"
2025-01-15 17:01:25 +08:00
v-hasPermi="['xj_equipment_edit']"
2024-10-12 14:35:31 +08:00
>修改
</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="handleDelete(scope.row)"
2025-01-15 17:01:25 +08:00
v-hasPermi="['xj_equipment_edit']"
2024-10-12 14:35:31 +08:00
>删除
</el-button>
</template>
</el-table-column>
</el-table>
<!-- 分页组件 -->
<div class="pagination-part">
<el-pagination
background
2024-10-12 17:25:56 +08:00
:current-page.sync="pagination.page"
2024-10-12 14:35:31 +08:00
@current-change="handleCurrentChange"
:page-sizes="[10, 20, 30, 40]"
2024-10-12 17:25:56 +08:00
:page-size.sync="pagination.size"
2024-10-12 14:35:31 +08:00
@size-change="handleSizeChange"
layout="total, sizes, prev, pager, next, jumper"
:total="tableTotal"
>
</el-pagination>
</div>
<!-- 新增/编辑弹窗 -->
<el-dialog
:title="addTitle"
:visible.sync="addVisible"
width="60rem"
append-to-body
:close-on-click-modal="false"
destroy-on-close
@close="addCancel"
>
<road-add
2024-11-21 15:38:45 +08:00
v-if="addVisible"
2024-10-12 14:35:31 +08:00
@cancel="addCancel"
:dialogItem="dialogItem"
:segmentList="segmentList"
:roadType="roadType"
:defectStatus="defectStatus"
></road-add>
</el-dialog>
<!-- 查看弹窗 -->
<el-dialog
title="查看路产"
:visible.sync="viewVisible"
width="55rem"
append-to-body
:close-on-click-modal="false"
destroy-on-close
@close="viewCancel"
>
<road-view
2024-11-21 15:38:45 +08:00
v-if="viewVisible"
2024-10-12 14:35:31 +08:00
@cancel="viewCancel"
:dialogItem="dialogItem"
:roadType="roadType"
></road-view>
</el-dialog>
2024-11-04 10:38:06 +08:00
<!-- 查看图片大图 -->
<el-dialog
title="查看图片"
:visible.sync="showImageDialog"
width="85rem"
2024-11-04 10:38:06 +08:00
append-to-body
destroy-on-close
@close="imgCancel"
>
<div class="image-container" ref="imageContainer">
<img
:src="currentImageItem.mediaUrl"
alt="Main Image"
ref="mainImage"
@load="updateRects"
/>
<div
v-for="(rect, index) in rects"
:key="index"
class="rect-overlay"
:style="getRectStyle(rect)"
></div>
<div class="rect-image">
采集时间:
{{ new Date(currentImageItem.createdTime).toLocaleString() }}
起始桩号 {{ currentImageItem.stakeStart || "暂无数据" }} 终止桩号
{{ currentImageItem.stakeEnd || "暂无数据" }}
路产类型
{{ filterDefect(currentImageItem.equipmentType) || "暂无数据" }}
</div>
2024-11-04 10:38:06 +08:00
</div>
</el-dialog>
2024-10-12 14:35:31 +08:00
</div>
</template>
2024-10-12 14:35:31 +08:00
<script>
import {
getRoadTable,
getSegment,
getRoadType,
getDefectStatus,
deleteRoad,
changeRoad,
2024-11-25 15:40:46 +08:00
getTaskList,
2025-01-15 17:01:25 +08:00
exportRoadData,
2024-10-12 14:35:31 +08:00
} from "@/api/xj/road";
2025-01-15 17:01:25 +08:00
import { Loading } from "element-ui";
2024-10-12 14:35:31 +08:00
import RoadAdd from "./components/road-add.vue";
import RoadView from "./components/road-view.vue";
export default {
components: { RoadAdd, RoadView },
data() {
return {
// 查询表单
queryParams: {
// 道路名称
segmentId: "",
2024-10-12 14:35:31 +08:00
// 路产类型
2024-11-04 10:38:06 +08:00
equipmentType: "",
2024-10-12 14:35:31 +08:00
// 校验状态
dataStatus: "",
// 巡检任务
2024-11-25 15:40:46 +08:00
taskId: "",
2024-10-12 14:35:31 +08:00
// 公里桩
stakeStart: "",
stakeEnd: "",
// 上下行
inspectDirection: "",
// 路产状态
state: "",
// 路产id
id: "",
},
// 采集时间
dateTime: [],
// 传查询接口表单
searchForm: {},
// 道路名称下拉
segmentList: [],
// 路产类型下拉
roadType: [],
// 路产状态下拉
defectStatus: [],
// 校验状态下拉
verifyStatus: [
{ label: "未校验", value: "1" },
{ label: "已校验", value: "2" },
],
// 列表数据绑定
roadList: [],
2024-11-25 15:40:46 +08:00
// 巡检任务下拉数据
taskList: [],
2024-10-12 14:35:31 +08:00
// 列表加载状态
loading: false,
// 列表已选数组
checkIds: [],
// 非单个禁用
single: true,
// 非多个禁用
multiple: true,
// 分页-列表总数
tableTotal: 0,
// 分页-页数页码
pagination: {
2024-10-12 17:25:56 +08:00
page: 1,
size: 10,
2024-10-12 14:35:31 +08:00
},
// 传弹窗的数据
dialogItem: {},
// 弹窗标题
addTitle: "添加路产",
// 新增/编辑弹窗显隐控制
addVisible: false,
// 查看弹窗显隐控制
viewVisible: false,
2024-11-04 10:38:06 +08:00
// 查看图片大图弹窗显隐控制
showImageDialog: false,
// 查看大图片路径
currentImageItem: "",
// 图片病害位置信息
rects: [],
2024-10-12 14:35:31 +08:00
};
},
created() {
this.getRoadList();
this.getSegmentList();
this.getRoadTypeList();
this.getDefectStatusList();
2024-11-25 15:40:46 +08:00
this.getTaskSelectList();
2024-10-12 14:35:31 +08:00
},
methods: {
2024-11-27 10:56:33 +08:00
/**
* @description: 获取道路名称下拉数据
* @param {*}
* @return {*}
*/
2024-10-12 14:35:31 +08:00
getSegmentList() {
getSegment().then(({ code, data }) => {
if (code === 200) {
this.segmentList = data;
}
});
},
2024-11-27 10:56:33 +08:00
/**
* @description: 获取路产类型下拉数据
* @param {*}
* @return {*}
*/
2024-10-12 14:35:31 +08:00
getRoadTypeList() {
getRoadType().then(({ code, data }) => {
if (code === 200) {
this.roadType = data;
}
});
},
2024-11-04 10:38:06 +08:00
2024-11-27 10:56:33 +08:00
/**
* @description: 获取路产状态下拉数据
* @param {*}
* @return {*}
*/
2024-10-12 14:35:31 +08:00
getDefectStatusList() {
getDefectStatus().then(({ data, code }) => {
if (code === 200) {
this.defectStatus = data;
}
});
},
2024-11-04 10:38:06 +08:00
2024-11-27 10:56:33 +08:00
/**
* @description: 获取巡检任务下拉数据
* @param {*}
* @return {*}
*/
2024-11-25 15:40:46 +08:00
getTaskSelectList() {
getTaskList().then(({ data, code }) => {
if (code === 200) {
this.taskList = data;
}
});
},
2024-11-27 10:56:33 +08:00
/**
* @description: 点击搜索事件
* @param {*}
* @return {*}
*/
2024-10-12 14:35:31 +08:00
handleQuery() {
const phonereg = /^K\d{4}\+\d{3}$/;
if (this.queryParams.stakeStart) {
if (phonereg.test(this.queryParams.stakeStart)) {
2024-10-12 17:25:56 +08:00
this.pagination.page = 1;
this.searchForm = JSON.parse(JSON.stringify(this.queryParams));
2024-10-12 14:35:31 +08:00
this.getRoadList();
} else {
this.$modal.msgWarning("请按照格式填写公里桩进行修改");
}
} else if (this.queryParams.stakeEnd) {
if (phonereg.test(this.queryParams.stakeEnd)) {
2024-10-12 17:25:56 +08:00
this.pagination.page = 1;
this.searchForm = JSON.parse(JSON.stringify(this.queryParams));
2024-10-12 14:35:31 +08:00
this.getRoadList();
} else {
this.$modal.msgWarning("请按照格式填写公里桩进行修改");
}
} else {
2024-10-12 17:25:56 +08:00
this.pagination.page = 1;
2024-10-12 14:35:31 +08:00
this.searchForm = JSON.parse(JSON.stringify(this.queryParams));
this.getRoadList();
}
},
2024-11-04 10:38:06 +08:00
2024-11-27 10:56:33 +08:00
/**
* @description: 点击重置事件
* @param {*}
* @return {*}
*/
2024-10-12 14:35:31 +08:00
resetQuery() {
this.searchForm = {};
2024-11-04 10:38:06 +08:00
this.queryParams = {
segmentId: "",
2024-11-04 10:38:06 +08:00
equipmentType: "",
2024-10-12 14:35:31 +08:00
dataStatus: "",
inspectDirection: "",
2024-11-25 15:40:46 +08:00
taskId: "",
2024-10-12 14:35:31 +08:00
stakeStart: "",
stakeEnd: "",
state: "",
id: "",
};
this.dateTime = [];
this.getRoadList();
},
2024-11-04 10:38:06 +08:00
2024-11-27 10:56:33 +08:00
/**
* @description: 获取列表数据
* @param {*}
* @return {*}
*/
2024-10-12 14:35:31 +08:00
getRoadList() {
const params = {
...this.pagination,
...this.searchForm,
startTime: this.dateTime ? this.dateTime[0] : "",
endTime: this.dateTime ? this.dateTime[1] : "",
};
getRoadTable(params).then(({ code, rows, total }) => {
if (code === 200) {
this.roadList = rows;
this.tableTotal = total;
}
});
},
2024-11-04 10:38:06 +08:00
2024-11-27 10:56:33 +08:00
/**
* @description: 过滤列表路产类型
* @param {*} value
* @return {*}
*/
2024-10-12 14:35:31 +08:00
filterDefect(value) {
let a = null;
[a] = this.roadType.filter((item) => {
return item.value === value;
});
if (a) {
return a.label;
}
},
2024-11-04 10:38:06 +08:00
2024-11-27 10:56:33 +08:00
/**
* @description: 过滤路产状态
* @param {*} value
* @return {*}
*/
2024-10-12 14:35:31 +08:00
filterState(value) {
let a = null;
[a] = this.defectStatus.filter((item) => {
return item.value === value;
});
if (a) {
return a.label;
}
},
2024-11-04 10:38:06 +08:00
2024-11-27 10:56:33 +08:00
/**
* @description: 点击新增事件
* @param {*}
* @return {*}
*/
2024-10-12 14:35:31 +08:00
handleAdd() {
this.addVisible = true;
2024-10-25 17:29:08 +08:00
this.addTitle = "添加路产";
2024-10-12 14:35:31 +08:00
this.dialogItem = {
title: "添加路产",
};
},
2024-11-04 10:38:06 +08:00
2024-11-27 10:56:33 +08:00
/**
* @description: 点击删除事件
* @param {*} row
* @return {*}
*/
2024-10-12 14:35:31 +08:00
handleDelete(row) {
const checkIds = row ? [row.snapshotId] : this.checkIds;
2024-10-12 14:35:31 +08:00
if (!checkIds.length) {
this.$modal.msgWarning("请选择要删除的记录");
return;
}
this.$modal
.confirm(`是否确认删除选中的${checkIds.length}条记录?`)
.then(() => {
return deleteRoad(checkIds);
})
.then(() => {
2025-01-15 15:09:36 +08:00
this.$modal.msgSuccess("删除成功");
2024-10-12 14:35:31 +08:00
this.getRoadList();
this.$refs.defectTable.clearSelection();
})
.catch(() => {});
},
2024-11-04 10:38:06 +08:00
2024-11-27 10:56:33 +08:00
/**
* @description: 点击导出事件
* @param {*}
* @return {*}
*/
2025-01-15 17:01:25 +08:00
handleExport() {
Loading.service({ fullscreen: true });
let loadingInstance = Loading.service({ fullscreen: true });
const params = {
...this.searchForm,
startTime: this.dateTime ? this.dateTime[0] : "",
endTime: this.dateTime ? this.dateTime[1] : "",
};
exportRoadData(params)
.then((res) => {
const link = document.createElement("a");
const blob = new Blob([res], {
// type: "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
// type: "application/zip",
type: "application/vnd.ms-excel",
});
link.style.display = "none";
link.href = URL.createObjectURL(blob);
// TODO 源文件名问题
link.download = "路产导出文档";
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
})
.finally(() => {
loadingInstance.close();
this.getRoadList();
});
},
2024-11-04 10:38:06 +08:00
2024-11-27 10:56:33 +08:00
/**
* @description: 批量确认事件
* @param {*}
* @return {*}
*/
2024-10-12 14:35:31 +08:00
handleUpdateBatch() {
if (this.checkIds.length > 0) {
changeRoad(this.checkIds).then(({ code, data }) => {
if (code === 200) {
this.$modal.msgSuccess(`修改${data}`);
this.$refs.defectTable.clearSelection();
this.checkIds = [];
}
});
} else {
this.$modal.msgWarning("请选择一条记录进行修改");
}
},
2024-11-04 10:38:06 +08:00
2024-11-27 10:56:33 +08:00
/**
* @description: 列表选择改变事件
* @param {*} selection
* @return {*}
*/
2024-10-12 14:35:31 +08:00
handleSelectionChange(selection) {
this.checkIds = selection.map((item) => item.snapshotId);
2024-10-12 14:35:31 +08:00
this.single = selection.length !== 1;
this.multiple = !selection.length;
},
2024-11-04 10:38:06 +08:00
2024-11-27 10:56:33 +08:00
/**
* @description: 列表-点击修改事件
* @param {*} item
* @return {*}
*/
2024-10-12 14:35:31 +08:00
handleUpdate(item) {
this.addVisible = true;
this.addTitle = "修改路产";
this.dialogItem = {
title: "修改路产",
...item,
};
},
2024-11-04 10:38:06 +08:00
2024-11-27 10:56:33 +08:00
/**
* @description: 列表-点击查看事件
* @param {*} item
* @return {*}
*/
2024-10-12 14:35:31 +08:00
viewDefect(item) {
this.viewVisible = true;
this.dialogItem = {
title: "查看路产",
...item,
};
},
2024-11-04 10:38:06 +08:00
2024-11-27 10:56:33 +08:00
/**
* @description: 切换分页
* @param {*} arg
* @return {*}
*/
2024-10-12 14:35:31 +08:00
handleCurrentChange(arg) {
2024-10-12 17:25:56 +08:00
this.pagination.page = arg;
2024-10-12 14:35:31 +08:00
this.getRoadList();
},
2024-11-04 10:38:06 +08:00
2024-11-27 10:56:33 +08:00
/**
* @description: 切换每条/
* @param {*} arg
* @return {*}
*/
2024-10-12 14:35:31 +08:00
handleSizeChange(arg) {
2024-10-12 17:25:56 +08:00
this.pagination.size = arg;
2024-10-12 14:35:31 +08:00
this.getRoadList();
},
2024-11-04 10:38:06 +08:00
2024-11-27 10:56:33 +08:00
/**
* @description: 关闭新增/编辑弹窗
* @param {*}
* @return {*}
*/
2024-10-12 14:35:31 +08:00
addCancel() {
this.addVisible = false;
2024-10-25 17:29:08 +08:00
this.dialogItem = { title: "添加路产" };
2024-10-12 14:35:31 +08:00
this.addTitle = "";
this.getRoadList();
},
2024-11-04 10:38:06 +08:00
2024-11-27 10:56:33 +08:00
/**
* @description: 关闭查看弹窗
* @param {*}
* @return {*}
*/
2024-10-12 14:35:31 +08:00
viewCancel() {
this.viewVisible = false;
2024-10-25 17:29:08 +08:00
this.dialogItem = { title: "添加路产" };
2024-10-12 14:35:31 +08:00
},
2024-11-21 15:38:45 +08:00
2024-11-27 10:56:33 +08:00
/**
* @description: 打开查看图片弹窗
* @param {*} item
* @return {*}
*/
2024-11-04 10:38:06 +08:00
showScreenImg(item) {
this.currentImageItem = item;
this.showImageDialog = true;
},
2024-11-27 10:56:33 +08:00
/**
* @description: 图片位置信息获取
* @param {*}
* @return {*}
*/
2024-11-04 10:38:06 +08:00
updateRects() {
this.rects = [];
this.rectsItem = {};
const image = this.$refs.mainImage;
const rects = this.currentImageItem?.rect?.split(",").map(Number) || [];
this.rects = [
{
left: rects[0],
top: rects[1],
width: rects[2],
height: rects[3],
},
];
// this.rectsItem = this.defectData[this.currentIndex];
},
2024-11-27 10:56:33 +08:00
/**
* @description: 图片红框位置
* @param {*} { left, top, width, height }
* @return {*}
*/
2024-11-04 10:38:06 +08:00
getRectStyle({ left, top, width, height }) {
const image = this.$refs.mainImage;
const container = this.$refs.imageContainer;
if (!image || !container) return {};
const scaleX = container.clientWidth / image.naturalWidth;
const scaleY = container.clientHeight / image.naturalHeight;
const scale = Math.min(scaleX, scaleY);
const renderedWidth = image.naturalWidth * scale;
const renderedHeight = image.naturalHeight * scale;
const offsetX = (container.clientWidth - renderedWidth) / 2;
const offsetY = (container.clientHeight - renderedHeight) / 2;
return {
position: "absolute",
left: `${left * scale + offsetX}px`,
top: `${top * scale + offsetY}px`,
width: `${width * scale}px`,
height: `${height * scale}px`,
border: "2px solid #FF0000",
boxSizing: "border-box",
};
},
2024-11-27 10:56:33 +08:00
/**
* @description: 关闭查看图片弹窗
* @param {*}
* @return {*}
*/
2024-11-04 10:38:06 +08:00
imgCancel() {
this.showImageDialog = false;
this.currentImageItem = {};
this.rects = [];
2024-11-04 10:38:06 +08:00
},
2024-10-12 14:35:31 +08:00
},
};
</script>
2024-10-12 14:35:31 +08:00
<style lang="scss" scoped>
.app-container {
padding: 20px;
}
.mb8 {
margin-bottom: 8px;
}
.small-padding {
padding: 0 5px;
}
.fixed-width {
width: 120px;
}
/* 分页样式 */
.pagination-part {
width: 100%;
display: flex;
padding-top: 1rem;
justify-content: flex-end;
}
/* 新增弹窗/编辑弹窗 */
.addForm {
.el-select,
.el-cascader {
width: 100%;
}
}
/* 新增地图框样式 */
.no-hand-cursor {
cursor: default !important;
width: 100%;
height: 20rem;
}
/* 上传文件列表样式 */
::v-deep .el-upload-list {
img {
width: auto;
}
}
/* 查看弹窗-图片框样式 */
.view-carousel {
height: 15rem;
// .el-carousel__item{
// height: 12rem;
img {
max-height: 15rem;
max-width: 25rem;
}
}
2024-11-04 10:38:06 +08:00
/* 查看大图弹窗 */
.image-container {
position: relative;
width: 100%;
height: 80%;
display: flex;
flex-direction: column;
2024-11-04 10:38:06 +08:00
align-items: center;
justify-content: center;
overflow: hidden;
}
.image-container img {
max-width: 100%;
max-height: 100%;
object-fit: contain;
}
.rect-overlay {
position: absolute;
pointer-events: none;
border: 2px solid red;
}
// 图片信息
.rect-image {
width: 90%;
position: absolute;
top: 0;
font-size: 1.2rem;
color: #ffffff;
background-color: rgba(0, 0, 0, 0.5);
}
2024-10-12 14:35:31 +08:00
</style>