From 2cc85c64f1c64a2dbaeae276a3e2ca8420de76b7 Mon Sep 17 00:00:00 2001
From: WXL <wl_5969728@163.com>
Date: 星期三, 22 四月 2026 18:09:58 +0800
Subject: [PATCH] 上报转运调试
---
pages/case/index.vue | 292 ++++++++++++++++++++++++++++++++++++++--------------------
1 files changed, 191 insertions(+), 101 deletions(-)
diff --git a/pages/case/index.vue b/pages/case/index.vue
index dea481c..79f8731 100644
--- a/pages/case/index.vue
+++ b/pages/case/index.vue
@@ -77,7 +77,7 @@
</view>
<text
class="status"
- :class="caseItem.reportStatus.replace('ed', '')"
+ :class="getStatusClass(caseItem.reportStatus)"
>{{ caseItem.statusText }}</text
>
</view>
@@ -197,15 +197,6 @@
鍒涘缓杞繍鍗�
</button>
- <!-- 闇�杞繍浣嗘湭鍚屾剰 -->
- <!-- <button
- v-if="caseItem.isTransport == '2' && !hasTransport(caseItem)"
- class="transport-btn disabled"
- disabled
- >
- 闇�鍏堝悓鎰忔渚�
- </button> -->
-
<!-- 鏈夎浆杩愬崟鍙煡鐪� -->
<button
v-if="hasTransport(caseItem)"
@@ -233,7 +224,7 @@
<view class="actions">
<button
class="action-btn"
- v-if="caseItem.reportStatus != '1'"
+ v-if="caseItem.reportStatus == '1' || caseItem.reportStatus == '2'"
@tap.stop="withdrawCase(caseItem)"
>
鎾ゅ洖
@@ -243,7 +234,7 @@
</button>
<button
class="action-btn secondary"
- v-if="caseItem.reportStatus != '1'"
+ v-if="caseItem.reportStatus == '1' || caseItem.reportStatus == '2'"
@tap.stop="editCase(caseItem)"
>
缂栬緫
@@ -253,19 +244,19 @@
</view>
<!-- 鍔犺浇鏇村 -->
- <view class="load-more" v-if="hasMore">
- <text>鍔犺浇涓�...</text>
+ <view class="load-more" v-if="loadingMore">
+ <u-loading-icon text="鍔犺浇涓�..."></u-loading-icon>
+ </view>
+
+ <!-- 鏃犳洿澶氭暟鎹� -->
+ <view class="no-more" v-if="!hasMore && filteredCases.length > 0">
+ <text>宸插姞杞藉叏閮ㄦ暟鎹�</text>
</view>
<!-- 绌虹姸鎬� -->
<view class="empty-state" v-if="!loading && filteredCases.length == 0">
<image src="/static/empty/no-case.png" mode="aspectFit" />
<text>鏆傛棤鍣ㄥ畼鎹愮尞妗堜緥璁板綍</text>
- </view>
-
- <!-- 鍔犺浇鐘舵�� -->
- <view class="empty-state" v-if="loading">
- <text>鏁版嵁鍔犺浇涓�...</text>
</view>
</scroll-view>
@@ -286,17 +277,25 @@
</view>
</view>
</view>
+
+ <!-- 鍔犺浇鐘舵�� -->
+ <u-loading-page v-if="initLoading" :loading="true" text="鏁版嵁鍔犺浇涓�..." />
+ </view>
+ <view class="float-button" @tap="createNewCase">
+ <u-icon name="plus" color="#fff" size="24"></u-icon>
</view>
</template>
<script setup>
import { ref, computed, onMounted } from "vue";
-import { onLoad, onShow } from "@dcloudio/uni-app";
+import { onLoad, onShow, onReachBottom } from "@dcloudio/uni-app";
import { useDict } from "@/utils/dict";
// 鍝嶅簲寮忔暟鎹�
const dict = ref({});
const loading = ref(false);
+const initLoading = ref(false);
+const loadingMore = ref(false);
const cases = ref([]);
const total = ref(0);
const pageNum = ref(1);
@@ -324,22 +323,6 @@
};
const statusInfo = statusMap[apiData.reportStatus] || statusMap["1"];
-
- // 杞繍鐘舵�佹槧灏�
- const getTransportStatusClass = (caseData) => {
- if (!hasTransport(caseData)) {
- return "not-transported";
- }
- const status = getTransportStatus(caseData);
- const map = {
- 1: "pending",
- 2: "transporting",
- 3: "completed",
- 4: "cancelled",
- 5: "draft",
- };
- return map[status] || "pending";
- };
return {
id: apiData.id || apiData.donatebaseinfoReportId,
@@ -393,13 +376,16 @@
};
// 杞繍鍒ゆ柇鏂规硶 - 涓嶱C绔繚鎸佷竴鑷�
const hasTransport = (caseData) => {
- console.log(caseData.serviceTransport);
return caseData.serviceTransport && caseData.serviceTransport.length > 0;
};
-
+const createNewCase = () => {
+ uni.navigateTo({
+ url: '/pages/case/CaseDetails'
+ });
+};
const canCreateTransport = (caseData) => {
return (
- (caseData.isTransport != "4" || caseData.isTransport == 2) && // 闇�瑕佽浆杩�
+ (caseData.isTransport == "2" || caseData.isTransport == 2) && // 闇�瑕佽浆杩�
!hasTransport(caseData)
); // 鏃犺浆杩愬崟
};
@@ -490,7 +476,15 @@
url: `/pages/case/transferinfo?caseId=${caseItem.id}&caseNo=${caseItem.donorNo}`,
});
};
-
+const getStatusClass = (status) => {
+ const map = {
+ '1': 'reported', // 宸蹭笂鎶�
+ '2': 'read', // 宸查槄璇�
+ '3': 'agreed', // 宸插悓鎰�
+ '4': 'rejected' // 宸查┏鍥�
+ };
+ return map[status] || 'reported';
+}
const viewTransportDetail = (caseItem) => {
if (hasTransport(caseItem)) {
const transport = caseItem.serviceTransport[0];
@@ -502,7 +496,7 @@
// 绛涢�夌浉鍏�
const caseTypes = [
- { label: "鍏ㄩ儴", value: "" },
+ { label: "鍏ㄩ儴", value: "all" },
{ label: "宸蹭笂鎶�", value: "1" },
{ label: "宸查槄璇�", value: "2" },
{ label: "宸插悓鎰�", value: "3" },
@@ -511,17 +505,6 @@
const currentType = ref("all");
const startDate = ref("");
const endDate = ref("");
-
-// 杞繍鐘舵�佹槧灏�
-const transportStatusMap = {
- not_transported: {
- text: "鏈浆杩�",
- color: "warning",
- class: "not-transported",
- },
- transporting: { text: "杞繍涓�", color: "primary", class: "transporting" },
- completed: { text: "宸插畬鎴�", color: "success", class: "completed" },
-};
// 鐢熷懡鍛ㄦ湡
onLoad(async (options) => {
@@ -537,6 +520,12 @@
await loadInitialData();
});
+onReachBottom(() => {
+ if (hasMore.value && !loading.value && !loadingMore.value) {
+ onLoadMore();
+ }
+});
+
onShow(() => {
const transportUpdate = uni.getStorageSync("transportStatusUpdate");
if (transportUpdate) {
@@ -547,46 +536,90 @@
// 鏁版嵁鍔犺浇鍑芥暟
const loadInitialData = async () => {
- loading.value = true;
+ initLoading.value = true;
try {
- await Promise.all([donatebaseinforeportList(), donateTotal()]);
+ await Promise.all([donatebaseinforeportList(true), donateTotal()]);
} catch (error) {
console.error("鍒濆鍖栨暟鎹け璐�:", error);
} finally {
- loading.value = false;
+ initLoading.value = false;
}
};
// 鑾峰彇妗堜緥鍒楄〃
-const donatebaseinforeportList = async () => {
+const donatebaseinforeportList = async (reset = false) => {
+ if (reset) {
+ pageNum.value = 1;
+ hasMore.value = true;
+ }
+
+ if (loading.value || loadingMore.value || !hasMore.value) return;
+
+ if (reset) {
+ loading.value = true;
+ } else {
+ loadingMore.value = true;
+ }
+
try {
const params = {
pageNum: pageNum.value,
pageSize: pageSize.value,
};
-
+
+ // 绛涢�夋潯浠� - 濡傛灉閫夋嫨浜�"鍏ㄩ儴"锛屼笉浼爎eportStatus鍙傛暟
+ if (currentType.value !== "all") {
+ params.reportStatus = currentType.value;
+ }
+
+ // 鏃堕棿绛涢�夋潯浠�
+ if (startDate.value && endDate.value) {
+ // 灏嗘椂闂存牸寮忚浆鎹负鎺ュ彛闇�瑕佺殑鏍煎紡
+ params.startDate = startDate.value;
+ params.endDate = endDate.value;
+ }
+
+ console.log("璇锋眰鍙傛暟:", params);
+
const res = await uni.$uapi.post(
"/project/donatebaseinforeport/list",
params,
);
- console.log(res, "res");
-
- const mappedData = res.map((item) => mapApiDataToCaseItem(item));
-
- if (pageNum.value == 1) {
- cases.value = mappedData;
+
+ console.log("鎺ュ彛杩斿洖鏁版嵁:", res);
+
+ if (res.code == 200) {
+ const data =res.data || [];
+ const mappedData = data.map((item) => mapApiDataToCaseItem(item));
+
+ if (reset || pageNum.value == 1) {
+ console.log(mappedData,'mappedData');
+
+ cases.value = mappedData;
+ } else {
+ cases.value = [...cases.value, ...mappedData];
+ }
+
+ // 鍒ゆ柇鏄惁杩樻湁鏇村鏁版嵁
+ hasMore.value = data.length >= pageSize.value;
+ total.value = res.total || 0;
+
+ // 濡傛灉鏈夋暟鎹姞杞芥垚鍔燂紝澧炲姞椤电爜
+ if (data.length > 0) {
+ pageNum.value++;
+ }
} else {
- cases.value = [...cases.value, ...mappedData];
+ throw new Error(res.msg || "鍔犺浇澶辫触");
}
-
- hasMore.value = pageNum.value * pageSize.value < res.total;
- total.value = res.total;
} catch (error) {
console.error("鑾峰彇妗堜緥鍒楄〃澶辫触:", error);
uni.showToast({
title: "缃戠粶璇锋眰澶辫触",
icon: "none",
});
+ } finally {
+ loading.value = false;
+ loadingMore.value = false;
}
};
@@ -594,62 +627,73 @@
const donateTotal = async () => {
try {
const res = await uni.$uapi.post("/project/donatebaseinforeport/getTotal");
- stats.value = {
- totalCases: res["all"] || 0,
- readCases: res["2"] || 0,
- agreedCases: res["3"] || 0,
- };
+ if (res.code === 200) {
+ stats.value = {
+ totalCases: res.data["all"] || 0,
+ readCases: res.data["2"] || 0,
+ agreedCases: res.data["3"] || 0,
+ };
+ } else {
+ throw new Error(res.msg || "鑾峰彇缁熻澶辫触");
+ }
} catch (error) {
console.error("鑾峰彇缁熻鏁版嵁澶辫触:", error);
}
};
-// 璁$畻灞炴�э細绛涢�夎褰�
+// 璁$畻灞炴�э細绛涢�夎褰� - 鐜板湪鍙仛鍓嶇鐘舵�佺瓫閫�
const filteredCases = computed(() => {
let result = cases.value;
-
- if (currentType.value !== "all") {
- result = result.filter(
- (caseItem) => caseItem.reportStatus == currentType.value,
- );
- }
-
- if (startDate.value && endDate.value) {
- result = result.filter((caseItem) => {
- const caseDate = caseItem.reportTime.split(" ")[0];
- return caseDate >= startDate.value && caseDate <= endDate.value;
- });
- }
-
+
+ // 鍙仛鍓嶇鐘舵�佺瓫閫夛紝鏃堕棿绛涢�夊凡缁忛�氳繃鎺ュ彛瀹炵幇
+ // if (currentType.value !== "all") {
+ // result = result.filter(
+ // (caseItem) => caseItem.reportStatus == currentType.value,
+ // );
+ // }
+
return result;
});
// 浜嬩欢澶勭悊鍑芥暟
const selectType = (type) => {
currentType.value = type;
+ // 閲嶇疆鍒嗛〉锛岄噸鏂板姞杞芥暟鎹�
+ pageNum.value = 1;
+ donatebaseinforeportList(true);
};
const onStartDateChange = (e) => {
startDate.value = e.detail.value;
+ // 濡傛灉缁撴潫鏃ユ湡宸查�夋嫨锛岀珛鍗宠Е鍙戠瓫閫�
+ if (endDate.value) {
+ pageNum.value = 1;
+ donatebaseinforeportList(true);
+ }
};
const onEndDateChange = (e) => {
endDate.value = e.detail.value;
+ // 濡傛灉寮�濮嬫棩鏈熷凡閫夋嫨锛岀珛鍗宠Е鍙戠瓫閫�
+ if (startDate.value) {
+ pageNum.value = 1;
+ donatebaseinforeportList(true);
+ }
};
// 鍒锋柊鍜屽姞杞芥洿澶�
const onRefresh = async () => {
refreshing.value = true;
pageNum.value = 1;
- await donatebaseinforeportList();
+ await donatebaseinforeportList(true);
+ await donateTotal();
setTimeout(() => {
refreshing.value = false;
}, 1000);
};
const onLoadMore = async () => {
- if (!hasMore.value || loading.value) return;
- pageNum.value += 1;
+ if (!hasMore.value || loading.value || loadingMore.value) return;
await donatebaseinforeportList();
};
@@ -677,19 +721,36 @@
showWithdrawModal.value = true;
};
-const confirmWithdraw = () => {
- const index = cases.value.findIndex(
- (item) => item.id == currentCase.value.id,
- );
- if (index !== -1) {
- cases.value.splice(index, 1);
- stats.value.totalCases -= 1;
+const confirmWithdraw = async () => {
+ try {
+ const res = await uni.$uapi.delete(`/project/donatebaseinforeport/${currentCase.value.id}`);
+
+ if (res.code === 200) {
+ // 浠庡垪琛ㄤ腑绉婚櫎
+ const index = cases.value.findIndex(
+ (item) => item.id == currentCase.value.id
+ );
+ if (index !== -1) {
+ cases.value.splice(index, 1);
+ stats.value.totalCases -= 1;
+ }
+
+ uni.showToast({
+ title: "鎾ゅ洖鎴愬姛",
+ icon: "success",
+ });
+ } else {
+ throw new Error(res.msg || "鎾ゅ洖澶辫触");
+ }
+ } catch (error) {
+ console.error("鎾ゅ洖澶辫触:", error);
uni.showToast({
- title: "鎾ゅ洖鎴愬姛",
- icon: "success",
+ title: "鎾ゅ洖澶辫触锛岃閲嶈瘯",
+ icon: "none",
});
+ } finally {
+ showWithdrawModal.value = false;
}
- showWithdrawModal.value = false;
};
const cancelWithdraw = () => {
@@ -1070,6 +1131,14 @@
}
}
}
+
+ .load-more, .no-more {
+ text-align: center;
+ padding: 40rpx 0;
+ color: $text-secondary;
+ font-size: 28rpx;
+ }
+
.empty-state {
padding: 120rpx 0;
text-align: center;
@@ -1154,4 +1223,25 @@
}
}
}
-</style>
+/* 娴姩鎸夐挳鏍峰紡 */
+.float-button {
+ position: fixed;
+ bottom: 120rpx;
+ right: 40rpx;
+ width: 100rpx;
+ height: 100rpx;
+ background: $primary-color;
+ border-radius: 50%;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ box-shadow: 0 8rpx 20rpx rgba($primary-color, 0.3);
+ z-index: 100;
+ transition: all 0.3s ease;
+
+ &:active {
+ opacity: 0.8;
+ transform: scale(0.95);
+ }
+}
+</style>
\ No newline at end of file
--
Gitblit v1.9.3