这一版本优化了很多

This commit is contained in:
王利强
2026-06-03 10:16:37 +08:00
parent 8046316216
commit 2af9f1fd59
954 changed files with 58194 additions and 1609 deletions

View File

@@ -16,7 +16,7 @@
<view class="padding radius bg-white list-list margin-bottom" v-for="item in filteredList"
:key="item.hazardId">
<view class="flex justify-between margin-bottom">
<view class="text-bold text-black">{{item.title}}</view>
<view class="text-bold text-black" style="word-break: break-all; flex: 1;">{{item.title}}</view>
<view class="text-blue" style="white-space: nowrap; flex-shrink: 0; margin-left: 16rpx;">{{item.statusName}}</view>
</view>
<view class="flex margin-bottom">
@@ -35,22 +35,22 @@
<view class="text-gray">创建时间</view>
<view class="text-black">{{item.createdAt}}</view>
</view>
<view class="flex justify-end" style="gap: 10rpx;">
<view class="flex justify-end card-actions" style="gap: 10rpx;">
<!-- 所有状态都显示查看详情 -->
<button class="round cu-btn lg light bg-blue" @click="details(item)">查看详情</button>
<button class="round cu-btn light bg-blue" @click="details(item)">查看详情</button>
<!-- 待整改状态canEdit为true时显示隐患交办和立即整改为false时不显示 -->
<button v-if="item.statusName === '待整改' && item.canEdit"
class="round cu-btn lg light bg-blue" @click="assignHazard(item)">隐患交办</button>
class="round cu-btn light bg-blue" @click="assignHazard(item)">隐患交办</button>
<button v-if="item.statusName === '待整改' && item.canEdit"
class="round cu-btn lg bg-blue" @click="Rectification(item)">立即整改</button>
class="round cu-btn bg-blue" @click="Rectification(item)">立即整改</button>
<!-- 待验收显示编辑整改信息和立即验收 -->
<button v-if="item.statusName === '待验收' && item.canEdit"
class="round cu-btn lg light bg-blue" @click="editRectification(item)">编辑整改信息</button>
class="round cu-btn light bg-blue" @click="editRectification(item)">编辑整改信息</button>
<button v-if="item.statusName === '待验收' && canAcceptance"
class="round cu-btn lg bg-blue" @click="acceptance(item)">立即验收</button>
class="round cu-btn bg-blue" @click="acceptance(item)">立即验收</button>
<!-- 待交办显示隐患交办 -->
<button v-if="item.statusName === '待交办'"
class="round cu-btn lg bg-blue" @click="assignHazard(item)">隐患交办</button>
class="round cu-btn bg-blue" @click="assignHazard(item)">隐患交办</button>
</view>
</view>
@@ -72,8 +72,10 @@
<view class="text-gray">隐患图片</view>
<view class="text-red">*</view>
</view>
<up-upload :fileList="fileList1" @afterRead="afterRead" @delete="deletePic" name="1" multiple
<up-upload :fileList="fileList1" @afterRead="afterRead" @delete="deletePic" name="1" multiple imageMode="aspectFill"
:maxCount="10"></up-upload>
<!-- 隐藏的 Canvas用于渲染防作弊时间戳水印 -->
<canvas canvas-id="watermarkCanvas" :width="canvasWidth" :height="canvasHeight" :style="{ width: canvasWidth + 'px', height: canvasHeight + 'px', position: 'fixed', left: '-9999px', top: '-9999px' }"></canvas>
<view class="text-gray text-sm">必填请上传现场照片作为隐患证据</view>
<view class="ai-btn-wrapper margin-top">
<button class="ai-analyze-btn" :loading="aiAnalyzing" :disabled="aiAnalyzing" @click="handleAiAnalyze">
@@ -116,6 +118,17 @@
</view>
<view class="text-gray text-sm margin-top-xs">办公楼3层东侧消防通道生产车间A区设备旁等或点击"选择地址"按钮在地图上选择</view>
<!-- 法律依据 -->
<view class="flex margin-bottom margin-top">
<view class="text-gray">法律依据</view>
</view>
<view class="select-trigger" @click="openLawPopup">
<view class="select-value" :class="{ 'placeholder': !formData.regulationName }">
{{ formData.regulationName || '请选择法律依据' }}
</view>
<text class="cuIcon-unfold"></text>
</view>
<!-- 隐患区域选择 -->
<view class="flex margin-bottom margin-top">
<view class="text-gray">隐患区域</view>
@@ -135,7 +148,7 @@
<view class="text-gray text-sm margin-top-xs">请详细说明隐患现状潜在风险及影响范围</view>
<view class="text-gray margin-bottom margin-top">隐患标签</view>
<up-choose v-model="formData.tagIndex" :options="tagOptions"></up-choose>
<view class="text-gray text-sm">可选择多个相关标签对隐患进行分类</view>
<!-- <view class="text-gray text-sm">可选择多个相关标签对隐患进行分类</view> -->
</scroll-view>
<view class="popup-footer">
<button class="btn-cancel" @click="showAddPopup = false">取消</button>
@@ -144,6 +157,45 @@
</view>
</u-popup>
<!-- 选择法规弹出框 -->
<u-popup :show="showLawPopup" mode="center" round="20" @close="showLawPopup = false">
<view class="law-popup">
<view class="popup-header">
<view class="popup-title">选择法律依据</view>
<view class="popup-close" @click="showLawPopup = false">×</view>
</view>
<view class="search-box">
<text class="cuIcon-search search-icon"></text>
<input class="search-input" v-model="lawKeyword" placeholder="请输入关键词搜索" @confirm="searchRegulation" />
<text class="search-btn" @click="searchRegulation">搜索</text>
</view>
<scroll-view class="law-list" scroll-y @scrolltolower="loadMoreLaw">
<view v-if="lawLoading && lawList.length === 0" class="loading-tip">加载中...</view>
<view v-else-if="!lawLoading && lawList.length === 0" class="empty-tip">暂无数据</view>
<template v-else>
<view
class="law-item"
:class="{ 'law-item-active': selectedLawId === item.id }"
v-for="item in lawList"
:key="item.id"
@click="selectLaw(item)"
>
<view class="law-title">{{ item.depict }}</view>
<view class="law-basis text-gray">{{ item.legalBasis }}</view>
</view>
<view v-if="lawLoading" class="loading-tip">加载中...</view>
</template>
</scroll-view>
<view class="popup-footer">
<button class="btn-cancel" @click="showLawPopup = false">取消</button>
<button class="btn-confirm" @click="confirmLaw">确定</button>
</view>
</view>
</u-popup>
<!-- 区域选择弹窗 -->
<u-popup :show="showAreaPicker" mode="bottom" round="20" @close="showAreaPicker = false">
<view class="picker-popup">
@@ -193,18 +245,25 @@
enterCheckPlan,
getCheckTaskDetail,
getMyHiddenDangerList,
getHiddenDangerLabelList,
getHiddenDangerLabelList, getRegulationList,
analyzeHazardImage
} from '@/request/api.js'
import { getAreaList } from '@/request/three_one_api/area.js'
import { addTimestampWatermark } from '@/utils/watermark.js'
import {
baseUrl,
getToken
getToken,
toImageUrl,
imageBaseUrl
} from '@/request/request.js'
// 弹窗控制
const showAddPopup = ref(false);
// 防作弊时间戳水印 Canvas 大小配置
const canvasWidth = ref(300);
const canvasHeight = ref(300);
// up-choose 组件的 ref
const levelChooseRef = ref(null);
@@ -265,7 +324,9 @@
level: 0, // 隐患等级索引
description: '', // 隐患描述
tagIndex: 0, // 隐患标签索引
source: '', // 隐患来源
source: 0, // 隐患来源
regulationId: null, // 法律依据ID
regulationName: '', // 法律依据名称(显示用)
});
// 用于强制刷新 up-choose 组件的 key
@@ -285,6 +346,87 @@
const selectedAreaName = ref('');
const tempAreaId = ref('');
// 选择法规(法律依据)相关
const showLawPopup = ref(false);
const lawKeyword = ref('');
const selectedLawId = ref(null);
const selectedLawName = ref('');
const lawList = ref([]);
const lawLoading = ref(false);
const lawPageNum = ref(1);
const lawPageSize = ref(10);
const hasMoreLaw = ref(true);
// 打开法规选择弹窗
const openLawPopup = () => {
showLawPopup.value = true;
if (lawList.value.length === 0) {
fetchRegulationList();
}
};
// 获取法规列表
const fetchRegulationList = async (isLoadMore = false) => {
if (lawLoading.value) return;
lawLoading.value = true;
try {
const params = {
pageNum: lawPageNum.value,
pageSize: lawPageSize.value,
status: 1 // 启用状态
};
if (lawKeyword.value && lawKeyword.value.trim()) {
params.keyword = lawKeyword.value.trim();
}
const res = await getRegulationList(params);
if (res.code === 0) {
const records = res.data.records || res.data || [];
if (isLoadMore) {
lawList.value = [...lawList.value, ...records];
} else {
lawList.value = records;
}
const total = res.data.total || 0;
hasMoreLaw.value = lawList.value.length < total;
}
} catch (error) {
console.error('获取法规列表失败:', error);
} finally {
lawLoading.value = false;
}
};
// 搜索法规
const searchRegulation = () => {
lawPageNum.value = 1;
lawList.value = [];
hasMoreLaw.value = true;
fetchRegulationList();
};
// 加载更多法规
const loadMoreLaw = () => {
if (!hasMoreLaw.value || lawLoading.value) return;
lawPageNum.value++;
fetchRegulationList(true);
};
// 选择法规
const selectLaw = (item) => {
selectedLawId.value = item.id;
selectedLawName.value = item.depict || item.keyword || '';
};
// 确认选择法规
const confirmLaw = () => {
if (selectedLawId.value) {
formData.regulationId = selectedLawId.value;
formData.regulationName = selectedLawName.value;
}
showLawPopup.value = false;
};
// 获取区域列表
const fetchAreaList = async () => {
try {
@@ -410,7 +552,7 @@
// 构建请求参数
const params = {
title: formData.title, //标题
level: formData.level + 1, // 1.轻微隐患 2.一般隐患 3.重大隐患
level: levelOptions.value[formData.level]?.id || 2, // 2.一般隐患 3.重大隐患
lng: lng.value || 0, //经度
lat: lat.value || 0, //纬度
address: selectedAddress.value || '', //详细地址
@@ -421,6 +563,7 @@
checkPointId: checkPointId.value, //关联检查点ID
source: sourceOptions.value[formData.source]?.title || '', //隐患来源(随手拍、企业自查、行业互查、专家诊查)
attachments: attachments, //附件列表(图片/视频)
regulationId: formData.regulationId || null, // 法律依据ID
};
console.log('提交的参数:', params);
@@ -442,6 +585,11 @@
selectedAreaId.value = '';
selectedAreaName.value = '';
fileList1.value = [];
// 重置法律依据
formData.regulationId = null;
formData.regulationName = '';
selectedLawId.value = null;
selectedLawName.value = '';
// 刷新隐患列表
fetchHiddenDangerList();
} else {
@@ -535,7 +683,20 @@
});
});
for (let i = 0; i < lists.length; i++) {
const result = await uploadFilePromise(lists[i].url);
let watermarkedUrl = lists[i].url;
try {
const instance = getCurrentInstance();
watermarkedUrl = await addTimestampWatermark({
tempFilePath: lists[i].url,
canvasId: 'watermarkCanvas',
canvasWidthRef: canvasWidth,
canvasHeightRef: canvasHeight,
instance
});
} catch (e) {
console.error('加水印失败,将使用原图上传:', e);
}
const result = await uploadFilePromise(watermarkedUrl);
let item = fileList1.value[fileListLen];
const serverPath = typeof result === 'string' ? result : (result?.url || result?.path || '');
fileList1.value.splice(fileListLen, 1, {
@@ -543,7 +704,7 @@
status: 'success',
message: '',
// url: baseUrl + serverPath,
url: baseUrl.replace('/prod-api', '') + serverPath,
url: toImageUrl(serverPath),
serverPath: serverPath,
});
fileListLen++;
@@ -604,7 +765,7 @@
if (aiData.description) formData.description = aiData.description;
if (aiData.level) {
const levelMap = { '轻微': 0, '轻微隐患': 0, '一般': 1, '一般隐患': 1, '重大': 2, '重大隐患': 2 };
const levelMap = { '轻微': 0, '轻微隐患': 0, '一般': 0, '一般隐患': 0, '重大': 1, '重大隐患': 1 };
const levelIndex = levelMap[aiData.level];
if (levelIndex !== undefined) {
formData.level = levelIndex;
@@ -655,10 +816,11 @@
//
// 隐患等级选项
const levelOptions = ref([{
id: 1,
title: '轻微隐患'
},
const levelOptions = ref([
// {
// id: 1,
// title: '轻微隐患'
// },
{
id: 2,
title: '一般隐患'
@@ -700,21 +862,22 @@
// 状态筛选 Tab
const statusTabs = ref([
{ label: '全部状态', value: '' },
{ label: '待验收', value: '待验收' },
{ label: '待整改', value: '待整改' },
{ label: '待交办', value: '待交办' },
{ label: '验收通过', value: '验收通过' }
{ label: '全部', value: null },
{ label: '待交办', value: 1 },
{ label: '待整改', value: 2 },
{ label: '待验收', value: 3 },
{ label: '待销号', value: 4 },
{ label: '已完成', value: 5 }
]);
const activeTab = ref(0);
// 根据选中 tab 过滤列表
const filteredList = computed(() => {
const currentTab = statusTabs.value[activeTab.value];
if (!currentTab || !currentTab.value) {
if (!currentTab || currentTab.value === null) {
return hiddenDangerList.value;
}
return hiddenDangerList.value.filter(item => item.statusName === currentTab.value);
return hiddenDangerList.value.filter(item => item.status === currentTab.value);
});
</script>
@@ -1073,10 +1236,152 @@
background: #2667E9;
border-radius: 3rpx;
}
// 选择法规弹窗
.law-popup {
width: 600rpx;
background: #fff;
border-radius: 20rpx;
overflow: hidden;
max-height: 80vh;
.popup-header {
display: flex;
justify-content: space-between;
align-items: center;
padding: 30rpx;
border-bottom: 1rpx solid #eee;
.popup-title {
font-size: 32rpx;
font-weight: bold;
color: #333;
}
.popup-close {
font-size: 40rpx;
color: #999;
cursor: pointer;
}
}
}
.search-box {
display: flex;
align-items: center;
background: #F5F5F5;
border-radius: 40rpx;
padding: 16rpx 24rpx;
margin: 20rpx 30rpx;
.search-icon {
font-size: 28rpx;
color: #999;
margin-right: 12rpx;
}
.search-input {
flex: 1;
font-size: 28rpx;
background: transparent;
border: none;
}
.search-btn {
color: #2667E9;
font-size: 26rpx;
margin-left: 16rpx;
cursor: pointer;
}
}
.loading-tip, .empty-tip {
text-align: center;
padding: 40rpx;
color: #999;
font-size: 26rpx;
}
.law-list {
max-height: 400rpx;
padding: 0 30rpx;
}
.law-item {
padding: 24rpx;
border: 2rpx solid #E5E5E5;
border-radius: 12rpx;
margin-bottom: 16rpx;
font-size: 28rpx;
color: #333;
.law-title {
line-height: 1.5;
margin-bottom: 8rpx;
font-weight: bold;
}
.law-basis {
font-size: 24rpx;
line-height: 1.4;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
overflow: hidden;
}
}
.law-item-active {
border-color: #2667E9;
background: #F0F6FF;
}
.popup-footer {
display: flex;
padding: 30rpx;
border-top: 1rpx solid #eee;
gap: 20rpx;
button {
flex: 1;
height: 80rpx;
line-height: 80rpx;
font-size: 28rpx;
border-radius: 40rpx;
&::after {
border: none;
}
}
.btn-cancel {
background: #f5f5f5;
color: #666;
}
.btn-confirm {
background: #2667E9;
color: #fff;
}
}
</style>
<style lang="scss">
/* 全局样式覆盖 up-tag 文字居中 */
.card-actions {
margin-top: 20rpx;
.cu-btn {
padding: 0 24rpx !important;
font-size: 28rpx !important;
height: 64rpx !important;
line-height: 64rpx !important;
white-space: nowrap !important;
flex-shrink: 0 !important;
width: auto !important;
}
}
.u-tag {
justify-content: center !important;
}