From bbdd646b82cb8c84079598b7200b1102fd247b28 Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期一, 29 十二月 2025 16:08:48 +0800
Subject: [PATCH] 昭德-巡检上传开发调整
---
src/pages/inspectionUpload/components/formDia.vue | 334 ++++-
src/pages/management/mould/equipmentRequisitionDialog.vue | 129 +
src/pages/management/index.vue | 382 +++---
src/pages/inspectionUpload/index.vue | 2400 ++++++------------------------------------
src/components/imageUpload/index.vue | 16
src/components/imageUpload/viewQrCodeFiles.vue | 17
6 files changed, 916 insertions(+), 2,362 deletions(-)
diff --git a/src/components/imageUpload/index.vue b/src/components/imageUpload/index.vue
index 51e4331..a329a81 100644
--- a/src/components/imageUpload/index.vue
+++ b/src/components/imageUpload/index.vue
@@ -99,6 +99,7 @@
<script setup>
import { ref, computed, watch, onMounted, onUnmounted, nextTick } from 'vue';
import { getToken } from "@/utils/auth";
+import config from '@/config.js';
// Props 瀹氫箟
const props = defineProps({
@@ -130,19 +131,10 @@
// 璁$畻灞炴��
const uploadFileUrl = computed(() => {
- // 鑾峰彇鍩虹API鍦板潃锛岄�傞厤uniapp鐜
- let baseUrl = '';
-
- // 灏濊瘯澶氱鏂瑰紡鑾峰彇baseUrl
- 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';
- } else {
- baseUrl = 'http://192.168.1.147:9036';
- }
-
+ // 鑾峰彇鍩虹API鍦板潃锛屼紭鍏堜娇鐢� config.js 涓殑 baseUrl
+ const baseUrl = config.baseUrl || process.env.VUE_APP_BASE_API || 'http://192.168.1.147:7016';
const fullUrl = baseUrl + props.action;
+ console.log('涓婁紶URL:', fullUrl);
return fullUrl;
});
const headers = computed(() => {
diff --git a/src/components/imageUpload/viewQrCodeFiles.vue b/src/components/imageUpload/viewQrCodeFiles.vue
index 32f5684..4961d4d 100644
--- a/src/components/imageUpload/viewQrCodeFiles.vue
+++ b/src/components/imageUpload/viewQrCodeFiles.vue
@@ -2,22 +2,20 @@
<view>
<!-- 寮圭獥 -->
<u-popup
- v-model="dialogVisitable"
+ :show="dialogVisitable"
mode="center"
- width="90%"
- height="80%"
border-radius="20"
@close="cancel"
+ :closeable="true"
+ :customStyle="{
+ width: '92vw',
+ maxWidth: '720rpx',
+ height: '82vh'
+ }"
>
<view class="popup-content">
<view class="popup-header">
<text class="popup-title">鏌ョ湅闄勪欢</text>
- <u-icon
- name="close"
- size="24"
- color="#999"
- @click="cancel"
- ></u-icon>
</view>
<view class="upload-container">
@@ -173,6 +171,7 @@
<style scoped lang="scss">
.popup-content {
height: 100%;
+ width: 100%;
display: flex;
flex-direction: column;
}
diff --git a/src/pages/inspectionUpload/components/formDia.vue b/src/pages/inspectionUpload/components/formDia.vue
index 41837cb..5372423 100644
--- a/src/pages/inspectionUpload/components/formDia.vue
+++ b/src/pages/inspectionUpload/components/formDia.vue
@@ -1,6 +1,6 @@
<template>
<u-popup
- v-model="dialogVisitable"
+ :show="dialogVisitable"
mode="center"
:round="10"
:closeable="true"
@@ -14,47 +14,68 @@
<view class="upload-container">
<view class="form-container">
<view class="title">鐢熶骇鍓�</view>
- <u-upload
- :fileList="beforeModelValue"
- @afterRead="afterRead"
- @delete="deleteFile"
- name="before"
- multiple
- :maxCount="10"
- :maxSize="1024 * 1024"
- accept="video/*"
- :previewFullImage="true"
- ></u-upload>
+ <view class="upload-buttons">
+ <u-button type="primary" size="small" @click="chooseVideo('before')" :disabled="beforeModelValue.length >= 10">
+ <u-icon name="video" size="16" color="#fff" style="margin-right: 5px;"></u-icon>
+ 閫夋嫨瑙嗛
+ </u-button>
+ <text class="file-count">{{ beforeModelValue.length }}/10</text>
+ </view>
+ <view class="file-list" v-if="beforeModelValue.length > 0">
+ <view v-for="(file, index) in beforeModelValue" :key="index" class="file-item">
+ <text class="file-name">瑙嗛{{ index + 1 }}</text>
+ <u-button
+ type="error"
+ size="mini"
+ :customStyle="{ minWidth: '120rpx', width: 'auto', padding: '0 20rpx', height: '60rpx' }"
+ @click="deleteFile(index, 'before')"
+ >鍒犻櫎</u-button>
+ </view>
+ </view>
</view>
<view class="form-container">
<view class="title">鐢熶骇鍚�</view>
- <u-upload
- :fileList="afterModelValue"
- @afterRead="afterRead"
- @delete="deleteFile"
- name="after"
- multiple
- :maxCount="10"
- :maxSize="1024 * 1024"
- accept="video/*"
- :previewFullImage="true"
- ></u-upload>
+ <view class="upload-buttons">
+ <u-button type="primary" size="small" @click="chooseVideo('after')" :disabled="afterModelValue.length >= 10">
+ <u-icon name="video" size="16" color="#fff" style="margin-right: 5px;"></u-icon>
+ 閫夋嫨瑙嗛
+ </u-button>
+ <text class="file-count">{{ afterModelValue.length }}/10</text>
+ </view>
+ <view class="file-list" v-if="afterModelValue.length > 0">
+ <view v-for="(file, index) in afterModelValue" :key="index" class="file-item">
+ <text class="file-name">瑙嗛{{ index + 1 }}</text>
+ <u-button
+ type="error"
+ size="mini"
+ :customStyle="{ minWidth: '120rpx', width: 'auto', padding: '0 20rpx', height: '60rpx' }"
+ @click="deleteFile(index, 'after')"
+ >鍒犻櫎</u-button>
+ </view>
+ </view>
</view>
<view class="form-container">
<view class="title">鐢熶骇闂</view>
- <u-upload
- :fileList="issueModelValue"
- @afterRead="afterRead"
- @delete="deleteFile"
- name="issue"
- multiple
- :maxCount="10"
- :maxSize="1024 * 1024"
- accept="video/*"
- :previewFullImage="true"
- ></u-upload>
+ <view class="upload-buttons">
+ <u-button type="primary" size="small" @click="chooseVideo('issue')" :disabled="issueModelValue.length >= 10">
+ <u-icon name="video" size="16" color="#fff" style="margin-right: 5px;"></u-icon>
+ 閫夋嫨瑙嗛
+ </u-button>
+ <text class="file-count">{{ issueModelValue.length }}/10</text>
+ </view>
+ <view class="file-list" v-if="issueModelValue.length > 0">
+ <view v-for="(file, index) in issueModelValue" :key="index" class="file-item">
+ <text class="file-name">瑙嗛{{ index + 1 }}</text>
+ <u-button
+ type="error"
+ size="mini"
+ :customStyle="{ minWidth: '120rpx', width: 'auto', padding: '0 20rpx', height: '60rpx' }"
+ @click="deleteFile(index, 'issue')"
+ >鍒犻櫎</u-button>
+ </view>
+ </view>
</view>
</view>
@@ -67,10 +88,23 @@
</template>
<script setup>
-import { ref } from 'vue'
+import { ref, computed } from 'vue'
import { submitInspectionRecord } from '@/api/equipmentManagement/inspection.js'
+import { getToken } from '@/utils/auth'
+import config from '@/config.js'
const emit = defineEmits(['closeDia'])
+
+// 涓婁紶鎺ュ彛URL
+const uploadFileUrl = computed(() => {
+ return config.baseUrl + '/common/minioUploads'
+})
+
+// 涓婁紶璇锋眰澶�
+const uploadHeaders = computed(() => {
+ const token = getToken()
+ return token ? { Authorization: 'Bearer ' + token } : {}
+})
const dialogVisitable = ref(false)
const beforeModelValue = ref([])
@@ -78,63 +112,171 @@
const issueModelValue = ref([])
const infoData = ref(null)
-// 鏂囦欢涓婁紶澶勭悊
-const afterRead = (event) => {
- const { name, file } = event
+// 閫夋嫨瑙嗛
+const chooseVideo = (type) => {
+ const currentList = type === 'before' ? beforeModelValue : type === 'after' ? afterModelValue : issueModelValue;
- // 涓婁紶鏂囦欢鍒版湇鍔″櫒
- uni.uploadFile({
- url: '/api/upload', // 鏇挎崲涓哄疄闄呯殑涓婁紶鎺ュ彛
- filePath: file.url,
- name: 'file',
+ if (currentList.value.length >= 10) {
+ uni.showToast({
+ title: '鏈�澶氬彧鑳介�夋嫨10涓棰�',
+ icon: 'none'
+ });
+ return;
+ }
+
+ uni.chooseVideo({
+ sourceType: ['camera', 'album'],
+ maxDuration: 60,
+ camera: 'back',
success: (res) => {
- const data = JSON.parse(res.data)
- if (data.code === 200) {
+ try {
+ if (!res.tempFilePath) {
+ throw new Error('鏈幏鍙栧埌瑙嗛鏂囦欢');
+ }
+
+ // 浠庝复鏃惰矾寰勪腑鎻愬彇鏂囦欢鍚嶏紝鍋氫负鍒濆灞曠ず
+ const tempName = res.tempFilePath.split('/').pop() || `video_${Date.now()}.mp4`
const fileItem = {
- url: data.data.url,
- name: file.name,
- status: 'success'
- }
+ url: res.tempFilePath,
+ name: tempName,
+ originalFilename: tempName,
+ size: res.size || 0,
+ duration: res.duration || 0,
+ status: 'pending' // 寰呬笂浼犵姸鎬�
+ };
- // 鏍规嵁name娣诲姞鍒板搴旂殑鏁扮粍
- if (name === 'before') {
- beforeModelValue.value.push(fileItem)
- } else if (name === 'after') {
- afterModelValue.value.push(fileItem)
- } else if (name === 'issue') {
- issueModelValue.value.push(fileItem)
- }
+ // 娣诲姞鍒板搴旂殑鏁扮粍
+ currentList.value.push(fileItem);
+ // 鑷姩涓婁紶
+ uploadFile(fileItem, type, currentList.value.length - 1);
+ } catch (error) {
+ console.error('澶勭悊瑙嗛澶辫触:', error);
uni.showToast({
- title: '涓婁紶鎴愬姛',
- icon: 'success'
- })
- } else {
- uni.showToast({
- title: '涓婁紶澶辫触',
+ title: '澶勭悊瑙嗛澶辫触',
icon: 'error'
- })
+ });
}
},
- fail: () => {
+ fail: (err) => {
+ console.error('閫夋嫨瑙嗛澶辫触:', err);
uni.showToast({
- title: '涓婁紶澶辫触',
+ title: '閫夋嫨瑙嗛澶辫触: ' + (err.errMsg || '鏈煡閿欒'),
icon: 'error'
- })
+ });
}
- })
+ });
+}
+
+// 涓婁紶鏂囦欢鍒版湇鍔″櫒
+const uploadFile = (fileItem, type, index) => {
+ fileItem.status = 'uploading';
+
+ // 纭繚token瀛樺湪
+ const token = getToken();
+ if (!token) {
+ fileItem.status = 'failed';
+ uni.showToast({
+ title: '鐢ㄦ埛鏈櫥褰�',
+ icon: 'error'
+ });
+ return;
+ }
+
+ uni.uploadFile({
+ url: uploadFileUrl.value,
+ filePath: fileItem.url,
+ name: 'files', // 娉ㄦ剰锛氭帴鍙d娇鐢ㄧ殑鏄� 'files' 鑰屼笉鏄� 'file'
+ header: {
+ 'Authorization': `Bearer ${token}`
+ },
+ success: (res) => {
+ try {
+ if (res.statusCode === 200) {
+ const response = typeof res.data === 'string' ? JSON.parse(res.data) : res.data;
+ if (response.code === 200) {
+ // 鍝嶅簲鏁版嵁鏄暟缁勬牸寮忥紝鍙栫涓�涓厓绱�
+ const uploadedFile = Array.isArray(response.data) ? response.data[0] : response.data;
+
+ console.log('涓婁紶鎴愬姛锛岃繑鍥炵殑鏂囦欢淇℃伅:', uploadedFile);
+ console.log('鍘熷鏂囦欢鍚�:', uploadedFile.originalFilename);
+
+ // 鏇存柊鏂囦欢淇℃伅 - 浣跨敤 Object.assign 纭繚鍝嶅簲寮忔洿鏂�
+ const displayName = uploadedFile.originalFilename
+ || uploadedFile.bucketFilename
+ || fileItem.name
+ || '鏈懡鍚嶆枃浠�';
+ Object.assign(fileItem, {
+ url: uploadedFile.url || uploadedFile.downloadUrl,
+ status: 'success',
+ id: uploadedFile.id,
+ name: displayName,
+ originalFilename: uploadedFile.originalFilename || displayName, // 淇濆瓨鍘熷鏂囦欢鍚�
+ bucketFilename: uploadedFile.bucketFilename,
+ downloadUrl: uploadedFile.downloadUrl || uploadedFile.url,
+ size: uploadedFile.byteSize || fileItem.size,
+ createTime: uploadedFile.createTime || new Date().getTime()
+ });
+
+ console.log('鏇存柊鍚庣殑鏂囦欢椤�:', fileItem);
+
+ uni.showToast({
+ title: '涓婁紶鎴愬姛',
+ icon: 'success'
+ });
+ } else {
+ fileItem.status = 'failed';
+ uni.showToast({
+ title: response.msg || '涓婁紶澶辫触',
+ icon: 'error'
+ });
+ }
+ } else {
+ fileItem.status = 'failed';
+ uni.showToast({
+ title: `鏈嶅姟鍣ㄩ敊璇紝鐘舵�佺爜: ${res.statusCode}`,
+ icon: 'error'
+ });
+ }
+ } catch (e) {
+ fileItem.status = 'failed';
+ console.error('瑙f瀽鍝嶅簲澶辫触:', e);
+ console.error('鍘熷鍝嶅簲鏁版嵁:', res.data);
+ uni.showToast({
+ title: '瑙f瀽鍝嶅簲澶辫触',
+ icon: 'error'
+ });
+ }
+ },
+ fail: (err) => {
+ fileItem.status = 'failed';
+ console.error('涓婁紶澶辫触:', err);
+ let errorMessage = '涓婁紶澶辫触';
+ if (err.errMsg) {
+ if (err.errMsg.includes('statusCode: null')) {
+ errorMessage = '缃戠粶杩炴帴澶辫触锛岃妫�鏌ョ綉缁滆缃�';
+ } else if (err.errMsg.includes('timeout')) {
+ errorMessage = '涓婁紶瓒呮椂锛岃閲嶈瘯';
+ } else {
+ errorMessage = err.errMsg;
+ }
+ }
+ uni.showToast({
+ title: errorMessage,
+ icon: 'error'
+ });
+ }
+ });
}
// 鍒犻櫎鏂囦欢
-const deleteFile = (event) => {
- const { name, index } = event
-
- if (name === 'before') {
- beforeModelValue.value.splice(index, 1)
- } else if (name === 'after') {
- afterModelValue.value.splice(index, 1)
- } else if (name === 'issue') {
- issueModelValue.value.splice(index, 1)
+const deleteFile = (index, type) => {
+ if (type === 'before') {
+ beforeModelValue.value.splice(index, 1);
+ } else if (type === 'after') {
+ afterModelValue.value.splice(index, 1);
+ } else if (type === 'issue') {
+ issueModelValue.value.splice(index, 1);
}
}
@@ -253,4 +395,42 @@
border-top: 1px solid #f0f0f0;
background-color: #fafafa;
}
+
+.upload-buttons {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ margin-bottom: 10px;
+}
+
+.file-count {
+ font-size: 12px;
+ color: #999;
+}
+
+.file-list {
+ margin-top: 10px;
+}
+
+.file-item {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ padding: 8px 0;
+ border-bottom: 1px solid #f0f0f0;
+}
+
+.file-item:last-child {
+ border-bottom: none;
+}
+
+.file-name {
+ font-size: 14px;
+ color: #333;
+ flex: 1;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+ margin-right: 10px;
+}
</style>
diff --git a/src/pages/inspectionUpload/index.vue b/src/pages/inspectionUpload/index.vue
index a31902d..4f257c1 100644
--- a/src/pages/inspectionUpload/index.vue
+++ b/src/pages/inspectionUpload/index.vue
@@ -1,2080 +1,430 @@
<template>
- <view class="inspection-upload-page">
- <!-- 椤甸潰澶撮儴 -->
- <PageHeader title="宸℃涓婁紶" @back="goBack"/>
-
- <!-- 鏁版嵁鍒楄〃 -->
- <view class="table-section">
- <!-- 鐢熶骇宸℃鍒楄〃 -->
- <view class="task-list">
- <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="startScanForTask(item)"
- :customStyle="{
- borderRadius: '15px',
- height: '30px',
- fontSize: '12px',
- marginRight: '8px'
- }"
- >
- 鎵爜涓婁紶
- </u-button>
- <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>
- </view>
- <view class="detail-item">
- <text class="detail-label">鎵ц浜�</text>
- <text class="detail-value">{{ item.inspector }}</text>
- </view>
- </view>
- </view>
- </view>
-
- <!-- 绌虹姸鎬� -->
- <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>
- <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>
-
- <!-- 鍥剧墖涓婁紶寮圭獥 - 鍘熺敓瀹炵幇 -->
- <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="upload-tabs">
- <view
- class="tab-item"
- :class="{ active: currentUploadType === 'before' }"
- @click="switchUploadType('before')"
- >
- 鐢熶骇鍓�
- </view>
- <view
- class="tab-item"
- :class="{ active: currentUploadType === 'after' }"
- @click="switchUploadType('after')"
- >
- 鐢熶骇涓�
- </view>
- <view
- class="tab-item"
- :class="{ active: currentUploadType === 'issue' }"
- @click="switchUploadType('issue')"
- >
- 鐢熶骇鍚�
- </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>姝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 class="simple-upload-area">
- <view class="upload-buttons">
- <u-button
- type="primary"
- @click="chooseImage"
- :loading="uploading"
- :disabled="getCurrentFiles().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="chooseVideo"
- :loading="uploading"
- :disabled="getCurrentFiles().length >= uploadConfig.limit"
- :customStyle="{ flex: 1 }"
- >
- <u-icon name="video" size="18" color="#fff" style="margin-right: 5px;"></u-icon>
- {{ 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="getCurrentFiles().length > 0" class="file-list">
- <view
- v-for="(file, index) in getCurrentFiles()"
- :key="index"
- class="file-item"
- >
- <view class="file-preview-container">
- <image
- v-if="file.type === 'image'"
- :src="file.url || file.tempFilePath || file.path"
- class="file-preview"
- mode="aspectFill"
- />
- <view v-else class="video-preview">
- <u-icon name="video" size="24" color="#409eff"></u-icon>
- <text class="video-text">瑙嗛</text>
- </view>
-
- <!-- 鍒犻櫎鎸夐挳 -->
- <view class="delete-btn" @click="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 || (file.type === 'image' ? '鍥剧墖' : '瑙嗛') }}</text>
- <text class="file-size">{{ formatFileSize(file.size) }}</text>
- </view>
- </view>
- </view>
-
- <view v-if="getCurrentFiles().length === 0" class="empty-state">
- <text>璇烽�夋嫨瑕佷笂浼犵殑{{ getUploadTypeText() }}鍥剧墖鎴栬棰�</text>
- </view>
-
- <!-- 缁熻淇℃伅 -->
- <view class="upload-summary">
- <text class="summary-text">
- 鐢熶骇鍓�: {{ beforeModelValue.length }}涓枃浠� |
- 鐢熶骇涓�: {{ afterModelValue.length }}涓枃浠� |
- 鐢熶骇鍚�: {{ issueModelValue.length }}涓枃浠�
- </text>
- </view>
- </view>
- </view>
-
- <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>
- </view>
- </view>
-
- <!-- 鏌ョ湅闄勪欢寮圭獥 -->
- <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="attachment-tabs">
- <view
- class="tab-item"
- :class="{ active: currentViewType === 'before' }"
- @click="switchViewType('before')"
- >
- 鐢熶骇鍓� ({{ getAttachmentsByType(0).length }})
- </view>
- <view
- class="tab-item"
- :class="{ active: currentViewType === 'after' }"
- @click="switchViewType('after')"
- >
- 鐢熶骇涓� ({{ getAttachmentsByType(1).length }})
- </view>
- <view
- class="tab-item"
- :class="{ active: currentViewType === 'issue' }"
- @click="switchViewType('issue')"
- >
- 鐢熶骇鍚� ({{ getAttachmentsByType(2).length }})
- </view>
- </view>
-
- <!-- 褰撳墠鍒嗙被鐨勯檮浠跺垪琛� -->
- <view class="attachment-content">
- <view v-if="getCurrentViewAttachments().length > 0" class="attachment-list">
- <view
- v-for="(file, index) in getCurrentViewAttachments()"
- :key="index"
- class="attachment-item"
- @click="previewAttachment(file)"
- >
- <view class="attachment-preview-container">
- <image
- v-if="file.type === 'image' || isImageFile(file)"
- :src="file.url || file.downloadUrl"
- 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.url || currentVideoFile.downloadUrl"
- class="video-player"
- controls
- autoplay
- @error="handleVideoError"
- ></video>
- </view>
- </view>
- </view>
- </view>
+ <view class="app-container">
+ <!-- 椤甸潰澶撮儴 -->
+ <PageHeader title="宸℃涓婁紶" @back="goBack"/>
+ <view class="card-container">
+ <!-- 鏍囩椤� -->
+ <u-tabs
+ :list="tabs"
+ :current="activeTabIndex"
+ @change="handleTabChange"
+ :scrollable="false"
+ lineWidth="30"
+ lineColor="#2979ff"
+ :activeStyle="{
+ color: '#2979ff',
+ fontWeight: 'bold'
+ }"
+ />
+ <view>
+ <!-- 鎵爜妯″潡 -->
+ <view v-if="activeTab === 'qrCode'" class="scan-section">
+ <view class="scan-controls">
+ <u-button
+ type="primary"
+ :loading="scanLoading"
+ @click="toggleScan"
+ >
+ {{ scanButtonText }}
+ </u-button>
+ </view>
+
+ <!-- 鐘舵�佹彁绀� -->
+ <view class="status-info">
+ <u-alert
+ v-if="cameraError"
+ :title="cameraError"
+ type="error"
+ :show-icon="true"
+ :closable="true"
+ @close="cameraError = null"
+ />
+ <view v-if="isScanning" class="scanning-text">
+ <u-loading-icon mode="spinner" :color="statusColor" />
+ <text>姝e湪鎵弿浜岀淮鐮�...</text>
+ </view>
+ </view>
+ </view>
+ <view>
+ <!-- 鍔犺浇鐘舵�� -->
+ <view v-if="tableLoading" class="loading-container">
+ <u-loading-icon text="鍔犺浇涓�..." />
+ </view>
+
+ <!-- 鐢熶骇宸℃鍒楄〃 -->
+ <view v-else-if="activeTab !== 'qrCode' && tableData.length > 0" class="list-container">
+ <view v-for="(item, index) in tableData" :key="index" class="list-item">
+ <view class="item-content">
+ <view class="item-row">
+ <text class="item-label">宸℃浠诲姟鍚嶇О锛�</text>
+ <text class="item-value">{{ item.taskName || '-' }}</text>
+ </view>
+ <view class="item-row">
+ <text class="item-label">鍦扮偣锛�</text>
+ <text class="item-value">{{ item.inspectionLocation || '-' }}</text>
+ </view>
+ <view class="item-row">
+ <text class="item-label">澶囨敞锛�</text>
+ <text class="item-value">{{ item.remarks || '-' }}</text>
+ </view>
+ <view class="item-row">
+ <text class="item-label">鎵ц宸℃浜猴細</text>
+ <text class="item-value">{{ item.inspector || '-' }}</text>
+ </view>
+ </view>
+ <view class="item-actions">
+ <u-button type="primary" size="small" @click="handleAdd(item)">涓婁紶</u-button>
+ </view>
+ </view>
+ </view>
+
+ <!-- 鐜板満宸℃鍒楄〃 -->
+ <view v-else-if="activeTab === 'qrCode' && tableData.length > 0" class="list-container">
+ <view v-for="(item, index) in tableData" :key="index" class="list-item">
+ <view class="item-content">
+ <view class="item-row">
+ <text class="item-label">璁惧鍚嶇О锛�</text>
+ <text class="item-value">{{ item.deviceName || '-' }}</text>
+ </view>
+ <view class="item-row">
+ <text class="item-label">鎵�鍦ㄤ綅缃弿杩帮細</text>
+ <text class="item-value">{{ item.location || '-' }}</text>
+ </view>
+ <view class="item-row">
+ <text class="item-label">宸℃浜猴細</text>
+ <text class="item-value">{{ item.scanner || '-' }}</text>
+ </view>
+ <view class="item-row">
+ <text class="item-label">宸℃鏃堕棿锛�</text>
+ <text class="item-value">{{ item.scanTime || '-' }}</text>
+ </view>
+ </view>
+ <view class="item-actions">
+ <u-button type="primary" size="small" @click="viewFile(item)">鏌ョ湅闄勪欢</u-button>
+ </view>
+ </view>
+ </view>
+
+ <!-- 绌烘暟鎹� -->
+ <view v-else-if="!tableLoading && tableData.length === 0" class="no-data">
+ <text>鏆傛棤鏁版嵁</text>
+ </view>
+ </view>
+ </view>
+ </view>
+ <form-dia ref="formDia" @closeDia="handleQuery"></form-dia>
+ <qr-code-form-dia ref="qrCodeFormDia" @closeDia="handleQuery"></qr-code-form-dia>
+ <view-qr-code-files ref="viewQrCodeFiles"></view-qr-code-files>
+ </view>
</template>
<script setup>
-import { onMounted, onUnmounted, ref, nextTick, computed } from 'vue'
-import { onShow } from '@dcloudio/uni-app'
-import PageHeader from '@/components/PageHeader.vue'
-import { getLedgerById } from '@/api/equipmentManagement/ledger.js'
-import {inspectionTaskList, uploadInspectionTask} from "@/api/inspectionManagement";
-import { getToken } from "@/utils/auth";
+import { onMounted, ref, reactive, computed, nextTick } from "vue";
+import FormDia from "@/pages/inspectionUpload/components/formDia.vue";
+import { useToast } from '@/utils/uviewplus';
+import QrCodeFormDia from "@/pages/inspectionUpload/components/qrCodeFormDia.vue";
+import { qrCodeList, qrCodeScanRecordList } from "@/api/inspectionUpload/index.js";
+import { inspectionTaskList } from "@/api/inspectionManagement/index.js";
+import ViewQrCodeFiles from "@/components/imageUpload/viewQrCodeFiles.vue";
-// 缁勪欢寮曠敤宸茬Щ闄�
+const { showToast } = useToast();
-// 鍔犺浇鎻愮ず鏂规硶
-const showLoadingToast = (message) => {
- uni.showLoading({
- title: message,
- mask: true
- })
-}
-const closeToast = () => {
- uni.hideLoading()
-}
+const formDia = ref();
+const qrCodeFormDia = ref();
+const viewQrCodeFiles = ref();
+
+// 褰撳墠鏍囩
+const activeTab = ref("task");
+const activeTabIndex = ref(0);
+const tabName = ref("task");
+
+// 鏍囩椤垫暟鎹�
+const tabs = reactive([
+ { name: "鐢熶骇宸℃", value: "task" },
+ { name: "鐜板満宸℃", value: "qrCode" },
+]);
+
// 琛ㄦ牸鏁版嵁
-const taskTableData = ref([]) // 鐢熶骇宸℃鏁版嵁
-
-// 褰撳墠鎵弿鐨勪换鍔�
-const currentScanningTask = ref(null)
-const infoData = ref(null);
-
-// 涓婁紶鐩稿叧鐘舵��
-const showUploadDialog = ref(false)
-const uploadFiles = ref([]) // 淇濈暀鐢ㄤ簬鍏煎鎬�
-const uploadStatusType = ref(0)
-const uploading = ref(false)
-const uploadProgress = ref(0)
-const number = ref(0)
-const uploadList = ref([])
-
-// 涓変釜鍒嗙被鐨勪笂浼犵姸鎬�
-const beforeModelValue = ref([]) // 鐢熶骇鍓�
-const afterModelValue = ref([]) // 鐢熶骇涓�
-const issueModelValue = ref([]) // 鐢熶骇鍚�
-
-// 褰撳墠婵�娲荤殑涓婁紶绫诲瀷
-const currentUploadType = ref('before') // 'before', 'after', 'issue'
-
-// 鏌ョ湅闄勪欢鐩稿叧鐘舵��
-const showAttachmentDialog = ref(false)
-const currentViewTask = ref(null)
-const currentViewType = ref('before') // 'before', 'after', 'issue'
-const attachmentList = ref([]) // 褰撳墠鏌ョ湅浠诲姟鐨勯檮浠跺垪琛�
-
-// 瑙嗛棰勮鐩稿叧鐘舵��
-const showVideoDialog = ref(false)
-const currentVideoFile = ref(null)
-
-// 寮傚父鐘舵��
-const hasException = ref(null) // null: 鏈�夋嫨, true: 瀛樺湪寮傚父, false: 姝e父
-
-// 涓婁紶閰嶇疆
-const uploadConfig = {
- action: "/common/minioUploads",
- limit: 10,
- fileSize: 50, // MB
- fileType: ['jpg', 'jpeg', 'png', 'mp4', 'mov'],
- maxVideoDuration: 60 // 绉�
-}
-
-// 璁$畻涓婁紶URL
-const uploadFileUrl = computed(() => {
- let baseUrl = '';
-
- 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';
- } else {
- baseUrl = 'http://192.168.1.147:9036';
- }
-
- return baseUrl + uploadConfig.action;
-})
-
-// 璁$畻璇锋眰澶�
-const headers = computed(() => {
- const token = getToken();
- return token ? { Authorization: "Bearer " + token } : {};
-})
-
-// 璇锋眰鍙栨秷鏍囧織锛岀敤浜庡彇娑堟鍦ㄨ繘琛岀殑璇锋眰
-let isRequestCancelled = false
+const tableData = ref([]);
+const tableLoading = ref(false);
// 鎵爜鐩稿叧鐘舵��
-const isScanning = ref(false)
-const cameraError = ref('')
+const isScanning = ref(false);
+const scanLoading = ref(false);
+const cameraError = ref(null);
-// 鐢熷懡鍛ㄦ湡
-onMounted(() => {
- // 寤惰繜鍒濆鍖栵紝纭繚DOM宸叉覆鏌�
- nextTick(() => {
- getList()
- })
-})
+const statusColor = computed(() => {
+ return isScanning.value ? '#67C23A' : '#F56C6C';
+});
-onShow(() => {
- // 椤甸潰鏄剧ず鏃跺埛鏂版暟鎹�
- getList()
-})
+// 鐢熷懡鍛ㄦ湡绠$悊
+onMounted(async () => {
+ handleTabChange({ index: 0 });
+});
-// 缁勪欢閿�姣佹椂鐨勬竻鐞�
-onUnmounted(() => {
- // 璁剧疆鍙栨秷鏍囧織锛岄樆姝㈠悗缁殑寮傛鎿嶄綔
- isRequestCancelled = true
-
- // 鍋滄鎵爜
- if (isScanning.value) {
- isScanning.value = false
- }
-
- // 鍏抽棴涓婁紶寮圭獥
- if (showUploadDialog.value) {
- showUploadDialog.value = false
- }
-})
+// 鏍囩椤靛垏鎹�
+const handleTabChange = (e) => {
+ const index = typeof e === 'object' && e.index !== undefined ? e.index : e;
+ const selectedTab = tabs[index];
+ if (selectedTab) {
+ activeTab.value = selectedTab.value;
+ activeTabIndex.value = index;
+ tabName.value = selectedTab.value;
+ tableData.value = [];
+ getList();
+ }
+};
-// 杩斿洖涓婁竴椤�
-const goBack = () => {
- uni.navigateBack()
-}
-
-// 鏌ヨ鏁版嵁
+// 鐐瑰嚮鏌ヨ
const handleQuery = () => {
- getList()
-}
+ getList();
+};
// 鑾峰彇鍒楄〃鏁版嵁
const getList = () => {
- // 鏄剧ず鍔犺浇鎻愮ず
- showLoadingToast('鍔犺浇涓�...')
-
- // 璁剧疆鍙栨秷鏍囧織
- isRequestCancelled = false
-
- inspectionTaskList({}).then(res => {
- // 妫�鏌ョ粍浠舵槸鍚﹁繕瀛樺湪涓旇姹傛湭琚彇娑�
- if (!isRequestCancelled) {
- // 澶勭悊涓嶅悓鐨勬暟鎹粨鏋�
- 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;
- }
- }
-
- if (records.length > 0) {
- taskTableData.value = records;
- } else {
- taskTableData.value = [];
- uni.showToast({
- title: '鏆傛棤宸℃浠诲姟鏁版嵁',
- icon: 'none'
- });
- }
- }
- // 鍏抽棴鍔犺浇鎻愮ず
- closeToast()
- }).catch(err => {
- // 妫�鏌ョ粍浠舵槸鍚﹁繕瀛樺湪涓旇姹傛湭琚彇娑�
- if (!isRequestCancelled) {
- taskTableData.value = [];
- // 娣诲姞閿欒鎻愮ず
- uni.showToast({
- title: '鑾峰彇鏁版嵁澶辫触',
- icon: 'error'
- })
- }
- // 鍏抽棴鍔犺浇鎻愮ず
- closeToast()
- })
-}
+ tableLoading.value = true;
+ if (tabName.value === "task") {
+ inspectionTaskList({ size: -1, current: -1 }).then(res => {
+ tableLoading.value = false;
+ tableData.value = res.data.records || [];
+ }).catch(err => {
+ tableLoading.value = false;
+ showToast('鑾峰彇鏁版嵁澶辫触', 'error');
+ });
+ } else {
+ qrCodeScanRecordList({ size: -1, current: -1 }).then(res => {
+ tableLoading.value = false;
+ // 澶勭悊鏁版嵁锛屾牸寮忓寲瀛楁
+ tableData.value = (res.data.records || []).map(item => ({
+ ...item,
+ deviceName: item.qrCode?.deviceName || '-',
+ location: item.qrCode?.location || '-'
+ }));
+ }).catch(err => {
+ tableLoading.value = false;
+ showToast('鑾峰彇鏁版嵁澶辫触', 'error');
+ });
+ }
+};
-// 涓烘寚瀹氫换鍔″紑濮嬫壂鐮�
-const startScanForTask = async (task) => {
- try {
- // 璁板綍褰撳墠鎵弿鐨勪换鍔�
- currentScanningTask.value = task
-
- // 鏄剧ず鎵弿鐣岄潰
- isScanning.value = true
-
- // 浣跨敤uniapp鐨勬壂鐮丄PI
- uni.scanCode({
- success: (res) => {
- handleScanSuccess(res)
- },
- fail: (err) => {
- uni.showToast({
- title: '鎵爜澶辫触',
- icon: 'error'
- })
- // 鍏抽棴鎵弿鐣岄潰
- isScanning.value = false
- }
- })
- } catch (e) {
- uni.showToast({
- title: '鍚姩鎵爜澶辫触',
- icon: 'error'
- })
- isScanning.value = false
- }
-}
+// 涓婁紶
+const handleAdd = (row) => {
+ console.log('handleAdd 琚皟鐢�', row);
+ console.log('formDia.value:', formDia.value);
+
+ if (!formDia.value) {
+ showToast('缁勪欢鏈垵濮嬪寲', 'error');
+ return;
+ }
+
+ nextTick(() => {
+ if (formDia.value && formDia.value.openDialog) {
+ formDia.value.openDialog(row);
+ } else {
+ console.error('formDia.value.openDialog 涓嶅瓨鍦�');
+ showToast('鎵撳紑寮圭獥澶辫触', 'error');
+ }
+ });
+};
+
+// 鏌ョ湅闄勪欢
+const viewFile = (row) => {
+ nextTick(() => {
+ viewQrCodeFiles.value?.openDialog(row);
+ });
+};
+
+// 鎵爜鎸夐挳鏂囨湰
+const scanButtonText = computed(() => {
+ if (scanLoading.value) return '姝e湪鍒濆鍖�...';
+ return isScanning.value ? '鍋滄鎵爜' : '寮�濮嬫壂鐮�';
+});
+
+// 鍒囨崲鎵爜鐘舵��
+const toggleScan = async () => {
+ if (isScanning.value) {
+ stopScan();
+ } else {
+ startScan();
+ }
+};
+
+// 寮�濮嬫壂鐮�
+const startScan = () => {
+ if (isScanning.value) {
+ showToast('姝e湪鎵弿涓紝璇风◢鍊�...', 'warning');
+ return;
+ }
+
+ scanLoading.value = true;
+
+ // 璋冪敤uni-app鐨勬壂鐮丄PI
+ uni.scanCode({
+ scanType: ['qrCode', 'barCode'],
+ success: (res) => {
+ scanLoading.value = false;
+ handleScanSuccess(res.result);
+ },
+ fail: (err) => {
+ scanLoading.value = false;
+ console.error('鎵爜澶辫触:', err);
+ cameraError.value = '鎵爜澶辫触锛岃閲嶈瘯';
+ setTimeout(() => {
+ cameraError.value = null;
+ }, 3000);
+ }
+ });
+};
+
+// 鎵弿鎴愬姛澶勭悊
+const handleScanSuccess = async (result) => {
+ try {
+ if (!result) {
+ showToast('鎵爜缁撴灉涓虹┖', 'warning');
+ return;
+ }
+
+ showToast('璇嗗埆鎴愬姛', 'success');
+
+ // 瑙f瀽浜岀淮鐮佹暟鎹�
+ let qrData;
+ try {
+ qrData = JSON.parse(result);
+ } catch (e) {
+ // 濡傛灉涓嶆槸JSON鏍煎紡锛岀洿鎺ヤ娇鐢ㄥ師濮嬫暟鎹�
+ qrData = { data: result };
+ }
+
+ callBackendAPI(qrData);
+ } catch (error) {
+ showToast(error.message || '澶勭悊鎵爜缁撴灉澶辫触', 'error');
+ }
+};
+
+// 璋冪敤鍚庣API
+const callBackendAPI = (result) => {
+ nextTick(() => {
+ qrCodeFormDia.value?.openDialog(result);
+ });
+};
// 鍋滄鎵爜
const stopScan = () => {
- isScanning.value = false
- currentScanningTask.value = null
-}
-
-// 鎵爜鎴愬姛澶勭悊
-const handleScanSuccess = async (result) => {
- try {
- // 瑙f瀽浜岀淮鐮佹暟鎹紝鎻愬彇deviceId
- let deviceId = ''
-
- // 妫�鏌ユ槸鍚︽槸URL鏍煎紡
- if (result.result.includes('deviceId=')) {
- // 浠嶶RL涓彁鍙杁eviceId
- const url = result.result
- const match = url.match(/deviceId=(\d+)/)
- if (match && match[1]) {
- deviceId = match[1]
- }
- } else {
- // 灏濊瘯瑙f瀽JSON鏍煎紡
- try {
- const qrData = JSON.parse(result.result)
- deviceId = qrData.deviceId || qrData.qrCodeId || ''
- } catch (e) {
- // 濡傛灉涓嶆槸JSON鏍煎紡锛岀洿鎺ヤ娇鐢ㄧ粨鏋�
- deviceId = result.result
- }
- }
-
- if (!deviceId) {
- uni.showToast({
- title: '鏈瘑鍒埌璁惧ID',
- icon: 'error'
- })
- isScanning.value = false
- return
- }
-
- // 鑾峰彇褰撳墠浠诲姟鐨則askId
- const currentTaskId = currentScanningTask.value?.taskId || currentScanningTask.value?.id
-
- // 瀵规瘮deviceId鍜宼askId
- if (deviceId === currentTaskId.toString()) {
- uni.showToast({
- title: '璇嗗埆鎴愬姛',
- icon: 'success'
- })
-
- // 鍏堝叧闂壂鎻忕晫闈�
- isScanning.value = false
-
- // 寤惰繜鎵撳紑涓婁紶寮圭獥锛岀‘淇濇壂鎻忕晫闈㈠畬鍏ㄥ叧闂�
- setTimeout(() => {
- openUploadDialog(currentScanningTask.value)
- }, 300)
- } else {
- uni.showToast({
- title: '璇锋壂鎻忔纭殑璁惧',
- icon: 'error'
- })
-
- // 鍏抽棴鎵弿鐣岄潰
- isScanning.value = false
- }
-
- } catch (error) {
- uni.showToast({
- title: error.message || '鏁版嵁瑙f瀽澶辫触',
- icon: 'error'
- })
- // 鍏抽棴鎵弿鐣岄潰
- isScanning.value = false
- }
-}
-
-// 鎵撳紑涓婁紶寮圭獥
-const openUploadDialog = (task) => {
- // 璁剧疆浠诲姟淇℃伅鍒癷nfoData
- if (task) {
- infoData.value = {
- ...task,
- taskId: task.taskId || task.id,
- storageBlobDTO: [] // 鍒濆鍖栨枃浠跺垪琛�
- };
- }
-
- // 璁剧疆涓婁紶鐘舵�佺被鍨嬶紙鍙互鏍规嵁浠诲姟绫诲瀷璁剧疆涓嶅悓鐨勭姸鎬侊級
- uploadStatusType.value = 0 // 榛樿鐘舵��
-
- // 娓呯┖涔嬪墠鐨勬枃浠�
- uploadFiles.value = []
-
- // 鏄剧ず涓婁紶寮圭獥
- showUploadDialog.value = true
-}
-
-// 鍏抽棴涓婁紶寮圭獥
-const closeUploadDialog = () => {
- showUploadDialog.value = false
- uploadFiles.value = []
- // 娓呯悊涓変釜鍒嗙被鐨勬暟鎹�
- beforeModelValue.value = []
- afterModelValue.value = []
- issueModelValue.value = []
- currentUploadType.value = 'before'
- hasException.value = null // 閲嶇疆寮傚父鐘舵��
- infoData.value = null // 娓呯悊浠诲姟鏁版嵁
-}
-
-// 鍒囨崲涓婁紶绫诲瀷
-const switchUploadType = (type) => {
- currentUploadType.value = type
-}
-
-// 鑾峰彇褰撳墠鍒嗙被鐨勬枃浠跺垪琛�
-const getCurrentFiles = () => {
- switch (currentUploadType.value) {
- case 'before':
- return beforeModelValue.value
- case 'after':
- return afterModelValue.value
- case 'issue':
- return issueModelValue.value
- default:
- return []
- }
-}
-
-// 鑾峰彇涓婁紶绫诲瀷鏂囨湰
-const getUploadTypeText = () => {
- switch (currentUploadType.value) {
- case 'before':
- return '鐢熶骇鍓�'
- case 'after':
- return '鐢熶骇涓�'
- case 'issue':
- return '鐢熶骇鍚�'
- default:
- return ''
- }
-}
-
-// 澶勭悊涓婁紶鏂囦欢鏇存柊
-const handleUploadUpdate = (files) => {
- uploadFiles.value = 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) {
- uni.showToast({
- title: '璇峰厛涓婁紶鏂囦欢',
- icon: 'none'
- })
- return
- }
-
- // 鏄剧ず鎻愪氦涓殑鍔犺浇鎻愮ず
- showLoadingToast('鎻愪氦涓�...')
-
- // 鎸夌収鎮ㄧ殑閫昏緫鍚堝苟鎵�鏈夊垎绫荤殑鏂囦欢
- let arr = [];
- if (beforeModelValue.value.length > 0) {
- arr.push(...beforeModelValue.value);
- }
- if (afterModelValue.value.length > 0) {
- arr.push(...afterModelValue.value);
- }
- if (issueModelValue.value.length > 0) {
- arr.push(...issueModelValue.value);
- }
-
- // 鎻愪氦鏁版嵁
- infoData.value.storageBlobDTO = arr;
- // 娣诲姞寮傚父鐘舵�佷俊鎭�
- infoData.value.hasException = hasException.value;
-
- const result = await uploadInspectionTask({...infoData.value});
-
- // 妫�鏌ユ彁浜ょ粨鏋�
- if (result && (result.code === 200 || result.success)) {
- // 鎻愪氦鎴愬姛
- closeToast(); // 鍏抽棴鍔犺浇鎻愮ず
-
- uni.showToast({
- title: '鎻愪氦鎴愬姛',
- icon: 'success'
- })
-
- // 鍏抽棴寮圭獥
- closeUploadDialog()
-
- // 鍒锋柊鍒楄〃
- setTimeout(() => {
- getList()
- }, 500)
-
- } else {
- // 鎻愪氦澶辫触
- closeToast();
- uni.showToast({
- title: result?.msg || result?.message || '鎻愪氦澶辫触',
- icon: 'error'
- })
- }
-
- } catch (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: errorMessage,
- icon: 'error'
- })
- }
-}
-
-// 鎽勫儚澶撮敊璇鐞�
-const handleCameraError = (error) => {
- cameraError.value = '鎽勫儚澶磋闂け璐ワ紝璇锋鏌ユ潈闄愯缃�'
-}
-
-// 鎵爜浜嬩欢澶勭悊
-const handleScanCode = (result) => {
- handleScanSuccess(result)
-}
-
-// 鏌ョ湅闄勪欢
-const viewAttachments = async (task) => {
- try {
- currentViewTask.value = task
- currentViewType.value = 'before'
-
- // 瑙f瀽鏂扮殑鏁版嵁缁撴瀯
- attachmentList.value = []
-
- // 鐢熶骇鍓嶉檮浠� (type=0)
- if (task.beforeProduction && Array.isArray(task.beforeProduction)) {
- const beforeFiles = task.beforeProduction.map(file => ({
- ...file,
- type: 0 // 纭繚type涓�0
- }))
- attachmentList.value.push(...beforeFiles)
- }
-
- // 鐢熶骇涓檮浠� (type=1)
- if (task.afterProduction && Array.isArray(task.afterProduction)) {
- const afterFiles = task.afterProduction.map(file => ({
- ...file,
- type: 1 // 纭繚type涓�1
- }))
- attachmentList.value.push(...afterFiles)
- }
-
- // 鐢熶骇鍚庨檮浠� (type=2)
- if (task.productionIssues && Array.isArray(task.productionIssues)) {
- const issueFiles = task.productionIssues.map(file => ({
- ...file,
- type: 2 // 纭繚type涓�2
- }))
- attachmentList.value.push(...issueFiles)
- }
-
- showAttachmentDialog.value = true
-
- } catch (error) {
- uni.showToast({
- title: '鑾峰彇闄勪欢澶辫触',
- icon: 'error'
- })
- }
-}
-
-// 鍏抽棴闄勪欢鏌ョ湅寮圭獥
-const closeAttachmentDialog = () => {
- showAttachmentDialog.value = false
- currentViewTask.value = null
- attachmentList.value = []
- currentViewType.value = 'before'
-}
-
-// 鍒囨崲鏌ョ湅绫诲瀷
-const switchViewType = (type) => {
- currentViewType.value = type
-}
-
-// 鏍规嵁type鑾峰彇瀵瑰簲鍒嗙被鐨勯檮浠�
-const getAttachmentsByType = (typeValue) => {
- return attachmentList.value.filter(file => file.type === typeValue) || []
-}
-
-// 鑾峰彇褰撳墠鏌ョ湅绫诲瀷鐨勯檮浠�
-const getCurrentViewAttachments = () => {
- switch (currentViewType.value) {
- case 'before':
- return getAttachmentsByType(0)
- case 'after':
- return getAttachmentsByType(1)
- case 'issue':
- return getAttachmentsByType(2)
- default:
- return []
- }
-}
-
-// 鍒ゆ柇鏄惁涓哄浘鐗囨枃浠�
-const isImageFile = (file) => {
- // 妫�鏌ontentType瀛楁
- if (file.contentType && file.contentType.startsWith('image/')) {
- return true
- }
-
- // 妫�鏌ュ師鏈夌殑type瀛楁
- if (file.type === '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 previewAttachment = (file) => {
- if (isImageFile(file)) {
- // 棰勮鍥剧墖
- const imageUrls = getCurrentViewAttachments()
- .filter(f => isImageFile(f))
- .map(f => f.url || f.downloadUrl)
-
- uni.previewImage({
- urls: imageUrls,
- current: file.url || file.downloadUrl
- })
- } else {
- // 棰勮瑙嗛 - 鏄剧ず瑙嗛鎾斁寮圭獥
- showVideoPreview(file)
- }
-}
-
-// 鏄剧ず瑙嗛棰勮
-const showVideoPreview = (file) => {
- currentVideoFile.value = file
- showVideoDialog.value = true
-}
-
-// 鍏抽棴瑙嗛棰勮
-const closeVideoPreview = () => {
- showVideoDialog.value = false
- currentVideoFile.value = null
-}
-
-// 瑙嗛鎾斁閿欒澶勭悊
-const handleVideoError = (error) => {
- uni.showToast({
- title: '瑙嗛鎾斁澶辫触',
- icon: 'error'
- })
-}
-
-// 鎷嶇収
-const chooseImage = () => {
- if (uploadFiles.value.length >= uploadConfig.limit) {
- uni.showToast({
- title: `鏈�澶氬彧鑳芥媿鎽�${uploadConfig.limit}涓枃浠禶,
- icon: 'none'
- });
- return;
- }
-
- uni.chooseImage({
- count: 1,
- sizeType: ['compressed', 'original'],
- sourceType: ['camera'],
- success: (res) => {
- try {
- if (!res.tempFilePaths || res.tempFilePaths.length === 0) {
- throw new Error('鏈幏鍙栧埌鍥剧墖鏂囦欢');
- }
-
- const tempFilePath = res.tempFilePaths[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 chooseVideo = () => {
- if (uploadFiles.value.length >= uploadConfig.limit) {
- uni.showToast({
- title: `鏈�澶氬彧鑳芥媿鎽�${uploadConfig.limit}涓枃浠禶,
- icon: 'none'
- });
- return;
- }
-
- uni.chooseVideo({
- sourceType: ['camera'],
- maxDuration: uploadConfig.maxVideoDuration,
- camera: 'back',
- success: (res) => {
- try {
- if (!res.tempFilePath) {
- throw new Error('鏈幏鍙栧埌瑙嗛鏂囦欢');
- }
-
- const file = {
- tempFilePath: res.tempFilePath,
- path: res.tempFilePath, // 淇濇寔鍏煎鎬�
- type: 'video',
- name: `video_${Date.now()}.mp4`,
- size: res.size || 0,
- duration: res.duration || 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 removeFile = (index) => {
- uni.showModal({
- title: '纭鍒犻櫎',
- content: '纭畾瑕佸垹闄よ繖涓枃浠跺悧锛�',
- success: (res) => {
- if (res.confirm) {
- // 鏍规嵁褰撳墠涓婁紶绫诲瀷鍒犻櫎瀵瑰簲鍒嗙被鐨勬枃浠�
- switch (currentUploadType.value) {
- case 'before':
- beforeModelValue.value.splice(index, 1);
- break;
- case 'after':
- afterModelValue.value.splice(index, 1);
- break;
- case 'issue':
- issueModelValue.value.splice(index, 1);
- break;
- }
- uni.showToast({
- title: '鍒犻櫎鎴愬姛',
- icon: 'success'
- });
- }
- }
- });
-}
-
-// 妫�鏌ョ綉缁滆繛鎺�
-const checkNetworkConnection = () => {
- return new Promise((resolve) => {
- uni.getNetworkType({
- success: (res) => {
- if (res.networkType === 'none') {
- resolve(false);
- } else {
- resolve(true);
- }
- },
- fail: () => {
- resolve(false);
- }
- });
- });
-}
-
-// 涓婁紶鍓嶆牎楠�
-const handleBeforeUpload = async (file) => {
- // 妫�鏌ョ綉缁滆繛鎺�
- const hasNetwork = await checkNetworkConnection();
- if (!hasNetwork) {
- uni.showToast({
- title: '缃戠粶杩炴帴涓嶅彲鐢紝璇锋鏌ョ綉缁滆缃�',
- icon: 'none'
- });
- return false;
- }
-
- // 鏍¢獙鏂囦欢澶у皬
- if (uploadConfig.fileSize && file.size) {
- const isLt = file.size / 1024 / 1024 < uploadConfig.fileSize;
- if (!isLt) {
- uni.showToast({
- title: `鏂囦欢澶у皬涓嶈兘瓒呰繃 ${uploadConfig.fileSize} MB!`,
- icon: 'none'
- });
- return false;
- }
- }
-
- // 鏍¢獙瑙嗛鏃堕暱
- if (file.type === 'video' && file.duration && file.duration > uploadConfig.maxVideoDuration) {
- uni.showToast({
- title: `瑙嗛鏃堕暱涓嶈兘瓒呰繃 ${uploadConfig.maxVideoDuration} 绉�!`,
- icon: 'none'
- });
- return false;
- }
-
- // 鏍¢獙鏂囦欢绫诲瀷
- 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 = (file) => {
- uploading.value = true;
- uploadProgress.value = 0;
- number.value++; // 澧炲姞涓婁紶璁℃暟
-
- // 纭繚鏂囦欢璺緞姝g‘
- const filePath = file.tempFilePath || file.path;
- if (!filePath) {
- handleUploadError('鏂囦欢璺緞涓嶅瓨鍦�');
- return;
- }
-
- // 纭繚token瀛樺湪
- const token = getToken();
- if (!token) {
- handleUploadError('鐢ㄦ埛鏈櫥褰�');
- return;
- }
-
- // 鍑嗗涓婁紶鍙傛暟
- const uploadParams = {
- url: uploadFileUrl.value,
- filePath: filePath,
- name: 'files',
- formData: {
- type: uploadStatusType.value || 0
- },
- header: {
- 'Authorization': `Bearer ${token}`
- }
- };
-
- const uploadTask = uni.uploadFile({
- ...uploadParams,
- 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);
- console.error('鍘熷鍝嶅簲鏁版嵁:', res.data);
- 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 = '涓婁紶鏂囦欢澶辫触', showRetry = true) => {
- if (showRetry) {
- uni.showModal({
- title: '涓婁紶澶辫触',
- content: message + '锛屾槸鍚﹂噸璇曪紵',
- success: (res) => {
- if (res.confirm) {
- // 鐢ㄦ埛閫夋嫨閲嶈瘯锛岃繖閲屽彲浠ラ噸鏂拌Е鍙戜笂浼�
- }
- }
- });
- } else {
- uni.showToast({
- title: message,
- icon: 'error'
- });
- }
-}
-
-// 涓婁紶鎴愬姛鍥炶皟
-const handleUploadSuccess = (res, file) => {
- if (res.code === 200 && res.data && Array.isArray(res.data) && res.data.length > 0) {
- const uploadedFile = res.data[0];
-
- // 鏍规嵁褰撳墠涓婁紶绫诲瀷璁剧疆type瀛楁
- let typeValue = 0; // 榛樿涓虹敓浜у墠
- switch (currentUploadType.value) {
- case 'before':
- typeValue = 0;
- break;
- case 'after':
- typeValue = 1;
- break;
- case 'issue':
- typeValue = 2;
- break;
- }
-
- // 纭繚涓婁紶鐨勬枃浠舵暟鎹畬鏁达紝鍖呭惈id鍜宼ype
- const fileData = {
- ...file,
- id: uploadedFile.id, // 娣诲姞鏈嶅姟鍣ㄨ繑鍥炵殑id
- url: uploadedFile.url || uploadedFile.downloadUrl,
- bucketFilename: uploadedFile.bucketFilename || file.name,
- downloadUrl: uploadedFile.downloadUrl || uploadedFile.url,
- size: uploadedFile.size || file.size,
- createTime: uploadedFile.createTime || new Date().getTime(),
- type: typeValue // 娣诲姞绫诲瀷瀛楁锛�0=鐢熶骇鍓�, 1=鐢熶骇涓�, 2=鐢熶骇鍚�
- };
-
- uploadList.value.push(fileData);
- uploadedSuccessfully();
- } else {
- number.value--; // 涓婁紶澶辫触鏃跺噺灏戣鏁�
- handleUploadError(res.msg || '涓婁紶澶辫触');
- }
-}
-
-// 涓婁紶缁撴潫澶勭悊
-const uploadedSuccessfully = () => {
- if (number.value > 0 && uploadList.value.length === number.value) {
- // 鏍规嵁褰撳墠涓婁紶绫诲瀷锛屽皢鏂囦欢娣诲姞鍒板搴旂殑鍒嗙被
- switch (currentUploadType.value) {
- case 'before':
- beforeModelValue.value = [...beforeModelValue.value, ...uploadList.value];
- break;
- case 'after':
- afterModelValue.value = [...afterModelValue.value, ...uploadList.value];
- break;
- case 'issue':
- issueModelValue.value = [...issueModelValue.value, ...uploadList.value];
- break;
- }
-
- // 閲嶇疆鐘舵��
- uploadList.value = [];
- 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';
-}
+ isScanning.value = false;
+ scanLoading.value = false;
+};
+// 杩斿洖涓婁竴椤�
+const goBack = () => {
+ uni.navigateBack();
+};
</script>
<style scoped>
-.inspection-upload-page {
- min-height: 100vh;
- background-color: #f5f5f5;
+.app-container {
+ padding: 20rpx;
+ background-color: #f5f5f5;
+ min-height: 100vh;
}
-.table-section {
- padding: 15px;
+.card-container {
+ background-color: #fff;
+ border-radius: 16rpx;
+ padding: 20rpx;
}
-.task-list {
- display: flex;
- flex-direction: column;
- gap: 12px;
+.scan-section {
+ margin: 20rpx 0;
}
-.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;
+.scan-controls {
+ display: flex;
+ justify-content: center;
+ margin-bottom: 20rpx;
}
-.task-header {
- display: flex;
- justify-content: space-between;
- align-items: flex-start;
- margin-bottom: 12px;
+.status-info {
+ margin-top: 32rpx;
+ text-align: center;
}
-.task-info {
- flex: 1;
- display: flex;
- flex-direction: column;
- gap: 4px;
+.scanning-text {
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ color: #2979ff;
+ margin-top: 16rpx;
+ font-size: 28rpx;
}
-.task-name {
- font-size: 16px;
- font-weight: 600;
- color: #333;
+.scanning-text text {
+ margin-left: 10rpx;
}
-.task-location {
- font-size: 14px;
- color: #666;
+.loading-container {
+ display: flex;
+ justify-content: center;
+ align-items: center;
+ padding: 40rpx 0;
}
-.task-actions {
- display: flex;
- gap: 8px;
+.list-container {
+ margin-top: 20rpx;
}
-.task-details {
- display: flex;
- flex-direction: column;
- gap: 6px;
+.list-item {
+ background-color: #fff;
+ border-radius: 16rpx;
+ padding: 24rpx;
+ margin-bottom: 20rpx;
+ border: 1px solid #f0f0f0;
}
-.detail-item {
- display: flex;
- justify-content: space-between;
- align-items: center;
+.item-content {
+ margin-bottom: 20rpx;
}
-.detail-label {
- font-size: 12px;
- color: #999;
+.item-row {
+ display: flex;
+ margin-bottom: 16rpx;
+ font-size: 28rpx;
+ line-height: 40rpx;
}
-.detail-value {
- font-size: 12px;
- color: #666;
- font-weight: 500;
+.item-row:last-child {
+ margin-bottom: 0;
+}
+
+.item-label {
+ color: #666;
+ width: 200rpx;
+ flex-shrink: 0;
+}
+
+.item-value {
+ color: #333;
+ flex: 1;
+ word-break: break-all;
+}
+
+.item-actions {
+ display: flex;
+ justify-content: flex-end;
+ padding-top: 20rpx;
+ border-top: 1px solid #f0f0f0;
}
.no-data {
- text-align: center;
- padding: 40px 20px;
- color: #999;
- font-size: 14px;
+ text-align: center;
+ padding: 80rpx 0;
+ color: #999;
+ font-size: 28rpx;
}
-/* 鎵爜寮圭獥鏍峰紡 */
-.qr-scan-overlay {
- position: fixed;
- top: 0;
- left: 0;
- right: 0;
- bottom: 0;
- background: rgba(0, 0, 0, 0.8);
- z-index: 9999;
- display: flex;
- align-items: center;
- justify-content: center;
+/* 绉诲姩绔紭鍖� */
+@media (max-width: 768px) {
+ .app-container {
+ padding: 10rpx;
+ }
}
-
-.qr-scan-container {
- width: 90vw;
- max-width: 400px;
- background: #fff;
- border-radius: 12px;
- padding: 20px;
- position: relative;
-}
-
-.scan-header {
- display: flex;
- justify-content: space-between;
- align-items: center;
- margin-bottom: 15px;
-}
-
-.scan-title {
- font-size: 18px;
- font-weight: 600;
- color: #333;
-}
-
-.qr-camera {
- width: 100%;
- height: 300px;
- border-radius: 8px;
- overflow: hidden;
- margin-bottom: 15px;
-}
-
-.scan-frame-wrapper {
- position: relative;
- display: flex;
- flex-direction: column;
- align-items: center;
-}
-
-.scan-frame {
- width: 200px;
- height: 200px;
- border: 2px solid #409eff;
- border-radius: 8px;
- position: relative;
-}
-
-.scan-frame::before,
-.scan-frame::after {
- content: '';
- position: absolute;
- width: 20px;
- height: 20px;
- border: 2px solid #409eff;
-}
-
-.scan-frame::before {
- top: -2px;
- left: -2px;
- border-right: none;
- border-bottom: none;
-}
-
-.scan-frame::after {
- bottom: -2px;
- right: -2px;
- border-left: none;
- border-top: none;
-}
-
-.scan-tip {
- margin-top: 10px;
- font-size: 14px;
- color: #666;
- text-align: center;
-}
-
-/* 鑷畾涔夋ā鎬佹鏍峰紡 */
-.custom-modal-overlay {
- position: fixed;
- top: 0;
- left: 0;
- right: 0;
- bottom: 0;
- background: rgba(0, 0, 0, 0.5);
- z-index: 10000;
- display: flex;
- align-items: center;
- justify-content: center;
- padding: 20px;
-}
-
-.custom-modal-container {
- width: 100%;
- max-width: 500px;
- max-height: 80vh;
- display: flex;
- align-items: center;
- justify-content: center;
-}
-
-/* 涓婁紶寮圭獥鏍峰紡 */
-.upload-popup-content {
- background: #fff;
- border-radius: 12px;
- width: 100%;
- min-height: 300px;
- max-height: 70vh;
- 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 20px;
- border-bottom: 1px solid #eee;
-}
-
-.upload-popup-title {
- font-size: 16px;
- font-weight: 600;
- color: #333;
-}
-
-.upload-popup-body {
- flex: 1;
- padding: 20px;
- overflow-y: auto;
-}
-
-.upload-popup-footer {
- display: flex;
- justify-content: flex-end;
- padding: 15px 20px;
- border-top: 1px solid #eee;
- gap: 10px;
-}
-
-/* 绠�鍖栦笂浼犵粍浠舵牱寮� */
-.simple-upload-area {
- padding: 15px;
-}
-
-.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-item:hover {
- box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
- transform: translateY(-2px);
-}
-
-.file-preview-container {
- position: relative;
- margin-bottom: 8px;
-}
-
-.file-preview {
- width: 80px;
- height: 80px;
- border-radius: 8px;
- object-fit: cover;
- border: 2px solid #f0f0f0;
-}
-
-.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;
- 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;
-}
-
-.delete-btn:hover {
- background: #ff3742;
- transform: scale(1.1);
-}
-
-.file-info {
- text-align: center;
- width: 100%;
-}
-
-.file-name {
- font-size: 12px;
- color: #333;
- font-weight: 500;
- display: block;
- white-space: nowrap;
- overflow: hidden;
- text-overflow: ellipsis;
- max-width: 100px;
-}
-
-.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;
-}
-
-/* 涓婁紶鏍囩椤垫牱寮� */
-.upload-tabs {
- display: flex;
- background: #f8f9fa;
- border-radius: 8px;
- margin-bottom: 15px;
- padding: 4px;
-}
-
-.tab-item {
- flex: 1;
- text-align: center;
- padding: 8px 12px;
- font-size: 14px;
- color: #666;
- border-radius: 6px;
- transition: all 0.3s ease;
- cursor: pointer;
-}
-
-.tab-item.active {
- background: #409eff;
- color: #fff;
- font-weight: 500;
-}
-
-.tab-item:hover:not(.active) {
- background: #e9ecef;
- 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;
- padding: 10px;
- background: #f8f9fa;
- border-radius: 6px;
- border-left: 3px solid #409eff;
-}
-
-.summary-text {
- font-size: 12px;
- color: #666;
- line-height: 1.4;
-}
-
-/* 鏌ョ湅闄勪欢寮圭獥鏍峰紡 */
-.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);
-}
-
-.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;
-}
-
-.close-btn-attachment:hover {
- background: #e9ecef;
- transform: scale(1.1);
-}
-
-.attachment-popup-body {
- flex: 1;
- padding: 15px 20px;
- overflow-y: auto;
-}
-
-.attachment-tabs {
- display: flex;
- background: #f8f9fa;
- border-radius: 8px;
- margin-bottom: 15px;
- padding: 4px;
-}
-
-.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-item:hover {
- box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
- transform: translateY(-2px);
-}
-
-.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;
-}
-
-.close-btn-video:hover {
- background: rgba(255, 255, 255, 0.3);
- transform: scale(1.1);
-}
-
-.video-modal-body {
- position: relative;
- background: #000;
-}
-
-.video-player {
- width: 100%;
- height: auto;
- max-height: 60vh;
- display: block;
-}
-</style>
\ No newline at end of file
+</style>
diff --git a/src/pages/management/index.vue b/src/pages/management/index.vue
index 3adfbd2..f08b67c 100644
--- a/src/pages/management/index.vue
+++ b/src/pages/management/index.vue
@@ -22,7 +22,7 @@
</view>
<!-- 鏍囩椤� -->
- <view class="tabs-section">
+ <!-- <view class="tabs-section">
<u-tabs
:list="tabs"
:current="activeTabIndex"
@@ -35,7 +35,7 @@
fontWeight: 'bold'
}"
/>
- </view>
+ </view> -->
<!-- 鍒楄〃鍖哄煙 -->
<scroll-view
@@ -66,7 +66,7 @@
<view class="item-details">
<!-- 璁惧鍒楄〃椤甸潰 -->
- <template v-if="activeTab === 'management'">
+ <!-- <template v-if="activeTab === 'management'"> -->
<view class="detail-row">
<text class="detail-label">璁惧鍚嶇О</text>
<text class="detail-value">{{ item.equipmentName || '-' }}</text>
@@ -95,10 +95,10 @@
<text class="detail-label">閲囪喘浠锋牸</text>
<text class="detail-value">{{ item.purchasePrice ? `楼${item.purchasePrice}` : '-' }}</text>
</view>
- </template>
+ <!-- </template> -->
<!-- 璁惧棰嗙敤椤甸潰 -->
- <template v-else-if="activeTab === 'equipmentRequisition'">
+ <!-- <template v-else-if="activeTab === 'equipmentRequisition'">
<view class="detail-row">
<text class="detail-label">棰嗙敤浜�</text>
<text class="detail-value">{{ item.userName || '-' }}</text>
@@ -133,11 +133,11 @@
<text class="detail-label">澶囨敞</text>
<text class="detail-value">{{ item.remarks }}</text>
</view>
- </template>
+ </template> -->
</view>
<!-- 鎿嶄綔鎸夐挳 - 鍙湪璁惧棰嗙敤椤甸潰鏄剧ず -->
- <template v-if="activeTab === 'equipmentRequisition'">
+ <!-- <template v-if="activeTab === 'equipmentRequisition'">
<up-divider></up-divider>
<view class="action-buttons">
<u-button
@@ -159,7 +159,7 @@
褰掕繕
</u-button>
</view>
- </template>
+ </template> -->
</view>
</view>
</view>
@@ -171,34 +171,34 @@
</scroll-view>
<!-- 娴姩鎿嶄綔鎸夐挳 - 璁惧棰嗙敤椤甸潰鏄剧ず棰嗙敤鎸夐挳 -->
- <view
+ <!-- <view
v-if="activeTab === 'equipmentRequisition'"
class="fab-button"
@tap="handleAdd"
>
<up-icon name="plus" size="24" color="#ffffff"></up-icon>
- </view>
+ </view> -->
<!-- 寮圭獥缁勪欢 -->
- <managementDialog
+ <!-- <managementDialog
v-if="activeTab == 'management'"
v-model:copyForm="copyForm"
v-model:managementFormDialog="manaDialog"
:addOrEdit="addOrEdit"
:form="form"
@submit="getList"
- />
- <EquipmentRequisition
+ /> -->
+ <!-- <EquipmentRequisition
v-model="equipmentRequisitionDialog"
:formData="form"
:maxQuantity="getMaxQuantity()"
:addOrEdit="addOrEdit"
:equipmentStatus="form.equipmentStatus"
@submit="onEquipmentRequisitionSubmit"
- />
+ /> -->
<!-- 鏌ョ湅璇︽儏寮圭獥 -->
- <u-popup
+ <!-- <u-popup
v-model="dialogTableVisible"
:title="dialogTableTitle"
mode="center"
@@ -211,7 +211,7 @@
height="400px"
/>
</view>
- </u-popup>
+ </u-popup> -->
</view>
</template>
@@ -224,14 +224,14 @@
// 缁勪欢瀵煎叆
import PageHeader from "@/components/PageHeader.vue";
-import managementDialog from "./mould/managementDialog.vue";
-import EquipmentRequisition from "./mould/equipmentRequisitionDialog.vue";
+// import managementDialog from "./mould/managementDialog.vue";
+// import EquipmentRequisition from "./mould/equipmentRequisitionDialog.vue";
// API 鏈嶅姟瀵煎叆
import {
getManagementList,
} from "@/api/equipment/management/index.js";
-import { getUsageRecordList, getUsageDetailList } from "@/api/equipment/requisition/index.js";
+// import { getUsageRecordList, getUsageDetailList } from "@/api/equipment/requisition/index.js";
// 璁惧鐘舵�佹灇涓�
const EQUIPMENT_STATUS = {
@@ -330,40 +330,46 @@
{ prop: "purchasePrice", label: "閲囪喘浠锋牸", minWidth: 100 },
],
},
- equipmentRequisition: {
- label: "璁惧棰嗙敤",
- searchPlaceholder: "璁惧缂栧彿/璁惧鍚嶇О/瑙勬牸鍨嬪彿",
- showSearch: true,
- api: getUsageRecordList,
- columns: [
- { prop: "userName", label: "棰嗙敤浜�", minWidth: 100 },
- { prop: "equipmentNo", label: "璁惧缂栧彿", minWidth: 100 },
- { prop: "equipmentName", label: "璁惧鍚嶇О", minWidth: 100 },
- { prop: "usageQuantity", label: "棰嗙敤鏁伴噺", minWidth: 100 },
- {prop: "returnQuantity" , label: "褰掕繕鏁伴噺", minWidth: 100,
- formatter: (row) => row.returnQuantity || 0
- },
- {
- prop: "equipmentStatus",
- label: "浣跨敤鐘舵��",
- minWidth: 100,
- formatter: (row) => getStatusText(row.equipmentStatus),
- cellStyle: (row) => ({ color: getStatusColor(row.equipmentStatus) }),
- },
- { prop: "usageStartTime", label: "浣跨敤寮�濮嬫椂闂�", minWidth: 100 },
- { prop: "usageEndTime", label: "浣跨敤缁撴潫鏃堕棿", minWidth: 100 },
- { prop: "remarks", label: "澶囨敞", minWidth: 100 },
- ],
- },
+ // equipmentRequisition: {
+ // label: "璁惧棰嗙敤",
+ // searchPlaceholder: "璁惧缂栧彿/璁惧鍚嶇О/瑙勬牸鍨嬪彿",
+ // showSearch: true,
+ // api: getUsageRecordList,
+ // columns: [
+ // { prop: "userName", label: "棰嗙敤浜�", minWidth: 100 },
+ // { prop: "equipmentNo", label: "璁惧缂栧彿", minWidth: 100 },
+ // { prop: "equipmentName", label: "璁惧鍚嶇О", minWidth: 100 },
+ // { prop: "usageQuantity", label: "棰嗙敤鏁伴噺", minWidth: 100 },
+ // {prop: "returnQuantity" , label: "褰掕繕鏁伴噺", minWidth: 100,
+ // formatter: (row) => row.returnQuantity || 0
+ // },
+ // {
+ // prop: "equipmentStatus",
+ // label: "浣跨敤鐘舵��",
+ // minWidth: 100,
+ // formatter: (row) => getStatusText(row.equipmentStatus),
+ // cellStyle: (row) => ({ color: getStatusColor(row.equipmentStatus) }),
+ // },
+ // { prop: "usageStartTime", label: "浣跨敤寮�濮嬫椂闂�", minWidth: 100 },
+ // { prop: "usageEndTime", label: "浣跨敤缁撴潫鏃堕棿", minWidth: 100 },
+ // { prop: "remarks", label: "澶囨敞", minWidth: 100 },
+ // ],
+ // },
};
// 鏍囩椤垫暟鎹� - u-tabs闇�瑕乶ame浣滀负鏄剧ず鏂囨湰
-const tabs = computed(() =>
- Object.entries(tabsConfig).map(([name, config]) => ({
- name: config.label, // 浣跨敤label浣滀负鏄剧ず鏂囨湰
- value: name, // 淇濆瓨鍘熷name鍊�
- }))
-);
+// const tabs = computed(() =>
+// Object.entries(tabsConfig).map(([name, config]) => ({
+// name: config.label, // 浣跨敤label浣滀负鏄剧ず鏂囨湰
+// value: name, // 淇濆瓨鍘熷name鍊�
+// }))
+// );
+const tabs = computed(() => [
+ {
+ name: tabsConfig.management.label,
+ value: 'management'
+ }
+]);
// 褰撳墠鏍囩椤电储寮� - 浣跨敤ref鑰屼笉鏄痗omputed锛岀‘淇濆搷搴斿紡鏇存柊
const activeTabIndex = ref(0);
@@ -380,68 +386,68 @@
);
// 鍒ゆ柇鏄惁鏄剧ず褰掕繕鎸夐挳
-const shouldShowReturnButton = (item) => {
- if (activeTab.value !== 'equipmentRequisition') {
- return false;
- }
- // 濡傛灉璁惧鐘舵�佹槸宸插綊杩橈紝涓嶆樉绀哄綊杩樻寜閽�
- if (item.equipmentStatus === EQUIPMENT_STATUS.RETURNED) {
- return false;
- }
- // 鍏朵粬鐘舵�侀兘鏄剧ず褰掕繕鎸夐挳锛堜娇鐢ㄤ腑銆侀儴鍒嗗綊杩樸�佹垨鑰呮病鏈夌姸鎬侊級
- return true;
-};
+// const shouldShowReturnButton = (item) => {
+// if (activeTab.value !== 'equipmentRequisition') {
+// return false;
+// }
+// // 濡傛灉璁惧鐘舵�佹槸宸插綊杩橈紝涓嶆樉绀哄綊杩樻寜閽�
+// if (item.equipmentStatus === EQUIPMENT_STATUS.RETURNED) {
+// return false;
+// }
+// // 鍏朵粬鐘舵�侀兘鏄剧ず褰掕繕鎸夐挳锛堜娇鐢ㄤ腑銆侀儴鍒嗗綊杩樸�佹垨鑰呮病鏈夌姸鎬侊級
+// return true;
+// };
// 鍔ㄦ�佽幏鍙栬嚜瀹氫箟鎸夐挳閰嶇疆锛堜繚鐣欑敤浜庡叾浠栫敤閫旓級
-const getCustomButtons = () => {
- const buttons = [];
-
- // 鍦ㄨ澶囬鐢ㄩ〉闈㈡坊鍔犲綊杩樻寜閽�
- if (activeTab.value === 'equipmentRequisition') {
- buttons.push({
- name: 'return',
- label: '褰掕繕',
- type: 'success',
- size: 'small',
- link: true,
- show: (row) => shouldShowReturnButton(row),
- disabled: (row) => row.equipmentStatus === EQUIPMENT_STATUS.RETURNED,
- });
- }
-
- return buttons;
-};
+// const getCustomButtons = () => {
+// const buttons = [];
+//
+// // 鍦ㄨ澶囬鐢ㄩ〉闈㈡坊鍔犲綊杩樻寜閽�
+// if (activeTab.value === 'equipmentRequisition') {
+// buttons.push({
+// name: 'return',
+// label: '褰掕繕',
+// type: 'success',
+// size: 'small',
+// link: true,
+// show: (row) => shouldShowReturnButton(row),
+// disabled: (row) => row.equipmentStatus === EQUIPMENT_STATUS.RETURNED,
+// });
+// }
+//
+// return buttons;
+// };
// 澶勭悊鑷畾涔夋寜閽偣鍑讳簨浠�
-const handleCustomButtonClick = ({ buttonName, row }) => {
- switch (buttonName) {
- case 'return':
- handleReturn(row);
- break;
- // 鍙互鍦ㄨ繖閲屾坊鍔犳洿澶氳嚜瀹氫箟鎸夐挳鐨勫鐞嗛�昏緫
- default:
- console.warn(`鏈鐞嗙殑鑷畾涔夋寜閽�: ${buttonName}`);
- }
-};
-const handleReturn = (row) => {
- // 妫�鏌ヨ澶囩姸鎬�
- if (row.equipmentStatus === EQUIPMENT_STATUS.RETURNED) {
- showToast('璇ヨ澶囧凡褰掕繕瀹屾垚锛屾棤闇�鍐嶆褰掕繕', 'warning');
- return;
- }
-
- if (row.equipmentStatus !== EQUIPMENT_STATUS.USING && row.equipmentStatus !== EQUIPMENT_STATUS.PARTIAL_RETURN) {
- showToast('璇ヨ澶囧綋鍓嶇姸鎬佷笉鏀寔褰掕繕鎿嶄綔', 'warning');
- return;
- }
-
- form.value = { ...row };
- addOrEdit.value = "return"; // 璁剧疆涓哄綊杩樻ā寮�
- title.value = `褰掕繕璁惧 - ${row.equipmentName || ''}`;
- copyForm.value = { ...row };
- equipmentRequisitionDialog.value = true;
- console.log("褰掕繕璁惧锛�", row);
-};
+// const handleCustomButtonClick = ({ buttonName, row }) => {
+// switch (buttonName) {
+// case 'return':
+// handleReturn(row);
+// break;
+// // 鍙互鍦ㄨ繖閲屾坊鍔犳洿澶氳嚜瀹氫箟鎸夐挳鐨勫鐞嗛�昏緫
+// default:
+// console.warn(`鏈鐞嗙殑鑷畾涔夋寜閽�: ${buttonName}`);
+// }
+// };
+// const handleReturn = (row) => {
+// // 妫�鏌ヨ澶囩姸鎬�
+// if (row.equipmentStatus === EQUIPMENT_STATUS.RETURNED) {
+// showToast('璇ヨ澶囧凡褰掕繕瀹屾垚锛屾棤闇�鍐嶆褰掕繕', 'warning');
+// return;
+// }
+//
+// if (row.equipmentStatus !== EQUIPMENT_STATUS.USING && row.equipmentStatus !== EQUIPMENT_STATUS.PARTIAL_RETURN) {
+// showToast('璇ヨ澶囧綋鍓嶇姸鎬佷笉鏀寔褰掕繕鎿嶄綔', 'warning');
+// return;
+// }
+//
+// form.value = { ...row };
+// addOrEdit.value = "return"; // 璁剧疆涓哄綊杩樻ā寮�
+// title.value = `褰掕繕璁惧 - ${row.equipmentName || ''}`;
+// copyForm.value = { ...row };
+// equipmentRequisitionDialog.value = true;
+// console.log("褰掕繕璁惧锛�", row);
+// };
// 鏍囩椤靛垏鎹㈠鐞� - u-tabs鐨凘change浜嬩欢浼犻�掔殑鏄璞� { index: number }
const handleTabChange = (e) => {
const index = typeof e === 'object' && e.index !== undefined ? e.index : e;
@@ -482,63 +488,63 @@
};
// 澶勭悊鏂板棰嗙敤
-const handleAdd = () => {
- console.log('handleAdd 琚皟鐢�', 'activeTab:', activeTab.value, 'activeTabIndex:', activeTabIndex.value);
- addOrEdit.value = "add";
- form.value = {};
- title.value = `鏂板${currentTabConfig.value?.label || '璁惧棰嗙敤'}`;
- copyForm.value = {};
- console.log('鍑嗗鎵撳紑寮圭獥锛宔quipmentRequisitionDialog褰撳墠鍊�:', equipmentRequisitionDialog.value);
- equipmentRequisitionDialog.value = true;
- console.log('寮圭獥宸叉墦寮�锛宔quipmentRequisitionDialog鏂板��:', equipmentRequisitionDialog.value);
-};
+// const handleAdd = () => {
+// console.log('handleAdd 琚皟鐢�', 'activeTab:', activeTab.value, 'activeTabIndex:', activeTabIndex.value);
+// addOrEdit.value = "add";
+// form.value = {};
+// title.value = `鏂板${currentTabConfig.value?.label || '璁惧棰嗙敤'}`;
+// copyForm.value = {};
+// console.log('鍑嗗鎵撳紑寮圭獥锛宔quipmentRequisitionDialog褰撳墠鍊�:', equipmentRequisitionDialog.value);
+// equipmentRequisitionDialog.value = true;
+// console.log('寮圭獥宸叉墦寮�锛宔quipmentRequisitionDialog鏂板��:', equipmentRequisitionDialog.value);
+// };
-const handleView = async (row) => {
- // 鍙鐞嗚澶囬鐢ㄩ〉闈㈢殑鏌ョ湅鍔熻兘
- if (activeTab.value === 'equipmentRequisition') {
- try {
- dialogTableTitle.value = `${row.equipmentName || '璁惧'} - 鎿嶄綔璁板綍璇︽儏`;
-
- // 鏄剧ず鍔犺浇鐘舵��
- dialogTableVisible.value = true;
- dialogTableData.value = [];
-
- // 璋冪敤璇︽儏鎺ュ彛鑾峰彇鏁版嵁
- const { data, code } = await getUsageDetailList(row.id);
- if (code === 200 && data) {
- // 澶勭悊鏁扮粍鏁版嵁锛岀洿鎺ユ樉绀烘搷浣滆褰曞垪琛�
- if (Array.isArray(data)) {
- dialogTableData.value = data;
- dialogTableColumns.value = [
- { prop: 'equipmentNo', label: '璁惧缂栧彿', minWidth: 100 },
- { prop: 'equipmentName', label: '璁惧鍚嶇О', minWidth: 120 },
- { prop: 'specification', label: '瑙勬牸鍨嬪彿', minWidth: 100 },
- {
- prop: 'operationType',
- label: '鎿嶄綔绫诲瀷',
- minWidth: 80,
- formatter: (row) => row.operationType === 1 ? '棰嗙敤' : '褰掕繕'
- },
- { prop: 'quantity', label: '鎿嶄綔鏁伴噺', minWidth: 80 },
- { prop: 'operator', label: '鎿嶄綔浜�', minWidth: 80 },
- { prop: 'remark', label: '澶囨敞', minWidth: 150, showOverflowTooltip: true },
- { prop: 'createTime', label: '鎿嶄綔鏃堕棿', minWidth: 150 }
- ];
- } else {
- showToast('鏆傛棤鎿嶄綔璁板綍', 'warning');
- }
- } else {
- showToast('鑾峰彇璇︽儏鏁版嵁澶辫触', 'error');
- dialogTableVisible.value = false;
- }
-
- } catch (error) {
- console.error('鑾峰彇璇︽儏澶辫触:', error);
- showToast('鑾峰彇璇︽儏鏁版嵁澶辫触', 'error');
- dialogTableVisible.value = false;
- }
- }
-};
+// const handleView = async (row) => {
+// // 鍙鐞嗚澶囬鐢ㄩ〉闈㈢殑鏌ョ湅鍔熻兘
+// if (activeTab.value === 'equipmentRequisition') {
+// try {
+// dialogTableTitle.value = `${row.equipmentName || '璁惧'} - 鎿嶄綔璁板綍璇︽儏`;
+//
+// // 鏄剧ず鍔犺浇鐘舵��
+// dialogTableVisible.value = true;
+// dialogTableData.value = [];
+//
+// // 璋冪敤璇︽儏鎺ュ彛鑾峰彇鏁版嵁
+// const { data, code } = await getUsageDetailList(row.id);
+// if (code === 200 && data) {
+// // 澶勭悊鏁扮粍鏁版嵁锛岀洿鎺ユ樉绀烘搷浣滆褰曞垪琛�
+// if (Array.isArray(data)) {
+// dialogTableData.value = data;
+// dialogTableColumns.value = [
+// { prop: 'equipmentNo', label: '璁惧缂栧彿', minWidth: 100 },
+// { prop: 'equipmentName', label: '璁惧鍚嶇О', minWidth: 120 },
+// { prop: 'specification', label: '瑙勬牸鍨嬪彿', minWidth: 100 },
+// {
+// prop: 'operationType',
+// label: '鎿嶄綔绫诲瀷',
+// minWidth: 80,
+// formatter: (row) => row.operationType === 1 ? '棰嗙敤' : '褰掕繕'
+// },
+// { prop: 'quantity', label: '鎿嶄綔鏁伴噺', minWidth: 80 },
+// { prop: 'operator', label: '鎿嶄綔浜�', minWidth: 80 },
+// { prop: 'remark', label: '澶囨敞', minWidth: 150, showOverflowTooltip: true },
+// { prop: 'createTime', label: '鎿嶄綔鏃堕棿', minWidth: 150 }
+// ];
+// } else {
+// showToast('鏆傛棤鎿嶄綔璁板綍', 'warning');
+// }
+// } else {
+// showToast('鑾峰彇璇︽儏鏁版嵁澶辫触', 'error');
+// dialogTableVisible.value = false;
+// }
+//
+// } catch (error) {
+// console.error('鑾峰彇璇︽儏澶辫触:', error);
+// showToast('鑾峰彇璇︽儏鏁版嵁澶辫触', 'error');
+// dialogTableVisible.value = false;
+// }
+// }
+// };
// 涓嬫媺鍒锋柊
const onRefresh = async () => {
@@ -549,32 +555,32 @@
};
// 鑾峰彇璁惧鏈�澶у彲棰嗙敤鏁伴噺
-const getMaxQuantity = () => {
- if (form.value.equipmentId) {
- const equipment = tableData.value.find(
- (item) => item.equipmentId === form.value.equipmentId
- );
- return equipment ? equipment.quantity : null;
- }
- return null;
-};
+// const getMaxQuantity = () => {
+// if (form.value.equipmentId) {
+// const equipment = tableData.value.find(
+// (item) => item.equipmentId === form.value.equipmentId
+// );
+// return equipment ? equipment.quantity : null;
+// }
+// return null;
+// };
// 璁惧棰嗙敤寮圭獥鎻愪氦澶勭悊
-const onEquipmentRequisitionSubmit = (formData) => {
- if (formData.equipmentStatus === EQUIPMENT_STATUS.RETURNED) {
- showToast("璁惧宸插畬鍏ㄥ綊杩�", 'success');
- } else if (formData.equipmentStatus === EQUIPMENT_STATUS.PARTIAL_RETURN) {
- } else if (formData.equipmentStatus === EQUIPMENT_STATUS.USING) {
- showToast("璁惧棰嗙敤鎴愬姛", 'success');
- } else {
- showToast("鎿嶄綔鎴愬姛", 'success');
- }
- equipmentRequisitionDialog.value = false;
- nextTick(() => {
- form.value = {};
- getList();
- });
-};
+// const onEquipmentRequisitionSubmit = (formData) => {
+// if (formData.equipmentStatus === EQUIPMENT_STATUS.RETURNED) {
+// showToast("璁惧宸插畬鍏ㄥ綊杩�", 'success');
+// } else if (formData.equipmentStatus === EQUIPMENT_STATUS.PARTIAL_RETURN) {
+// } else if (formData.equipmentStatus === EQUIPMENT_STATUS.USING) {
+// showToast("璁惧棰嗙敤鎴愬姛", 'success');
+// } else {
+// showToast("鎿嶄綔鎴愬姛", 'success');
+// }
+// equipmentRequisitionDialog.value = false;
+// nextTick(() => {
+// form.value = {};
+// getList();
+// });
+// };
// 鏁版嵁鑾峰彇
const getList = async () => {
diff --git a/src/pages/management/mould/equipmentRequisitionDialog.vue b/src/pages/management/mould/equipmentRequisitionDialog.vue
index bae484b..d92e779 100644
--- a/src/pages/management/mould/equipmentRequisitionDialog.vue
+++ b/src/pages/management/mould/equipmentRequisitionDialog.vue
@@ -54,22 +54,6 @@
</template>
</u-form-item>
- <u-form-item v-if="isReturnMode" label="宸蹭娇鐢ㄦ暟閲�" border-bottom>
- <u-input
- :value="formData.usageQuantity"
- disabled
- placeholder="宸蹭娇鐢ㄦ暟閲�"
- />
- </u-form-item>
-
- <u-form-item v-if="isReturnMode" label="宸插綊杩樻暟閲�" border-bottom>
- <u-input
- :value="formData.totalReturnNo || 0"
- disabled
- placeholder="宸插綊杩樻暟閲�"
- />
- </u-form-item>
-
<u-form-item v-if="!isReturnMode && formData.status !== 2" label="棰嗙敤鏁伴噺" prop="usageQuantity" border-bottom required>
<view class="number-box-wrapper">
<u-number-box
@@ -95,12 +79,6 @@
/>
<text class="info-text" v-if="remainingReturnQuantity > 0">(鏈�澶歿{ remainingReturnQuantity }}鍙�)</text>
<text class="info-text" v-else>(宸插叏閮ㄥ綊杩�)</text>
- </view>
- <view
- v-if="remainingReturnQuantity > 0 && form.returnQuantity === remainingReturnQuantity"
- class="tip-text"
- >
- 馃挕 鎻愮ず锛氭湰娆″綊杩樺悗灏嗗畬鎴愬叏閮ㄥ綊杩�
</view>
</u-form-item>
@@ -141,8 +119,8 @@
</scroll-view>
<view class="popup-footer">
- <u-button @click="handleClose" :customStyle="{ marginRight: '10px', flex: 1 }">鍙栨秷</u-button>
- <u-button type="primary" @click="debouncedSubmit" v-if="!isViewMode" :customStyle="{ flex: 1 }">纭畾</u-button>
+ <u-button @click="handleClose" :customStyle="{ marginRight: '10px', flex: 1 }" :disabled="isSubmitting">鍙栨秷</u-button>
+ <u-button type="primary" @click="debouncedSubmit" v-if="!isViewMode" :customStyle="{ flex: 1 }" :loading="isSubmitting">纭畾</u-button>
</view>
</view>
@@ -348,13 +326,18 @@
// 棰嗙敤鏁伴噺鍙樺寲
const onUsageQuantityChange = (value) => {
// 纭繚鍊兼槸鏁板瓧绫诲瀷
- form.value.usageQuantity = Number(value) || 1;
- // 瑙﹀彂楠岃瘉
- nextTick(() => {
- if (formRef.value) {
- formRef.value.validateField('usageQuantity');
- }
- });
+ const numValue = Number(value) || 1;
+ form.value.usageQuantity = numValue;
+ // 鍙湁鍦ㄥ�兼湁鏁堟椂鎵嶈Е鍙戦獙璇侊紝閬垮厤榛樿鍊�1瑙﹀彂閿欒鎻愮ず
+ if (numValue >= 1) {
+ nextTick(() => {
+ if (formRef.value) {
+ // 娓呴櫎涔嬪墠鐨勯敊璇紝鐒跺悗閲嶆柊楠岃瘉
+ formRef.value.clearValidate('usageQuantity');
+ formRef.value.validateField('usageQuantity');
+ }
+ });
+ }
};
// 鑾峰彇璁惧鍒楄〃
@@ -458,6 +441,7 @@
const isEdit = computed(() => !!props.formData?.id);
const formRef = ref();
+const isSubmitting = ref(false);
// 鏃ユ湡閫夋嫨鍣�
const showDatePickerVisible = ref(false);
@@ -633,14 +617,15 @@
{
required: true,
message: "璇疯緭鍏ラ鐢ㄦ暟閲�",
- trigger: "change",
+ trigger: "blur",
validator: (rule, value, callback) => {
const numValue = Number(value) || 0;
- if (!value && value !== 0) {
+ // 濡傛灉鍊间负绌烘垨鏈畾涔夛紝鎵嶆姤閿�
+ if (value === null || value === undefined || value === '') {
callback(new Error("璇疯緭鍏ラ鐢ㄦ暟閲�"));
} else if (numValue < 1) {
callback(new Error("鑷冲皯棰嗙敤1鍙�"));
- } else if (maxQuantity.value !== null && numValue > maxQuantity.value) {
+ } else if (maxQuantity.value !== null && maxQuantity.value > 0 && numValue > maxQuantity.value) {
callback(new Error("棰嗙敤鏁伴噺涓嶈兘澶т簬璁惧鏁伴噺"));
} else {
callback();
@@ -657,6 +642,7 @@
function handleClose() {
emit("update:modelValue", false);
+ isSubmitting.value = false;
}
// 閫氱敤闃叉姈鍑芥暟
@@ -674,10 +660,45 @@
// 闃叉姈鍚庣殑鎻愪氦鏂规硶
const debouncedSubmit = debounce(handleSubmit, 800);
-function handleSubmit() {
- formRef.value.validate(async (valid) => {
- if (!valid) return;
+async function handleSubmit() {
+ console.log('handleSubmit 琚皟鐢�');
+ console.log('formRef.value:', formRef.value);
+ console.log('褰撳墠琛ㄥ崟鏁版嵁:', JSON.stringify(form.value));
+
+ if (isSubmitting.value) {
+ console.log('姝e湪鎻愪氦涓紝蹇界暐閲嶅鐐瑰嚮');
+ return;
+ }
+
+ if (!formRef.value) {
+ console.error('formRef 涓嶅瓨鍦�');
+ showToast('琛ㄥ崟寮曠敤涓嶅瓨鍦紝璇峰埛鏂伴〉闈㈤噸璇�', 'error');
+ return;
+ }
+
+ try {
+ console.log('寮�濮嬮獙璇佽〃鍗�...');
+ const valid = await formRef.value.validate().catch((errors) => {
+ console.log('琛ㄥ崟楠岃瘉澶辫触锛岄敊璇俊鎭�:', errors);
+ // 濡傛灉楠岃瘉澶辫触锛宔rrors 鍙兘鏄敊璇暟缁勬垨 false
+ if (errors && Array.isArray(errors) && errors.length > 0) {
+ const firstError = errors[0];
+ showToast(firstError.message || '璇峰畬鍠勮〃鍗曚俊鎭�', 'error');
+ } else {
+ showToast('璇峰畬鍠勮〃鍗曚俊鎭�', 'error');
+ }
+ return false;
+ });
+ console.log('琛ㄥ崟楠岃瘉缁撴灉:', valid);
+
+ if (!valid) {
+ console.log('琛ㄥ崟楠岃瘉澶辫触锛屽仠姝㈡彁浜�');
+ return;
+ }
+ console.log('琛ㄥ崟楠岃瘉閫氳繃锛屽紑濮嬫彁浜�');
+ isSubmitting.value = true;
+
let submitData = { ...form.value };
// 褰掕繕妯″紡澶勭悊
@@ -707,10 +728,12 @@
if (!result) {
showToast('宸插彇娑堝綊杩樻搷浣�', 'info');
+ isSubmitting.value = false;
return;
}
} catch (error) {
showToast('宸插彇娑堝綊杩樻搷浣�', 'info');
+ isSubmitting.value = false;
return;
}
@@ -741,21 +764,25 @@
};
}
- try {
- let { code, data } = await addOrEditUsageRecord(submitData);
- if (code !== 200) {
- showToast(data.msg || "鎿嶄綔澶辫触", 'error');
- return;
- }
- if (code == 200 && data == 1) {
- emit("submit", submitData);
- }
- handleClose();
- } catch (error) {
- console.error("鎻愪氦澶辫触:", error);
- showToast("鎿嶄綔澶辫触锛岃绋嶅悗鍐嶈瘯", 'error');
+ let { code, data } = await addOrEditUsageRecord(submitData);
+ if (code !== 200) {
+ showToast(data.msg || "鎿嶄綔澶辫触", 'error');
+ isSubmitting.value = false;
+ return;
}
- });
+ if (code == 200 && data == 1) {
+ showToast('鎿嶄綔鎴愬姛', 'success');
+ emit("submit", submitData);
+ handleClose();
+ } else {
+ showToast(data.msg || "鎿嶄綔澶辫触", 'error');
+ isSubmitting.value = false;
+ }
+ } catch (error) {
+ console.error("鎻愪氦澶辫触:", error);
+ showToast("鎿嶄綔澶辫触锛岃绋嶅悗鍐嶈瘯", 'error');
+ isSubmitting.value = false;
+ }
}
</script>
--
Gitblit v1.9.3