| | |
| | | </view> |
| | | </view> |
| | | |
| | | <!-- 异常状态选择 --> |
| | | <view class="exception-section"> |
| | | <text class="section-title">是否存在异常?</text> |
| | | <view class="exception-options"> |
| | | <view |
| | | class="exception-option" |
| | | :class="{ active: hasException === false }" |
| | | @click="setExceptionStatus(false)" |
| | | > |
| | | <u-icon name="checkmark-circle" size="20" color="#52c41a"></u-icon> |
| | | <text>正常</text> |
| | | </view> |
| | | <view |
| | | class="exception-option" |
| | | :class="{ active: hasException === true }" |
| | | @click="setExceptionStatus(true)" |
| | | > |
| | | <u-icon name="close-circle" size="20" color="#ff4d4f"></u-icon> |
| | | <text>存在异常</text> |
| | | </view> |
| | | </view> |
| | | </view> |
| | | |
| | | <!-- 当前分类的上传区域 --> |
| | | <view class="simple-upload-area"> |
| | | <view class="upload-buttons"> |
| | |
| | | |
| | | <view class="upload-popup-footer"> |
| | | <u-button @click="closeUploadDialog" :customStyle="{ marginRight: '10px' }">取消</u-button> |
| | | <u-button |
| | | v-if="hasException === true" |
| | | type="warning" |
| | | @click="goToRepair" |
| | | :customStyle="{ marginRight: '10px' }" |
| | | > |
| | | 新增报修 |
| | | </u-button> |
| | | <u-button type="primary" @click="submitUpload">提交</u-button> |
| | | </view> |
| | | </view> |
| | |
| | | const showVideoDialog = ref(false) |
| | | const currentVideoFile = ref(null) |
| | | |
| | | // 异常状态 |
| | | const hasException = ref(null) // null: 未选择, true: 存在异常, false: 正常 |
| | | |
| | | // 上传配置 |
| | | const uploadConfig = { |
| | | action: "/common/minioUploads", |
| | |
| | | inspectionTaskList({}).then(res => { |
| | | // 检查组件是否还存在且请求未被取消 |
| | | if (!isRequestCancelled) { |
| | | console.log('生产巡检API返回数据:', res); |
| | | |
| | | // 处理不同的数据结构 |
| | | let records = []; |
| | | if (res && res.data) { |
| | |
| | | |
| | | if (records.length > 0) { |
| | | taskTableData.value = records; |
| | | console.log('生产巡检数据设置成功,记录数:', records.length); |
| | | } else { |
| | | console.warn('生产巡检数据为空或格式不正确:', res); |
| | | taskTableData.value = []; |
| | | uni.showToast({ |
| | | title: '暂无巡检任务数据', |
| | |
| | | }).catch(err => { |
| | | // 检查组件是否还存在且请求未被取消 |
| | | if (!isRequestCancelled) { |
| | | console.error('获取生产巡检数据失败:', err); |
| | | taskTableData.value = []; |
| | | // 添加错误提示 |
| | | uni.showToast({ |
| | |
| | | try { |
| | | // 记录当前扫描的任务 |
| | | currentScanningTask.value = task |
| | | console.log('为任务开始扫码,任务ID:', task.taskId || task.id, '任务名称:', task.taskName) |
| | | |
| | | // 显示扫描界面 |
| | | isScanning.value = true |
| | |
| | | // 使用uniapp的扫码API |
| | | uni.scanCode({ |
| | | success: (res) => { |
| | | console.log('=== 扫码API成功回调 ===') |
| | | console.log('扫码结果:', res) |
| | | console.log('当前扫描任务:', currentScanningTask.value) |
| | | handleScanSuccess(res) |
| | | }, |
| | | fail: (err) => { |
| | | console.error('扫码失败:', err) |
| | | uni.showToast({ |
| | | title: '扫码失败', |
| | | icon: 'error' |
| | |
| | | // 关闭扫描界面 |
| | | isScanning.value = false |
| | | } |
| | | // 移除complete回调,避免干扰弹窗显示 |
| | | }) |
| | | } catch (e) { |
| | | console.error('启动扫码失败:', e) |
| | | uni.showToast({ |
| | | title: '启动扫码失败', |
| | | icon: 'error' |
| | |
| | | // 扫码成功处理 |
| | | const handleScanSuccess = async (result) => { |
| | | try { |
| | | console.log('处理扫码结果:', result) |
| | | console.log('当前关联任务:', currentScanningTask.value?.taskName) |
| | | |
| | | // 解析二维码数据,提取deviceId |
| | | let deviceId = '' |
| | | |
| | |
| | | const match = url.match(/deviceId=(\d+)/) |
| | | if (match && match[1]) { |
| | | deviceId = match[1] |
| | | console.log('从URL中提取到deviceId:', deviceId) |
| | | } |
| | | } else { |
| | | // 尝试解析JSON格式 |
| | | try { |
| | | const qrData = JSON.parse(result.result) |
| | | console.log('解析的二维码数据:', qrData) |
| | | deviceId = qrData.deviceId || qrData.qrCodeId || '' |
| | | } catch (e) { |
| | | // 如果不是JSON格式,直接使用结果 |
| | |
| | | |
| | | // 获取当前任务的taskId |
| | | const currentTaskId = currentScanningTask.value?.taskId || currentScanningTask.value?.id |
| | | console.log('当前任务ID:', currentTaskId, '扫码设备ID:', deviceId) |
| | | |
| | | // 对比deviceId和taskId |
| | | if (deviceId === currentTaskId.toString()) { |
| | | console.log('=== 设备ID匹配成功 ===') |
| | | uni.showToast({ |
| | | title: '识别成功', |
| | | icon: 'success' |
| | | }) |
| | | |
| | | console.log('准备打开上传弹窗,当前任务:', currentScanningTask.value) |
| | | |
| | | // 先关闭扫描界面 |
| | | isScanning.value = false |
| | | console.log('扫描界面已关闭') |
| | | |
| | | // 延迟打开上传弹窗,确保扫描界面完全关闭 |
| | | setTimeout(() => { |
| | | console.log('延迟打开上传弹窗') |
| | | openUploadDialog(currentScanningTask.value) |
| | | }, 300) |
| | | } else { |
| | |
| | | title: '请扫描正确的设备', |
| | | icon: 'error' |
| | | }) |
| | | console.warn('设备ID不匹配,期望:', currentTaskId, '实际:', deviceId) |
| | | |
| | | // 关闭扫描界面 |
| | | isScanning.value = false |
| | | } |
| | | |
| | | } catch (error) { |
| | | console.error('处理扫码结果失败:', error) |
| | | uni.showToast({ |
| | | title: error.message || '数据解析失败', |
| | | icon: 'error' |
| | |
| | | |
| | | // 打开上传弹窗 |
| | | const openUploadDialog = (task) => { |
| | | console.log('=== 开始打开上传弹窗 ===') |
| | | console.log('传入的任务:', task) |
| | | console.log('任务名称:', task?.taskName || '未知任务') |
| | | console.log('当前showUploadDialog状态(调用前):', showUploadDialog.value) |
| | | |
| | | // 设置任务信息到infoData |
| | | if (task) { |
| | | infoData.value = { |
| | |
| | | taskId: task.taskId || task.id, |
| | | storageBlobDTO: [] // 初始化文件列表 |
| | | }; |
| | | console.log('设置infoData:', infoData.value); |
| | | } |
| | | |
| | | // 设置上传状态类型(可以根据任务类型设置不同的状态) |
| | |
| | | |
| | | // 显示上传弹窗 |
| | | showUploadDialog.value = true |
| | | |
| | | console.log('当前showUploadDialog状态(设置后):', showUploadDialog.value) |
| | | console.log('=== 上传弹窗设置完成 ===') |
| | | |
| | | // 延迟检查状态 |
| | | setTimeout(() => { |
| | | console.log('延迟检查showUploadDialog状态:', showUploadDialog.value) |
| | | }, 100) |
| | | } |
| | | |
| | | // 关闭上传弹窗 |
| | |
| | | afterModelValue.value = [] |
| | | issueModelValue.value = [] |
| | | currentUploadType.value = 'before' |
| | | hasException.value = null // 重置异常状态 |
| | | infoData.value = null // 清理任务数据 |
| | | console.log('上传弹窗已关闭,数据已清理') |
| | | } |
| | | |
| | | // 切换上传类型 |
| | | const switchUploadType = (type) => { |
| | | currentUploadType.value = type |
| | | console.log('切换到上传类型:', type) |
| | | } |
| | | |
| | | // 获取当前分类的文件列表 |
| | |
| | | // 处理上传文件更新 |
| | | const handleUploadUpdate = (files) => { |
| | | uploadFiles.value = files |
| | | console.log('上传文件更新:', files) |
| | | } |
| | | |
| | | // 设置异常状态 |
| | | const setExceptionStatus = (status) => { |
| | | hasException.value = status |
| | | } |
| | | |
| | | // 跳转到新增报修页面 |
| | | const goToRepair = () => { |
| | | try { |
| | | // 存储当前任务信息到本地存储,供报修页面使用 |
| | | const taskInfo = { |
| | | taskId: infoData.value?.taskId || infoData.value?.id, |
| | | taskName: infoData.value?.taskName, |
| | | inspectionLocation: infoData.value?.inspectionLocation, |
| | | inspector: infoData.value?.inspector, |
| | | // 传递当前上传的文件信息 |
| | | uploadedFiles: { |
| | | before: beforeModelValue.value, |
| | | after: afterModelValue.value, |
| | | issue: issueModelValue.value |
| | | } |
| | | } |
| | | |
| | | uni.setStorageSync('repairTaskInfo', JSON.stringify(taskInfo)) |
| | | |
| | | // 跳转到新增报修页面 |
| | | uni.navigateTo({ |
| | | url: '/pages/equipmentManagement/repair/add' |
| | | }) |
| | | |
| | | // 关闭上传弹窗 |
| | | closeUploadDialog() |
| | | |
| | | } catch (error) { |
| | | console.error('跳转报修页面失败:', error) |
| | | uni.showToast({ |
| | | title: '跳转失败,请重试', |
| | | icon: 'error' |
| | | }) |
| | | } |
| | | } |
| | | |
| | | // 提交上传 |
| | | const submitUpload = async () => { |
| | | try { |
| | | // 检查是否选择了异常状态 |
| | | if (hasException.value === null) { |
| | | uni.showToast({ |
| | | title: '请选择是否存在异常', |
| | | icon: 'none' |
| | | }) |
| | | return |
| | | } |
| | | |
| | | // 检查是否有任何文件上传 |
| | | const totalFiles = beforeModelValue.value.length + afterModelValue.value.length + issueModelValue.value.length; |
| | | if (totalFiles === 0) { |
| | |
| | | |
| | | // 提交数据 |
| | | infoData.value.storageBlobDTO = arr; |
| | | |
| | | console.log('准备提交巡检任务数据:', infoData.value); |
| | | console.log('合并的文件列表:', arr); |
| | | console.log('生产前文件(type=0):', beforeModelValue.value.length, beforeModelValue.value); |
| | | console.log('生产中文件(type=1):', afterModelValue.value.length, afterModelValue.value); |
| | | console.log('生产后文件(type=2):', issueModelValue.value.length, issueModelValue.value); |
| | | // 添加异常状态信息 |
| | | infoData.value.hasException = hasException.value; |
| | | |
| | | const result = await uploadInspectionTask({...infoData.value}); |
| | | |
| | | console.log('巡检任务提交结果:', result); |
| | | |
| | | // 检查提交结果 |
| | | if (result && (result.code === 200 || result.success)) { |
| | |
| | | |
| | | // 摄像头错误处理 |
| | | const handleCameraError = (error) => { |
| | | console.error('摄像头错误:', error) |
| | | cameraError.value = '摄像头访问失败,请检查权限设置' |
| | | } |
| | | |
| | | // 扫码事件处理 |
| | | const handleScanCode = (result) => { |
| | | console.log('扫码结果:', result) |
| | | handleScanSuccess(result) |
| | | } |
| | | |
| | | // 查看附件 |
| | | const viewAttachments = async (task) => { |
| | | try { |
| | | console.log('查看附件,任务:', task) |
| | | currentViewTask.value = task |
| | | currentViewType.value = 'before' |
| | | |
| | |
| | | attachmentList.value.push(...issueFiles) |
| | | } |
| | | |
| | | console.log('解析后的附件列表:', attachmentList.value) |
| | | console.log('生产前附件:', task.beforeProduction?.length || 0) |
| | | console.log('生产中附件:', task.afterProduction?.length || 0) |
| | | console.log('生产后附件:', task.productionIssues?.length || 0) |
| | | |
| | | showAttachmentDialog.value = true |
| | | |
| | | } catch (error) { |
| | | console.error('获取附件列表失败:', error) |
| | | uni.showToast({ |
| | | title: '获取附件失败', |
| | | icon: 'error' |
| | |
| | | // 切换查看类型 |
| | | const switchViewType = (type) => { |
| | | currentViewType.value = type |
| | | console.log('切换查看类型到:', type) |
| | | } |
| | | |
| | | // 根据type获取对应分类的附件 |
| | |
| | | const showVideoPreview = (file) => { |
| | | currentVideoFile.value = file |
| | | showVideoDialog.value = true |
| | | console.log('播放视频:', file.url || file.downloadUrl) |
| | | } |
| | | |
| | | // 关闭视频预览 |
| | |
| | | |
| | | // 视频播放错误处理 |
| | | const handleVideoError = (error) => { |
| | | console.error('视频播放错误:', error) |
| | | uni.showToast({ |
| | | title: '视频播放失败', |
| | | icon: 'error' |
| | |
| | | type: typeValue // 添加类型字段:0=生产前, 1=生产中, 2=生产后 |
| | | }; |
| | | |
| | | console.log(`${getUploadTypeText()}文件上传成功,类型值:`, typeValue, '文件数据:', fileData); |
| | | |
| | | uploadList.value.push(fileData); |
| | | uploadedSuccessfully(); |
| | | } else { |
| | |
| | | // 重置状态 |
| | | uploadList.value = []; |
| | | number.value = 0; |
| | | |
| | | console.log(`${getUploadTypeText()}文件上传完成:`, getCurrentFiles()); |
| | | } |
| | | } |
| | | |
| | |
| | | color: #333; |
| | | } |
| | | |
| | | /* 异常状态选择样式 */ |
| | | .exception-section { |
| | | margin-bottom: 20px; |
| | | padding: 15px; |
| | | background: #f8f9fa; |
| | | border-radius: 8px; |
| | | border: 1px solid #e9ecef; |
| | | } |
| | | |
| | | .section-title { |
| | | display: block; |
| | | font-size: 14px; |
| | | font-weight: 600; |
| | | color: #333; |
| | | margin-bottom: 12px; |
| | | } |
| | | |
| | | .exception-options { |
| | | display: flex; |
| | | gap: 12px; |
| | | } |
| | | |
| | | .exception-option { |
| | | flex: 1; |
| | | display: flex; |
| | | align-items: center; |
| | | justify-content: center; |
| | | gap: 8px; |
| | | padding: 12px 16px; |
| | | background: #fff; |
| | | border: 2px solid #e9ecef; |
| | | border-radius: 8px; |
| | | cursor: pointer; |
| | | transition: all 0.3s ease; |
| | | font-size: 14px; |
| | | color: #666; |
| | | } |
| | | |
| | | .exception-option.active { |
| | | border-color: #409eff; |
| | | background: #f0f8ff; |
| | | color: #409eff; |
| | | font-weight: 500; |
| | | } |
| | | |
| | | .exception-option:hover:not(.active) { |
| | | border-color: #d9d9d9; |
| | | background: #fafafa; |
| | | } |
| | | |
| | | /* 统计信息样式 */ |
| | | .upload-summary { |
| | | margin-top: 15px; |