这一版本优化了很多
This commit is contained in:
@@ -181,7 +181,7 @@ import {
|
||||
updateLicense,
|
||||
deleteLicense
|
||||
} from '@/request/three_one_api/license.js';
|
||||
import { getToken, toImageUrl } from '@/request/request.js';
|
||||
import { baseUrl, getToken, toImageUrl } from '@/request/request.js';
|
||||
|
||||
// 证照列表
|
||||
const licenseList = ref([]);
|
||||
|
||||
@@ -88,19 +88,29 @@
|
||||
<button class="bg-blue round margin-top-xl" @click="handleSubmit">提交</button>
|
||||
|
||||
<!-- 新增隐患弹窗 -->
|
||||
<u-popup :show="showHazardPopup" mode="center" round="20" @close="showHazardPopup = false">
|
||||
<u-popup :show="showHazardPopup" mode="center" round="20" :safeAreaInsetBottom="false" @close="showHazardPopup = false">
|
||||
<view class="popup-content">
|
||||
<view class="popup-header">
|
||||
<view class="popup-title text-bold">填写隐患信息</view>
|
||||
<view class="popup-close" @click="showHazardPopup = false">×</view>
|
||||
</view>
|
||||
<scroll-view class="popup-body" scroll-y :style="{ height: '60vh' }">
|
||||
<!-- 草稿恢复提示 -->
|
||||
<view v-if="showRestoreBanner" class="bg-orange-light text-orange padding-sm radius margin-bottom flex justify-between align-center" style="font-size: 24rpx; background-color: #FFF7EB; border: 1rpx solid #FFE4CC; width: 100%; box-sizing: border-box; display: flex; flex-direction: row; justify-content: space-between; align-items: center; margin-bottom: 20rpx;">
|
||||
<view class="flex align-center" style="display: flex; flex-direction: row; align-items: center;">
|
||||
<text class="cuIcon-info margin-right-xs" style="margin-right: 10rpx;"></text>
|
||||
<text>已自动恢复您上次未提交的内容</text>
|
||||
</view>
|
||||
<text class="text-blue text-bold" style="cursor: pointer; padding: 0 10rpx; color: #2667E9; font-weight: bold;" @click="clearDraft(true)">清空草稿</text>
|
||||
</view>
|
||||
<view class="flex margin-bottom">
|
||||
<view class="text-gray">隐患图片</view>
|
||||
<view class="text-red">*</view>
|
||||
</view>
|
||||
<up-upload :fileList="hazardFileList" @afterRead="afterRead" @delete="deletePic" name="1" multiple
|
||||
<up-upload :fileList="hazardFileList" @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">
|
||||
@@ -143,6 +153,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': !hazardFormData.regulationName }">
|
||||
{{ hazardFormData.regulationName || '请选择法律依据' }}
|
||||
</view>
|
||||
<text class="cuIcon-unfold"></text>
|
||||
</view>
|
||||
|
||||
<!-- 隐患区域选择 -->
|
||||
<view class="flex margin-bottom margin-top">
|
||||
<view class="text-gray">隐患区域</view>
|
||||
@@ -162,7 +183,7 @@
|
||||
<view class="text-gray text-sm margin-top-xs">请详细说明隐患现状、潜在风险及影响范围</view>
|
||||
<view class="text-gray margin-bottom margin-top">隐患标签</view>
|
||||
<up-choose v-model="hazardFormData.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="showHazardPopup = false">取消</button>
|
||||
@@ -171,6 +192,45 @@
|
||||
</view>
|
||||
</u-popup>
|
||||
|
||||
<!-- 选择法规弹出框 -->
|
||||
<u-popup :show="showLawPopup" mode="center" round="20" :safeAreaInsetBottom="false" @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 bg-blue" @click="confirmLaw">确定</button>
|
||||
</view>
|
||||
</view>
|
||||
</u-popup>
|
||||
|
||||
<!-- 区域选择弹窗 -->
|
||||
<u-popup :show="showAreaPicker" mode="bottom" round="20" @close="showAreaPicker = false">
|
||||
<view class="picker-popup">
|
||||
@@ -203,14 +263,19 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, reactive, computed, nextTick } from 'vue';
|
||||
import { ref, reactive, computed, nextTick, watch, getCurrentInstance } from 'vue';
|
||||
import { onLoad } from '@dcloudio/uni-app';
|
||||
import { enterCheckPlan, submitCheckResult, addHiddenDanger, getHiddenDangerLabelList, analyzeHazardImage } from '@/request/api.js';
|
||||
import { baseUrl, getToken } from '@/request/request.js';
|
||||
import { enterCheckPlan, submitCheckResult, addHiddenDanger, getHiddenDangerLabelList, getRegulationList, analyzeHazardImage } from '@/request/api.js';
|
||||
import { baseUrl, getToken, toImageUrl, imageBaseUrl } from '@/request/request.js';
|
||||
import { addTimestampWatermark } from '@/utils/watermark.js';
|
||||
import { getAreaList } from '@/request/three_one_api/area.js';
|
||||
|
||||
// 页面参数
|
||||
const oneTableId = ref('');
|
||||
|
||||
// 防作弊时间戳水印 Canvas 大小配置
|
||||
const canvasWidth = ref(300);
|
||||
const canvasHeight = ref(300);
|
||||
// 检查项数据
|
||||
const checkData = ref(null);
|
||||
|
||||
@@ -262,7 +327,9 @@
|
||||
level: 0,
|
||||
source: 0,
|
||||
description: '',
|
||||
tagIndex: 0
|
||||
tagIndex: 0,
|
||||
regulationId: null, // 法律依据ID
|
||||
regulationName: '' // 法律依据名称(显示用)
|
||||
});
|
||||
|
||||
// 隐患地址和经纬度
|
||||
@@ -277,6 +344,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) {
|
||||
hazardFormData.regulationId = selectedLawId.value;
|
||||
hazardFormData.regulationName = selectedLawName.value;
|
||||
}
|
||||
showLawPopup.value = false;
|
||||
};
|
||||
|
||||
// 获取区域列表
|
||||
const fetchAreaList = async () => {
|
||||
try {
|
||||
@@ -323,7 +471,7 @@
|
||||
|
||||
// 隐患等级选项
|
||||
const levelOptions = ref([
|
||||
{ id: 1, title: '轻微隐患' },
|
||||
// { id: 1, title: '轻微隐患' },
|
||||
{ id: 2, title: '一般隐患' },
|
||||
{ id: 3, title: '重大隐患' }
|
||||
]);
|
||||
@@ -366,6 +514,10 @@
|
||||
|
||||
// 清除隐患信息
|
||||
const clearHazard = () => {
|
||||
hazardFormData.regulationId = null;
|
||||
hazardFormData.regulationName = '';
|
||||
selectedLawId.value = null;
|
||||
selectedLawName.value = '';
|
||||
hazardFormData.title = '';
|
||||
hazardFormData.level = 0;
|
||||
hazardFormData.source = 0;
|
||||
@@ -443,14 +595,27 @@
|
||||
});
|
||||
});
|
||||
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 = hazardFileList.value[fileListLen];
|
||||
const serverPath = typeof result === 'string' ? result : (result?.url || result?.path || '');
|
||||
hazardFileList.value.splice(fileListLen, 1, {
|
||||
...item,
|
||||
status: 'success',
|
||||
message: '',
|
||||
url: baseUrl.replace('/prod-api', '') + serverPath,
|
||||
url: toImageUrl(serverPath),
|
||||
serverPath: serverPath,
|
||||
});
|
||||
fileListLen++;
|
||||
@@ -572,6 +737,9 @@
|
||||
} else if (file.url && typeof file.url === 'object') {
|
||||
url = file.url.url || file.url.path || '';
|
||||
}
|
||||
if (typeof url === 'string' && url.startsWith('http')) {
|
||||
url = url.replace(imageBaseUrl, '');
|
||||
}
|
||||
const fileName = (typeof url === 'string' && url) ? url.split('/').pop() : (file.name || '');
|
||||
return {
|
||||
fileName: fileName || '',
|
||||
@@ -598,7 +766,8 @@
|
||||
description: hazardFormData.description || '',
|
||||
source: sourceOptions.value[hazardFormData.source]?.title || '',
|
||||
tagId: tagId,
|
||||
attachments: attachments
|
||||
attachments: attachments,
|
||||
regulationId: hazardFormData.regulationId || null
|
||||
};
|
||||
|
||||
console.log('隐患参数:', hazardParams);
|
||||
@@ -625,6 +794,7 @@
|
||||
uni.hideLoading();
|
||||
|
||||
if (res.code === 0) {
|
||||
clearDraft(false);
|
||||
// 判断是否全部完成
|
||||
if (res.data && res.data.allFinished === true) {
|
||||
// 全部完成,退出页面
|
||||
@@ -675,6 +845,8 @@
|
||||
console.log('检查项数据:', res);
|
||||
if (res.code === 0) {
|
||||
checkData.value = res.data;
|
||||
// 拿到题目后,安全触发恢复草稿
|
||||
restoreDraft();
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
@@ -682,6 +854,171 @@
|
||||
};
|
||||
|
||||
// 页面加载时获取参数并调用接口
|
||||
// 草稿缓存与恢复逻辑 (已深度适配,排除区域选择器列表缓存,仅缓存文字、单选、备注、图片等输入信息)
|
||||
const hasDraft = ref(false);
|
||||
const showRestoreBanner = ref(false); // 独立控制提示 Banner,仅在初次确实从本地恢复了内容时才显示
|
||||
const isRestoring = ref(false); // 正在恢复标志,避免触发冗余watch
|
||||
const isInitialized = ref(false); // 初始化标识,防止初期空值覆盖已有草稿
|
||||
const getDraftKey = () => `draft_inspection_result_${oneTableId.value || ''}_${checkData.value?.currentIndex || ''}`;
|
||||
|
||||
// 保存草稿
|
||||
const saveDraft = () => {
|
||||
if (isRestoring.value || !isInitialized.value) {
|
||||
console.log('【草稿Debug - 巡检】saveDraft 被跳过:', { isRestoring: isRestoring.value, isInitialized: isInitialized.value });
|
||||
return;
|
||||
}
|
||||
const key = getDraftKey();
|
||||
const hasContent = radiovalue1.value ||
|
||||
value1.value ||
|
||||
hazardFormData.title ||
|
||||
hazardFormData.description ||
|
||||
hazardFileList.value.length > 0;
|
||||
|
||||
console.log('【草稿Debug - 巡检】尝试自动保存草稿. Key:', key, '是否有实质内容:', !!hasContent, '当前数据:', {
|
||||
radiovalue1: radiovalue1.value,
|
||||
value1: value1.value,
|
||||
title: hazardFormData.title,
|
||||
description: hazardFormData.description,
|
||||
fileCount: hazardFileList.value.length
|
||||
});
|
||||
|
||||
if (!hasContent) {
|
||||
uni.removeStorageSync(key);
|
||||
console.log('【草稿Debug - 巡检】当前表单为空,自动删除本地缓存 Key:', key);
|
||||
hasDraft.value = false;
|
||||
return;
|
||||
}
|
||||
|
||||
const data = {
|
||||
radiovalue1: radiovalue1.value,
|
||||
value1: value1.value,
|
||||
hazardFormData: {
|
||||
title: hazardFormData.title,
|
||||
level: hazardFormData.level,
|
||||
source: hazardFormData.source,
|
||||
description: hazardFormData.description,
|
||||
tagIndex: hazardFormData.tagIndex
|
||||
},
|
||||
hazardFileList: hazardFileList.value,
|
||||
hazardAddress: hazardAddress.value,
|
||||
hazardLng: hazardLng.value,
|
||||
hazardLat: hazardLat.value
|
||||
};
|
||||
uni.setStorageSync(key, JSON.stringify(data));
|
||||
console.log('【草稿Debug - 巡检】成功保存草稿到 LocalStorage, Key:', key);
|
||||
hasDraft.value = true;
|
||||
};
|
||||
|
||||
// 清空草稿
|
||||
const clearDraft = (showToast = true) => {
|
||||
const key = getDraftKey();
|
||||
console.log('【草稿Debug - 巡检】手动清空草稿, Key:', key);
|
||||
uni.removeStorageSync(key);
|
||||
hasDraft.value = false;
|
||||
showRestoreBanner.value = false;
|
||||
|
||||
isRestoring.value = true;
|
||||
radiovalue1.value = '';
|
||||
value1.value = '';
|
||||
hazardFormData.title = '';
|
||||
hazardFormData.level = 0;
|
||||
hazardFormData.source = 0;
|
||||
hazardFormData.description = '';
|
||||
hazardFormData.tagIndex = 0;
|
||||
hazardFileList.value = [];
|
||||
hazardAddress.value = '';
|
||||
hazardLng.value = 0;
|
||||
hazardLat.value = 0;
|
||||
|
||||
nextTick(() => {
|
||||
isRestoring.value = false;
|
||||
});
|
||||
if (showToast) {
|
||||
uni.showToast({ title: '草稿已清空', icon: 'none' });
|
||||
}
|
||||
};
|
||||
|
||||
// 恢复草稿
|
||||
const restoreDraft = () => {
|
||||
const key = getDraftKey();
|
||||
const cached = uni.getStorageSync(key);
|
||||
console.log('【草稿Debug - 巡检】尝试恢复草稿, Key:', key, '获取本地缓存结果:', !!cached);
|
||||
if (cached) {
|
||||
try {
|
||||
const data = JSON.parse(cached);
|
||||
const hasContent = data.radiovalue1 ||
|
||||
data.value1 ||
|
||||
data.hazardFormData.title ||
|
||||
data.hazardFormData.description ||
|
||||
(data.hazardFileList && data.hazardFileList.length > 0);
|
||||
|
||||
console.log('【草稿Debug - 巡检】解析本地缓存成功, 是否有实质内容:', !!hasContent, '缓存数据:', data);
|
||||
if (!hasContent) {
|
||||
isInitialized.value = true;
|
||||
return;
|
||||
}
|
||||
|
||||
isRestoring.value = true;
|
||||
radiovalue1.value = data.radiovalue1 || '';
|
||||
value1.value = data.value1 || '';
|
||||
hazardFormData.title = data.hazardFormData.title || '';
|
||||
hazardFormData.level = data.hazardFormData.level || 0;
|
||||
hazardFormData.source = data.hazardFormData.source || 0;
|
||||
hazardFormData.description = data.hazardFormData.description || '';
|
||||
hazardFormData.tagIndex = data.hazardFormData.tagIndex || 0;
|
||||
hazardFileList.value = data.hazardFileList || [];
|
||||
hazardAddress.value = data.hazardAddress || '';
|
||||
hazardLng.value = data.hazardLng || 0;
|
||||
hazardLat.value = data.hazardLat || 0;
|
||||
hasDraft.value = true;
|
||||
showRestoreBanner.value = true; // 确实存在内容并恢复了,才亮起提示 Banner
|
||||
|
||||
nextTick(() => {
|
||||
isRestoring.value = false;
|
||||
isInitialized.value = true;
|
||||
if (levelChooseRef.value && levelChooseRef.value.$data) {
|
||||
levelChooseRef.value.$data.currentIndex = hazardFormData.level;
|
||||
}
|
||||
console.log('【草稿Debug - 巡检】UI与多选组件状态同步重绘完毕!');
|
||||
});
|
||||
|
||||
uni.showToast({
|
||||
title: '已自动恢复您上次未提交的内容',
|
||||
icon: 'none',
|
||||
duration: 2500
|
||||
});
|
||||
} catch (e) {
|
||||
console.error('【草稿Debug - 巡检】解析草稿异常:', e);
|
||||
isRestoring.value = false;
|
||||
isInitialized.value = true;
|
||||
}
|
||||
} else {
|
||||
console.log('【草稿Debug - 巡检】本地无任何缓存, 页面已安全标记为 initialized');
|
||||
isInitialized.value = true;
|
||||
}
|
||||
};
|
||||
|
||||
// 监听变量变化,自动保存草稿
|
||||
watch(
|
||||
() => [
|
||||
radiovalue1.value,
|
||||
value1.value,
|
||||
hazardFormData.title,
|
||||
hazardFormData.level,
|
||||
hazardFormData.source,
|
||||
hazardFormData.description,
|
||||
hazardFormData.tagIndex,
|
||||
hazardAddress.value,
|
||||
hazardFileList.value
|
||||
],
|
||||
() => {
|
||||
if (oneTableId.value) {
|
||||
saveDraft();
|
||||
}
|
||||
},
|
||||
{ deep: true }
|
||||
);
|
||||
|
||||
onLoad((options) => {
|
||||
console.log('接收到的参数:', options);
|
||||
if (options.id) {
|
||||
@@ -947,6 +1284,8 @@
|
||||
button {
|
||||
flex: 1;
|
||||
height: 90rpx;
|
||||
margin: 0 !important;
|
||||
padding: 0 !important;
|
||||
line-height: 90rpx;
|
||||
border-radius: 0;
|
||||
font-size: 30rpx;
|
||||
@@ -1064,6 +1403,106 @@
|
||||
}
|
||||
|
||||
// 区域颜色圆点
|
||||
// 选择法规(法律依据)弹出框样式
|
||||
.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: 500rpx;
|
||||
padding: 0 30rpx;
|
||||
}
|
||||
|
||||
.law-item {
|
||||
padding: 24rpx;
|
||||
border: 2rpx solid #E5E5E5;
|
||||
border-radius: 12rpx;
|
||||
margin-bottom: 16rpx;
|
||||
font-size: 28rpx;
|
||||
color: #333;
|
||||
text-align: left;
|
||||
|
||||
.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;
|
||||
}
|
||||
|
||||
.area-color-dot {
|
||||
width: 24rpx;
|
||||
height: 24rpx;
|
||||
|
||||
@@ -66,11 +66,11 @@
|
||||
<view class="stat-label">逾期</view>
|
||||
</view>
|
||||
<view class="stat-item stat-completed">
|
||||
<view class="stat-num">{{ statistics.completed }}</view>
|
||||
<view class="stat-num">{{ statistics.onTimeCompleted }}</view>
|
||||
<view class="stat-label">已完成</view>
|
||||
</view>
|
||||
<view class="stat-item stat-pending">
|
||||
<view class="stat-num">{{ statistics.pending }}</view>
|
||||
<view class="stat-num">{{ statistics.completed }}</view>
|
||||
<view class="stat-label">待处理</view>
|
||||
</view>
|
||||
</view>
|
||||
@@ -130,6 +130,9 @@
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 加载更多 -->
|
||||
<u-loadmore :status="loadStatus" v-if="dataList.length > 0" style="margin-top: 20rpx; margin-bottom: 20rpx;" />
|
||||
|
||||
<!-- 空状态 -->
|
||||
<view v-if="dataList.length === 0" class="empty-tip">
|
||||
<text>暂无数据</text>
|
||||
@@ -139,7 +142,7 @@
|
||||
|
||||
<script setup>
|
||||
import { ref, reactive, onMounted } from 'vue'
|
||||
import { onShow } from '@dcloudio/uni-app'
|
||||
import { onShow, onReachBottom } from '@dcloudio/uni-app'
|
||||
import { getInspectionWarningList } from '@/request/api.js'
|
||||
|
||||
// 搜索表单
|
||||
@@ -156,7 +159,7 @@ const startDateValue = ref(Number(new Date()))
|
||||
const endDateValue = ref(Number(new Date()))
|
||||
|
||||
// 统计数据
|
||||
const statistics = reactive({
|
||||
const statistics = reactive({ total: 0, overdue: 0, pending: 0, completed: 0, overdueCompleted: 0, onTimeCompleted: 0 }); const _old_stats = reactive({
|
||||
total: 0,
|
||||
overdue: 0,
|
||||
completed: 0,
|
||||
@@ -167,6 +170,7 @@ const statistics = reactive({
|
||||
const dataList = ref([])
|
||||
const pageNum = ref(1)
|
||||
const pageSize = ref(20)
|
||||
const loadStatus = ref('loadmore')
|
||||
|
||||
// 状态筛选 Tab
|
||||
const statusTabs = ref([
|
||||
@@ -179,7 +183,7 @@ const statusTabs = ref([
|
||||
])
|
||||
const activeStatusTab = ref(0)
|
||||
|
||||
const switchStatusTab = (index) => {
|
||||
const switchStatusTab = (index) => { activeStatusTab.value = index; pageNum.value = 1; dataList.value = []; fetchData(); }; const _unused_tab = (index) => {
|
||||
activeStatusTab.value = index
|
||||
pageNum.value = 1
|
||||
fetchData()
|
||||
@@ -197,14 +201,14 @@ const formatDate = (timestamp) => {
|
||||
// 日期选择确认(开始日期补 00:00:00)
|
||||
const onStartDateConfirm = (e) => {
|
||||
const dateStr = formatDate(e.value)
|
||||
searchForm.startDate = `${dateStr} 00:00:00`
|
||||
searchForm.startDate = dateStr
|
||||
showStartDatePicker.value = false
|
||||
}
|
||||
|
||||
// 日期选择确认(结束日期补 23:59:59)
|
||||
const onEndDateConfirm = (e) => {
|
||||
const dateStr = formatDate(e.value)
|
||||
searchForm.endDate = `${dateStr} 23:59:59`
|
||||
searchForm.endDate = dateStr
|
||||
showEndDatePicker.value = false
|
||||
}
|
||||
|
||||
@@ -239,38 +243,43 @@ const getStatusText = (overdueDays, statusName) => {
|
||||
// 获取数据
|
||||
const fetchData = async () => {
|
||||
try {
|
||||
const params = {
|
||||
pageNum: pageNum.value,
|
||||
pageSize: pageSize.value
|
||||
}
|
||||
// 添加查询条件
|
||||
if (searchForm.startDate) {
|
||||
params.startDate = searchForm.startDate
|
||||
}
|
||||
if (searchForm.endDate) {
|
||||
params.endDate = searchForm.endDate
|
||||
}
|
||||
if (searchForm.deptName && searchForm.deptName.trim()) {
|
||||
params.deptName = searchForm.deptName.trim()
|
||||
}
|
||||
// 状态筛选
|
||||
const params = { pageNum: pageNum.value, pageSize: pageSize.value }
|
||||
if (searchForm.startDate) params.startDate = searchForm.startDate
|
||||
if (searchForm.endDate) params.endDate = searchForm.endDate
|
||||
if (searchForm.deptName && searchForm.deptName.trim()) params.deptName = searchForm.deptName.trim()
|
||||
const statusValue = statusTabs.value[activeStatusTab.value].value
|
||||
if (statusValue !== 0) {
|
||||
params.inspectionStatus = statusValue
|
||||
}
|
||||
|
||||
if (statusValue !== 0) params.inspectionStatus = statusValue
|
||||
const res = await getInspectionWarningList(params)
|
||||
if (res.code === 0) {
|
||||
// 更新统计数据
|
||||
if (res.data.statistics) {
|
||||
statistics.total = res.data.statistics.total || 0
|
||||
statistics.overdue = res.data.statistics.overdue || 0
|
||||
statistics.completed = res.data.statistics.completed || 0
|
||||
statistics.pending = res.data.statistics.pending || 0
|
||||
statistics.completed = res.data.statistics.completed || 0
|
||||
statistics.overdueCompleted = res.data.statistics.overdueCompleted || 0
|
||||
statistics.onTimeCompleted = res.data.statistics.onTimeCompleted || 0
|
||||
statusTabs.value[0].count = res.data.statistics.total || 0
|
||||
statusTabs.value[1].count = res.data.statistics.overdue || 0
|
||||
statusTabs.value[2].count = res.data.statistics.pending || 0
|
||||
statusTabs.value[3].count = res.data.statistics.completed || 0
|
||||
statusTabs.value[4].count = res.data.statistics.overdueCompleted || 0
|
||||
statusTabs.value[5].count = res.data.statistics.onTimeCompleted || 0
|
||||
}
|
||||
// 更新列表数据
|
||||
if (res.data.page && res.data.page.records) {
|
||||
dataList.value = res.data.page.records
|
||||
const records = res.data.page.records
|
||||
if (pageNum.value === 1) {
|
||||
dataList.value = records
|
||||
} else {
|
||||
dataList.value = [...dataList.value, ...records]
|
||||
}
|
||||
const totalRecords = res.data.page.total || 0
|
||||
if (dataList.value.length >= totalRecords) {
|
||||
loadStatus.value = 'nomore'
|
||||
} else {
|
||||
loadStatus.value = 'loadmore'
|
||||
}
|
||||
} else {
|
||||
loadStatus.value = 'nomore'
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
@@ -281,9 +290,18 @@ const fetchData = async () => {
|
||||
// 搜索
|
||||
const handleSearch = () => {
|
||||
pageNum.value = 1
|
||||
dataList.value = []
|
||||
fetchData()
|
||||
}
|
||||
|
||||
// 监听触底上拉加载更多
|
||||
onReachBottom(() => {
|
||||
if (loadStatus.value === 'loadmore') {
|
||||
pageNum.value++
|
||||
fetchData()
|
||||
}
|
||||
})
|
||||
|
||||
// 页面加载
|
||||
onShow(() => {
|
||||
fetchData()
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
</view>
|
||||
<button class="cuIcon-add bg-blue round margin-top" @click="openAddPopup">新增</button>
|
||||
<!-- 弹出框 -->
|
||||
<u-popup :show="showAddPopup" mode="center" round="20" @close="showAddPopup = false">
|
||||
<u-popup :show="showAddPopup" mode="center" round="20" :safeAreaInsetBottom="false" @close="showAddPopup = false">
|
||||
<view class="popup-content">
|
||||
<view class="popup-header">
|
||||
<view class="popup-title text-bold">新增销号申请</view>
|
||||
@@ -44,7 +44,7 @@
|
||||
<text :class="selectedHazard ? '' : 'text-gray'">{{ selectedHazard || '请选择隐患' }}</text>
|
||||
</view>
|
||||
<up-picker
|
||||
:show="showHazardPicker"
|
||||
v-if="false" :show="showHazardPicker"
|
||||
:columns="hazardColumns"
|
||||
@confirm="onHazardConfirm"
|
||||
@cancel="showHazardPicker = false"
|
||||
@@ -58,7 +58,7 @@
|
||||
<text :class="formData.rectifyDeadline ? '' : 'text-gray'">{{ formData.rectifyDeadline || '请选择整改时限' }}</text>
|
||||
</view>
|
||||
<up-datetime-picker
|
||||
:show="showDatePicker"
|
||||
v-if="false" :show="showDatePicker"
|
||||
v-model="dateValue"
|
||||
mode="datetime"
|
||||
@confirm="onDateConfirm"
|
||||
@@ -70,7 +70,7 @@
|
||||
<text :class="selectedDeptName ? '' : 'text-gray'">{{ selectedDeptName || '请选择隐患治理责任单位' }}</text>
|
||||
</view>
|
||||
<up-picker
|
||||
:show="showDeptPicker"
|
||||
v-if="false" :show="showDeptPicker"
|
||||
:columns="deptColumns"
|
||||
@confirm="onDeptConfirm"
|
||||
@cancel="showDeptPicker = false"
|
||||
@@ -97,6 +97,32 @@
|
||||
</view>
|
||||
</view>
|
||||
</u-popup>
|
||||
|
||||
<!-- 移出到外层的选择器组件,防止其定位样式被 scroll-view 剪裁并导致暗色遮罩溢出异常 -->
|
||||
<up-picker
|
||||
:show="showHazardPicker"
|
||||
:columns="hazardColumns"
|
||||
@confirm="onHazardConfirm"
|
||||
@cancel="showHazardPicker = false"
|
||||
@close="showHazardPicker = false"
|
||||
></up-picker>
|
||||
|
||||
<up-datetime-picker
|
||||
:show="showDatePicker"
|
||||
v-model="dateValue"
|
||||
mode="datetime"
|
||||
@confirm="onDateConfirm"
|
||||
@cancel="showDatePicker = false"
|
||||
@close="showDatePicker = false"
|
||||
></up-datetime-picker>
|
||||
|
||||
<up-picker
|
||||
:show="showDeptPicker"
|
||||
:columns="deptColumns"
|
||||
@confirm="onDeptConfirm"
|
||||
@cancel="showDeptPicker = false"
|
||||
@close="showDeptPicker = false"
|
||||
></up-picker>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
@@ -454,6 +480,8 @@
|
||||
height: 90rpx;
|
||||
line-height: 90rpx;
|
||||
border-radius: 0;
|
||||
margin: 0 !important;
|
||||
padding: 0 !important;
|
||||
font-size: 30rpx;
|
||||
|
||||
&::after {
|
||||
|
||||
@@ -967,7 +967,7 @@ const addSelectedLibrary = async () => {
|
||||
try {
|
||||
// 遍历选中的检查库,获取详情
|
||||
for (const id of selectedLibraries.value) {
|
||||
const res = await getCheckItemListDetail({ itemId: id });
|
||||
const res = await getCheckItemListDetail({ id: id });
|
||||
if (res.code === 0 && res.data) {
|
||||
const records = res.data.records || [];
|
||||
const total = res.data.total || 0;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -3,13 +3,13 @@
|
||||
<view class="padding bg-white radius">
|
||||
<view class="text-gray margin-bottom">整改记录</view>
|
||||
<view class="padding solid radius">
|
||||
<view class="flex">
|
||||
<view>整改方案:</view>
|
||||
<view>{{ rectifyData.rectifyPlan || '暂无' }}</view>
|
||||
<view>
|
||||
<view style="color: #999; margin-bottom: 10rpx;">整改方案:</view>
|
||||
<view style="word-break: break-all; line-height: 1.6; color: #333;">{{ rectifyData.rectifyPlan || '暂无' }}</view>
|
||||
</view>
|
||||
<view class="flex margin-top-sm">
|
||||
<view>完成情况:</view>
|
||||
<view>{{ rectifyData.rectifyResult || '暂无' }}</view>
|
||||
<view class="margin-top">
|
||||
<view style="color: #999; margin-bottom: 10rpx;">完成情况:</view>
|
||||
<view style="word-break: break-all; line-height: 1.6; color: #333;">{{ rectifyData.rectifyResult || '暂无' }}</view>
|
||||
</view>
|
||||
<view class="margin-top-sm">
|
||||
<view>整改附件:</view>
|
||||
@@ -34,7 +34,44 @@
|
||||
<view class="flex margin-bottom margin-top">
|
||||
<view class="text-gray">验收图片/视频</view>
|
||||
</view>
|
||||
<up-upload :fileList="fileList1" @afterRead="afterRead" @delete="deletePic" name="1" multiple :maxCount="10"></up-upload>
|
||||
<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="flex justify-between margin-bottom margin-top-sm align-center">
|
||||
<view class="text-gray flex align-center">
|
||||
电子签名
|
||||
<view class="text-red">*</view>
|
||||
</view>
|
||||
<button v-if="showCanvas" class="cu-btn sm round line-blue" style="margin: 0; padding: 0 20rpx; height: 50rpx; font-size: 22rpx;" @click="clearSignature">清除重写</button>
|
||||
<button v-else class="cu-btn sm round line-blue" style="margin: 0; padding: 0 20rpx; height: 50rpx; font-size: 22rpx;" @click="reSign">重新签名</button>
|
||||
</view>
|
||||
<view class="signature-box margin-bottom">
|
||||
<view v-if="!showCanvas" class="signature-display flex align-center justify-center" style="width: 100%; height: 160px; background-color: #f8f8f8; display: flex; align-items: center; justify-content: center;">
|
||||
<image :src="signatureUrl" class="signature-img" mode="aspectFit" style="width: 100%; height: 100%;"></image>
|
||||
</view>
|
||||
<!-- 改为 v-if 解决小程序原生 canvas 真机渲染与生命周期挂载残留问题 -->
|
||||
<view v-if="showCanvas" class="signature-pad-wrap" style="border: 1px dashed #dcdfe6; border-radius: 8rpx; overflow: hidden; background-color: #f8f8f8;">
|
||||
<wd-signature
|
||||
ref="signatureRef"
|
||||
:width="signatureWidth"
|
||||
:height="160"
|
||||
backgroundColor="#f8f8f8"
|
||||
penColor="#000000"
|
||||
:lineWidth="3"
|
||||
:enableHistory="false"
|
||||
@confirm="(res) => onSignatureConfirm(res.tempFilePath)"
|
||||
@start="isSignatureEmpty = false"
|
||||
@signing="isSignatureEmpty = false"
|
||||
@clear="isSignatureEmpty = true"
|
||||
>
|
||||
<template #footer></template>
|
||||
</wd-signature>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="flex margin-top-xl" style="gap: 20rpx;">
|
||||
<button class="round flex-sub" @click="handleCancel">取消</button>
|
||||
<button class="bg-blue round flex-sub" @click="handleSubmit">提交验收</button>
|
||||
@@ -44,10 +81,11 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, reactive } from 'vue';
|
||||
import { ref, reactive, watch, nextTick, getCurrentInstance } from 'vue';
|
||||
import { onLoad } from '@dcloudio/uni-app';
|
||||
import { acceptanceRectification, getHiddenDangerDetail } from '@/request/api.js';
|
||||
import { baseUrl, getToken, toImageUrl } from '@/request/request.js';
|
||||
import { baseUrl, getToken, toImageUrl, imageBaseUrl } from '@/request/request.js';
|
||||
import { addTimestampWatermark } from '@/utils/watermark.js';
|
||||
|
||||
// 页面参数
|
||||
const rectifyId = ref('');
|
||||
@@ -71,6 +109,27 @@
|
||||
|
||||
const fileList1 = ref([]);
|
||||
|
||||
// 防作弊时间戳水印 Canvas 大小配置
|
||||
const canvasWidth = ref(300);
|
||||
const canvasHeight = ref(300);
|
||||
|
||||
// 电子签名及草稿相关
|
||||
const showCanvas = ref(true); // 是否显示签字画板
|
||||
const signatureUrl = ref(''); // 签名完整预览地址
|
||||
const signatureServerPath = ref(''); // 签名服务器相对路径
|
||||
const signatureWidth = ref(340); // 签名画板宽度(动态计算)
|
||||
const signatureRef = ref(null); // 签名组件 ref
|
||||
const isSignatureEmpty = ref(true); // 签名是否为空
|
||||
const isSubmitting = ref(false); // 是否正在提交表单
|
||||
|
||||
const hasDraft = ref(false);
|
||||
const showRestoreBanner = ref(false); // 独立控制提示 Banner
|
||||
const isRestoring = ref(false); // 正在恢复标志
|
||||
const isInitialized = ref(false); // 初始化标识
|
||||
const signaturePaths = ref([]); // 缓存手写签名的绘制路径
|
||||
|
||||
const getDraftKey = () => `draft_accept_${rectifyId.value || ''}`;
|
||||
|
||||
// 获取完整图片路径
|
||||
const getFullPath = (filePath) => {
|
||||
if (!filePath) return '';
|
||||
@@ -148,7 +207,38 @@
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// 电子签名验证与处理
|
||||
if (showCanvas.value) {
|
||||
if (!signatureRef.value || isSignatureEmpty.value) {
|
||||
uni.showToast({
|
||||
title: '请进行电子签名',
|
||||
icon: 'none'
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
isSubmitting.value = true;
|
||||
uni.showLoading({ title: '正在提交...', mask: true });
|
||||
// 触发组件导出,导出成功会回调 onSignatureConfirm
|
||||
signatureRef.value.confirm();
|
||||
} else {
|
||||
// 已经有回显的签名
|
||||
if (!signatureServerPath.value) {
|
||||
uni.showToast({
|
||||
title: '请进行电子签名',
|
||||
icon: 'none'
|
||||
});
|
||||
return;
|
||||
}
|
||||
isSubmitting.value = true;
|
||||
uni.showLoading({ title: '正在提交...', mask: true });
|
||||
await executeSubmit();
|
||||
}
|
||||
};
|
||||
|
||||
// 真正调取后台接口提交验收
|
||||
const executeSubmit = async () => {
|
||||
// 构建附件列表
|
||||
const attachments = fileList1.value.map(file => {
|
||||
let url = '';
|
||||
@@ -157,6 +247,10 @@
|
||||
} else if (file.url && typeof file.url === 'object') {
|
||||
url = file.url.url || file.url.path || '';
|
||||
}
|
||||
// 将预览绝对路径还原为服务端相对路径,避免后端保存带域名的绝对地址
|
||||
if (typeof url === 'string' && url.startsWith('http')) {
|
||||
url = url.replace(imageBaseUrl, '');
|
||||
}
|
||||
const fileName = (typeof url === 'string' && url) ? url.split('/').pop() : (file.name || '');
|
||||
return {
|
||||
fileName: fileName || '',
|
||||
@@ -170,14 +264,17 @@
|
||||
rectifyId: Number(rectifyId.value),
|
||||
result: formData.result,
|
||||
verifyRemark: formData.verifyRemark || '',
|
||||
attachments: attachments
|
||||
attachments: attachments,
|
||||
signPath: signatureServerPath.value || '' // 电子签名路径
|
||||
};
|
||||
|
||||
console.log('提交验收参数:', params);
|
||||
|
||||
try {
|
||||
const res = await acceptanceRectification(params);
|
||||
uni.hideLoading();
|
||||
if (res.code === 0) {
|
||||
clearDraft(false);
|
||||
uni.showToast({
|
||||
title: '验收成功',
|
||||
icon: 'success'
|
||||
@@ -192,11 +289,14 @@
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
uni.hideLoading();
|
||||
console.error('验收失败:', error);
|
||||
uni.showToast({
|
||||
title: '请求失败',
|
||||
icon: 'none'
|
||||
});
|
||||
} finally {
|
||||
isSubmitting.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -206,6 +306,23 @@
|
||||
};
|
||||
|
||||
// 新增图片
|
||||
/**
|
||||
* 在前端为图片进行实时渲染,添加当前系统时间戳水印(防作弊)
|
||||
* @param {string} tempFilePath 原始选择的图片临时路径
|
||||
* @returns {Promise<string>} 渲染后的带水印图片临时文件路径
|
||||
*/
|
||||
const addWatermark = (tempFilePath) => {
|
||||
const instance = getCurrentInstance();
|
||||
return addTimestampWatermark({
|
||||
tempFilePath,
|
||||
canvasId: 'watermarkCanvas',
|
||||
canvasWidthRef: canvasWidth,
|
||||
canvasHeightRef: canvasHeight,
|
||||
instance
|
||||
});
|
||||
};
|
||||
|
||||
// 新增图片(自动加入实时前端水印渲染防作弊功能)
|
||||
const afterRead = async (event) => {
|
||||
let lists = [].concat(event.file);
|
||||
let fileListLen = fileList1.value.length;
|
||||
@@ -213,46 +330,276 @@
|
||||
fileList1.value.push({
|
||||
...item,
|
||||
status: 'uploading',
|
||||
message: '上传中',
|
||||
message: '处理中...',
|
||||
});
|
||||
});
|
||||
for (let i = 0; i < lists.length; i++) {
|
||||
const result = await uploadFilePromise(lists[i].url);
|
||||
let item = fileList1.value[fileListLen];
|
||||
fileList1.value.splice(fileListLen, 1, {
|
||||
...item,
|
||||
status: 'success',
|
||||
message: '',
|
||||
url: result,
|
||||
});
|
||||
try {
|
||||
// 1. 进行前端实时渲染绘制水印,得到新图片临时路径
|
||||
const watermarkedUrl = await addWatermark(lists[i].url);
|
||||
|
||||
// 2. 将加完水印的新图片进行服务器上传
|
||||
const result = await uploadFilePromise(watermarkedUrl);
|
||||
|
||||
let item = fileList1.value[fileListLen];
|
||||
fileList1.value.splice(fileListLen, 1, {
|
||||
...item,
|
||||
status: 'success',
|
||||
message: '',
|
||||
url: toImageUrl(result.url || result.filePath || result),
|
||||
});
|
||||
} catch (e) {
|
||||
console.error('加水印或上传失败:', e);
|
||||
let item = fileList1.value[fileListLen];
|
||||
fileList1.value.splice(fileListLen, 1, {
|
||||
...item,
|
||||
status: 'failed',
|
||||
message: '处理失败',
|
||||
});
|
||||
}
|
||||
fileListLen++;
|
||||
}
|
||||
};
|
||||
|
||||
const uploadFilePromise = (filePath) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
uni.uploadFile({
|
||||
url: baseUrl + '/frontend/attachment/upload',
|
||||
filePath: filePath,
|
||||
name: 'file',
|
||||
header: {
|
||||
'Authorization': getToken()
|
||||
},
|
||||
success: (res) => {
|
||||
const data = JSON.parse(res.data);
|
||||
if (data.code === 0) {
|
||||
resolve(data.data);
|
||||
} else {
|
||||
reject(data.msg || '上传失败');
|
||||
}
|
||||
},
|
||||
fail: (err) => {
|
||||
console.error('上传失败:', err);
|
||||
reject(err);
|
||||
}
|
||||
});
|
||||
uni.uploadFile({
|
||||
url: baseUrl + '/frontend/attachment/upload',
|
||||
filePath: filePath,
|
||||
name: 'file',
|
||||
header: {
|
||||
'Authorization': getToken()
|
||||
},
|
||||
success: (res) => {
|
||||
const data = JSON.parse(res.data);
|
||||
if (data.code === 0) {
|
||||
resolve(data.data);
|
||||
} else {
|
||||
reject(data.msg || '上传失败');
|
||||
}
|
||||
},
|
||||
fail: (err) => {
|
||||
console.error('上传失败:', err);
|
||||
reject(err);
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
// 电子签名画布手写线条变动回调
|
||||
const onSignatureChange = () => {
|
||||
isSignatureEmpty.value = false;
|
||||
signaturePaths.value = [];
|
||||
if (rectifyId.value) {
|
||||
saveDraft();
|
||||
}
|
||||
};
|
||||
|
||||
// 保存草稿
|
||||
const saveDraft = () => {
|
||||
if (isRestoring.value || !isInitialized.value) return;
|
||||
const key = getDraftKey();
|
||||
const hasContent = formData.verifyRemark ||
|
||||
fileList1.value.length > 0 ||
|
||||
signatureServerPath.value ||
|
||||
signaturePaths.value.length > 0;
|
||||
if (!hasContent) {
|
||||
uni.removeStorageSync(key);
|
||||
hasDraft.value = false;
|
||||
return;
|
||||
}
|
||||
|
||||
const data = {
|
||||
formData: {
|
||||
result: formData.result,
|
||||
verifyRemark: formData.verifyRemark
|
||||
},
|
||||
fileList1: fileList1.value,
|
||||
signatureServerPath: signatureServerPath.value,
|
||||
signatureUrl: signatureUrl.value,
|
||||
showCanvas: showCanvas.value,
|
||||
signaturePaths: signaturePaths.value
|
||||
};
|
||||
uni.setStorageSync(key, JSON.stringify(data));
|
||||
hasDraft.value = true;
|
||||
};
|
||||
|
||||
// 清空草稿
|
||||
const clearDraft = (showToast = true) => {
|
||||
const key = getDraftKey();
|
||||
uni.removeStorageSync(key);
|
||||
hasDraft.value = false;
|
||||
showRestoreBanner.value = false;
|
||||
|
||||
isRestoring.value = true;
|
||||
formData.result = 1;
|
||||
formData.verifyRemark = '';
|
||||
fileList1.value = [];
|
||||
signatureServerPath.value = '';
|
||||
signatureUrl.value = '';
|
||||
showCanvas.value = true;
|
||||
signaturePaths.value = [];
|
||||
if (signatureRef.value) {
|
||||
signatureRef.value.clear();
|
||||
}
|
||||
|
||||
nextTick(() => {
|
||||
isRestoring.value = false;
|
||||
});
|
||||
if (showToast) {
|
||||
uni.showToast({ title: '草稿已清空', icon: 'none' });
|
||||
}
|
||||
};
|
||||
|
||||
// 恢复草稿
|
||||
const restoreDraft = () => {
|
||||
const key = getDraftKey();
|
||||
const cached = uni.getStorageSync(key);
|
||||
if (cached) {
|
||||
try {
|
||||
const data = JSON.parse(cached);
|
||||
const hasContent = data.formData.verifyRemark ||
|
||||
(data.fileList1 && data.fileList1.length > 0) ||
|
||||
data.signatureServerPath ||
|
||||
(data.signaturePaths && data.signaturePaths.length > 0);
|
||||
if (!hasContent) {
|
||||
isInitialized.value = true;
|
||||
return;
|
||||
}
|
||||
|
||||
isRestoring.value = true;
|
||||
formData.result = data.formData.result !== undefined ? data.formData.result : 1;
|
||||
formData.verifyRemark = data.formData.verifyRemark || '';
|
||||
fileList1.value = data.fileList1 || [];
|
||||
signatureServerPath.value = data.signatureServerPath || '';
|
||||
signatureUrl.value = data.signatureUrl || '';
|
||||
showCanvas.value = data.showCanvas !== undefined ? data.showCanvas : true;
|
||||
signaturePaths.value = data.signaturePaths || [];
|
||||
hasDraft.value = true;
|
||||
showRestoreBanner.value = true;
|
||||
|
||||
// 延迟恢复签名画布线条重绘
|
||||
if (signaturePaths.value.length > 0) {
|
||||
setTimeout(() => {
|
||||
if (signatureRef.value) {
|
||||
isSignatureEmpty.value = false;
|
||||
// wot-design-uni auto rendering
|
||||
}
|
||||
}, 450);
|
||||
}
|
||||
|
||||
nextTick(() => {
|
||||
isRestoring.value = false;
|
||||
isInitialized.value = true;
|
||||
});
|
||||
|
||||
uni.showToast({
|
||||
title: '已自动恢复您上次未提交的内容',
|
||||
icon: 'none',
|
||||
duration: 2500
|
||||
});
|
||||
} catch (e) {
|
||||
console.error('解析草稿失败:', e);
|
||||
isRestoring.value = false;
|
||||
isInitialized.value = true;
|
||||
}
|
||||
} else {
|
||||
isInitialized.value = true;
|
||||
}
|
||||
};
|
||||
|
||||
// 深度监听验收项和签名笔画变化,自动保存草稿
|
||||
watch(
|
||||
() => [
|
||||
formData.result,
|
||||
formData.verifyRemark,
|
||||
fileList1.value,
|
||||
signatureServerPath.value,
|
||||
signaturePaths.value
|
||||
],
|
||||
() => {
|
||||
if (rectifyId.value) {
|
||||
saveDraft();
|
||||
}
|
||||
},
|
||||
{ deep: true }
|
||||
);
|
||||
|
||||
// 清除画布
|
||||
const clearSignature = () => {
|
||||
isSignatureEmpty.value = true;
|
||||
if (signatureRef.value) {
|
||||
signatureRef.value.clear();
|
||||
}
|
||||
};
|
||||
|
||||
// 重新签字
|
||||
const reSign = () => {
|
||||
isSignatureEmpty.value = true;
|
||||
showCanvas.value = true;
|
||||
signatureUrl.value = '';
|
||||
signatureServerPath.value = '';
|
||||
nextTick(() => {
|
||||
if (signatureRef.value) {
|
||||
signatureRef.value.clear();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
// 签名导出失败
|
||||
const onSignatureError = (err) => {
|
||||
console.error('签名绘制失败:', err);
|
||||
uni.showToast({ title: '签名生成失败', icon: 'none' });
|
||||
isSubmitting.value = false;
|
||||
uni.hideLoading();
|
||||
};
|
||||
|
||||
// 签名导出成功回调
|
||||
const onSignatureConfirm = async (tempFilePath) => {
|
||||
try {
|
||||
// 上传签名
|
||||
const res = await uploadFilePromise(tempFilePath);
|
||||
// 兼容后端返回对象或者单纯字符串路径
|
||||
const path = (res && typeof res === 'object') ? (res.url || res.filePath || '') : (res || '');
|
||||
signatureServerPath.value = path;
|
||||
signatureUrl.value = path.startsWith('http') ? path : (baseUrl.replace('/api', '') + path);
|
||||
|
||||
if (isSubmitting.value) {
|
||||
await executeSubmit();
|
||||
}
|
||||
} catch (err) {
|
||||
isSubmitting.value = false;
|
||||
uni.hideLoading();
|
||||
console.error('签名上传失败:', err);
|
||||
uni.showToast({ title: '签名上传失败,请重试', icon: 'none' });
|
||||
}
|
||||
};
|
||||
|
||||
onLoad((options) => {
|
||||
// 计算签名画布宽度
|
||||
try {
|
||||
const sysInfo = uni.getSystemInfoSync();
|
||||
signatureWidth.value = sysInfo.windowWidth - 40;
|
||||
} catch (e) {
|
||||
console.error('获取系统信息失败:', e);
|
||||
}
|
||||
if (options.rectifyId) {
|
||||
rectifyId.value = options.rectifyId;
|
||||
}
|
||||
if (options.hazardId) {
|
||||
hazardId.value = options.hazardId;
|
||||
}
|
||||
if (options.assignId) {
|
||||
assignId.value = options.assignId;
|
||||
}
|
||||
console.log('验收页面参数:', { rectifyId: rectifyId.value, hazardId: hazardId.value, assignId: assignId.value });
|
||||
|
||||
// 获取隐患详情
|
||||
fetchDetail();
|
||||
|
||||
// 页面打开时自动恢复草稿
|
||||
restoreDraft();
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
@@ -279,4 +626,24 @@
|
||||
color: #fff;
|
||||
}
|
||||
}
|
||||
|
||||
// 签名相关样式
|
||||
.signature-box {
|
||||
width: 100%;
|
||||
min-height: 240rpx;
|
||||
background: #f8f8f8;
|
||||
border: 1rpx dashed #dcdfe6;
|
||||
border-radius: 8rpx;
|
||||
margin-top: 16rpx;
|
||||
|
||||
.signature-img {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.signature-placeholder {
|
||||
color: #909399;
|
||||
font-size: 28rpx;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -1,6 +1,14 @@
|
||||
<template>
|
||||
<view class="padding page">
|
||||
<view class="padding radius bg-white">
|
||||
<!-- 草稿恢复提示 -->
|
||||
<view v-if="showRestoreBanner" class="bg-orange-light text-orange padding-sm radius margin-bottom flex justify-between align-center" style="font-size: 24rpx; background-color: #FFF7EB; border: 1rpx solid #FFE4CC; width: 100%; box-sizing: border-box; display: flex; flex-direction: row; justify-content: space-between; align-items: center; margin-bottom: 20rpx;">
|
||||
<view class="flex align-center" style="display: flex; flex-direction: row; align-items: center;">
|
||||
<text class="cuIcon-info margin-right-xs" style="margin-right: 10rpx;"></text>
|
||||
<text>已自动恢复您上次未提交的内容</text>
|
||||
</view>
|
||||
<text class="text-blue text-bold" style="cursor: pointer; padding: 0 10rpx; color: #2667E9; font-weight: bold;" @click="clearDraft(true)">清空草稿</text>
|
||||
</view>
|
||||
<view class="flex margin-bottom">
|
||||
<view class="text-gray">整改人员</view>
|
||||
<view class="text-red">*</view>
|
||||
@@ -41,7 +49,7 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, reactive } from 'vue';
|
||||
import { ref, reactive, watch, nextTick } from 'vue';
|
||||
import { onLoad } from '@dcloudio/uni-app';
|
||||
import { getDepartmentPersonUsers,assignHiddenDanger } from '@/request/api.js';
|
||||
|
||||
@@ -144,6 +152,7 @@
|
||||
try {
|
||||
const res = await assignHiddenDanger(params);
|
||||
if (res.code === 0) {
|
||||
clearDraft(false);
|
||||
uni.showToast({ title: '交办成功', icon: 'success' });
|
||||
setTimeout(() => {
|
||||
uni.navigateBack();
|
||||
@@ -157,10 +166,99 @@
|
||||
}
|
||||
};
|
||||
|
||||
// 草稿缓存与恢复逻辑 (移至底部以确保 formData 等响应式状态已被正常定义)
|
||||
const hasDraft = ref(false);
|
||||
const showRestoreBanner = ref(false); // 独立控制提示 Banner,仅在初次确实从本地恢复了内容时才显示
|
||||
const isRestoring = ref(false); // 正在恢复标志,避免触发冗余watch
|
||||
const getDraftKey = () => `draft_assign_${hazardId.value || ''}`;
|
||||
|
||||
// 保存草稿 (排除选择器人员缓存,仅缓存整改期限日期值)
|
||||
const saveDraft = () => {
|
||||
if (isRestoring.value) return;
|
||||
const key = getDraftKey();
|
||||
const hasContent = selectedDate.value;
|
||||
if (!hasContent) {
|
||||
uni.removeStorageSync(key);
|
||||
hasDraft.value = false;
|
||||
return;
|
||||
}
|
||||
|
||||
const data = {
|
||||
selectedDate: selectedDate.value,
|
||||
dateValue: dateValue.value
|
||||
};
|
||||
uni.setStorageSync(key, JSON.stringify(data));
|
||||
hasDraft.value = true;
|
||||
};
|
||||
|
||||
// 清空草稿
|
||||
const clearDraft = (showToast = true) => {
|
||||
const key = getDraftKey();
|
||||
uni.removeStorageSync(key);
|
||||
hasDraft.value = false;
|
||||
showRestoreBanner.value = false;
|
||||
|
||||
isRestoring.value = true;
|
||||
selectedDate.value = '';
|
||||
dateValue.value = Date.now();
|
||||
|
||||
nextTick(() => {
|
||||
isRestoring.value = false;
|
||||
});
|
||||
if (showToast) {
|
||||
uni.showToast({ title: '草稿已清空', icon: 'none' });
|
||||
}
|
||||
};
|
||||
|
||||
// 恢复草稿
|
||||
const restoreDraft = () => {
|
||||
const key = getDraftKey();
|
||||
const cached = uni.getStorageSync(key);
|
||||
if (cached) {
|
||||
try {
|
||||
const data = JSON.parse(cached);
|
||||
const hasContent = data.selectedDate;
|
||||
if (!hasContent) return;
|
||||
|
||||
isRestoring.value = true;
|
||||
selectedDate.value = data.selectedDate || '';
|
||||
dateValue.value = data.dateValue || Date.now();
|
||||
hasDraft.value = true;
|
||||
showRestoreBanner.value = true; // 确实存在内容并恢复了,才亮起提示 Banner
|
||||
|
||||
nextTick(() => {
|
||||
isRestoring.value = false;
|
||||
});
|
||||
|
||||
uni.showToast({
|
||||
title: '已自动恢复您上次未提交的内容',
|
||||
icon: 'none',
|
||||
duration: 2500
|
||||
});
|
||||
} catch (e) {
|
||||
console.error('解析草稿失败:', e);
|
||||
isRestoring.value = false;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// 监听变量变化,自动保存草稿
|
||||
watch(
|
||||
() => [selectedDate.value],
|
||||
() => {
|
||||
if (hazardId.value) {
|
||||
saveDraft();
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
onLoad((options) => {
|
||||
if (options.hazardId) hazardId.value = options.hazardId;
|
||||
if (options.assignId) assignId.value = options.assignId;
|
||||
fetchDeptUsers();
|
||||
|
||||
// 恢复草稿 (不恢复任何人员选择器数据)
|
||||
restoreDraft();
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
@@ -1,6 +1,14 @@
|
||||
<template>
|
||||
<view class="page padding">
|
||||
<view class="padding bg-white radius">
|
||||
<!-- 草稿恢复提示 -->
|
||||
<view v-if="showRestoreBanner" class="bg-orange-light text-orange padding-sm radius margin-bottom flex justify-between align-center" style="font-size: 24rpx; background-color: #FFF7EB; border: 1rpx solid #FFE4CC; width: 100%; box-sizing: border-box; display: flex; flex-direction: row; justify-content: space-between; align-items: center; margin-bottom: 20rpx;">
|
||||
<view class="flex align-center" style="display: flex; flex-direction: row; align-items: center;">
|
||||
<text class="cuIcon-info margin-right-xs" style="margin-right: 10rpx;"></text>
|
||||
<text>已自动恢复您上次未提交的内容</text>
|
||||
</view>
|
||||
<text class="text-blue text-bold" style="cursor: pointer; padding: 0 10rpx; color: #2667E9; font-weight: bold;" @click="clearDraft(true)">清空草稿</text>
|
||||
</view>
|
||||
<view class="form-header margin-bottom">
|
||||
<view class="form-label">
|
||||
<view class="text-gray">整改方案</view>
|
||||
@@ -51,7 +59,7 @@
|
||||
<view class="popup-title text-bold">选择整改人员</view>
|
||||
<view class="popup-close" @click="showUserPopup = false">×</view>
|
||||
</view>
|
||||
<view class="popup-body">
|
||||
<scroll-view class="popup-body" scroll-y="true">
|
||||
<up-checkbox-group v-model="selectedUserIds" placement="column" @change="onUserChange">
|
||||
<view class="user-item" v-for="item in cateList" :key="item.id">
|
||||
<up-checkbox
|
||||
@@ -62,7 +70,7 @@
|
||||
></up-checkbox>
|
||||
</view>
|
||||
</up-checkbox-group>
|
||||
</view>
|
||||
</scroll-view>
|
||||
<view class="popup-footer">
|
||||
<button class="btn-cancel" @click="showUserPopup = false">取消</button>
|
||||
<button class="btn-confirm bg-blue" @click="confirmUserSelect">确定</button>
|
||||
@@ -71,21 +79,57 @@
|
||||
</u-popup>
|
||||
|
||||
<view class="form-label margin-bottom margin-top">
|
||||
<view class="text-gray">整改图片/视频</view>
|
||||
<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="form-label margin-bottom margin-top flex justify-between align-center" style="width: 100%;">
|
||||
<view class="flex align-center">
|
||||
<view class="text-gray">电子签名</view>
|
||||
<view class="text-red">*</view>
|
||||
</view>
|
||||
<button v-if="showCanvas" class="cu-btn sm round line-blue" style="margin: 0; padding: 0 20rpx; height: 50rpx; font-size: 22rpx;" @click="clearSignature">清除重写</button>
|
||||
<button v-else class="cu-btn sm round line-blue" style="margin: 0; padding: 0 20rpx; height: 50rpx; font-size: 22rpx;" @click="reSign">重新签名</button>
|
||||
</view>
|
||||
<view class="signature-box margin-bottom">
|
||||
<view v-if="!showCanvas" class="signature-display flex align-center justify-center">
|
||||
<image :src="signatureUrl" class="signature-img" mode="aspectFit"></image>
|
||||
</view>
|
||||
<!-- 改为 v-if 并在人员多选弹窗打开时卸载 Canvas,解决微信原生 canvas 真机穿透盖住弹窗的问题 -->
|
||||
<view v-if="showCanvas && !showUserPopup" class="signature-pad-wrap">
|
||||
<wd-signature
|
||||
ref="signatureRef"
|
||||
:width="signatureWidth"
|
||||
:height="160"
|
||||
backgroundColor="#f8f8f8"
|
||||
penColor="#000000"
|
||||
:lineWidth="3"
|
||||
:enableHistory="false"
|
||||
@confirm="(res) => onSignatureConfirm(res.tempFilePath)"
|
||||
@start="isSignatureEmpty = false"
|
||||
@signing="isSignatureEmpty = false"
|
||||
@clear="isSignatureEmpty = true"
|
||||
>
|
||||
<template #footer></template>
|
||||
</wd-signature>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<button class="bg-blue round margin-top-xl" @click="handleSubmit">{{ isEdit ? '保存修改' : '提交整改' }}</button>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import {ref,reactive,computed} from 'vue'
|
||||
import {ref,reactive,computed,nextTick,watch,getCurrentInstance} from 'vue'
|
||||
import {onLoad} from '@dcloudio/uni-app'
|
||||
import {submitRectification,getDepartmentPersonUsers,getRectifyDetail,getDeptUsersWithSubordinates,getHiddenDangerDetail,generateRectifyPlan} from '@/request/api.js'
|
||||
import {baseUrl,getToken} from '@/request/request.js'
|
||||
import {baseUrl,getToken,toImageUrl,toRelativeFilePath} from '@/request/request.js'
|
||||
import {addTimestampWatermark} from '@/utils/watermark.js'
|
||||
|
||||
// 从页面参数获取的ID
|
||||
const hazardId = ref('');
|
||||
@@ -93,6 +137,48 @@
|
||||
const rectifyId = ref(''); // 整改ID(编辑模式时使用)
|
||||
const isEdit = ref(false); // 是否为编辑模式
|
||||
|
||||
// 防作弊时间戳水印 Canvas 大小配置
|
||||
const canvasWidth = ref(300);
|
||||
const canvasHeight = ref(300);
|
||||
|
||||
// 电子签名相关
|
||||
const showCanvas = ref(true); // 是否显示签字画板
|
||||
const signatureUrl = ref(''); // 签名完整预览地址
|
||||
const signatureServerPath = ref(''); // 签名服务器相对路径
|
||||
const signatureWidth = ref(340); // 签名画板宽度(动态计算)
|
||||
const signatureRef = ref(null); // 签名组件 ref
|
||||
const isSignatureEmpty = ref(true); // 签名是否为空
|
||||
const isSubmitting = ref(false); // 是否正在提交表单
|
||||
|
||||
// 清除画布
|
||||
const clearSignature = () => {
|
||||
isSignatureEmpty.value = true;
|
||||
if (signatureRef.value) {
|
||||
signatureRef.value.clear();
|
||||
}
|
||||
};
|
||||
|
||||
// 重新签字
|
||||
const reSign = () => {
|
||||
isSignatureEmpty.value = true;
|
||||
showCanvas.value = true;
|
||||
signatureUrl.value = '';
|
||||
signatureServerPath.value = '';
|
||||
nextTick(() => {
|
||||
if (signatureRef.value) {
|
||||
signatureRef.value.clear();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
// 签名导出失败
|
||||
const onSignatureError = (err) => {
|
||||
console.error('签名绘制失败:', err);
|
||||
uni.showToast({ title: '签名生成失败', icon: 'none' });
|
||||
isSubmitting.value = false;
|
||||
uni.hideLoading();
|
||||
};
|
||||
|
||||
// 表单数据
|
||||
const formData = reactive({
|
||||
rectifyPlan: '', // 整改方案
|
||||
@@ -181,13 +267,30 @@
|
||||
});
|
||||
});
|
||||
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?.filePath || result?.path || '');
|
||||
fileList1.value.splice(fileListLen, 1, {
|
||||
...item,
|
||||
status: 'success',
|
||||
message: '',
|
||||
url: result,
|
||||
url: toImageUrl(serverPath),
|
||||
serverPath,
|
||||
});
|
||||
fileListLen++;
|
||||
}
|
||||
@@ -219,6 +322,89 @@
|
||||
};
|
||||
|
||||
// 提交整改
|
||||
// 真正的提交接口请求
|
||||
const executeSubmit = async () => {
|
||||
// 构建附件列表
|
||||
const attachments = fileList1.value.map(file => {
|
||||
const path = toRelativeFilePath(file.serverPath || file.filePath || file.url || '');
|
||||
const fileName = path ? path.split('/').pop() : (file.name || '');
|
||||
return {
|
||||
fileName: fileName || '',
|
||||
filePath: path || '',
|
||||
fileType: file.type || 'image/png',
|
||||
fileSize: file.size || 0
|
||||
};
|
||||
});
|
||||
|
||||
const params = {
|
||||
hazardId: hazardId.value,
|
||||
assignId: assignId.value,
|
||||
rectifyPlan: formData.rectifyPlan,
|
||||
rectifyResult: formData.rectifyResult,
|
||||
planCost: Number(formData.planCost) || 0,
|
||||
actualCost: Number(formData.actualCost) || 0,
|
||||
attachments: attachments,
|
||||
// 整改人员ID数组
|
||||
rectifyUserIds: selectedUserIds.value.map(id => Number(id)),
|
||||
signPath: signatureServerPath.value || '' // 电子签名路径
|
||||
};
|
||||
|
||||
// 编辑模式需要传递rectifyId
|
||||
if (rectifyId.value) {
|
||||
params.rectifyId = rectifyId.value;
|
||||
}
|
||||
|
||||
try {
|
||||
const res = await submitRectification(params);
|
||||
uni.hideLoading();
|
||||
if (res.code === 0) {
|
||||
clearDraft(false);
|
||||
uni.showToast({
|
||||
title: isEdit.value ? '保存成功' : '提交成功',
|
||||
icon: 'success'
|
||||
});
|
||||
setTimeout(() => {
|
||||
uni.navigateBack();
|
||||
}, 1500);
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: res.msg || (isEdit.value ? '保存失败' : '提交失败'),
|
||||
icon: 'none'
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
uni.hideLoading();
|
||||
console.error('提交整改失败:', error);
|
||||
uni.showToast({
|
||||
title: '操作失败',
|
||||
icon: 'none'
|
||||
});
|
||||
} finally {
|
||||
isSubmitting.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
// 签名导出成功回调
|
||||
const onSignatureConfirm = async (tempFilePath) => {
|
||||
try {
|
||||
// 上传签名
|
||||
const res = await uploadFilePromise(tempFilePath);
|
||||
const path = (res && typeof res === 'object') ? (res.url || res.filePath || '') : (res || '');
|
||||
signatureServerPath.value = toRelativeFilePath(path);
|
||||
signatureUrl.value = toImageUrl(signatureServerPath.value);
|
||||
|
||||
if (isSubmitting.value) {
|
||||
await executeSubmit();
|
||||
}
|
||||
} catch (err) {
|
||||
isSubmitting.value = false;
|
||||
uni.hideLoading();
|
||||
console.error('签名上传失败:', err);
|
||||
uni.showToast({ title: '签名上传失败,请重试', icon: 'none' });
|
||||
}
|
||||
};
|
||||
|
||||
// 提交整改(触发签名导出或直接提交)
|
||||
const handleSubmit = async () => {
|
||||
if (!formData.rectifyPlan) {
|
||||
uni.showToast({
|
||||
@@ -242,18 +428,65 @@
|
||||
return;
|
||||
}
|
||||
|
||||
// 电子签名验证与处理
|
||||
if (showCanvas.value) {
|
||||
if (!signatureRef.value || isSignatureEmpty.value) {
|
||||
uni.showToast({
|
||||
title: '请进行电子签名',
|
||||
icon: 'none'
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
isSubmitting.value = true;
|
||||
uni.showLoading({ title: '正在提交...', mask: true });
|
||||
// 触发组件导出,导出成功会回调 onSignatureConfirm
|
||||
signatureRef.value.confirm();
|
||||
} else {
|
||||
// 已经有回显的签名
|
||||
if (!signatureServerPath.value) {
|
||||
uni.showToast({
|
||||
title: '请进行电子签名',
|
||||
icon: 'none'
|
||||
});
|
||||
return;
|
||||
}
|
||||
isSubmitting.value = true;
|
||||
uni.showLoading({ title: '正在提交...', mask: true });
|
||||
await executeSubmit();
|
||||
}
|
||||
};
|
||||
|
||||
const handleSubmitOld = async () => {
|
||||
if (!formData.rectifyPlan) {
|
||||
uni.showToast({
|
||||
title: '请输入整改方案',
|
||||
icon: 'none'
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (!formData.rectifyResult) {
|
||||
uni.showToast({
|
||||
title: '请输入整改完成情况',
|
||||
icon: 'none'
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (selectedUsers.value.length === 0) {
|
||||
uni.showToast({
|
||||
title: '请选择整改人员',
|
||||
icon: 'none'
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
// 构建附件列表
|
||||
const attachments = fileList1.value.map(file => {
|
||||
let url = '';
|
||||
if (typeof file.url === 'string') {
|
||||
url = file.url;
|
||||
} else if (file.url && typeof file.url === 'object') {
|
||||
url = file.url.url || file.url.path || '';
|
||||
}
|
||||
const fileName = (typeof url === 'string' && url) ? url.split('/').pop() : (file.name || '');
|
||||
const path = toRelativeFilePath(file.serverPath || file.filePath || file.url || '');
|
||||
const fileName = path ? path.split('/').pop() : (file.name || '');
|
||||
return {
|
||||
fileName: fileName || '',
|
||||
filePath: url || '',
|
||||
filePath: path || '',
|
||||
fileType: file.type || 'image/png',
|
||||
fileSize: file.size || 0
|
||||
};
|
||||
@@ -316,20 +549,31 @@
|
||||
formData.planCost = data.planCost ? String(data.planCost) : '';
|
||||
formData.actualCost = data.actualCost ? String(data.actualCost) : '';
|
||||
|
||||
// 回显电子签名(字段名暂定为 signPath,根据后端返回调整)
|
||||
if (data.signPath) {
|
||||
signatureServerPath.value = toRelativeFilePath(data.signPath);
|
||||
signatureUrl.value = toImageUrl(signatureServerPath.value);
|
||||
showCanvas.value = false;
|
||||
}
|
||||
|
||||
// 保存hazardId和assignId
|
||||
hazardId.value = data.hazardId || '';
|
||||
assignId.value = data.assignId || '';
|
||||
await fetchDeptUsers();
|
||||
|
||||
// 回显附件
|
||||
if (data.attachments && data.attachments.length > 0) {
|
||||
fileList1.value = data.attachments.map(att => ({
|
||||
url: att.filePath.startsWith('http') ? att.filePath : (baseUrl.replace('/api', '') + att.filePath),
|
||||
status: 'success',
|
||||
message: '',
|
||||
name: att.fileName,
|
||||
type: att.fileType,
|
||||
filePath: att.filePath // 保存原始路径用于提交
|
||||
}));
|
||||
fileList1.value = data.attachments.map(att => {
|
||||
const serverPath = toRelativeFilePath(att.filePath);
|
||||
return {
|
||||
url: toImageUrl(serverPath),
|
||||
status: 'success',
|
||||
message: '',
|
||||
name: att.fileName,
|
||||
type: att.fileType,
|
||||
serverPath,
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
// 回显整改人员(如果有)
|
||||
@@ -397,7 +641,167 @@
|
||||
}
|
||||
};
|
||||
|
||||
// 草稿缓存与恢复逻辑 (移至底部以确保 formData 等响应式状态已被正常定义)
|
||||
const hasDraft = ref(false);
|
||||
const showRestoreBanner = ref(false); // 独立控制提示 Banner,仅在初次确实从本地恢复了内容时才显示
|
||||
const isRestoring = ref(false); // 正在恢复标志,避免触发冗余watch
|
||||
const signaturePaths = ref([]); // 缓存手写签名的绘制路径
|
||||
const getDraftKey = () => `draft_rectify_${hazardId.value || ''}_${rectifyId.value || ''}`;
|
||||
|
||||
// 电子签名画布手写线条变动回调
|
||||
const onSignatureChange = () => {
|
||||
isSignatureEmpty.value = false;
|
||||
signaturePaths.value = [];
|
||||
if (hazardId.value || rectifyId.value) {
|
||||
saveDraft();
|
||||
}
|
||||
};
|
||||
|
||||
// 保存草稿 (排除选择器人员缓存,仅缓存方案、情况、金额、图片、签名等输入信息)
|
||||
const saveDraft = () => {
|
||||
if (isRestoring.value) return;
|
||||
const key = getDraftKey();
|
||||
const hasContent = formData.rectifyPlan ||
|
||||
formData.rectifyResult ||
|
||||
formData.planCost ||
|
||||
formData.actualCost ||
|
||||
fileList1.value.length > 0 ||
|
||||
signatureServerPath.value ||
|
||||
signaturePaths.value.length > 0;
|
||||
if (!hasContent) {
|
||||
uni.removeStorageSync(key);
|
||||
hasDraft.value = false;
|
||||
return;
|
||||
}
|
||||
|
||||
const data = {
|
||||
formData: {
|
||||
rectifyPlan: formData.rectifyPlan,
|
||||
rectifyResult: formData.rectifyResult,
|
||||
planCost: formData.planCost,
|
||||
actualCost: formData.actualCost
|
||||
},
|
||||
fileList1: fileList1.value,
|
||||
signatureServerPath: signatureServerPath.value,
|
||||
signatureUrl: signatureUrl.value,
|
||||
showCanvas: showCanvas.value,
|
||||
signaturePaths: signaturePaths.value
|
||||
};
|
||||
uni.setStorageSync(key, JSON.stringify(data));
|
||||
hasDraft.value = true;
|
||||
};
|
||||
|
||||
// 清空草稿
|
||||
const clearDraft = (showToast = true) => {
|
||||
const key = getDraftKey();
|
||||
uni.removeStorageSync(key);
|
||||
hasDraft.value = false;
|
||||
showRestoreBanner.value = false;
|
||||
|
||||
isRestoring.value = true;
|
||||
formData.rectifyPlan = '';
|
||||
formData.rectifyResult = '';
|
||||
formData.planCost = '';
|
||||
formData.actualCost = '';
|
||||
fileList1.value = [];
|
||||
signatureServerPath.value = '';
|
||||
signatureUrl.value = '';
|
||||
showCanvas.value = true;
|
||||
signaturePaths.value = [];
|
||||
if (signatureRef.value) {
|
||||
signatureRef.value.clear();
|
||||
}
|
||||
|
||||
nextTick(() => {
|
||||
isRestoring.value = false;
|
||||
});
|
||||
if (showToast) {
|
||||
uni.showToast({ title: '草稿已清空', icon: 'none' });
|
||||
}
|
||||
};
|
||||
|
||||
// 恢复草稿 (不恢复任何选择器数据)
|
||||
const restoreDraft = () => {
|
||||
const key = getDraftKey();
|
||||
const cached = uni.getStorageSync(key);
|
||||
if (cached) {
|
||||
try {
|
||||
const data = JSON.parse(cached);
|
||||
const hasContent = data.formData.rectifyPlan ||
|
||||
data.formData.rectifyResult ||
|
||||
data.formData.planCost ||
|
||||
data.formData.actualCost ||
|
||||
(data.fileList1 && data.fileList1.length > 0) ||
|
||||
data.signatureServerPath ||
|
||||
(data.signaturePaths && data.signaturePaths.length > 0);
|
||||
if (!hasContent) return;
|
||||
|
||||
isRestoring.value = true;
|
||||
formData.rectifyPlan = data.formData.rectifyPlan || '';
|
||||
formData.rectifyResult = data.formData.rectifyResult || '';
|
||||
formData.planCost = data.formData.planCost || '';
|
||||
formData.actualCost = data.formData.actualCost || '';
|
||||
fileList1.value = data.fileList1 || [];
|
||||
signatureServerPath.value = data.signatureServerPath || '';
|
||||
signatureUrl.value = data.signatureUrl || '';
|
||||
showCanvas.value = data.showCanvas !== undefined ? data.showCanvas : true;
|
||||
signaturePaths.value = data.signaturePaths || [];
|
||||
hasDraft.value = true;
|
||||
showRestoreBanner.value = true; // 确实存在内容并恢复了,才亮起提示 Banner
|
||||
|
||||
// 延迟恢复签名画布线条重绘,等待 Canvas 组件完全加载完毕
|
||||
if (signaturePaths.value.length > 0) {
|
||||
setTimeout(() => {
|
||||
if (signatureRef.value) {
|
||||
isSignatureEmpty.value = false;
|
||||
// wot-design-uni auto rendering
|
||||
}
|
||||
}, 450);
|
||||
}
|
||||
|
||||
nextTick(() => {
|
||||
isRestoring.value = false;
|
||||
});
|
||||
|
||||
uni.showToast({
|
||||
title: '已自动恢复您上次未提交的内容',
|
||||
icon: 'none',
|
||||
duration: 2500
|
||||
});
|
||||
} catch (e) {
|
||||
console.error('解析草稿失败:', e);
|
||||
isRestoring.value = false;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// 深度监听表单项和签名笔画变化,自动保存草稿
|
||||
watch(
|
||||
() => [
|
||||
formData.rectifyPlan,
|
||||
formData.rectifyResult,
|
||||
formData.planCost,
|
||||
formData.actualCost,
|
||||
fileList1.value,
|
||||
signatureServerPath.value,
|
||||
signaturePaths.value
|
||||
],
|
||||
() => {
|
||||
if (hazardId.value || rectifyId.value) {
|
||||
saveDraft();
|
||||
}
|
||||
},
|
||||
{ deep: true }
|
||||
);
|
||||
|
||||
onLoad((options) => {
|
||||
// 计算签名画布宽度
|
||||
try {
|
||||
const sysInfo = uni.getSystemInfoSync();
|
||||
signatureWidth.value = sysInfo.windowWidth - 40;
|
||||
} catch (e) {
|
||||
console.error('获取系统信息失败:', e);
|
||||
}
|
||||
if (options.hazardId) {
|
||||
hazardId.value = options.hazardId;
|
||||
}
|
||||
@@ -406,7 +810,7 @@
|
||||
}
|
||||
|
||||
// 在hazardId赋值后调用,确保有值
|
||||
fetchDeptUsers();
|
||||
if (!options.rectifyId) fetchDeptUsers();
|
||||
|
||||
// 编辑模式
|
||||
if (options.rectifyId) {
|
||||
@@ -414,6 +818,9 @@
|
||||
isEdit.value = options.isEdit === '1';
|
||||
// 获取整改详情
|
||||
fetchRectifyDetail();
|
||||
} else {
|
||||
// 页面打开时自动恢复草稿 (不包含选择器缓存,以防打乱UI时钟)
|
||||
restoreDraft();
|
||||
}
|
||||
});
|
||||
</script>
|
||||
@@ -542,6 +949,7 @@
|
||||
.popup-footer {
|
||||
display: flex;
|
||||
border-top: 1rpx solid #eee;
|
||||
padding-bottom: env(safe-area-inset-bottom);
|
||||
|
||||
button {
|
||||
flex: 1;
|
||||
@@ -560,6 +968,83 @@
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.btn-confirm {
|
||||
color: #fff;
|
||||
}
|
||||
}
|
||||
}
|
||||
// 签名相关样式
|
||||
.signature-box {
|
||||
width: 100%;
|
||||
min-height: 240rpx;
|
||||
background: #f8f8f8;
|
||||
border: 1rpx dashed #dcdfe6;
|
||||
border-radius: 8rpx;
|
||||
margin-top: 16rpx;
|
||||
|
||||
.signature-img {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.signature-placeholder {
|
||||
color: #909399;
|
||||
font-size: 28rpx;
|
||||
}
|
||||
}
|
||||
|
||||
.signature-popup {
|
||||
width: 650rpx;
|
||||
background: #fff;
|
||||
border-radius: 16rpx;
|
||||
overflow: hidden;
|
||||
|
||||
.popup-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 30rpx;
|
||||
border-bottom: 1rpx solid #eee;
|
||||
|
||||
.popup-title {
|
||||
font-size: 32rpx;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.popup-close {
|
||||
font-size: 40rpx;
|
||||
color: #999;
|
||||
line-height: 1;
|
||||
}
|
||||
}
|
||||
|
||||
.popup-body {
|
||||
padding: 40rpx 30rpx;
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
.popup-footer {
|
||||
display: flex;
|
||||
padding: 0 30rpx 30rpx;
|
||||
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 {
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
@@ -82,11 +82,11 @@
|
||||
<view class="plan-stats margin-top">
|
||||
<view class="plan-stat-item">
|
||||
<view class="plan-stat-num text-orange">{{ item.totalCount }}</view>
|
||||
<view class="plan-stat-label">隐患</view>
|
||||
<view class="plan-stat-label">排查项</view>
|
||||
</view>
|
||||
<view class="plan-stat-item">
|
||||
<view class="plan-stat-num text-yellow">{{ item.totalCount - item.finishedCount }}</view>
|
||||
<view class="plan-stat-label">待整改</view>
|
||||
<view class="plan-stat-label">待排查</view>
|
||||
</view>
|
||||
<view class="plan-stat-item">
|
||||
<view class="plan-stat-num text-olive">0</view>
|
||||
@@ -120,7 +120,7 @@
|
||||
v-for="(tab, index) in dangerTabs"
|
||||
:key="index"
|
||||
@click="switchDangerTab(index)"
|
||||
>{{ tab }}</view>
|
||||
>{{ tab.label }}</view>
|
||||
</view>
|
||||
</scroll-view>
|
||||
<!-- 无数据提示 -->
|
||||
@@ -131,9 +131,9 @@
|
||||
<view class="danger-card margin-top" v-for="(item, index) in filteredDangerData" :key="item.hazardId">
|
||||
<!-- 标题行:图标+标题 + 等级标签 -->
|
||||
<view class="flex justify-between align-center">
|
||||
<view class="flex align-center">
|
||||
<text class="cuIcon-infofill text-blue" style="font-size: 36rpx; margin-right: 12rpx;"></text>
|
||||
<text class="text-bold" style="font-size: 30rpx;">{{ item.title }}</text>
|
||||
<view class="flex align-center" style="flex: 1; min-width: 0; margin-right: 24rpx;">
|
||||
<text class="cuIcon-infofill text-blue" style="font-size: 36rpx; margin-right: 12rpx; flex-shrink: 0;"></text>
|
||||
<view class="text-bold" style="font-size: 30rpx; word-break: break-all; flex: 1;">{{ item.title }}</view>
|
||||
</view>
|
||||
<view class="level-tag" :class="{
|
||||
'level-minor': item.levelName === '轻微隐患',
|
||||
@@ -373,7 +373,14 @@
|
||||
const hiddenDangerData = ref([]);
|
||||
|
||||
// 隐患排查 Tab 筛选
|
||||
const dangerTabs = ref(['全部状态', '待验收', '待整改', '待交办', '验收通过']);
|
||||
const dangerTabs = ref([
|
||||
{ label: '全部', value: null },
|
||||
{ label: '待交办', value: 1 },
|
||||
{ label: '待整改', value: 2 },
|
||||
{ label: '待验收', value: 3 },
|
||||
{ label: '待销号', value: 4 },
|
||||
{ label: '已完成', value: 5 }
|
||||
]);
|
||||
const activeDangerTab = ref(0);
|
||||
|
||||
// 切换 Tab
|
||||
@@ -383,11 +390,11 @@
|
||||
|
||||
// 根据 Tab 过滤隐患数据
|
||||
const filteredDangerData = computed(() => {
|
||||
if (activeDangerTab.value === 0) {
|
||||
const activeTab = dangerTabs.value[activeDangerTab.value];
|
||||
if (!activeTab || activeTab.value === null) {
|
||||
return hiddenDangerData.value;
|
||||
}
|
||||
const status = dangerTabs.value[activeDangerTab.value];
|
||||
return hiddenDangerData.value.filter(item => item.statusName === status);
|
||||
return hiddenDangerData.value.filter(item => item.status === activeTab.value);
|
||||
});
|
||||
|
||||
const getHiddenDangerLists = async () => {
|
||||
|
||||
@@ -47,7 +47,7 @@
|
||||
</view>
|
||||
|
||||
<!-- 添加成员弹出框 -->
|
||||
<u-popup :show="showPopup" mode="center" round="20" @close="showPopup = false">
|
||||
<u-popup :show="showPopup" mode="center" round="20" :safeAreaInsetBottom="false" @close="showPopup = false">
|
||||
<view class="popup-content">
|
||||
<view class="popup-header">
|
||||
<view class="popup-title text-bold">添加成员</view>
|
||||
@@ -88,14 +88,10 @@
|
||||
</text>
|
||||
<text class="cuIcon-unfold"></text>
|
||||
</view>
|
||||
<up-picker
|
||||
:show="showRolePicker"
|
||||
:columns="roleColumns"
|
||||
@confirm="onRoleConfirm"
|
||||
@cancel="showRolePicker = false"
|
||||
@close="showRolePicker = false"
|
||||
></up-picker>
|
||||
</view>
|
||||
|
||||
<!-- 占位空白,防止被底部按钮遮挡 -->
|
||||
<view style="height: 40rpx;"></view>
|
||||
</scroll-view>
|
||||
|
||||
<view class="popup-footer">
|
||||
@@ -104,6 +100,15 @@
|
||||
</view>
|
||||
</view>
|
||||
</u-popup>
|
||||
|
||||
<up-picker
|
||||
:show="showRolePicker"
|
||||
:columns="roleColumns"
|
||||
@confirm="onRoleConfirm"
|
||||
@cancel="showRolePicker = false"
|
||||
@close="showRolePicker = false"
|
||||
></up-picker>
|
||||
|
||||
<TabBar />
|
||||
</view>
|
||||
</template>
|
||||
@@ -422,6 +427,10 @@ onMounted(() => {
|
||||
|
||||
// 弹出框样式
|
||||
.popup-content {
|
||||
position: relative;
|
||||
z-index: 99;
|
||||
transform: translateZ(0);
|
||||
-webkit-transform: translateZ(0);
|
||||
width: 600rpx;
|
||||
background: #fff;
|
||||
border-radius: 20rpx;
|
||||
@@ -448,6 +457,10 @@ onMounted(() => {
|
||||
}
|
||||
|
||||
.popup-body {
|
||||
position: relative;
|
||||
z-index: 100;
|
||||
transform: translateZ(0);
|
||||
-webkit-transform: translateZ(0);
|
||||
padding: 30rpx;
|
||||
max-height: 700rpx;
|
||||
overflow-y: auto;
|
||||
@@ -485,6 +498,8 @@ onMounted(() => {
|
||||
height: 90rpx;
|
||||
line-height: 90rpx;
|
||||
border-radius: 0;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
font-size: 30rpx;
|
||||
|
||||
&::after {
|
||||
|
||||
Reference in New Issue
Block a user