周宾
8 天以前 8845ac3d32217b6cf765934dc29dffe0065232d8
src/pages/inspectionUpload/index.vue
@@ -174,7 +174,7 @@
                <view class="upload-buttons">
                  <u-button 
                    type="primary" 
                    @click="chooseImage"
                    @click="chooseMedia('image')"
                    :loading="uploading"
                    :disabled="getCurrentFiles().length >= uploadConfig.limit"
                    :customStyle="{ marginRight: '10px', flex: 1 }"
@@ -184,12 +184,12 @@
                  </u-button>
                  <u-button 
                    type="success" 
                    @click="chooseVideo"
                    @click="chooseMedia('video')"
                    :loading="uploading"
                    :disabled="getCurrentFiles().length >= uploadConfig.limit"
                    :customStyle="{ flex: 1 }"
                  >
                    <u-icon name="video" size="18" color="#fff" style="margin-right: 5px;"></u-icon>
                    <uni-icons type="videocam" name="videocam" size="18" color="#fff" style="margin-right: 5px;"></uni-icons>
                    {{ uploading ? '上传中...' : '拍视频' }}
                  </u-button>
                </view>
@@ -212,13 +212,13 @@
                  >
                    <view class="file-preview-container">
                      <image 
                        v-if="file.type === 'image'"
                        :src="file.url || file.tempFilePath || file.path"
                        v-if="file?.path?.fileType === 'image'"
                        :src="file?.url || file?.tempFilePath?.tempFilePath || file?.path?.tempFilePath"
                        class="file-preview"
                        mode="aspectFill"
                      />
                      <view v-else class="video-preview">
                        <u-icon name="video" size="24" color="#409eff"></u-icon>
                        <uni-icons type="videocam" name="videocam" size="18" color="#fff" style="margin-right: 5px;"></uni-icons>
                        <text class="video-text">视频</text>
                      </view>
                      
@@ -439,9 +439,9 @@
  if (process.env.VUE_APP_BASE_API) {
    baseUrl = process.env.VUE_APP_BASE_API;
  } else if (process.env.NODE_ENV === 'development') {
    baseUrl = 'http://192.168.1.147:9036';
    baseUrl = 'http://114.132.189.42:9068';
  } else {
    baseUrl = 'http://192.168.1.147:9036';
    baseUrl = 'http://114.132.189.42:9068';
  }
  
  return baseUrl + uploadConfig.action;
@@ -815,7 +815,6 @@
    infoData.value.storageBlobDTO = arr;
    // 添加异常状态信息
    infoData.value.hasException = hasException.value;
    const result = await uploadInspectionTask({...infoData.value});
    
    // 检查提交结果
@@ -938,7 +937,19 @@
const getAttachmentsByType = (typeValue) => {
  return attachmentList.value.filter(file => file.type === typeValue) || []
}
// 获取type值
const getTabType = () => {
   switch (currentUploadType.value) {
     case 'before':
       return 0
     case 'after':
       return 1
     case 'issue':
       return 2
     default:
       return 0
   }
}
// 获取当前查看类型的附件
const getCurrentViewAttachments = () => {
  switch (currentViewType.value) {
@@ -1007,6 +1018,54 @@
  })
}
// 使用相机
const chooseMedia = (type) => {
   let mediaPamaes={
      count: 1,
      mediaType:[type||'image'],
      sizeType: ['compressed', 'original'],
      sourceType: ['camera'],
   }
   uni.chooseMedia({
     ...mediaPamaes,
     success: (res) => {
       try {
         if (!res.tempFiles || res.tempFiles.length === 0) {
           throw new Error('未获取到图片文件');
         }
         const tempFilePath = res.tempFiles[0];
         const tempFile = res.tempFiles && res.tempFiles[0] ? res.tempFiles[0] : {};
         const file = {
           tempFilePath: tempFilePath,
           path: tempFilePath, // 保持兼容性
           type: 'image',
           name: `photo_${Date.now()}.jpg`,
           size: tempFile.size || 0,
           createTime: new Date().getTime(),
           uid: Date.now() + Math.random()
         };
         handleBeforeUpload(file);
       } catch (error) {
         console.error('处理拍照结果失败:', error);
         uni.showToast({
           title: '处理图片失败',
           icon: 'error'
         });
       }
     },
     fail: (err) => {
       console.error('拍照失败:', err);
       uni.showToast({
         title: '拍照失败: ' + (err.errMsg || '未知错误'),
         icon: 'error'
       });
     }
   })
}
// 拍照
const chooseImage = () => {
  if (uploadFiles.value.length >= uploadConfig.limit) {
@@ -1017,17 +1076,18 @@
    return;
  }
  
  uni.chooseImage({
  uni.chooseMedia({
    count: 1,
   mediaType:['image', 'video'],
    sizeType: ['compressed', 'original'],
    sourceType: ['camera'],
    success: (res) => {
      try {
        if (!res.tempFilePaths || res.tempFilePaths.length === 0) {
        if (!res.tempFiles || res.tempFiles.length === 0) {
          throw new Error('未获取到图片文件');
        }
        
        const tempFilePath = res.tempFilePaths[0];
        const tempFilePath = res.tempFiles[0];
        const tempFile = res.tempFiles && res.tempFiles[0] ? res.tempFiles[0] : {};
        
        const file = {
@@ -1229,7 +1289,7 @@
  number.value++; // 增加上传计数
  
  // 确保文件路径正确
  const filePath = file.tempFilePath || file.path;
  const filePath = file.tempFilePath?.tempFilePath || file.path?.tempFilePath||'';
  if (!filePath) {
    handleUploadError('文件路径不存在');
    return;
@@ -1248,13 +1308,12 @@
    filePath: filePath,
    name: 'files',
    formData: {
      type: uploadStatusType.value || 0
      type: getTabType() || 0
    },
    header: {
      'Authorization': `Bearer ${token}`
    }
  };
  const uploadTask = uni.uploadFile({
    ...uploadParams,
    success: (res) => {