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/pointsManage/personal/index.vue | 81 +++++++++++++++++++++++++++++----------- 1 files changed, 59 insertions(+), 22 deletions(-) diff --git a/src/views/pointsManage/personal/index.vue b/src/views/pointsManage/personal/index.vue index 4ee14ac..caf6695 100644 --- a/src/views/pointsManage/personal/index.vue +++ b/src/views/pointsManage/personal/index.vue @@ -58,11 +58,11 @@ <span class="filter-label">鏁版嵁绫荤洰:</span> <el-select v-model="queryParams.dataCategory" placeholder="鍏ㄩ儴" clearable> <el-option label="鍏ㄩ儴" value="" /> - <el-option - v-for="category in categoryList" - :key="category" - :label="getCategoryLabel(category)" - :value="category" + <el-option + v-for="category in categoryList" + :key="category" + :label="getCategoryLabel(category)" + :value="category" /> </el-select> </div> @@ -103,8 +103,8 @@ <!-- 娴佹按琛ㄦ牸 --> <div class="table-section"> - <el-table :data="flowList" stripe style="width: 100%"> - <el-table-column prop="id" label="搴忓彿" width="80" align="center" /> + <el-table :data="flowList" stripe style="width: 100%" :height="440"> + <el-table-column type="index" label="搴忓彿" width="80" align="center" /> <el-table-column prop="dataCategory" label="鏁版嵁绫荤洰" width="120"> <template #default="{ row }"> <span>{{ getCategoryLabel(row.dataCategory) }}</span> @@ -145,18 +145,23 @@ <script setup lang="ts"> import { ref, reactive, onMounted, computed } from 'vue' import { dayjs, ElMessage } from 'element-plus' -import { - ArrowLeft, - Refresh, - Setting, - Close, - Money, - Plus, - Minus, - Search +import { + ArrowLeft, + Refresh, + Setting, + Close, + Money, + Plus, + Minus, + Search } from '@element-plus/icons-vue' import pointsApi from '@/api/pointsApi' import type { PointsStats, PointsFlow, PointsQueryParams } from '@/types/points' +import { useUserInfo } from '@/stores/modules/userInfo' +import { queryUserDetail } from '@/api/userInfo' + +// 鑾峰彇鐢ㄦ埛淇℃伅 store +const userStore = useUserInfo() // 绉垎缁熻 const stats = ref<PointsStats>({ @@ -168,7 +173,7 @@ // 鏌ヨ鍙傛暟 const queryParams = reactive<PointsQueryParams>({ - userId: '1', + userId: '', dataCategory: '', dataType: '', pageNum: 1, @@ -208,7 +213,13 @@ // 鑾峰彇绉垎缁熻 const getPointsStats = async () => { try { - const userId = 1; + const userId = userStore.getUserId || userStore.getUserInfo?.userId + if (!userId) { + console.error('鏃犳硶鑾峰彇鐢ㄦ埛ID') + return + } + // 鏇存柊鏌ヨ鍙傛暟涓殑 userId + queryParams.userId = userId.toString() const res = await pointsApi.getPersonalPointsStats(userId) if (res.code === 200 && res.data) { stats.value = res.data @@ -233,6 +244,13 @@ // 鑾峰彇绉垎娴佹按 const getPointsFlow = async () => { try { + const userId = userStore.getUserId || userStore.getUserInfo?.userId + if (!userId) { + console.error('鏃犳硶鑾峰彇鐢ㄦ埛ID') + return + } + // 鏇存柊鏌ヨ鍙傛暟涓殑 userId + queryParams.userId = userId.toString() const res = await pointsApi.getPersonalPointsFlow(queryParams) if (res.code === 200) { flowList.value = res.data.list || [] @@ -300,7 +318,26 @@ ElMessage.info('鍏抽棴鍏ㄩ儴鍔熻兘') } -onMounted(() => { +onMounted(async () => { + // 椤甸潰鎸傝浇鏃讹紝妫�鏌� userStore 鏄惁宸叉湁鐢ㄦ埛淇℃伅 + let userId = userStore.getUserId || userStore.getUserInfo?.userId + if (!userId) { + try { + const res: any = await queryUserDetail() + if (res?.code === 200 && res.data) { + userStore.updateUserDetail(res.data) + userId = res.data.userId || res.data.id + } else { + ElMessage.error(res?.msg || '鏃犳硶鑾峰彇鐢ㄦ埛淇℃伅锛岃鍏堢櫥褰�') + return + } + } catch (e) { + console.error('鑾峰彇鐢ㄦ埛璇︽儏澶辫触:', e) + ElMessage.error('鑾峰彇鐢ㄦ埛淇℃伅澶辫触锛岃绋嶅悗閲嶈瘯') + return + } + } + getPointsStats() getPointsFlow() getCategoryList() @@ -332,7 +369,7 @@ cursor: pointer; color: #409eff; font-size: 18px; - + &:hover { color: #66b1ff; } @@ -354,7 +391,7 @@ cursor: pointer; color: #909399; font-size: 16px; - + &:hover { color: #409eff; } @@ -548,7 +585,7 @@ :deep(.el-select), :deep(.el-date-picker) { width: 100%; - + @media (min-width: 768px) { width: auto; min-width: 120px; -- Gitblit v1.8.0