From 80ca024e9ae633df0dc9f4e8f533f33b526afb3d Mon Sep 17 00:00:00 2001 From: p-honggang.li <p-honggang.li@pcitc.com> Date: 星期一, 08 九月 2025 16:24:38 +0800 Subject: [PATCH] 修复文件上传获取不到用户信息的BUG --- src/views/tradeManage/upload/index.vue | 67 ++++++++++++++++++++++++++++++--- 1 files changed, 60 insertions(+), 7 deletions(-) diff --git a/src/views/tradeManage/upload/index.vue b/src/views/tradeManage/upload/index.vue index eceaea1..3f34ba1 100644 --- a/src/views/tradeManage/upload/index.vue +++ b/src/views/tradeManage/upload/index.vue @@ -255,6 +255,9 @@ import { ElMessage, ElMessageBox } from 'element-plus' import { useUserInfo } from '@/stores/modules/userInfo' import createAxios from '@/utils/axios' +import productApi from "@/api/productApi"; +import sysUserService from "@/api/sysUser"; +import {queryUserDetail} from "@/api/userInfo"; const route = useRoute() const router = useRouter() @@ -310,12 +313,62 @@ return } + // 鑾峰彇鐢ㄦ埛淇℃伅 + if (!userStore.getUserId) { + try { + const res: any = await queryUserDetail() + if (res?.code === 200 && res.data) { + userStore.updateUserDetail(res.data) + } else { + ElMessage.error(res?.msg || '鏃犳硶鑾峰彇鐢ㄦ埛淇℃伅锛岃鍏堢櫥褰�') + return + } + } catch (e) { + console.error('鑾峰彇鐢ㄦ埛璇︽儏澶辫触:', e) + ElMessage.error('鑾峰彇鐢ㄦ埛淇℃伅澶辫触锛岃绋嶅悗閲嶈瘯') + return + } + } + try { const res = (await orderApi.getOrderDetail(orderId)) as any const data = res?.data || {} const statusName: string = data.orderStatus || '' const uiStatus = statusServerToUi[statusName] || 'INFO' + + // 鏍规嵁浜у搧id鑾峰彇浜у搧淇℃伅锛屾洿鏂板ご閮ㄥ睍绀� + try { + if (data.productId) { + const detailRes: any = await productApi.getProductById({ id: data.productId }) + if (detailRes?.code === 200 && detailRes.data) { + // 鐢ㄤ骇鍝佽鎯呰ˉ鍏ㄥご淇℃伅 + data.productName = detailRes.data.name || data.productName + data.providerName = detailRes.data.submissionUnit || data.providerName + data.industry = detailRes.data.industrialChainName || data.industry + data.productDesc = detailRes.data.describe || data.productDesc + data.projectUnit = detailRes.data.importantAreaName || data.productDesc + data.productType = detailRes.data.typeName || data.productDesc + } + } + } catch (e) { + // 蹇界暐浜у搧璇︽儏澶辫触锛屼笉闃诲璁㈠崟璇︽儏 + } + + // 鑾峰彇鐢ㄦ埛淇℃伅 + try { + const userRes: any = await sysUserService.getUserdetail({ userId: data.userId }) + if (userRes?.code === 200 && userRes.data) { + // 鐢ㄤ骇鍝佽鎯呰ˉ鍏ㄥご淇℃伅 + data.unitName = userRes.data.unitName || data.unitName + data.userName = userRes.data.name || data.userName + data.userDept = userRes.data.departmentName || data.userDept + data.userPhone = userRes.data.phone || data.userPhone + data.userAccount = userRes.data.username || data.userAccount + } + }catch (e){ + + } // 鏄犲皠璁㈠崟璇︽儏澶撮儴淇℃伅 const head = { @@ -388,9 +441,9 @@ // 鏂囦欢涓婁紶鍓嶇殑楠岃瘉 const beforeUpload = (file: File) => { // 妫�鏌ユ枃浠跺ぇ灏忥紙闄愬埗涓�100MB锛� - const maxSize = 100 * 1024 * 1024 + const maxSize = 500 * 1024 * 1024 if (file.size > maxSize) { - ElMessage.error('鏂囦欢澶у皬涓嶈兘瓒呰繃100MB') + ElMessage.error('鏂囦欢澶у皬涓嶈兘瓒呰繃500MB') return false } @@ -575,11 +628,11 @@ fileType: fileItem.type || 'application/octet-stream', fileSize: fileItem.size, fileUrl: fileUrl, - bucketName: 'order-attachments', + bucketName: 'dev', objectName: fileUrl.split('/').pop(), uploadUserId: userId, uploadUserName: userName, - attachmentType: 'TRADE_FILE', + attachmentType: '鍏朵粬', description: '浜ゆ槗鏂囦欢' } @@ -756,7 +809,7 @@ // 妫�鏌ュ搷搴旀牸寮� const responseData = previewResponse as any if (responseData && responseData.code === 200 && responseData.data) { - previewUrl = responseData.data + // previewUrl = responseData.data.replaceAll("192.168.20.52", import.meta.env.) console.log('浣跨敤棰勮URL:', previewUrl) } else { console.log('棰勮URL鑾峰彇澶辫触锛屼娇鐢ㄤ笅杞芥柟寮�') @@ -848,11 +901,11 @@ fileType: file.type || 'application/octet-stream', fileSize: file.size, fileUrl: fileUrl, - bucketName: 'order-attachments', + bucketName: 'dev', objectName: fileUrl.split('/').pop(), uploadUserId: userId, uploadUserName: userName, - attachmentType: 'TRADE_FILE', + attachmentType: '鍏朵粬', description: '浜ゆ槗鏂囦欢' } -- Gitblit v1.8.0