| | |
| | | <view class="inspection-hint"> |
| | | <view class="hint-text">没有最大值和最小值时填写0(未通过检验)或1(通过检验)</view> |
| | | </view> |
| | | |
| | | <!-- 不合格检验项目提示 --> |
| | | <view class="validation-hint" v-if="isUnqualifiedResult()"> |
| | | <view class="validation-icon">⚠️</view> |
| | | <view class="validation-text"> |
| | | <view class="validation-title">检验项目不合格,必须完成以下操作:</view> |
| | | <view class="validation-requirements"> |
| | | <view class="requirement-item" :class="{ 'completed': hasImage(), 'required': !hasImage() }"> |
| | | <text class="requirement-icon">{{ hasImage() ? '✅' : '❌' }}</text> |
| | | <text class="requirement-text">上传图片</text> |
| | | </view> |
| | | <view class="requirement-item" :class="{ 'completed': hasRemarks(), 'required': !hasRemarks() }"> |
| | | <text class="requirement-icon">{{ hasRemarks() ? '✅' : '❌' }}</text> |
| | | <text class="requirement-text">填写不良描述</text> |
| | | </view> |
| | | </view> |
| | | </view> |
| | | </view> |
| | | |
| | | <view class="input-group"> |
| | | <view class="input-wrapper"> |
| | | <input v-if="tableData.length < formData.levelNum" |
| | |
| | | </view> |
| | | <!-- 图片预览 --> |
| | | <view v-if="isShowImg" class="section"> |
| | | <view class="section-header">相关图片</view> |
| | | <view class="section-header"> |
| | | <view class="section-title">相关图片</view> |
| | | <view class="section-actions"> |
| | | <button class="delete-image-btn" @click="deleteImage">删除图片</button> |
| | | </view> |
| | | </view> |
| | | <view class="section-body"> |
| | | <view class="image-preview" @click="previewImage"> |
| | | <image :src="base64Image" mode="aspectFit" class="preview-image"/> |
| | |
| | | <view class="action-buttons"> |
| | | <button class="action-btn warning" @click="saveRemarks">添加不合格描述</button> |
| | | <button class="action-btn primary" @click="viewAttachmentInfo">查看检验项目</button> |
| | | <button class="action-btn success tablet-upload-btn" @click="uploadImage"> |
| | | <view class="btn-content"> |
| | | <view class="btn-icon">📷</view> |
| | | <view class="btn-text">拍照/上传图片</view> |
| | | </view> |
| | | </button> |
| | | </view> |
| | | |
| | | <!-- 修改检验结果弹出框 --> |
| | |
| | | } |
| | | }, |
| | | methods: { |
| | | // 判断当前检验结果是否为不合格 |
| | | isUnqualifiedResult() { |
| | | if (!this.formData.fcheckResu) return false; |
| | | |
| | | // 如果有最大值和最小值,检查是否超出范围 |
| | | if (this.formData.maxValue && this.formData.minValue) { |
| | | return this.formData.fcheckResu < this.formData.minValue || |
| | | this.formData.fcheckResu > this.formData.maxValue; |
| | | } |
| | | |
| | | // 如果没有最大值和最小值,检查是否为0(不合格) |
| | | return this.formData.fcheckResu == 0; |
| | | }, |
| | | |
| | | // 判断是否已上传图片 |
| | | hasImage() { |
| | | return this.formData.imageData && this.formData.imageData.length > 0; |
| | | }, |
| | | |
| | | // 判断是否已填写不良描述 |
| | | hasRemarks() { |
| | | return this.formData.remarks && this.formData.remarks.trim() !== ''; |
| | | }, |
| | | |
| | | previewImage() { |
| | | uni.previewImage({ |
| | |
| | | count = count - this.tableData.length; |
| | | } |
| | | |
| | | // 验证不合格检验项目必须上传图片并填写不良描述 |
| | | if (fstand === "×" || this.formData.fcheckResu == 0) { |
| | | // 检查是否已上传图片 |
| | | if (!this.formData.imageData || this.formData.imageData.length === 0) { |
| | | this.$showMessage("检验项目不合格,必须上传图片!"); |
| | | return; |
| | | } |
| | | |
| | | // 检查是否已填写不良描述 |
| | | if (!this.formData.remarks || this.formData.remarks.trim() === '') { |
| | | this.$showMessage("检验项目不合格,必须填写不良描述!"); |
| | | return; |
| | | } |
| | | } |
| | | |
| | | this.formData.updater = this.$loginInfo.account; |
| | | |
| | | this.$post({ |
| | |
| | | |
| | | this.tableData = res.data.tbBillList.itemXj02s; |
| | | |
| | | if (this.formData.imageData) { |
| | | // 处理图片显示状态 |
| | | if (this.formData.imageData && this.formData.imageData.length > 0) { |
| | | this.isShowImg = true; |
| | | this.base64Image = 'data:image/jpeg;base64,' + this.formData.imageData; |
| | | } else { |
| | | // 如果没有图片数据,隐藏图片显示区域 |
| | | this.isShowImg = false; |
| | | this.base64Image = ''; |
| | | } |
| | | |
| | | //maxValue minValue standardValue |
| | |
| | | } |
| | | } |
| | | |
| | | // 验证不合格检验项目必须上传图片并填写不良描述 |
| | | if (fstand === "×" || this.editData.fcheckResu == 0) { |
| | | // 检查是否已上传图片 |
| | | if (!this.formData.imageData || this.formData.imageData.length === 0) { |
| | | this.$showMessage("检验项目不合格,必须上传图片!"); |
| | | return; |
| | | } |
| | | |
| | | // 检查是否已填写不良描述 |
| | | if (!this.formData.remarks || this.formData.remarks.trim() === '') { |
| | | this.$showMessage("检验项目不合格,必须填写不良描述!"); |
| | | return; |
| | | } |
| | | } |
| | | |
| | | this.editData.updater = this.$loginInfo.account; |
| | | |
| | | this.$post({ |
| | |
| | | if (item.fcheckResu == '1') { |
| | | fstand = "×"; |
| | | fcheckResu = 0; |
| | | } |
| | | |
| | | // 验证不合格检验项目必须上传图片并填写不良描述 |
| | | if (fstand === "×" || fcheckResu == 0) { |
| | | // 检查是否已上传图片 |
| | | if (!this.formData.imageData || this.formData.imageData.length === 0) { |
| | | this.$showMessage("检验项目不合格,必须上传图片!"); |
| | | return; |
| | | } |
| | | |
| | | // 检查是否已填写不良描述 |
| | | if (!this.formData.remarks || this.formData.remarks.trim() === '') { |
| | | this.$showMessage("检验项目不合格,必须填写不良描述!"); |
| | | return; |
| | | } |
| | | } |
| | | |
| | | this.$post({ |
| | |
| | | current: this.previewContent |
| | | }); |
| | | } |
| | | }, |
| | | |
| | | // 上传图片方法 - 保存到当前检验项目的PICTURE字段(LONG RAW类型) |
| | | // 后端会自动生成时间戳文件名,格式:1746945271304.jpg |
| | | uploadImage() { |
| | | // 显示选择弹窗,让用户选择拍照或从相册选择 |
| | | uni.showActionSheet({ |
| | | itemList: ['拍照', '从相册选择'], |
| | | success: (res) => { |
| | | const sourceType = res.tapIndex === 0 ? ['camera'] : ['album']; |
| | | this.chooseImageWithSource(sourceType); |
| | | }, |
| | | fail: (error) => { |
| | | console.log('用户取消选择:', error); |
| | | } |
| | | }); |
| | | }, |
| | | |
| | | // 根据选择的来源选择图片 |
| | | chooseImageWithSource(sourceType) { |
| | | uni.chooseImage({ |
| | | count: 1, // 最多选择1张图片 |
| | | sizeType: ['compressed', 'original'], // 提供压缩和原图选项 |
| | | sourceType: sourceType, // 根据用户选择设置来源 |
| | | success: (res) => { |
| | | const tempFilePath = res.tempFilePaths[0]; |
| | | |
| | | // 如果是拍照,显示预览确认 |
| | | if (sourceType.includes('camera')) { |
| | | this.showImagePreview(tempFilePath); |
| | | } else { |
| | | this.uploadImageToServer(tempFilePath); |
| | | } |
| | | }, |
| | | fail: (error) => { |
| | | console.error('选择图片失败:', error); |
| | | let errorMessage = '选择图片失败'; |
| | | if (sourceType.includes('camera')) { |
| | | errorMessage = '拍照失败,请检查相机权限'; |
| | | } |
| | | uni.showToast({ |
| | | title: errorMessage, |
| | | icon: 'none' |
| | | }); |
| | | } |
| | | }); |
| | | }, |
| | | |
| | | // 显示图片预览确认(主要用于拍照后的确认) |
| | | showImagePreview(imagePath) { |
| | | uni.previewImage({ |
| | | urls: [imagePath], |
| | | current: imagePath, |
| | | success: () => { |
| | | // 用户查看图片后,询问是否使用此图片 |
| | | uni.showModal({ |
| | | title: '确认使用此图片', |
| | | content: '是否使用刚才拍摄的图片?', |
| | | confirmText: '使用', |
| | | cancelText: '重新拍摄', |
| | | success: (res) => { |
| | | if (res.confirm) { |
| | | this.uploadImageToServer(imagePath); |
| | | } else if (res.cancel) { |
| | | // 用户选择重新拍摄 |
| | | this.chooseImageWithSource(['camera']); |
| | | } |
| | | } |
| | | }); |
| | | }, |
| | | fail: () => { |
| | | // 预览失败,直接上传 |
| | | this.uploadImageToServer(imagePath); |
| | | } |
| | | }); |
| | | }, |
| | | |
| | | // 上传图片到服务器并保存到数据库PICTURE字段(LONG RAW类型) |
| | | // 后端会自动生成时间戳文件名存储到TPICTURENAME字段 |
| | | uploadImageToServer(filePath) { |
| | | uni.showLoading({ |
| | | title: '上传中...' |
| | | }); |
| | | |
| | | // 构建上传URL |
| | | const uploadUrl = this.$store.state.serverInfo.serverAPI + "/RKJ/UploadImageToPicture"; |
| | | |
| | | uni.uploadFile({ |
| | | url: uploadUrl, |
| | | filePath: filePath, |
| | | name: 'file', |
| | | formData: { |
| | | id: this.id, // 当前检验项目ID |
| | | gid: this.gid, |
| | | billNo: this.billNo, |
| | | createBy: this.$loginInfo.account |
| | | }, |
| | | success: (uploadRes) => { |
| | | uni.hideLoading(); |
| | | try { |
| | | const result = JSON.parse(uploadRes.data); |
| | | if (result.status === 0) { |
| | | uni.showToast({ |
| | | title: '图片保存成功', |
| | | icon: 'success' |
| | | }); |
| | | // 刷新页面数据 |
| | | this.refreshResult(); |
| | | } else { |
| | | uni.showToast({ |
| | | title: result.message || '图片保存失败', |
| | | icon: 'none' |
| | | }); |
| | | } |
| | | } catch (error) { |
| | | console.error('解析上传结果失败:', error); |
| | | uni.showToast({ |
| | | title: '图片保存失败', |
| | | icon: 'none' |
| | | }); |
| | | } |
| | | }, |
| | | fail: (error) => { |
| | | uni.hideLoading(); |
| | | console.error('上传失败:', error); |
| | | uni.showToast({ |
| | | title: '图片保存失败', |
| | | icon: 'none' |
| | | }); |
| | | } |
| | | }); |
| | | }, |
| | | |
| | | // 删除图片 |
| | | deleteImage() { |
| | | uni.showModal({ |
| | | title: '确认删除', |
| | | content: '确定要删除当前图片吗?删除后无法恢复。', |
| | | confirmText: '删除', |
| | | cancelText: '取消', |
| | | confirmColor: '#e74c3c', |
| | | success: (res) => { |
| | | if (res.confirm) { |
| | | this.deleteImageFromServer(); |
| | | } |
| | | } |
| | | }); |
| | | }, |
| | | |
| | | // 从服务器删除图片 |
| | | deleteImageFromServer() { |
| | | uni.showLoading({ |
| | | title: '删除中...' |
| | | }); |
| | | |
| | | this.$post({ |
| | | url: "/RKJ/DeleteImageFromPicture", |
| | | data: { |
| | | id: this.id // 当前检验项目ID |
| | | } |
| | | }).then(res => { |
| | | uni.hideLoading(); |
| | | if (res.status === 0) { |
| | | uni.showToast({ |
| | | title: '图片删除成功', |
| | | icon: 'success' |
| | | }); |
| | | // 刷新页面数据 |
| | | this.refreshResult(); |
| | | } else { |
| | | uni.showToast({ |
| | | title: res.message || '图片删除失败', |
| | | icon: 'none' |
| | | }); |
| | | } |
| | | }).catch(error => { |
| | | uni.hideLoading(); |
| | | console.error('删除图片失败:', error); |
| | | uni.showToast({ |
| | | title: '图片删除失败', |
| | | icon: 'none' |
| | | }); |
| | | }); |
| | | } |
| | | }, |
| | | onLoad(options) { |
| | |
| | | background-color: $bg-color; |
| | | border-bottom: 1px solid $border-color; |
| | | font-weight: bold; |
| | | display: flex; |
| | | justify-content: space-between; |
| | | align-items: center; |
| | | } |
| | | |
| | | &-title { |
| | | flex: 1; |
| | | } |
| | | |
| | | &-actions { |
| | | display: flex; |
| | | gap: 10px; |
| | | } |
| | | |
| | | &-body { |
| | |
| | | .hint-text { |
| | | font-size: 12px; |
| | | color: #856404; |
| | | } |
| | | |
| | | /* 验证提示样式 */ |
| | | .validation-hint { |
| | | background: linear-gradient(135deg, #ffe6e6 0%, #ffcccc 100%); |
| | | border: 2px solid #ff6b6b; |
| | | border-radius: 8px; |
| | | padding: 16px; |
| | | margin-bottom: 20px; |
| | | display: flex; |
| | | align-items: flex-start; |
| | | gap: 12px; |
| | | box-shadow: 0 2px 8px rgba(255, 107, 107, 0.2); |
| | | } |
| | | |
| | | .validation-icon { |
| | | font-size: 24px; |
| | | flex-shrink: 0; |
| | | margin-top: 2px; |
| | | } |
| | | |
| | | .validation-text { |
| | | flex: 1; |
| | | } |
| | | |
| | | .validation-title { |
| | | font-size: 14px; |
| | | font-weight: 600; |
| | | color: #d63031; |
| | | margin-bottom: 12px; |
| | | line-height: 1.4; |
| | | } |
| | | |
| | | .validation-requirements { |
| | | display: flex; |
| | | flex-direction: column; |
| | | gap: 8px; |
| | | } |
| | | |
| | | .requirement-item { |
| | | display: flex; |
| | | align-items: center; |
| | | gap: 8px; |
| | | padding: 6px 10px; |
| | | border-radius: 6px; |
| | | transition: all 0.3s ease; |
| | | } |
| | | |
| | | .requirement-item.completed { |
| | | background-color: #d4edda; |
| | | border: 1px solid #c3e6cb; |
| | | } |
| | | |
| | | .requirement-item.required { |
| | | background-color: #f8d7da; |
| | | border: 1px solid #f5c6cb; |
| | | } |
| | | |
| | | .requirement-icon { |
| | | font-size: 16px; |
| | | flex-shrink: 0; |
| | | } |
| | | |
| | | .requirement-text { |
| | | font-size: 13px; |
| | | font-weight: 500; |
| | | color: #2c3e50; |
| | | } |
| | | |
| | | .input-group { |
| | |
| | | background-color: $warning-color; |
| | | color: white; |
| | | } |
| | | |
| | | &.success { |
| | | background-color: $success-color; |
| | | color: white; |
| | | } |
| | | } |
| | | |
| | | .delete-image-btn { |
| | | padding: 6px 12px; |
| | | border: 1px solid #e74c3c; |
| | | border-radius: 4px; |
| | | background-color: #e74c3c; |
| | | color: white; |
| | | font-size: 12px; |
| | | font-weight: 500; |
| | | cursor: pointer; |
| | | transition: all 0.2s; |
| | | } |
| | | |
| | | .delete-image-btn:hover { |
| | | background-color: #c0392b; |
| | | border-color: #c0392b; |
| | | } |
| | | |
| | | .delete-image-btn:active { |
| | | background-color: #a93226; |
| | | border-color: #a93226; |
| | | } |
| | | |
| | | /* 平板上传按钮样式 */ |
| | | .tablet-upload-btn { |
| | | position: relative; |
| | | overflow: hidden; |
| | | background: linear-gradient(135deg, #2ecc71 0%, #27ae60 100%); |
| | | box-shadow: 0 4px 15px rgba(46, 204, 113, 0.3); |
| | | transition: all 0.3s ease; |
| | | } |
| | | |
| | | .tablet-upload-btn:hover { |
| | | transform: translateY(-2px); |
| | | box-shadow: 0 6px 20px rgba(46, 204, 113, 0.4); |
| | | } |
| | | |
| | | .tablet-upload-btn:active { |
| | | transform: translateY(0); |
| | | box-shadow: 0 2px 10px rgba(46, 204, 113, 0.3); |
| | | } |
| | | |
| | | .btn-content { |
| | | display: flex; |
| | | flex-direction: column; |
| | | align-items: center; |
| | | justify-content: center; |
| | | gap: 8px; |
| | | padding: 8px; |
| | | } |
| | | |
| | | .btn-icon { |
| | | font-size: 24px; |
| | | line-height: 1; |
| | | } |
| | | |
| | | .btn-text { |
| | | font-size: 14px; |
| | | font-weight: 600; |
| | | line-height: 1.2; |
| | | text-align: center; |
| | | } |
| | | |
| | | .overlay { |
| | |
| | | flex-direction: column; |
| | | } |
| | | } |
| | | |
| | | /* 平板优化样式 */ |
| | | @media (min-width: 768px) and (max-width: 1024px) { |
| | | .action-buttons { |
| | | display: grid; |
| | | grid-template-columns: repeat(3, 1fr); |
| | | gap: 15px; |
| | | margin-bottom: 30px; |
| | | } |
| | | |
| | | .action-btn { |
| | | padding: 20px 16px; |
| | | font-size: 16px; |
| | | min-height: 80px; |
| | | display: flex; |
| | | align-items: center; |
| | | justify-content: center; |
| | | } |
| | | |
| | | .tablet-upload-btn { |
| | | min-height: 100px; |
| | | } |
| | | |
| | | .btn-content { |
| | | gap: 12px; |
| | | padding: 12px; |
| | | } |
| | | |
| | | .btn-icon { |
| | | font-size: 32px; |
| | | } |
| | | |
| | | .btn-text { |
| | | font-size: 16px; |
| | | } |
| | | |
| | | .info-grid { |
| | | grid-template-columns: repeat(2, 1fr); |
| | | gap: 20px; |
| | | } |
| | | |
| | | .section-body { |
| | | padding: 30px; |
| | | } |
| | | } |
| | | |
| | | /* 大屏平板优化 */ |
| | | @media (min-width: 1024px) { |
| | | .action-buttons { |
| | | display: grid; |
| | | grid-template-columns: repeat(3, 1fr); |
| | | gap: 20px; |
| | | margin-bottom: 40px; |
| | | } |
| | | |
| | | .action-btn { |
| | | padding: 25px 20px; |
| | | font-size: 18px; |
| | | min-height: 100px; |
| | | } |
| | | |
| | | .tablet-upload-btn { |
| | | min-height: 120px; |
| | | } |
| | | |
| | | .btn-content { |
| | | gap: 15px; |
| | | padding: 15px; |
| | | } |
| | | |
| | | .btn-icon { |
| | | font-size: 36px; |
| | | } |
| | | |
| | | .btn-text { |
| | | font-size: 18px; |
| | | } |
| | | |
| | | .info-grid { |
| | | grid-template-columns: repeat(3, 1fr); |
| | | gap: 25px; |
| | | } |
| | | |
| | | .section-body { |
| | | padding: 40px; |
| | | } |
| | | |
| | | .validation-hint { |
| | | padding: 25px; |
| | | margin-bottom: 30px; |
| | | } |
| | | |
| | | .validation-title { |
| | | font-size: 18px; |
| | | } |
| | | |
| | | .requirement-item { |
| | | padding: 12px 18px; |
| | | } |
| | | |
| | | .requirement-text { |
| | | font-size: 15px; |
| | | } |
| | | } |
| | | </style> |