From 944f8c5c49b1dad9bea2c82f422d9e90d150398c Mon Sep 17 00:00:00 2001
From: yyb <995253665@qq.com>
Date: 星期三, 20 五月 2026 15:39:38 +0800
Subject: [PATCH] 设备巡检
---
src/pages/inspectionUpload/index.vue | 1963 +++++++++++++++++++++++++++++++++++++++++++++-------------
1 files changed, 1,507 insertions(+), 456 deletions(-)
diff --git a/src/pages/inspectionUpload/index.vue b/src/pages/inspectionUpload/index.vue
index 3b9e0d7..bb4ea87 100644
--- a/src/pages/inspectionUpload/index.vue
+++ b/src/pages/inspectionUpload/index.vue
@@ -1,51 +1,41 @@
<template>
<view class="inspection-upload-page">
<!-- 椤甸潰澶撮儴 -->
- <PageHeader title="宸℃涓婁紶" @back="goBack"/>
-
+ <PageHeader title="璁惧宸℃" @back="goBack" />
<!-- 鏁版嵁鍒楄〃 -->
<view class="table-section">
<!-- 鐢熶骇宸℃鍒楄〃 -->
<view class="task-list">
- <view
- v-for="(item, index) in taskTableData"
- :key="index"
- class="task-item"
- @click="handleAdd(item)"
- >
+ <view v-for="(item, index) in taskTableData" :key="index" class="task-item">
<view class="task-header">
<view class="task-info">
<text class="task-name">{{ item.taskName }}</text>
<text class="task-location">{{ item.inspectionLocation }}</text>
</view>
<view class="task-actions">
- <u-button
- type="primary"
- size="small"
- @click.stop="handleAdd(item)"
- :customStyle="{
+ <u-button type="primary" size="small" :disabled="item.inspectionStatus > 0 && item.acceptStatus !== 2"
+ @click.stop="startUploadForTask(item)" :customStyle="{
borderRadius: '15px',
height: '30px',
- fontSize: '12px'
- }"
- >
- 涓婁紶
+ fontSize: '12px',
+ marginRight: '8px'
+ }">
+ 宸℃
</u-button>
- <u-button
- type="info"
- size="small"
- @click.stop="startScanForTask(item)"
- :customStyle="{
- borderRadius: '15px',
- height: '30px',
- fontSize: '12px'
- }"
- >
- 鎵爜
+ <u-button type="success" size="small" @click.stop="viewAttachments(item)" :customStyle="{
+ borderRadius: '15px',
+ height: '30px',
+ fontSize: '12px'
+ }">
+ 鏌ョ湅璇︽儏
</u-button>
</view>
</view>
<view class="task-details">
+ <view class="detail-item">
+ <text class="detail-label">浠诲姟ID</text>
+ <text class="detail-value">{{ item.taskId || item.id }}</text>
+ </view>
<view class="detail-item">
<text class="detail-label">澶囨敞</text>
<text class="detail-value">{{ item.remarks || '鏃�' }}</text>
@@ -54,557 +44,1618 @@
<text class="detail-label">鎵ц浜�</text>
<text class="detail-value">{{ item.inspector }}</text>
</view>
+ <view class="detail-item">
+ <text class="detail-label">浠诲姟涓嬪彂鏃ユ湡</text>
+ <text class="detail-value">{{ item.dateStr }}</text>
+ </view>
+ <view class="detail-item">
+ <text class="detail-label">宸℃鐘舵��</text>
+ <view class="detail-value">
+ <uni-tag v-if="item.inspectionStatus === 1" text="姝e父" size="small" type="success" inverted></uni-tag>
+ <uni-tag v-else-if="item.inspectionStatus === 2" text="寮傚父" size="small" type="error" inverted></uni-tag>
+ <uni-tag v-else text="鏈贰妫�" size="small" type="warning" inverted></uni-tag>
+ </view>
+ </view>
+ <view class="detail-item">
+ <text class="detail-label">楠屾敹鐘舵��</text>
+ <view class="detail-value">
+ <uni-tag v-if="item.acceptStatus === 1" text="宸查�氳繃" size="small" type="success" inverted></uni-tag>
+ <uni-tag v-else-if="item.acceptStatus === 2" text="宸查��鍥�" size="small" type="error" inverted></uni-tag>
+ <uni-tag v-else-if="item.inspectionStatus > 0" text="寰呴獙鏀�" size="small" type="warning"
+ inverted></uni-tag>
+ <text v-else>--</text>
+ </view>
+ </view>
</view>
</view>
+ <uni-load-more :status="loadMoreStatus"></uni-load-more>
</view>
-
<!-- 绌虹姸鎬� -->
- <view v-if="taskTableData.length === 0" class="no-data">
+ <view v-if="taskTableData?.length === 0" class="no-data">
<text>鏆傛棤鏁版嵁</text>
</view>
</view>
-
- <!-- 鎵爜鍖哄煙 - 鍏ㄥ眬寮圭獥 -->
- <view v-if="isScanning" class="qr-scan-overlay">
- <view class="qr-scan-container">
- <view class="scan-header">
- <text class="scan-title">鎵弿浜岀淮鐮�</text>
- <u-button
- type="error"
- size="small"
- @click.stop="stopScan"
- :customStyle="{
- borderRadius: '15px',
- height: '30px',
- fontSize: '12px'
- }"
- >
- 鍏抽棴
- </u-button>
+
+ <!-- 宸℃寮圭獥 -->
+ <view v-if="showUploadDialog" class="custom-modal-overlay" @click="closeUploadDialog">
+ <view class="custom-modal-container" @click.stop>
+ <view class="upload-popup-content">
+ <view class="upload-popup-header">
+ <text class="upload-popup-title">璁惧宸℃</text>
+ </view>
+ <view class="upload-popup-body">
+ <!-- 寮傚父鐘舵�侀�夋嫨 -->
+ <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>姝e父</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 v-if="hasException === true" class="media-upload-section">
+ <!-- 鎷嶇収鍜岃棰戜笂浼犳寜閽� -->
+ <view class="upload-buttons">
+ <u-button type="primary" @click="chooseMedia('image')" :loading="uploading"
+ :disabled="uploadFiles.length >= uploadConfig.limit" :customStyle="{ marginRight: '10px', flex: 1 }">
+ <u-icon name="camera" size="18" color="#fff" style="margin-right: 5px;"></u-icon>
+ {{ uploading ? '涓婁紶涓�...' : '鎷嶇収' }}
+ </u-button>
+ <u-button type="success" @click="chooseMedia('video')" :loading="uploading"
+ :disabled="uploadFiles.length >= uploadConfig.limit" :customStyle="{ flex: 1 }">
+ <uni-icons type="videocam" name="videocam" size="18" color="#fff"
+ style="margin-right: 5px;"></uni-icons>
+ {{ uploading ? '涓婁紶涓�...' : '鎷嶈棰�' }}
+ </u-button>
+ </view>
+
+ <!-- 涓婁紶杩涘害 -->
+ <view v-if="uploading" class="upload-progress">
+ <u-line-progress :percentage="uploadProgress" :showText="true" activeColor="#409eff"></u-line-progress>
+ </view>
+
+ <!-- 鏂囦欢鍒楄〃 -->
+ <view v-if="uploadFiles.length > 0" class="file-list">
+ <view v-for="(file, index) in uploadFiles" :key="index" class="file-item">
+ <view class="file-preview-container" @click="previewUploadedMedia(file)">
+ <image v-if="isImageFile(file)" :src="getFileAccessUrl(file)" class="file-preview"
+ mode="aspectFill" />
+ <view v-else-if="isVideoFile(file)" class="video-preview">
+ <uni-icons type="videocam" name="videocam" size="18" color="#fff"
+ style="margin-right: 5px;"></uni-icons>
+ <text class="video-text">瑙嗛</text>
+ </view>
+ <!-- 鍒犻櫎鎸夐挳 -->
+ <view class="delete-btn" @click.stop="removeFile(index)">
+ <u-icon name="close" size="12" color="#fff"></u-icon>
+ </view>
+ </view>
+ <view class="file-info">
+ <text class="file-name">{{ file.bucketFilename || file.name || (isImageFile(file) ? '鍥剧墖' : '瑙嗛')
+ }}</text>
+ <text class="file-size">{{ formatFileSize(file.size) }}</text>
+ </view>
+ </view>
+ </view>
+
+ <!-- 绌虹姸鎬佹彁绀� -->
+ <view v-if="uploadFiles.length === 0" class="empty-state">
+ <text>璇锋媿鎽勫紓甯告儏鍐电殑鐓х墖鎴栬棰�</text>
+ </view>
+
+ <!-- 缁熻淇℃伅 -->
+ <view class="upload-summary">
+ <text class="summary-text">
+ 宸蹭笂浼� {{ uploadFiles.length }} 涓枃浠讹紙鍥剧墖/瑙嗛锛�
+ </text>
+ </view>
+ </view>
+
+ <!-- 寮傚父鎻忚堪杈撳叆妗� -->
+ <view v-if="hasException === true" class="exception-desc-section">
+ <text class="section-title">寮傚父鎻忚堪</text>
+ <u-input v-model="exceptionDesc" type="textarea" :autoHeight="true" :minHeight="120"
+ placeholder="璇疯缁嗘弿杩板紓甯哥幇璞″強鎯呭喌" :maxlength="500" count />
+ </view>
+
+ <!-- 姝e父鐘舵�佺殑鎻愮ず -->
+ <view v-if="hasException === false" class="normal-tip">
+ <u-icon name="info-circle" size="20" color="#52c41a"></u-icon>
+ <text class="tip-text">璁惧妫�鏌ユ甯革紝鏃犻渶涓婁紶闄勪欢</text>
+ </view>
+ </view>
+
+ <view class="upload-popup-footer">
+ <u-button @click="closeUploadDialog" :customStyle="{ marginRight: '10px' }">鍙栨秷</u-button>
+ <u-button type="primary" @click="submitUpload">鎻愪氦</u-button>
+ </view>
</view>
- <camera
- class="qr-camera"
- device-position="back"
- flash="off"
- @scancode="handleScanCode"
- @error="handleCameraError"
- ></camera>
- <view class="scan-frame-wrapper">
- <view class="scan-frame"></view>
- <view class="scan-tip">璇峰皢浜岀淮鐮佹斁鍏ユ鍐�</view>
- </view>
- <u-alert
- v-if="cameraError"
- :title="cameraError"
- type="error"
- :showIcon="true"
- :closable="true"
- @close="cameraError = ''"
- :customStyle="{
- margin: '10px 0'
- }"
- ></u-alert>
</view>
</view>
-
- <!-- 寮圭獥缁勪欢 -->
- <form-dia ref="formDia" @closeDia="handleQuery"></form-dia>
+
+ <!-- 鏌ョ湅闄勪欢寮圭獥 -->
+ <view v-if="showAttachmentDialog" class="custom-modal-overlay" @click="closeAttachmentDialog">
+ <view class="custom-modal-container" @click.stop>
+ <view class="attachment-popup-content">
+ <view class="attachment-popup-header">
+ <text class="attachment-popup-title">鏌ョ湅璇︽儏 - {{ currentViewTask?.taskName }}</text>
+ <view class="close-btn-attachment" @click="closeAttachmentDialog">
+ <u-icon name="close" size="16" color="#666"></u-icon>
+ </view>
+ </view>
+ <view class="attachment-popup-body">
+ <!-- 寮傚父鎻忚堪 -->
+ <view class="detail-info-section" v-if="currentViewTask?.inspectionStatus === 2">
+ <text class="info-label">寮傚父鎻忚堪锛�</text>
+ <text class="info-value">{{ currentViewTask?.inspectionRemark || '鏃�' }}</text>
+ </view>
+ <!-- 闄勪欢鍒楄〃 -->
+ <view class="attachment-content">
+ <view v-if="attachmentList.length > 0" class="attachment-list">
+ <view v-for="(file, index) in attachmentList" :key="index" class="attachment-item"
+ @click="previewAttachment(file)">
+ <view class="attachment-preview-container">
+ <image v-if="isImageFile(file)" :src="getFileAccessUrl(file)" class="attachment-preview"
+ mode="aspectFill" />
+ <view v-else class="attachment-video-preview">
+ <u-icon name="video" size="24" color="#409eff"></u-icon>
+ <text class="video-text">瑙嗛</text>
+ </view>
+ </view>
+ <view class="attachment-info">
+ <text class="attachment-name">{{ file.originalFilename || file.bucketFilename || file.name || '闄勪欢'
+ }}</text>
+ <text class="attachment-size">{{ formatFileSize(file.byteSize || file.size) }}</text>
+ </view>
+ </view>
+ </view>
+ <view v-else class="attachment-empty">
+ <text>鏆傛棤闄勪欢</text>
+ </view>
+ </view>
+ </view>
+ </view>
+ </view>
+ </view>
+
+ <!-- 瑙嗛棰勮寮圭獥 -->
+ <view v-if="showVideoDialog" class="video-modal-overlay" @click="closeVideoPreview">
+ <view class="video-modal-container" @click.stop>
+ <view class="video-modal-header">
+ <text class="video-modal-title">{{ currentVideoFile?.originalFilename || '瑙嗛棰勮' }}</text>
+ <view class="close-btn-video" @click="closeVideoPreview">
+ <u-icon name="close" size="16" color="#fff"></u-icon>
+ </view>
+ </view>
+ <view class="video-modal-body">
+ <video v-if="currentVideoFile" :src="currentVideoFile._playUrl" class="video-player" controls autoplay
+ @error="handleVideoError"></video>
+ </view>
+ </view>
+ </view>
</view>
</template>
<script setup>
-import { onMounted, onUnmounted, ref, nextTick } from 'vue'
-import { onShow } from '@dcloudio/uni-app'
-import PageHeader from '@/components/PageHeader.vue'
-import FormDia from './components/formDia.vue'
-import { getLedgerById } from '@/api/equipmentManagement/ledger.js'
-import {inspectionTaskList} from "@/api/inspectionManagement";
-
-// 缁勪欢寮曠敤
-const formDia = ref()
+import { onMounted, onUnmounted, ref, nextTick, computed, reactive } from "vue";
+import { onShow, onReachBottom, onPullDownRefresh } from "@dcloudio/uni-app";
+import PageHeader from "@/components/PageHeader.vue";
+import {
+ inspectionTaskList,
+ uploadInspectionTask,
+} from "@/api/inspectionManagement";
+import { getToken } from "@/utils/auth";
+import config from "@/config";
// 鍔犺浇鎻愮ず鏂规硶
-const showLoadingToast = (message) => {
+const showLoadingToast = message => {
uni.showLoading({
title: message,
- mask: true
- })
-}
+ mask: true,
+ });
+};
const closeToast = () => {
- uni.hideLoading()
-}
+ uni.hideLoading();
+};
// 琛ㄦ牸鏁版嵁
-const taskTableData = ref([]) // 鐢熶骇宸℃鏁版嵁
+const taskTableData = ref([]);
-// 褰撳墠鎵弿鐨勪换鍔�
-const currentScanningTask = ref(null)
+// 褰撳墠浠诲姟淇℃伅
+const currentScanningTask = ref(null);
+const infoData = ref(null);
-// 璇锋眰鍙栨秷鏍囧織锛岀敤浜庡彇娑堟鍦ㄨ繘琛岀殑璇锋眰
-let isRequestCancelled = false
+// 涓婁紶鐩稿叧鐘舵��
+const showUploadDialog = ref(false);
+const uploadFiles = ref([]);
+const uploading = ref(false);
+const uploadProgress = ref(0);
+const number = ref(0);
-// 鎵爜鐩稿叧鐘舵��
-const isScanning = ref(false)
-const cameraError = ref('')
+// 寮傚父鐘舵��
+const hasException = ref(null);
+// 寮傚父鎻忚堪
+const exceptionDesc = ref("");
-// 鐢熷懡鍛ㄦ湡
-onMounted(() => {
- // 寤惰繜鍒濆鍖栵紝纭繚DOM宸叉覆鏌�
- nextTick(() => {
- getList()
- })
-})
+// 鏌ョ湅闄勪欢鐩稿叧鐘舵��
+const showAttachmentDialog = ref(false);
+const currentViewTask = ref(null);
+const attachmentList = ref([]);
+
+// 瑙嗛棰勮鐩稿叧鐘舵��
+const showVideoDialog = ref(false);
+const currentVideoFile = ref(null);
+
+// 涓婁紶閰嶇疆
+const uploadConfig = {
+ action: "/file/upload",
+ limit: 10,
+ fileSize: 50,
+ fileType: ["jpg", "jpeg", "png", "mp4", "mov"],
+ maxVideoDuration: 60,
+};
+
+const uploadFileUrl = computed(() => {
+ const baseUrl = config.baseUrl;
+ return baseUrl + uploadConfig.action;
+});
+
+let isRequestCancelled = false;
+
+const pagesPames = reactive({
+ size: 10,
+ current: 1,
+});
+
+const loadMoreStatus = computed(() => {
+ if (loading.value) {
+ return "loading";
+ }
+ if (noMore.value) {
+ return "noMore";
+ }
+ return "more";
+});
+const totalSize = ref(0);
+const noMore = computed(() => {
+ return taskTableData.value.length >= totalSize.value;
+});
+const loading = ref(false);
+
+const reloadPage = () => {
+ pagesPames.current = 1;
+ taskTableData.value = [];
+ getList();
+};
+const loadPage = () => {
+ if (noMore.value || loading.value) return;
+ pagesPames.current += 1;
+ getList();
+};
+
+onMounted(() => { });
+
+onReachBottom(() => {
+ loadPage();
+});
+onPullDownRefresh(() => {
+ reloadPage();
+ uni.stopPullDownRefresh();
+});
onShow(() => {
- // 椤甸潰鏄剧ず鏃跺埛鏂版暟鎹�
- getList()
-})
+ reloadPage();
+});
-// 缁勪欢閿�姣佹椂鐨勬竻鐞�
onUnmounted(() => {
- // 璁剧疆鍙栨秷鏍囧織锛岄樆姝㈠悗缁殑寮傛鎿嶄綔
- isRequestCancelled = true
-
- // 鍋滄鎵爜
- if (isScanning.value) {
- isScanning.value = false
+ isRequestCancelled = true;
+ if (showUploadDialog.value) {
+ showUploadDialog.value = false;
}
-})
+});
-// 杩斿洖涓婁竴椤�
const goBack = () => {
- uni.navigateBack()
-}
+ uni.navigateBack();
+};
-// 鏌ヨ鏁版嵁
-const handleQuery = () => {
- getList()
-}
-
-// 鑾峰彇鍒楄〃鏁版嵁
const getList = () => {
- // 鏄剧ず鍔犺浇鎻愮ず
- showLoadingToast('鍔犺浇涓�...')
-
- // 璁剧疆鍙栨秷鏍囧織
- isRequestCancelled = false
-
- inspectionTaskList({}).then(res => {
- // 妫�鏌ョ粍浠舵槸鍚﹁繕瀛樺湪涓旇姹傛湭琚彇娑�
- if (!isRequestCancelled) {
- console.log('鐢熶骇宸℃API杩斿洖鏁版嵁:', res);
-
- // 澶勭悊涓嶅悓鐨勬暟鎹粨鏋�
- let records = [];
- if (res && res.data) {
- // 灏濊瘯澶氱鍙兘鐨勬暟鎹粨鏋�
- if (Array.isArray(res.data.records)) {
- records = res.data.records;
- } else if (Array.isArray(res.data.rows)) {
- records = res.data.rows;
- } else if (Array.isArray(res.data)) {
- records = res.data;
- } else if (Array.isArray(res.data.list)) {
- records = res.data.list;
+ isRequestCancelled = false;
+ loading.value = true;
+ inspectionTaskList({ ...pagesPames })
+ .then(res => {
+ if (!isRequestCancelled) {
+ let records = [];
+ if (res && res.data) {
+ totalSize.value = res.data.total;
+ if (Array.isArray(res.data.records)) {
+ records = res.data.records;
+ } else if (Array.isArray(res.data.rows)) {
+ records = res.data.rows;
+ } else if (Array.isArray(res.data)) {
+ records = res.data;
+ } else if (Array.isArray(res.data.list)) {
+ records = res.data.list;
+ }
+ }
+
+ if (records.length > 0) {
+ taskTableData.value = [
+ ...taskTableData.value,
+ ...records.map(record => {
+ record.fileStatus = getFileStatus(record);
+ return record;
+ }),
+ ];
+ } else {
+ taskTableData.value = [];
+ uni.showToast({
+ title: "鏆傛棤宸℃浠诲姟鏁版嵁",
+ icon: "none",
+ });
}
}
-
- if (records.length > 0) {
- taskTableData.value = records;
- console.log('鐢熶骇宸℃鏁版嵁璁剧疆鎴愬姛锛岃褰曟暟:', records.length);
- } else {
- console.warn('鐢熶骇宸℃鏁版嵁涓虹┖鎴栨牸寮忎笉姝g‘:', res);
+ loading.value = false;
+ })
+ .catch(err => {
+ if (!isRequestCancelled) {
taskTableData.value = [];
uni.showToast({
- title: '鏆傛棤宸℃浠诲姟鏁版嵁',
- icon: 'none'
+ title: "鑾峰彇鏁版嵁澶辫触",
+ icon: "error",
});
}
- }
- // 鍏抽棴鍔犺浇鎻愮ず
- closeToast()
- }).catch(err => {
- // 妫�鏌ョ粍浠舵槸鍚﹁繕瀛樺湪涓旇姹傛湭琚彇娑�
- if (!isRequestCancelled) {
- console.error('鑾峰彇鐢熶骇宸℃鏁版嵁澶辫触:', err);
- taskTableData.value = [];
- // 娣诲姞閿欒鎻愮ず
- uni.showToast({
- title: '鑾峰彇鏁版嵁澶辫触',
- icon: 'error'
- })
- }
- // 鍏抽棴鍔犺浇鎻愮ず
- closeToast()
- })
-}
+ loading.value = false;
+ });
+};
-
-// 涓婁紶
-const handleAdd = (row) => {
- nextTick(() => {
- // 妫�鏌ョ粍浠舵槸鍚﹁繕瀛樺湪
- if (formDia.value && formDia.value.openDialog) {
- formDia.value.openDialog(row)
- } else {
- console.error('涓婁紶缁勪欢寮曠敤涓嶅瓨鍦�')
- uni.showToast({
- title: '缁勪欢鏈噯澶囧ソ',
- icon: 'error'
- })
- }
- })
-}
-
-// 涓烘寚瀹氫换鍔″紑濮嬫壂鐮�
-const startScanForTask = async (task) => {
- try {
- // 璁板綍褰撳墠鎵弿鐨勪换鍔�
- currentScanningTask.value = task
- console.log('涓轰换鍔″紑濮嬫壂鐮�:', task.taskName)
-
- // 鏄剧ず鎵弿鐣岄潰
- isScanning.value = true
-
- // 浣跨敤uniapp鐨勬壂鐮丄PI
- uni.scanCode({
- success: (res) => {
- console.log('鎵爜鎴愬姛:', res)
- handleScanSuccess(res)
- },
- fail: (err) => {
- console.error('鎵爜澶辫触:', err)
- uni.showToast({
- title: '鎵爜澶辫触',
- icon: 'error'
- })
- // 鍏抽棴鎵弿鐣岄潰
- isScanning.value = false
- },
- complete: () => {
- // 鎵爜瀹屾垚鍚庡叧闂壂鎻忕晫闈�
- setTimeout(() => {
- isScanning.value = false
- }, 1000)
- }
- })
- } catch (e) {
- console.error('鍚姩鎵爜澶辫触:', e)
- uni.showToast({
- title: '鍚姩鎵爜澶辫触',
- icon: 'error'
- })
- isScanning.value = false
+const getFileStatus = record => {
+ // 鏍规嵁鏄惁鏈夐檮浠跺垽鏂姸鎬�
+ let hasFiles = false;
+ if (record.commonFileList && record.commonFileList.length > 0) {
+ hasFiles = true;
}
-}
+ if (record.commonFileListBefore && record.commonFileListBefore.length > 0) {
+ hasFiles = true;
+ }
+ if (record.commonFileListAfter && record.commonFileListAfter.length > 0) {
+ hasFiles = true;
+ }
+ return hasFiles ? 2 : 0;
+};
-// 鍋滄鎵爜
-const stopScan = () => {
- isScanning.value = false
- currentScanningTask.value = null
-}
+const openUploadDialog = task => {
+ if (task) {
+ infoData.value = {
+ ...task,
+ taskId: task.taskId || task.id,
+ storageBlobDTO: [],
+ };
+ }
+ showUploadDialog.value = true;
+};
-// 鎵爜鎴愬姛澶勭悊
-const handleScanSuccess = async (result) => {
+const closeUploadDialog = () => {
+ showUploadDialog.value = false;
+ uploadFiles.value = [];
+ hasException.value = null;
+ exceptionDesc.value = "";
+ infoData.value = null;
+};
+
+const setExceptionStatus = status => {
+ hasException.value = status;
+ // 鍒囨崲鐘舵�佹椂娓呯┖鏂囦欢
+ if (status === false) {
+ uploadFiles.value = [];
+ exceptionDesc.value = "";
+ }
+};
+
+const goToRepair = () => {
try {
- console.log('澶勭悊鎵爜缁撴灉:', result)
- console.log('褰撳墠鍏宠仈浠诲姟:', currentScanningTask.value?.taskName)
-
+ const taskInfo = {
+ taskId: infoData.value?.taskId || infoData.value?.id,
+ taskName: infoData.value?.taskName,
+ inspectionLocation: infoData.value?.inspectionLocation,
+ inspector: infoData.value?.inspector,
+ uploadedFiles: uploadFiles.value,
+ exceptionDesc: exceptionDesc.value,
+ };
+
+ uni.setStorageSync("repairTaskInfo", JSON.stringify(taskInfo));
+ uni.navigateTo({
+ url: "/pages/equipmentManagement/repair/add",
+ });
+ closeUploadDialog();
+ } catch (error) {
+ console.error("璺宠浆鎶ヤ慨椤甸潰澶辫触:", error);
uni.showToast({
- title: '璇嗗埆鎴愬姛',
- icon: 'success'
- })
-
- // 瑙f瀽浜岀淮鐮佹暟鎹�
- let qrData
- let deviceId = ''
-
- try {
- qrData = JSON.parse(result.result)
- console.log('瑙f瀽鐨勪簩缁寸爜鏁版嵁:', qrData)
- deviceId = qrData.deviceId || qrData.qrCodeId
- } catch (e) {
- // 濡傛灉涓嶆槸JSON鏍煎紡锛屽皾璇曚粠URL涓彁鍙杁eviceId
- const url = result.result
-
- if (url.includes('deviceId=')) {
- // 浠嶶RL涓彁鍙杁eviceId
- const match = url.match(/deviceId=(\d+)/)
- if (match && match[1]) {
- deviceId = match[1]
- }
- }
-
- qrData = {
- deviceName: deviceId ? `璁惧${deviceId}` : result.result,
- location: '',
- qrCodeId: deviceId // 浣跨敤鎻愬彇鐨刣eviceId鎴栧師濮嬬粨鏋�
- }
+ title: "璺宠浆澶辫触锛岃閲嶈瘯",
+ icon: "error",
+ });
+ }
+};
+
+const submitUpload = async () => {
+ try {
+ // 妫�鏌ユ槸鍚﹂�夋嫨浜嗗紓甯哥姸鎬�
+ if (hasException.value === null) {
+ uni.showToast({
+ title: "璇烽�夋嫨璁惧鐘舵��",
+ icon: "none",
+ });
+ return;
}
-
- // 濡傛灉鏈夎澶嘔D锛屽皾璇曚粠API鑾峰彇鐪熷疄鐨勮澶囧悕绉�
- if (deviceId) {
- try {
- console.log('姝e湪鏌ヨ璁惧淇℃伅锛岃澶嘔D:', deviceId)
- const response = await getLedgerById(deviceId)
- console.log('璁惧淇℃伅鏌ヨ缁撴灉:', response)
-
- if (response.code === 200 && response.data) {
- qrData.deviceName = response.data.deviceName || `璁惧${deviceId}`
- qrData.location = response.data.storageLocation || ''
- console.log('鑾峰彇鍒拌澶囧悕绉�:', qrData.deviceName)
- } else {
- console.warn('璁惧淇℃伅鏌ヨ澶辫触锛屼娇鐢ㄩ粯璁ゅ悕绉�')
- qrData.deviceName = qrData.deviceName || `璁惧${deviceId}`
- }
- } catch (apiError) {
- console.error('鏌ヨ璁惧淇℃伅澶辫触:', apiError)
- // API璋冪敤澶辫触鏃朵娇鐢ㄩ粯璁ゅ悕绉�
- qrData.deviceName = qrData.deviceName || `璁惧${deviceId}`
+
+ // 濡傛灉寮傚父鐘舵�侊紝妫�鏌ユ槸鍚︽湁鏂囦欢
+ if (hasException.value === true && uploadFiles.value.length === 0) {
+ uni.showToast({
+ title: "璇蜂笂浼犲紓甯哥収鐗囨垨瑙嗛",
+ icon: "none",
+ });
+ return;
+ }
+
+ showLoadingToast("鎻愪氦涓�...");
+
+ // 鏀堕泦鎵�鏈夋枃浠�
+ let arr = [...uploadFiles.value];
+
+ // 涓存椂鏂囦欢ID鍒楄〃
+ let tempFileIds = [];
+ if (arr.length > 0) {
+ tempFileIds = arr
+ .map(item => item?.tempId ?? item?.tempFileId ?? item?.id)
+ .filter(v => v !== undefined && v !== null && v !== "");
+ }
+
+ // 鎻愪氦鏁版嵁
+ infoData.value.storageBlobDTO = arr;
+ infoData.value.hasException = hasException.value;
+ infoData.value.tempFileIds = tempFileIds;
+ // 濡傛灉瀛樺湪寮傚父锛屾坊鍔犲紓甯告弿杩�
+ if (hasException.value === true) {
+ infoData.value.inspectionRemark = exceptionDesc.value;
+ }
+
+ const result = await uploadInspectionTask({ ...infoData.value });
+
+ if (result && (result.code === 200 || result.success)) {
+ closeToast();
+ uni.showToast({
+ title: "鎻愪氦鎴愬姛",
+ icon: "success",
+ });
+
+ const currentHasException = hasException.value;
+ const taskInfoCopy = {
+ taskId: infoData.value?.taskId || infoData.value?.id,
+ taskName: infoData.value?.taskName,
+ inspectionLocation: infoData.value?.inspectionLocation,
+ inspector: infoData.value?.inspector,
+ uploadedFiles: [...uploadFiles.value],
+ exceptionDesc: exceptionDesc.value,
+ };
+
+ closeUploadDialog();
+
+ if (currentHasException) {
+ uni.showModal({
+ title: "鎻愮ず",
+ content: "鏄惁鏂板鎶ヤ慨锛�",
+ success: function (res) {
+ if (res.confirm) {
+ uni.setStorageSync("repairTaskInfo", JSON.stringify(taskInfoCopy));
+ uni.navigateTo({
+ url: "/pages/equipmentManagement/repair/add",
+ });
+ }
+ setTimeout(() => {
+ reloadPage();
+ }, 500);
+ }
+ });
+ } else {
+ setTimeout(() => {
+ reloadPage();
+ }, 500);
}
- }
-
- // 纭繚鏁版嵁瀹屾暣鎬�
- if (!qrData.deviceName) {
- qrData.deviceName = result.result
- }
- if (!qrData.qrCodeId) {
- qrData.qrCodeId = deviceId || result.result
- }
-
- // 灏嗘壂鐮佹暟鎹笌浠诲姟鍏宠仈
- if (currentScanningTask.value) {
- // 鍏宠仈浠诲姟淇℃伅
- const taskData = {
- ...currentScanningTask.value,
- qrCodeData: qrData
- }
-
- // 鎵撳紑涓婁紶寮圭獥锛屼紶閫掑叧鑱斿悗鐨勪换鍔℃暟鎹�
- nextTick(() => {
- if (formDia.value && formDia.value.openDialog) {
- formDia.value.openDialog(taskData)
- } else {
- console.error('涓婁紶缁勪欢寮曠敤涓嶅瓨鍦�')
- uni.showToast({
- title: '缁勪欢鏈噯澶囧ソ',
- icon: 'error'
- })
- }
- })
+ } else {
+ closeToast();
+ uni.showToast({
+ title: result?.msg || result?.message || "鎻愪氦澶辫触",
+ icon: "error",
+ });
}
} catch (error) {
- console.error('澶勭悊鎵爜缁撴灉澶辫触:', error)
+ console.error("鎻愪氦澶辫触:", error);
+ closeToast();
+
+ let errorMessage = "鎻愪氦澶辫触";
+ if (error.message) {
+ errorMessage = error.message;
+ } else if (error.msg) {
+ errorMessage = error.msg;
+ } else if (typeof error === "string") {
+ errorMessage = error;
+ }
+
uni.showToast({
- title: error.message || '鏁版嵁瑙f瀽澶辫触',
- icon: 'error'
- })
- } finally {
- // 鍏抽棴鎵弿鐣岄潰
- isScanning.value = false
+ title: errorMessage,
+ icon: "error",
+ });
}
-}
+};
-// 鎽勫儚澶撮敊璇鐞�
-const handleCameraError = (error) => {
- console.error('鎽勫儚澶撮敊璇�:', error)
- cameraError.value = '鎽勫儚澶磋闂け璐ワ紝璇锋鏌ユ潈闄愯缃�'
-}
-</script>
+const startUploadForTask = async (task, type) => {
+ openUploadDialog(task);
+};
-<style scoped lang="scss">
-// 瀵煎叆閿�鍞ā鍧楀叕鍏辨牱寮�
-@import '@/styles/sales-common.scss';
+const viewAttachments = async task => {
+ try {
+ currentViewTask.value = task;
+ attachmentList.value = [];
-// 椤甸潰瀹瑰櫒鏍峰紡
-.inspection-upload-page {
- min-height: 100vh;
- background: #f8f9fa;
- position: relative;
-}
+ // 鏀堕泦鎵�鏈夐檮浠�
+ let allFiles = [];
+ if (task?.commonFileList) {
+ allFiles = allFiles.concat(task.commonFileList);
+ }
+ if (task?.commonFileListBefore) {
+ allFiles = allFiles.concat(task.commonFileListBefore);
+ }
+ if (task?.commonFileListAfter) {
+ allFiles = allFiles.concat(task.commonFileListAfter);
+ }
-// 鍒楄〃瀹瑰櫒鏍峰紡
-.table-section {
- padding: 20px;
-}
+ attachmentList.value = allFiles.map(file => ({
+ ...file,
+ name: file?.name || file?.originalFilename || file?.bucketFilename,
+ bucketFilename: file?.bucketFilename || file?.name,
+ originalFilename: file?.originalFilename || file?.name,
+ url: getFileAccessUrl(file),
+ downloadUrl: getFileAccessUrl(file),
+ size: file?.size || file?.byteSize,
+ }));
-// 浠诲姟鍒楄〃鏍峰紡 - 浣跨敤閿�鍞彴璐︾殑鏍峰紡瑙勮寖
-.task-list {
- .task-item {
- background: #ffffff;
- border-radius: 12px;
- margin-bottom: 16px;
- overflow: hidden;
- box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
- padding: 0 16px;
-
- &:active {
- transform: scale(0.98);
- box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
+ showAttachmentDialog.value = true;
+ } catch (error) {
+ uni.showToast({
+ title: "鑾峰彇闄勪欢澶辫触",
+ icon: "error",
+ });
+ }
+};
+
+const closeAttachmentDialog = () => {
+ showAttachmentDialog.value = false;
+ currentViewTask.value = null;
+ attachmentList.value = [];
+};
+
+const isImageFile = file => {
+ if (file.contentType && file.contentType.startsWith("image/")) {
+ return true;
+ }
+ if (file.type === "image" || file.mediaType === "image") return true;
+ const name = file.bucketFilename || file.originalFilename || file.name || "";
+ const ext = name.split(".").pop()?.toLowerCase();
+ return ["jpg", "jpeg", "png", "gif", "webp"].includes(ext);
+};
+
+const isVideoFile = file => {
+ if (!file) return false;
+ if (file.type === "video" || file.mediaType === "video") return true;
+ const name = file.bucketFilename || file.originalFilename || file.name || "";
+ const ext = name.split(".").pop()?.toLowerCase();
+ return ["mp4", "mov", "avi", "wmv", "mkv", "webm"].includes(ext);
+};
+
+const filePreviewBase = config.fileUrl;
+
+const normalizeFileUrl = (rawUrl = "") => {
+ let fileUrl = rawUrl || "";
+ if (typeof fileUrl === "string") {
+ fileUrl = fileUrl.trim().replace(/^['"]|['"]$/g, "");
+ }
+ const javaApi = filePreviewBase;
+ const localPrefixes = ["wxfile://", "file://", "content://", "blob:", "data:"];
+
+ if (localPrefixes.some(prefix => fileUrl.startsWith(prefix))) {
+ return fileUrl;
+ }
+
+ if (fileUrl && fileUrl.indexOf("\\") > -1) {
+ const lowerPath = fileUrl.toLowerCase();
+ const uploadPathIndex = lowerPath.indexOf("uploadpath");
+ const prodIndex = lowerPath.indexOf("\\prod\\");
+
+ if (uploadPathIndex > -1) {
+ fileUrl = fileUrl.substring(uploadPathIndex).replace(/\\/g, "/");
+ } else if (prodIndex > -1) {
+ fileUrl = fileUrl
+ .substring(prodIndex + "\\prod\\".length)
+ .replace(/\\/g, "/");
+ } else {
+ fileUrl = fileUrl.replace(/\\/g, "/");
}
}
+
+ const normalizedLower = String(fileUrl).toLowerCase();
+ const fileProdIdx = normalizedLower.indexOf("/file/prod/");
+ if (fileProdIdx > -1) {
+ fileUrl = `/profile/prod/${fileUrl.substring(fileProdIdx + "/file/prod/".length)}`;
+ }
+ const fileTempIdx = normalizedLower.indexOf("/file/temp/");
+ if (fileTempIdx > -1) {
+ fileUrl = `/profile/temp/${fileUrl.substring(fileTempIdx + "/file/temp/".length)}`;
+ }
+
+ if (/^\/?uploadPath/i.test(fileUrl)) {
+ fileUrl = fileUrl.replace(/^\/?uploadPath/i, "/profile");
+ }
+
+ if (fileUrl && !fileUrl.startsWith("http")) {
+ if (!fileUrl.startsWith("/")) fileUrl = "/" + fileUrl;
+ fileUrl = javaApi + fileUrl;
+ }
+
+ return fileUrl;
+};
+
+const getFileAccessUrl = (file = {}) => {
+ if (file?.link) {
+ if (String(file.link).startsWith("http")) return file.link;
+ return normalizeFileUrl(file.link);
+ }
+ const remoteUrl = normalizeFileUrl(
+ file?.url ||
+ file?.downloadUrl ||
+ file?.tempPath ||
+ ""
+ );
+ if (remoteUrl) return remoteUrl;
+ if (file?._localPreviewUrl) return file._localPreviewUrl;
+ return normalizeFileUrl(file?.tempFilePath || file?.path || "");
+};
+
+const previewUploadedMedia = file => {
+ if (!file) return;
+ if (isImageFile(file)) {
+ const imageUrls = uploadFiles.value
+ .filter(f => isImageFile(f))
+ .map(f => getFileAccessUrl(f))
+ .filter(Boolean);
+ const current = getFileAccessUrl(file);
+ if (!imageUrls.length || !current) return;
+ uni.previewImage({
+ urls: imageUrls,
+ current,
+ });
+ return;
+ }
+ if (isVideoFile(file)) {
+ playVideoFile(file);
+ }
+};
+
+const previewAttachment = file => {
+ if (isImageFile(file)) {
+ const imageUrls = attachmentList.value
+ .filter(f => isImageFile(f))
+ .map(f => getFileAccessUrl(f));
+
+ uni.previewImage({
+ urls: imageUrls,
+ current: getFileAccessUrl(file),
+ });
+ } else {
+ playVideoFile(file);
+ }
+};
+
+const safeEncodeUrl = url => {
+ if (!url) return "";
+ if (!/^https?:\/\//i.test(url)) return url;
+ try {
+ return encodeURI(url);
+ } catch (e) {
+ return url;
+ }
+};
+
+const getPlayableVideoUrl = file => {
+ return safeEncodeUrl(getFileAccessUrl(file));
+};
+
+const getFallbackLocalVideoUrl = file => {
+ const local = file?._localPreviewUrl || file?.tempFilePath || file?.path || "";
+ return safeEncodeUrl(local);
+};
+
+const playVideoFile = file => {
+ const remoteSrc = getPlayableVideoUrl(file);
+ const localSrc = getFallbackLocalVideoUrl(file);
+ const src = remoteSrc || localSrc;
+ if (!src) {
+ uni.showToast({
+ title: "瑙嗛鍦板潃鏃犳晥",
+ icon: "none",
+ });
+ return;
+ }
+
+ showVideoPreview({
+ ...file,
+ _playUrl: src,
+ _playUrlLocal: localSrc,
+ _playUrlRemote: remoteSrc,
+ });
+};
+
+const showVideoPreview = file => {
+ currentVideoFile.value = file;
+ showVideoDialog.value = true;
+};
+
+const closeVideoPreview = () => {
+ showVideoDialog.value = false;
+ currentVideoFile.value = null;
+};
+
+const handleVideoError = () => {
+ const localUrl = currentVideoFile.value?._playUrlLocal;
+ const remoteUrl = currentVideoFile.value?._playUrlRemote;
+ const currentUrl = currentVideoFile.value?._playUrl;
+ if (remoteUrl && currentUrl !== remoteUrl) {
+ currentVideoFile.value = {
+ ...currentVideoFile.value,
+ _playUrl: remoteUrl,
+ };
+ uni.showToast({
+ title: "宸插垏鎹㈣繙绋嬭棰戦噸璇曟挱鏀�",
+ icon: "none",
+ });
+ return;
+ }
+ if (localUrl && currentUrl !== localUrl) {
+ currentVideoFile.value = {
+ ...currentVideoFile.value,
+ _playUrl: localUrl,
+ };
+ uni.showToast({
+ title: "宸插垏鎹㈡湰鍦拌棰戦噸璇曟挱鏀�",
+ icon: "none",
+ });
+ return;
+ }
+ uni.showToast({
+ title: "瑙嗛鎾斁澶辫触",
+ icon: "error",
+ });
+};
+
+const chooseMedia = type => {
+ if (uploadFiles.value.length >= uploadConfig.limit) {
+ uni.showToast({
+ title: `鏈�澶氬彧鑳介�夋嫨${uploadConfig.limit}涓枃浠禶,
+ icon: "none",
+ });
+ return;
+ }
+
+ const remaining = uploadConfig.limit - uploadFiles.value.length;
+
+ if (typeof uni.chooseMedia === "function") {
+ uni.chooseMedia({
+ count: Math.min(remaining, 1),
+ mediaType: [type || "image"],
+ sizeType: ["compressed", "original"],
+ sourceType: ["camera"],
+ success: res => {
+ try {
+ const files = res?.tempFiles || [];
+ if (!files.length) throw new Error("鏈幏鍙栧埌鏂囦欢");
+
+ files.forEach((tf, idx) => {
+ const filePath = tf.tempFilePath || tf.path || "";
+ const fileType = tf.fileType || type || "image";
+ const ext = fileType === "video" ? "mp4" : "jpg";
+ const file = {
+ tempFilePath: filePath,
+ path: filePath,
+ type: fileType,
+ name: `${fileType}_${Date.now()}_${idx}.${ext}`,
+ size: tf.size || 0,
+ duration: tf.duration || 0,
+ createTime: Date.now(),
+ uid: Date.now() + Math.random() + idx,
+ };
+ handleBeforeUpload(file);
+ });
+ } catch (e) {
+ console.error("澶勭悊鎷嶆憚缁撴灉澶辫触:", e);
+ uni.showToast({ title: "澶勭悊鏂囦欢澶辫触", icon: "error" });
+ }
+ },
+ fail: err => {
+ console.error("鎷嶆憚澶辫触:", err);
+ uni.showToast({ title: "鎷嶆憚澶辫触", icon: "error" });
+ },
+ });
+ return;
+ }
+
+ if (type === "video") {
+ chooseVideo();
+ } else {
+ uni.chooseImage({
+ count: 1,
+ sizeType: ["compressed", "original"],
+ sourceType: ["camera"],
+ success: res => {
+ const tempFilePath = res?.tempFilePaths?.[0];
+ const tempFile = res?.tempFiles?.[0] || {};
+ if (!tempFilePath) return;
+ handleBeforeUpload({
+ tempFilePath,
+ path: tempFilePath,
+ type: "image",
+ name: `photo_${Date.now()}.jpg`,
+ size: tempFile.size || 0,
+ createTime: Date.now(),
+ uid: Date.now() + Math.random(),
+ });
+ },
+ });
+ }
+};
+
+const removeFile = index => {
+ uni.showModal({
+ title: "纭鍒犻櫎",
+ content: "纭畾瑕佸垹闄よ繖涓枃浠跺悧锛�",
+ success: res => {
+ if (res.confirm) {
+ uploadFiles.value.splice(index, 1);
+ uni.showToast({
+ title: "鍒犻櫎鎴愬姛",
+ icon: "success",
+ });
+ }
+ },
+ });
+};
+
+const handleBeforeUpload = async file => {
+ if (uploadConfig.fileType && Array.isArray(uploadConfig.fileType) && uploadConfig.fileType.length > 0) {
+ const fileName = file.name || "";
+ const fileExtension = fileName ? fileName.split(".").pop().toLowerCase() : "";
+
+ let expectedTypes = [];
+ if (file.type === "image") {
+ expectedTypes = ["jpg", "jpeg", "png", "gif", "webp"];
+ } else if (file.type === "video") {
+ expectedTypes = ["mp4", "mov", "avi", "wmv"];
+ }
+
+ if (fileExtension && expectedTypes.length > 0) {
+ const isAllowed = expectedTypes.some(
+ type => uploadConfig.fileType.includes(type) && type === fileExtension
+ );
+
+ if (!isAllowed) {
+ uni.showToast({
+ title: `鏂囦欢鏍煎紡涓嶆敮鎸侊紝璇锋媿鎽� ${expectedTypes.join("/")} 鏍煎紡鐨勬枃浠禶,
+ icon: "none",
+ });
+ return false;
+ }
+ }
+ }
+
+ uploadFile(file);
+ return true;
+};
+
+const uploadFile = async file => {
+ uploading.value = true;
+ uploadProgress.value = 0;
+ number.value++;
+
+ const token = getToken();
+ if (!token) {
+ handleUploadError("鐢ㄦ埛鏈櫥褰�");
+ return;
+ }
+
+ const typeValue = 12; // 缁熶竴浣跨敤 type=12 琛ㄧず宸℃闄勪欢
+
+ uploadWithUniUploadFile(
+ file,
+ file.tempFilePath || file.path || "",
+ typeValue,
+ token
+ );
+};
+
+const uploadWithUniUploadFile = (file, filePath, typeValue, token) => {
+ if (!filePath) {
+ handleUploadError("鏂囦欢璺緞涓嶅瓨鍦�");
+ return;
+ }
+
+ const uploadTask = uni.uploadFile({
+ url: uploadFileUrl.value,
+ filePath: filePath,
+ name: "file",
+ formData: {
+ type: typeValue,
+ },
+ header: {
+ Authorization: `Bearer ${token}`,
+ },
+ success: res => {
+ try {
+ if (res.statusCode === 200) {
+ const response = JSON.parse(res.data);
+ if (response.code === 200) {
+ handleUploadSuccess(response, file);
+ uni.showToast({
+ title: "涓婁紶鎴愬姛",
+ icon: "success",
+ });
+ } else {
+ handleUploadError(response.msg || "鏈嶅姟鍣ㄨ繑鍥為敊璇�");
+ }
+ } else {
+ handleUploadError(`鏈嶅姟鍣ㄩ敊璇紝鐘舵�佺爜: ${res.statusCode}`);
+ }
+ } catch (e) {
+ console.error("瑙f瀽鍝嶅簲澶辫触:", e);
+ handleUploadError("鍝嶅簲鏁版嵁瑙f瀽澶辫触: " + e.message);
+ }
+ },
+ fail: err => {
+ console.error("涓婁紶澶辫触:", err.errMsg || err);
+ number.value--;
+
+ let errorMessage = "涓婁紶澶辫触";
+ if (err.errMsg) {
+ if (err.errMsg.includes("statusCode: null")) {
+ errorMessage = "缃戠粶杩炴帴澶辫触锛岃妫�鏌ョ綉缁滆缃�";
+ } else if (err.errMsg.includes("timeout")) {
+ errorMessage = "涓婁紶瓒呮椂锛岃閲嶈瘯";
+ } else if (err.errMsg.includes("fail")) {
+ errorMessage = "涓婁紶澶辫触锛岃妫�鏌ョ綉缁滆繛鎺�";
+ } else {
+ errorMessage = err.errMsg;
+ }
+ }
+
+ handleUploadError(errorMessage);
+ },
+ complete: () => {
+ uploading.value = false;
+ uploadProgress.value = 0;
+ },
+ });
+
+ if (uploadTask && uploadTask.onProgressUpdate) {
+ uploadTask.onProgressUpdate(res => {
+ uploadProgress.value = res.progress;
+ });
+ }
+};
+
+const handleUploadError = (message = "涓婁紶鏂囦欢澶辫触") => {
+ uploading.value = false;
+ uploadProgress.value = 0;
+ uni.showToast({
+ title: message,
+ icon: "error",
+ });
+};
+
+const handleUploadSuccess = (res, file) => {
+ console.log("涓婁紶鎴愬姛鍝嶅簲:", res);
+
+ let uploadedFile = null;
+ uploadedFile = res.data;
+
+ if (!uploadedFile) {
+ console.error("鏃犳硶瑙f瀽涓婁紶鍝嶅簲鏁版嵁:", res);
+ number.value--;
+ handleUploadError("涓婁紶鍝嶅簲鏁版嵁鏍煎紡閿欒");
+ return;
+ }
+
+ const fileData = {
+ ...file,
+ id: uploadedFile.id,
+ tempId: uploadedFile.tempId ?? uploadedFile.tempFileId ?? uploadedFile.id,
+ url: uploadedFile.url || uploadedFile.downloadUrl || uploadedFile.tempPath || file.tempFilePath || file.path,
+ tempPath: uploadedFile.tempPath || file.tempPath || "",
+ _localPreviewUrl: file.tempFilePath || file.path || "",
+ bucketFilename: uploadedFile.bucketFilename || uploadedFile.originalFilename || uploadedFile.originalName || file.name,
+ downloadUrl: uploadedFile.downloadUrl || uploadedFile.url,
+ size: uploadedFile.size || uploadedFile.byteSize || file.size,
+ createTime: uploadedFile.createTime || new Date().getTime(),
+ mediaType: file.type || uploadedFile.mediaType,
+ type: 20, // 缁熶竴浣跨敤 type=20
+ };
+
+ uploadFiles.value.push(fileData);
+ number.value = 0;
+};
+
+const formatFileSize = size => {
+ if (!size) return "";
+ if (size < 1024) return size + "B";
+ if (size < 1024 * 1024) return (size / 1024).toFixed(1) + "KB";
+ return (size / (1024 * 1024)).toFixed(1) + "MB";
+};
+</script>
+
+<style scoped>
+.inspection-upload-page {
+ min-height: 100vh;
+ background-color: #f5f5f5;
}
-// 椤圭洰澶撮儴鏍峰紡
-.task-header {
- padding: 16px 0;
+.table-section {
+ padding: 15px;
+}
+
+.task-list {
display: flex;
- align-items: center;
+ flex-direction: column;
+ gap: 12px;
+}
+
+.task-item {
+ background: #fff;
+ border-radius: 12px;
+ padding: 15px;
+ box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
+ transition: all 0.3s ease;
+}
+
+.task-header {
+ display: flex;
justify-content: space-between;
- margin-bottom: 0;
+ align-items: flex-start;
+ margin-bottom: 12px;
}
.task-info {
flex: 1;
+ display: flex;
+ flex-direction: column;
+ gap: 4px;
}
.task-name {
- font-size: 14px;
+ font-size: 16px;
+ font-weight: 600;
color: #333;
- font-weight: 500;
- margin-bottom: 0;
- line-height: 1.4;
}
.task-location {
- font-size: 12px;
+ font-size: 14px;
color: #666;
- margin-top: 4px;
}
-// 浠诲姟鎿嶄綔鎸夐挳鏍峰紡
.task-actions {
display: flex;
- align-items: center;
gap: 8px;
- margin-left: 0;
}
-// 浠诲姟璇︽儏鏍峰紡 - 浣跨敤閿�鍞彴璐︾殑璇︽儏琛屾牱寮�
.task-details {
- padding: 16px 0;
-
- .detail-item {
- display: flex;
- align-items: flex-end;
- justify-content: space-between;
- margin-bottom: 8px;
-
- &:last-child {
- margin-bottom: 0;
- }
-
- .detail-label {
- font-size: 12px;
- color: #777777;
- min-width: 60px;
- flex-shrink: 0;
- }
-
- .detail-value {
- font-size: 12px;
- color: #000000;
- text-align: right;
- flex: 1;
- margin-left: 16px;
- line-height: 1.4;
- }
- }
+ display: flex;
+ flex-direction: column;
+ gap: 6px;
}
-// 鏃犳暟鎹彁绀烘牱寮� - 浣跨敤閿�鍞彴璐︾殑鏍峰紡
+.detail-item {
+ display: flex;
+ justify-content: space-between;
+ align-items: center;
+}
+
+.detail-label {
+ font-size: 12px;
+ color: #999;
+}
+
+.detail-value {
+ font-size: 12px;
+ color: #666;
+ font-weight: 500;
+}
+
.no-data {
- padding: 40px 0;
text-align: center;
+ padding: 40px 20px;
color: #999;
- background: none;
- margin: 0;
-}
-
-.no-data text {
font-size: 14px;
- color: #999;
}
-/* 鎵爜寮圭獥鏍峰紡 */
-.qr-scan-overlay {
+.custom-modal-overlay {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
- background-color: rgba(0, 0, 0, 0.8);
- z-index: 9999;
+ background: rgba(0, 0, 0, 0.5);
+ z-index: 10000;
display: flex;
- flex-direction: column;
- justify-content: center;
align-items: center;
+ justify-content: center;
padding: 20px;
}
-.qr-scan-container {
+.custom-modal-container {
width: 100%;
- max-width: 400px;
- background-color: #000;
- border-radius: 12px;
- overflow: hidden;
+ max-width: 500px;
+ max-height: 80vh;
+ display: flex;
+ align-items: center;
+ justify-content: center;
}
-.scan-header {
+.upload-popup-content {
+ background: #fff;
+ border-radius: 12px;
+ width: 100%;
+ min-height: 300px;
+ max-height: 80vh;
+ overflow: hidden;
+ display: flex;
+ flex-direction: column;
+ box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
+}
+
+.upload-popup-header {
display: flex;
justify-content: space-between;
align-items: center;
- padding: 15px;
- background-color: rgba(0, 0, 0, 0.7);
+ padding: 15px 20px;
+ border-bottom: 1px solid #eee;
}
-.scan-title {
- font-size: 18px;
+.upload-popup-title {
+ font-size: 16px;
font-weight: 600;
- color: #fff;
+ color: #333;
}
-.qr-camera {
- width: 100%;
- height: 400px;
+.upload-popup-body {
+ flex: 1;
+ padding: 20px;
+ overflow-y: auto;
}
-.scan-frame-wrapper {
+.upload-popup-footer {
+ display: flex;
+ justify-content: flex-end;
+ padding: 15px 20px;
+ border-top: 1px solid #eee;
+ gap: 10px;
+}
+
+.upload-buttons {
+ display: flex;
+ gap: 10px;
+ margin-bottom: 15px;
+}
+
+.file-list {
+ margin-top: 15px;
+ display: flex;
+ flex-wrap: wrap;
+ gap: 12px;
+}
+
+.file-item {
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ background: #fff;
+ border-radius: 12px;
+ padding: 8px;
+ border: 1px solid #e9ecef;
+ box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
+ transition: all 0.3s ease;
+ width: calc(50% - 6px);
+ min-width: 120px;
+}
+
+.file-preview-container {
position: relative;
- width: 100%;
- height: 300px;
+ margin-bottom: 8px;
}
-.scan-frame {
- position: absolute;
- top: 50%;
- left: 50%;
- transform: translate(-50%, -50%);
- width: 80%;
- height: 80%;
- border: 3px solid #1890ff;
+.file-preview {
+ width: 80px;
+ height: 80px;
border-radius: 8px;
- box-shadow: 0 0 20px rgba(24, 144, 255, 0.3);
- animation: pulse 2s infinite;
+ object-fit: cover;
+ border: 2px solid #f0f0f0;
}
-.scan-tip {
+.video-preview {
+ width: 80px;
+ height: 80px;
+ background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
+ border-radius: 8px;
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ justify-content: center;
+ border: 2px solid #f0f0f0;
+}
+
+.video-text {
+ font-size: 12px;
+ color: #666;
+ margin-top: 4px;
+}
+
+.delete-btn {
position: absolute;
- bottom: 10px;
- left: 50%;
- transform: translateX(-50%);
- color: #fff;
- font-size: 14px;
+ top: -6px;
+ right: -6px;
+ width: 20px;
+ height: 20px;
+ background: #ff4757;
+ border-radius: 50%;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ cursor: pointer;
+ box-shadow: 0 2px 4px rgba(255, 71, 87, 0.3);
+ transition: all 0.3s ease;
+}
+
+.file-info {
text-align: center;
- background-color: rgba(0, 0, 0, 0.6);
- padding: 5px 15px;
- border-radius: 20px;
+ width: 100%;
}
-@keyframes pulse {
- 0% { opacity: 0.8; }
- 50% { opacity: 0.4; }
- 100% { opacity: 0.8; }
+.file-name {
+ font-size: 12px;
+ color: #333;
+ font-weight: 500;
+ display: block;
+ white-space: nowrap;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ max-width: 100px;
}
-</style>
\ No newline at end of file
+.file-size {
+ font-size: 10px;
+ color: #999;
+ margin-top: 2px;
+ display: block;
+}
+
+.empty-state {
+ text-align: center;
+ padding: 40px 20px;
+ color: #999;
+ font-size: 14px;
+ background: #f8f9fa;
+ border-radius: 8px;
+ border: 2px dashed #ddd;
+}
+
+.upload-progress {
+ margin: 15px 0;
+ padding: 0 10px;
+}
+
+.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-desc-section {
+ margin-top: 15px;
+}
+
+.normal-tip {
+ display: flex;
+ align-items: center;
+ gap: 8px;
+ padding: 15px;
+ background: #f6ffed;
+ border: 1px solid #b7eb8f;
+ border-radius: 8px;
+}
+
+.tip-text {
+ font-size: 14px;
+ color: #52c41a;
+}
+
+.upload-summary {
+ margin-top: 15px;
+ padding: 10px;
+ background: #f8f9fa;
+ border-radius: 6px;
+ border-left: 3px solid #409eff;
+}
+
+.summary-text {
+ font-size: 12px;
+ color: #666;
+ line-height: 1.4;
+}
+
+.media-upload-section {
+ margin-bottom: 15px;
+}
+
+.attachment-popup-content {
+ background: #fff;
+ border-radius: 12px;
+ width: 100%;
+ min-height: 400px;
+ max-height: 70vh;
+ overflow: hidden;
+ display: flex;
+ flex-direction: column;
+ box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
+}
+
+.detail-info-section {
+ padding: 10px;
+ background-color: #fff2f0;
+ border: 1px solid #ffccc7;
+ border-radius: 8px;
+ margin-bottom: 15px;
+}
+
+.info-label {
+ font-size: 14px;
+ font-weight: 600;
+ color: #ff4d4f;
+}
+
+.info-value {
+ font-size: 14px;
+ color: #ff4d4f;
+ margin-top: 5px;
+ display: block;
+}
+
+.attachment-popup-header {
+ display: flex;
+ justify-content: space-between;
+ align-items: center;
+ padding: 15px 20px;
+ border-bottom: 1px solid #eee;
+ background: #f8f9fa;
+}
+
+.attachment-popup-title {
+ font-size: 16px;
+ font-weight: 600;
+ color: #333;
+}
+
+.close-btn-attachment {
+ width: 28px;
+ height: 28px;
+ border-radius: 50%;
+ background: #f5f5f5;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ cursor: pointer;
+ transition: all 0.3s ease;
+}
+
+.attachment-popup-body {
+ flex: 1;
+ padding: 15px 20px;
+ overflow-y: auto;
+}
+
+.attachment-content {
+ min-height: 200px;
+}
+
+.attachment-list {
+ display: flex;
+ flex-wrap: wrap;
+ gap: 12px;
+}
+
+.attachment-item {
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ background: #fff;
+ border-radius: 12px;
+ padding: 8px;
+ border: 1px solid #e9ecef;
+ box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
+ transition: all 0.3s ease;
+ width: calc(33.33% - 8px);
+ min-width: 100px;
+ cursor: pointer;
+}
+
+.attachment-preview-container {
+ margin-bottom: 8px;
+}
+
+.attachment-preview {
+ width: 80px;
+ height: 80px;
+ border-radius: 8px;
+ object-fit: cover;
+ border: 2px solid #f0f0f0;
+}
+
+.attachment-video-preview {
+ width: 80px;
+ height: 80px;
+ background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
+ border-radius: 8px;
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ justify-content: center;
+ border: 2px solid #f0f0f0;
+}
+
+.attachment-info {
+ text-align: center;
+ width: 100%;
+}
+
+.attachment-name {
+ font-size: 12px;
+ color: #333;
+ font-weight: 500;
+ display: block;
+ white-space: nowrap;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ max-width: 80px;
+}
+
+.attachment-size {
+ font-size: 10px;
+ color: #999;
+ margin-top: 2px;
+ display: block;
+}
+
+.attachment-empty {
+ text-align: center;
+ padding: 60px 20px;
+ color: #999;
+ font-size: 14px;
+ background: #f8f9fa;
+ border-radius: 8px;
+ border: 2px dashed #ddd;
+}
+
+.video-modal-overlay {
+ position: fixed;
+ top: 0;
+ left: 0;
+ right: 0;
+ bottom: 0;
+ background: rgba(0, 0, 0, 0.8);
+ z-index: 10001;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ padding: 20px;
+}
+
+.video-modal-container {
+ width: 90%;
+ max-width: 800px;
+ max-height: 80vh;
+ background: #000;
+ border-radius: 12px;
+ overflow: hidden;
+ box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
+}
+
+.video-modal-header {
+ display: flex;
+ justify-content: space-between;
+ align-items: center;
+ padding: 15px 20px;
+ background: rgba(0, 0, 0, 0.7);
+ color: #fff;
+}
+
+.video-modal-title {
+ font-size: 16px;
+ font-weight: 500;
+ color: #fff;
+}
+
+.close-btn-video {
+ width: 28px;
+ height: 28px;
+ border-radius: 50%;
+ background: rgba(255, 255, 255, 0.2);
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ cursor: pointer;
+ transition: all 0.3s ease;
+}
+
+.video-modal-body {
+ position: relative;
+ background: #000;
+}
+
+.video-player {
+ width: 100%;
+ height: 56vh;
+ min-height: 260px;
+ max-height: 60vh;
+ display: block;
+ object-fit: contain;
+}
+</style>
--
Gitblit v1.9.3