From 8aa85b0dfd3d0305e06b3e4637ba708bbf4a4f77 Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期二, 31 三月 2026 15:39:20 +0800
Subject: [PATCH] 酒泉app 1.巡检上传图片预览修改
---
src/pages/inspectionUpload/index.vue | 200 +++++++++++++++++++++++++++++++++++--------------
1 files changed, 143 insertions(+), 57 deletions(-)
diff --git a/src/pages/inspectionUpload/index.vue b/src/pages/inspectionUpload/index.vue
index ee907f0..6ff80b6 100644
--- a/src/pages/inspectionUpload/index.vue
+++ b/src/pages/inspectionUpload/index.vue
@@ -3,6 +3,19 @@
<!-- 椤甸潰澶撮儴 -->
<PageHeader title="宸℃涓婁紶" @back="goBack" />
+ <!-- 鎼滅储鍖哄煙 -->
+ <view class="search-section">
+ <up-input
+ v-model="searchAll"
+ placeholder="璇疯緭鍏ヨ澶囧悕绉�"
+ prefixIcon="search"
+ border="surround"
+ :clearable="true"
+ @change="handleSearch"
+ @clear="handleClear"
+ ></up-input>
+ </view>
+
<!-- 鏁版嵁鍒楄〃 -->
<view class="table-section">
<!-- 鐢熶骇宸℃鍒楄〃 -->
@@ -51,8 +64,7 @@
<view class="detail-item">
<text class="detail-label">宸℃鐘舵��</text>
<view class="detail-value">
- <uni-tag v-if="item.fileStatus==2" text="宸插畬鎴�" size="small" type="success" inverted></uni-tag>
- <uni-tag v-else-if="item.fileStatus==1" text="宸℃涓�" size="small" type="primary" inverted></uni-tag>
+ <uni-tag v-if="item.status=='宸插贰妫�'" text="宸插贰妫�" size="small" type="success" inverted></uni-tag>
<uni-tag v-else="" text="鏈贰妫�" size="small" type="warning" inverted></uni-tag>
</view>
</view>
@@ -218,7 +230,7 @@
<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"
+ <image v-if="file.type === 'image' || isImageFile(file)" :src="getAttachmentImageUrl(file)"
class="attachment-preview" mode="aspectFill" />
<view v-else class="attachment-video-preview">
<u-icon name="video" size="24" color="#409eff"></u-icon>
@@ -320,6 +332,22 @@
// 寮傚父鐘舵��
const hasException = ref(null) // null: 鏈�夋嫨, true: 瀛樺湪寮傚父, false: 姝e父
+// 鎼滅储鐩稿叧
+const searchAll = ref('')
+
+const handleSearch = () => {
+ pagesPames.current = 1
+ taskTableData.value = []
+ getList()
+}
+
+const handleClear = () => {
+ searchAll.value = ''
+ pagesPames.current = 1
+ taskTableData.value = []
+ getList()
+}
+
// 涓婁紶閰嶇疆
const uploadConfig = {
action: "/file/upload",
@@ -331,9 +359,7 @@
// 璁$畻涓婁紶URL
const uploadFileUrl = computed(() => {
- const baseUrl = 'https://1181ybjh99334.vicp.fun';
-
- return baseUrl + uploadConfig.action;
+ return config.baseUrl + uploadConfig.action;
})
// 璁$畻璇锋眰澶�
@@ -422,7 +448,14 @@
// 璁剧疆鍙栨秷鏍囧織
isRequestCancelled = false
loading.value = true
- inspectionTaskList({...pagesPames}).then(res => {
+
+ // 鏋勫缓鏌ヨ鍙傛暟
+ const params = { ...pagesPames }
+ if (searchAll.value) {
+ params.searchAll = searchAll.value
+ }
+
+ inspectionTaskList(params).then(res => {
// 妫�鏌ョ粍浠舵槸鍚﹁繕瀛樺湪涓旇姹傛湭琚彇娑�
if (!isRequestCancelled) {
// 澶勭悊涓嶅悓鐨勬暟鎹粨鏋�
@@ -674,6 +707,18 @@
// 鎻愪氦涓婁紶
const submitUpload = async () => {
try {
+ // 妫�鏌ョ綉缁滆繛鎺�
+ const hasNetwork = await checkNetworkConnection();
+ if (!hasNetwork) {
+ uni.showModal({
+ title: '缃戠粶閿欒',
+ content: '缃戠粶杩炴帴涓嶅彲鐢紝璇锋鏌ョ綉缁滆缃悗閲嶈瘯',
+ showCancel: false,
+ confirmText: '鐭ラ亾浜�'
+ });
+ return;
+ }
+
// 妫�鏌ユ槸鍚﹂�夋嫨浜嗗紓甯哥姸鎬�
if (hasException.value === null) {
uni.showToast({
@@ -722,6 +767,7 @@
// 娣诲姞寮傚父鐘舵�佷俊鎭�
infoData.value.hasException = hasException.value;
infoData.value.tempFileIds = tempFileIds;
+
const result = await uploadInspectionTask({ ...infoData.value });
// 妫�鏌ユ彁浜ょ粨鏋�
@@ -745,10 +791,13 @@
} else {
// 鎻愪氦澶辫触
closeToast();
- uni.showToast({
- title: result?.msg || result?.message || '鎻愪氦澶辫触',
- icon: 'error'
- })
+ const failMsg = result?.msg || result?.message || '鏈嶅姟鍣ㄨ繑鍥為敊璇�';
+ uni.showModal({
+ title: '鎻愪氦澶辫触',
+ content: failMsg,
+ showCancel: false,
+ confirmText: '鐭ラ亾浜�'
+ });
}
} catch (error) {
@@ -764,10 +813,13 @@
errorMessage = error;
}
- uni.showToast({
- title: errorMessage,
- icon: 'error'
- })
+ // 浣跨敤寮圭獥鏄剧ず璇︾粏閿欒淇℃伅
+ uni.showModal({
+ title: '鎻愪氦澶辫触',
+ content: errorMessage,
+ showCancel: false,
+ confirmText: '鐭ラ亾浜�'
+ });
}
}
@@ -885,8 +937,13 @@
return ['jpg', 'jpeg', 'png', 'gif', 'webp'].includes(ext)
}
+// 鑾峰彇鏌ョ湅闄勪欢鍥剧墖鐨勫畬鏁碪RL锛坖avaApi + url锛�
+const getAttachmentImageUrl = (file) => {
+ return file.url
+}
+
// 鏂囦欢璁块棶鍩虹鍩燂紙鍚庣瑕佹眰鍓嶇紑锛�
-const filePreviewBase = 'http://1181ybjh99334.vicp.fun'
+const filePreviewBase = config.javaApi
// 灏嗗悗绔繑鍥炵殑鏂囦欢鍦板潃瑙勮寖鎴愬彲璁块棶URL
// 鍏煎鍦烘櫙锛�
@@ -961,8 +1018,13 @@
// 鎷嶇収/鎷嶈棰戯紙鐪熸満浼樺厛鐢� chooseMedia锛涗笉鏀寔鍒欓檷绾э級
const chooseMedia = (type) => {
if (getCurrentFiles().length >= uploadConfig.limit) {
- uni.showToast({ title: `鏈�澶氬彧鑳介�夋嫨${uploadConfig.limit}涓枃浠禶, icon: 'none' })
- return
+ uni.showModal({
+ title: '鏁伴噺闄愬埗',
+ content: `鏈�澶氬彧鑳戒笂浼� ${uploadConfig.limit} 涓枃浠讹紝璇峰厛鍒犻櫎閮ㄥ垎鏂囦欢鍚庡啀涓婁紶`,
+ showCancel: false,
+ confirmText: '鐭ラ亾浜�'
+ });
+ return;
}
const remaining = uploadConfig.limit - getCurrentFiles().length
@@ -996,16 +1058,31 @@
handleBeforeUpload(file)
})
} catch (e) {
- console.error('澶勭悊鎷嶆憚缁撴灉澶辫触:', e)
- uni.showToast({ title: '澶勭悊鏂囦欢澶辫触', icon: 'error' })
+ console.error('澶勭悊鎷嶆憚缁撴灉澶辫触:', e);
+ uni.showModal({
+ title: '澶勭悊澶辫触',
+ content: '鏂囦欢澶勭悊澶辫触锛�' + (e.message || '鏈煡閿欒'),
+ showCancel: false,
+ confirmText: '鐭ラ亾浜�'
+ });
}
},
fail: (err) => {
- console.error('鎷嶆憚澶辫触:', err)
- uni.showToast({ title: '鎷嶆憚澶辫触', icon: 'error' })
+ console.error('鎷嶆憚澶辫触:', err);
+ const msg = err.errMsg || '鏈煡閿欒';
+ if (msg.includes('cancel')) {
+ // 鐢ㄦ埛鍙栨秷锛屼笉鎻愮ず
+ return;
+ }
+ uni.showModal({
+ title: '鎷嶆憚澶辫触',
+ content: '閿欒淇℃伅锛�' + msg,
+ showCancel: false,
+ confirmText: '鐭ラ亾浜�'
+ });
}
})
- return
+ return;
}
// 闄嶇骇锛歝hooseImage / chooseVideo
@@ -1206,9 +1283,11 @@
);
if (!isAllowed) {
- uni.showToast({
- title: `鏂囦欢鏍煎紡涓嶆敮鎸侊紝璇锋媿鎽� ${expectedTypes.join('/')} 鏍煎紡鐨勬枃浠禶,
- icon: 'none'
+ uni.showModal({
+ title: '鏍煎紡涓嶆敮鎸�',
+ content: `褰撳墠鏍煎紡涓� .${fileExtension}锛岃鎷嶆憚 ${expectedTypes.join('/')} 鏍煎紡鐨勬枃浠禶,
+ showCancel: false,
+ confirmText: '鐭ラ亾浜�'
});
return false;
}
@@ -1229,7 +1308,7 @@
// 纭繚token瀛樺湪
const token = getToken();
if (!token) {
- handleUploadError('鐢ㄦ埛鏈櫥褰�');
+ handleUploadError('鐢ㄦ埛鏈櫥褰曪紝璇烽噸鏂扮櫥褰曞悗鍐嶈瘯');
return;
}
@@ -1241,7 +1320,7 @@
// 浣跨敤uni.uploadFile涓婁紶锛堥潪H5鐜鎴朒5鍥為��鏂规锛�
const uploadWithUniUploadFile = (file, filePath, typeValue, token) => {
if (!filePath) {
- handleUploadError('鏂囦欢璺緞涓嶅瓨鍦�');
+ handleUploadError('鏂囦欢璺緞涓嶅瓨鍦紝璇烽噸鏂版媿鎽�');
return;
}
@@ -1266,31 +1345,29 @@
icon: 'success'
});
} else {
- handleUploadError(response.msg || '鏈嶅姟鍣ㄨ繑鍥為敊璇�');
+ handleUploadError(response.msg || `鏈嶅姟鍣ㄨ繑鍥為敊璇� (code: ${response.code})`);
}
} else {
- handleUploadError(`鏈嶅姟鍣ㄩ敊璇紝鐘舵�佺爜: ${res.statusCode}`);
+ handleUploadError(`鏈嶅姟鍣ㄩ敊璇紝鐘舵�佺爜: ${res.statusCode}锛岃绋嶅悗閲嶈瘯鎴栬仈绯荤鐞嗗憳`);
}
} catch (e) {
console.error('瑙f瀽鍝嶅簲澶辫触:', e);
console.error('鍘熷鍝嶅簲鏁版嵁:', res.data);
- handleUploadError('鍝嶅簲鏁版嵁瑙f瀽澶辫触: ' + e.message);
+ handleUploadError('鏈嶅姟鍣ㄥ搷搴旇В鏋愬け璐ワ紝璇疯仈绯荤鐞嗗憳');
}
},
fail: (err) => {
- console.error('涓婁紶澶辫触:', err.errMsg || err);
+ console.error('涓婁紶澶辫触:', err);
number.value--; // 涓婁紶澶辫触鏃跺噺灏戣鏁�
let errorMessage = '涓婁紶澶辫触';
if (err.errMsg) {
- if (err.errMsg.includes('statusCode: null')) {
- errorMessage = '缃戠粶杩炴帴澶辫触锛岃妫�鏌ョ綉缁滆缃�';
+ if (err.errMsg.includes('statusCode: null') || err.errMsg.includes('fail')) {
+ errorMessage = '缃戠粶杩炴帴澶辫触锛岃妫�鏌ョ綉缁滆缃悗閲嶈瘯';
} else if (err.errMsg.includes('timeout')) {
- errorMessage = '涓婁紶瓒呮椂锛岃閲嶈瘯';
- } else if (err.errMsg.includes('fail')) {
- errorMessage = '涓婁紶澶辫触锛岃妫�鏌ョ綉缁滆繛鎺�';
+ errorMessage = '涓婁紶瓒呮椂锛岃妫�鏌ョ綉缁滃悗閲嶈瘯';
} else {
- errorMessage = err.errMsg;
+ errorMessage = '涓婁紶澶辫触锛�' + err.errMsg;
}
}
@@ -1311,26 +1388,16 @@
}
// 涓婁紶澶辫触澶勭悊
-const handleUploadError = (message = '涓婁紶鏂囦欢澶辫触', showRetry = false) => {
+const handleUploadError = (message = '涓婁紶鏂囦欢澶辫触') => {
uploading.value = false;
uploadProgress.value = 0;
-
- if (showRetry) {
- uni.showModal({
- title: '涓婁紶澶辫触',
- content: message + '锛屾槸鍚﹂噸璇曪紵',
- success: (res) => {
- if (res.confirm) {
- // 鐢ㄦ埛閫夋嫨閲嶈瘯锛岃繖閲屽彲浠ラ噸鏂拌Е鍙戜笂浼�
- }
- }
- });
- } else {
- uni.showToast({
- title: message,
- icon: 'error'
- });
- }
+
+ uni.showModal({
+ title: '涓婁紶澶辫触',
+ content: message,
+ showCancel: false,
+ confirmText: '鐭ラ亾浜�'
+ });
}
// 涓婁紶鎴愬姛鍥炶皟
@@ -1344,7 +1411,7 @@
if (!uploadedFile) {
console.error('鏃犳硶瑙f瀽涓婁紶鍝嶅簲鏁版嵁:', res);
number.value--; // 涓婁紶澶辫触鏃跺噺灏戣鏁�
- handleUploadError('涓婁紶鍝嶅簲鏁版嵁鏍煎紡閿欒', false);
+ handleUploadError('涓婁紶鍝嶅簲鏁版嵁鏍煎紡閿欒');
return;
}
@@ -2084,4 +2151,23 @@
max-height: 60vh;
display: block;
}
+
+/* 鎼滅储鍖哄煙鏍峰紡 */
+.search-section {
+ padding: 15px 20px;
+ background: #fff;
+ border-bottom: 1px solid #f0f0f0;
+}
+
+:deep(.u-input) {
+ width: 100%;
+}
+
+:deep(.u-input__content) {
+ border-radius: 8px;
+}
+
+:deep(.u-input__content__field) {
+ font-size: 14px;
+}
</style>
\ No newline at end of file
--
Gitblit v1.9.3