v1.2.1版本,优化调整了很多,整改验收阶段新加字段
This commit is contained in:
@@ -58,7 +58,7 @@
|
||||
</view>
|
||||
<view class="card-body">
|
||||
<view class="info-row">
|
||||
<text class="text-gray">隐患来源:</text>
|
||||
<text class="text-gray">检查形式:</text>
|
||||
<text>{{ sourceOptions[hazardFormData.source]?.title || '-' }}</text>
|
||||
</view>
|
||||
<view class="info-row">
|
||||
@@ -104,6 +104,19 @@
|
||||
<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>
|
||||
<view class="source-choose-scroll">
|
||||
<up-choose
|
||||
v-model="hazardFormData.source"
|
||||
:options="sourceOptions"
|
||||
:wrap="false"
|
||||
item-width="152rpx"
|
||||
item-height="64rpx"
|
||||
></up-choose>
|
||||
</view>
|
||||
<view class="flex margin-bottom margin-top">
|
||||
<view class="text-gray">隐患图片</view>
|
||||
<view class="text-red">*</view>
|
||||
</view>
|
||||
@@ -136,12 +149,6 @@
|
||||
item-width="183rpx"
|
||||
item-height="72rpx"
|
||||
></up-choose>
|
||||
<view class="flex margin-bottom margin-top">
|
||||
<view class="text-gray">隐患来源</view>
|
||||
<view class="text-red">*</view>
|
||||
</view>
|
||||
<up-choose v-model="hazardFormData.source" :options="sourceOptions" :wrap="false" item-width="183rpx"
|
||||
item-height="72rpx"></up-choose>
|
||||
<view class="flex margin-bottom margin-top">
|
||||
<view class="text-gray">隐患位置</view>
|
||||
<view class="text-red">*</view>
|
||||
@@ -266,8 +273,8 @@
|
||||
import { ref, reactive, computed, nextTick, watch, getCurrentInstance } from 'vue';
|
||||
import { onLoad } from '@dcloudio/uni-app';
|
||||
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 { toImageUrl } from '@/request/request.js';
|
||||
import { createUploadListHandlers, buildAttachmentItem } from '@/utils/upload.js';
|
||||
import { getAreaList } from '@/request/three_one_api/area.js';
|
||||
|
||||
// 页面参数
|
||||
@@ -476,12 +483,12 @@
|
||||
{ id: 3, title: '重大隐患' }
|
||||
]);
|
||||
|
||||
// 隐患来源选项
|
||||
// 检查形式选项
|
||||
const sourceOptions = ref([
|
||||
{ id: 1, title: '随手拍' },
|
||||
{ id: 2, title: '企业自查' },
|
||||
{ id: 3, title: '行业互查' },
|
||||
{ id: 4, title: '专家诊查' }
|
||||
{ id: 1, title: '部门检查' },
|
||||
{ id: 2, title: '都导检查' },
|
||||
{ id: 3, title: '企业自查' },
|
||||
{ id: 4, title: '行业互查' }
|
||||
]);
|
||||
|
||||
// 隐患标签选项
|
||||
@@ -578,75 +585,15 @@
|
||||
}, 300);
|
||||
};
|
||||
|
||||
// 删除图片
|
||||
const deletePic = (event) => {
|
||||
hazardFileList.value.splice(event.index, 1);
|
||||
};
|
||||
|
||||
// 新增图片
|
||||
const afterRead = async (event) => {
|
||||
let lists = [].concat(event.file);
|
||||
let fileListLen = hazardFileList.value.length;
|
||||
lists.map((item) => {
|
||||
hazardFileList.value.push({
|
||||
...item,
|
||||
status: 'uploading',
|
||||
message: '上传中',
|
||||
});
|
||||
});
|
||||
for (let i = 0; i < lists.length; i++) {
|
||||
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: toImageUrl(serverPath),
|
||||
serverPath: serverPath,
|
||||
});
|
||||
fileListLen++;
|
||||
const inspectionUploadInstance = getCurrentInstance();
|
||||
const { afterRead, deletePic } = createUploadListHandlers(hazardFileList, {
|
||||
watermark: {
|
||||
canvasId: 'watermarkCanvas',
|
||||
canvasWidthRef: canvasWidth,
|
||||
canvasHeightRef: canvasHeight,
|
||||
instance: inspectionUploadInstance
|
||||
}
|
||||
};
|
||||
|
||||
// 上传文件
|
||||
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);
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
});
|
||||
|
||||
// AI 识别隐患
|
||||
const handleAiAnalyze = async () => {
|
||||
@@ -730,24 +677,9 @@
|
||||
// 如果选择异常,先调用新增隐患接口
|
||||
if (radiovalue1.value === '异常' && hasHazardData.value) {
|
||||
// 构建附件列表
|
||||
const attachments = hazardFileList.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 || '';
|
||||
}
|
||||
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 || '',
|
||||
filePath: url || '',
|
||||
fileType: file.type || 'image/png',
|
||||
fileSize: file.size || 0
|
||||
};
|
||||
});
|
||||
const attachments = hazardFileList.value
|
||||
.filter((f) => f.status === 'success')
|
||||
.map((file) => buildAttachmentItem(file));
|
||||
|
||||
// 获取隐患标签ID
|
||||
const selectedTag = tagOptions.value[hazardFormData.tagIndex];
|
||||
@@ -758,7 +690,7 @@
|
||||
taskId: checkData.value?.taskId,
|
||||
checkPointId: checkData.value?.checkPointId,
|
||||
title: hazardFormData.title,
|
||||
level: hazardFormData.level + 1,
|
||||
level: levelOptions.value[hazardFormData.level]?.id || 2,
|
||||
lng: hazardLng.value || 0,
|
||||
lat: hazardLat.value || 0,
|
||||
address: hazardAddress.value || '',
|
||||
@@ -1244,6 +1176,43 @@
|
||||
.popup-body {
|
||||
padding: 30rpx;
|
||||
}
|
||||
|
||||
// 检查形式横向滚动,露出第 4 项一角提示可滑动
|
||||
.source-choose-scroll {
|
||||
width: 100%;
|
||||
overflow: hidden;
|
||||
|
||||
:deep(.up-choose) {
|
||||
width: 100%;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
:deep(.u-tag-wrapper) {
|
||||
margin-right: 12rpx;
|
||||
}
|
||||
|
||||
:deep(.u-tag) {
|
||||
display: flex !important;
|
||||
align-items: center !important;
|
||||
justify-content: center !important;
|
||||
box-sizing: border-box;
|
||||
padding: 0 8rpx !important;
|
||||
line-height: normal !important;
|
||||
}
|
||||
|
||||
:deep(.u-tag__content) {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
:deep(.u-tag__text) {
|
||||
font-size: 24rpx !important;
|
||||
line-height: 1.3 !important;
|
||||
text-align: center;
|
||||
}
|
||||
}
|
||||
|
||||
// AI 识别按钮样式
|
||||
.ai-btn-wrapper {
|
||||
|
||||
Reference in New Issue
Block a user