From dc49b96b835326a64056da9da0b43eabd2d96e32 Mon Sep 17 00:00:00 2001
From: zuoxiao <470321431@qq.com>
Date: 星期五, 25 七月 2025 19:37:11 +0800
Subject: [PATCH] 常用取水口列表搜索接口兼容性
---
pages/irrigationDetail/irrigationDetail.js | 131 ++++++++++++++++++++++++++++++++++++++++---
1 files changed, 121 insertions(+), 10 deletions(-)
diff --git a/pages/irrigationDetail/irrigationDetail.js b/pages/irrigationDetail/irrigationDetail.js
index d8a1a92..fff0558 100644
--- a/pages/irrigationDetail/irrigationDetail.js
+++ b/pages/irrigationDetail/irrigationDetail.js
@@ -12,7 +12,10 @@
planId: '',
planStatusText: '',
planStatusClass: '',
- failureCount: 0
+ failureCount: 0,
+ realStopTime: '',
+ originalStatus: '',
+ currentStatus: null
},
/**
@@ -23,7 +26,35 @@
this.setData({
planId: options.planId
});
- this.fetchIrrigationData(options.planId);
+
+ // 鑾峰彇鏈�鏂扮姸鎬�
+ this.fetchPlanLatestState(options.planId).then(res => {
+ if (res.success) {
+ const currentStatus = res.content;
+ this.setData({
+ currentStatus: currentStatus,
+ originalStatus: currentStatus
+ });
+
+ // 鏍规嵁鏈�鏂扮姸鎬佽皟鐢ㄧ浉搴旂殑鎺ュ彛
+ if (currentStatus === 5) {
+ this.fetchTerminatedIrrigationData(options.planId);
+ } else {
+ this.fetchNormalIrrigationData(options.planId);
+ }
+ } else {
+ wx.showToast({
+ title: res.msg || '鑾峰彇鐘舵�佸け璐�',
+ icon: 'none'
+ });
+ }
+ }).catch(err => {
+ console.error('鑾峰彇鐘舵�佸け璐ワ細', err);
+ wx.showToast({
+ title: '鑾峰彇鐘舵�佸け璐�',
+ icon: 'none'
+ });
+ });
} else {
wx.showToast({
title: '缂哄皯璁″垝ID',
@@ -36,9 +67,9 @@
},
/**
- * 鑾峰彇鐏屾簤璁″垝鏁版嵁
+ * 鑾峰彇甯歌鐏屾簤璁″垝璇︾粏鏁版嵁
*/
- fetchIrrigationData: function(planId) {
+ fetchNormalIrrigationData: function(planId) {
const { get } = require('../../api/request');
const data = {
@@ -69,6 +100,57 @@
},
/**
+ * 鑾峰彇宸茬粓姝㈢亴婧夎鍒掕缁嗘暟鎹�
+ */
+ fetchTerminatedIrrigationData: function(planId) {
+ const { get } = require('../../api/request');
+
+ const data = {
+ planId: planId || this.data.planId,
+ };
+
+ get({
+ url: 'wx/plan/getTerminateResults',
+ isShowLoding: true,
+ useParams: true,
+ data: data
+ }).then(res => {
+ if (res.success) {
+ this.processIrrigationData(res.content);
+ } else {
+ wx.showToast({
+ title: res.msg || '鑾峰彇鏁版嵁澶辫触',
+ icon: 'none'
+ });
+ }
+ }).catch(err => {
+ console.error('璇锋眰澶辫触锛�', err);
+ wx.showToast({
+ title: '璇锋眰澶辫触',
+ icon: 'none'
+ });
+ });
+ },
+
+ /**
+ * 鑾峰彇璁″垝鏈�鏂扮姸鎬�
+ */
+ fetchPlanLatestState: function(planId) {
+ const { get } = require('../../api/request');
+
+ const data = {
+ planId: planId || this.data.planId,
+ };
+
+ return get({
+ url: 'wx/plan/getPlanLatestState',
+ isShowLoding: true,
+ useParams: true,
+ data: data
+ });
+ },
+
+ /**
* 澶勭悊鎺ュ彛杩斿洖鐨勬暟鎹�
*/
processIrrigationData: function(data) {
@@ -78,7 +160,9 @@
const statusMap = {
2: {status: 'pending', statusText: '鏈紑濮�'},
3: {status: 'in_progress', statusText: '鐏屾簤涓�'},
- 4: {status: 'completed', statusText: '宸茬粨鏉�'}
+ 4: {status: 'completed', statusText: '宸茬粨鏉�'},
+ 5: {status: 'terminated', statusText: '涓�斿叧闃�'},
+ 6: {status: 'canceled', statusText: '鍙栨秷寮�闃�'}
};
// 澶勭悊璁″垝鐘舵��
@@ -140,6 +224,7 @@
projectName: data.projectName,
startTime: data.planStartTime,
stopTime: data.planStopTime,
+ realStopTime: data.realStopTime || '',
groupList: groupList,
planStatusText: planStatusText,
planStatusClass: planStatusClass,
@@ -182,15 +267,41 @@
this.setData({
isRefreshing: true
});
-
- this.fetchIrrigationData(this.data.planId);
- // 瀹屾垚鍒锋柊
- setTimeout(() => {
+ // 鑾峰彇鏈�鏂扮姸鎬佸苟鍒锋柊鏁版嵁
+ this.fetchPlanLatestState(this.data.planId).then(res => {
+ if (res.success) {
+ const currentStatus = res.content;
+ this.setData({
+ currentStatus: currentStatus
+ });
+
+ if (currentStatus === 5) {
+ this.fetchTerminatedIrrigationData(this.data.planId);
+ } else {
+ this.fetchNormalIrrigationData(this.data.planId);
+ }
+ } else {
+ wx.showToast({
+ title: res.msg || '鑾峰彇鐘舵�佸け璐�',
+ icon: 'none'
+ });
+ }
+
+ // 瀹屾垚鍒锋柊
this.setData({
isRefreshing: false
});
- }, 1000);
+ }).catch(err => {
+ console.error('鑾峰彇鐘舵�佸け璐ワ細', err);
+ wx.showToast({
+ title: '鑾峰彇鐘舵�佸け璐�',
+ icon: 'none'
+ });
+ this.setData({
+ isRefreshing: false
+ });
+ });
},
/**
--
Gitblit v1.8.0