From fe3ce21a469f7e2584dbcb85cb75022d149f436c Mon Sep 17 00:00:00 2001
From: zuoxiao <zuoxiao>
Date: 星期二, 25 三月 2025 19:28:56 +0800
Subject: [PATCH] 更新灌溉计划页面,添加项目选择器和总灌溉时间计算功能;优化界面样式,增加SVG图标;修复项目列表和轮灌组显示逻辑;调整配置文件,添加libVersion字段。

---
 pages/irrigationDetail/irrigationDetail.js |  295 +++++++++++------------------------------------------------
 1 files changed, 55 insertions(+), 240 deletions(-)

diff --git a/pages/irrigationDetail/irrigationDetail.js b/pages/irrigationDetail/irrigationDetail.js
index 5b4907b..5012c84 100644
--- a/pages/irrigationDetail/irrigationDetail.js
+++ b/pages/irrigationDetail/irrigationDetail.js
@@ -5,248 +5,51 @@
   data: {
     planCode: '',
     startTime: '',
-    projects: [],
-    isRefreshing: false, // 涓嬫媺鍒锋柊鐘舵��
-    planId: '' // 淇濆瓨璁″垝ID
+    isRefreshing: false,
+    projects: []
   },
 
   /**
    * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍔犺浇
    */
   onLoad: function (options) {
-    if (options.id) {
-      this.setData({
-        planId: options.id
-      });
-      // 浠庡垪琛ㄩ〉闈㈣繘鍏ユ椂锛屾墍鏈夐」鐩粯璁ゆ敹璧�
-      const fromListPage = options.fromList === 'true';
-      this.loadIrrigationDetail(options.id, !fromListPage);
-    }
-  },
-
-  /**
-   * 鍔犺浇鐏屾簤璁″垝璇︽儏
-   * @param {string} id 鐏屾簤璁″垝ID
-   * @param {boolean} isFirstLoad 鏄惁棣栨鍔犺浇
-   */
-  loadIrrigationDetail: function (id, isFirstLoad = false) {
-    // 寮�濮嬪姞杞斤紝璁剧疆鍒锋柊鐘舵��
+    // 妯℃嫙鏁版嵁
     this.setData({
-      isRefreshing: true
-    });
-
-    // 淇濆瓨褰撳墠椤圭洰鐨勫睍寮�鐘舵��
-    const currentExpandStates = {};
-    if (!isFirstLoad && this.data.projects.length > 0) {
-      this.data.projects.forEach((project, index) => {
-        currentExpandStates[project.id] = project.expanded;
-      });
-    }
-
-    // 杩欓噷搴旇鏄粠API鑾峰彇鏁版嵁
-    // 浠ヤ笅鏄ā鎷熸暟鎹�
-    const mockData = {
-      planCode: 'IRG20240317001',
-      startTime: '2024-03-17 08:00',
-      projects: [
-        {
-          id: 1,
-          name: '椤圭洰A',
-          expanded: isFirstLoad ? true : false, // 浠呭湪闈炲垪琛ㄩ〉杩涘叆涓旈娆″姞杞芥椂灞曞紑绗竴涓」鐩�
-          groups: [
-            {
-              id: 1,
-              name: '杞亴缁凙-1',
-              status: 'irrigated', // 宸茬亴婧�
-              statusText: '宸茬亴婧�',
-              startTime: '2024-03-17 08:00',
-              endTime: '2024-03-17 09:30',
-              duration: 90
-            },
-            {
-              id: 2,
-              name: '杞亴缁凙-2',
-              status: 'irrigating', // 姝e湪鐏屾簤
-              statusText: '姝e湪鐏屾簤',
-              startTime: '2024-03-17 09:30',
-              endTime: '2024-03-17 11:00',
-              duration: 90
-            }
-          ]
-        },
-        {
-          id: 2,
-          name: '椤圭洰B',
-          expanded: false,
-          groups: [
-            {
-              id: 3,
-              name: '杞亴缁凚-1',
-              status: 'waiting', // 鏈亴婧�
-              statusText: '鏈亴婧�',
-              startTime: '2024-03-17 11:00',
-              endTime: '2024-03-17 12:30',
-              duration: 90
-            },
-            {
-              id: 4,
-              name: '杞亴缁凚-2',
-              status: 'waiting', // 鏈亴婧�
-              statusText: '鏈亴婧�',
-              startTime: '2024-03-17 12:30',
-              endTime: '2024-03-17 14:00',
-              duration: 90
-            }
-          ]
-        },
-        {
-          id: 3,
-          name: '椤圭洰C',
-          expanded: false,
-          groups: [
-            {
-              id: 5,
-              name: '杞亴缁凜-1',
-              status: 'waiting', // 鏈亴婧�
-              statusText: '鏈亴婧�',
-              startTime: '2024-03-17 14:00',
-              endTime: '2024-03-17 15:30',
-              duration: 90
-            }
-          ]
-        }
-      ]
-    };
-
-    // 璁$畻姣忎釜椤圭洰鐨勬�荤亴婧夋椂闀�
-    mockData.projects = this.calculateProjectTotalDuration(mockData.projects);
-
-    // 濡傛灉涓嶆槸棣栨鍔犺浇锛屾仮澶嶉」鐩殑灞曞紑鐘舵��
-    if (!isFirstLoad) {
-      mockData.projects.forEach(project => {
-        if (currentExpandStates[project.id] !== undefined) {
-          project.expanded = currentExpandStates[project.id];
-        }
-      });
-    }
-
-    // 妯℃嫙缃戠粶璇锋眰寤惰繜
-    setTimeout(() => {
-      // 璁剧疆椤甸潰鏁版嵁
-      this.setData({
-        planCode: mockData.planCode,
-        startTime: mockData.startTime,
-        projects: mockData.projects,
-        isRefreshing: false // 缁撴潫鍒锋柊鐘舵��
-      });
-    }, 1000);
-
-    // 瀹為檯椤圭洰涓簲璇ヤ娇鐢╳x.request鑾峰彇鏁版嵁
-    // wx.request({
-    //   url: 'https://your-api-url/irrigation/' + id,
-    //   method: 'GET',
-    //   success: (res) => {
-    //     if (res.data && res.data.code === 0) {
-    //       // 鑾峰彇鏂版暟鎹�
-    //       let projects = res.data.data.projects;
-    //       
-    //       // 濡傛灉鏄娆″姞杞斤紝璁剧疆榛樿灞曞紑鐘舵��
-    //       if (isFirstLoad) {
-    //         projects = projects.map((project, index) => {
-    //           return {
-    //             ...project,
-    //             expanded: index === 0 // 榛樿鍙睍寮�绗竴涓」鐩�
-    //           };
-    //         });
-    //       } else {
-    //         // 濡傛灉涓嶆槸棣栨鍔犺浇锛屾仮澶嶉」鐩殑灞曞紑鐘舵��
-    //         projects = projects.map(project => {
-    //           return {
-    //             ...project,
-    //             expanded: currentExpandStates[project.id] !== undefined 
-    //               ? currentExpandStates[project.id] 
-    //               : false
-    //           };
-    //         });
-    //       }
-    //       
-    //       // 璁$畻姣忎釜椤圭洰鐨勬�荤亴婧夋椂闀�
-    //       projects = this.calculateProjectTotalDuration(projects);
-    //       
-    //       this.setData({
-    //         planCode: res.data.data.planCode,
-    //         startTime: res.data.data.startTime,
-    //         projects: projects,
-    //         isRefreshing: false // 缁撴潫鍒锋柊鐘舵��
-    //       });
-    //     } else {
-    //       wx.showToast({
-    //         title: '鑾峰彇鏁版嵁澶辫触',
-    //         icon: 'none'
-    //       });
-    //       this.setData({
-    //         isRefreshing: false // 缁撴潫鍒锋柊鐘舵��
-    //       });
-    //     }
-    //   },
-    //   fail: () => {
-    //     wx.showToast({
-    //       title: '缃戠粶閿欒',
-    //       icon: 'none'
-    //     });
-    //     this.setData({
-    //       isRefreshing: false // 缁撴潫鍒锋柊鐘舵��
-    //     });
-    //   }
-    // });
-  },
-
-  /**
-   * 璁$畻姣忎釜椤圭洰鐨勬�荤亴婧夋椂闀�
-   */
-  calculateProjectTotalDuration: function(projects) {
-    return projects.map(project => {
-      // 璁$畻椤圭洰涓嬫墍鏈夎疆鐏岀粍鐨勬�绘椂闀�
-      const totalDuration = project.groups.reduce((total, group) => {
-        return total + (group.duration || 0);
-      }, 0);
-      
-      return {
-        ...project,
-        totalDuration: totalDuration
-      };
-    });
-  },
-
-  /**
-   * 鍒囨崲椤圭洰灞曞紑/鏀惰捣鐘舵��
-   */
-  toggleProject: function (e) {
-    const index = e.currentTarget.dataset.index;
-    const expanded = this.data.projects[index].expanded;
-    
-    // 鏇存柊椤圭洰鐨勫睍寮�鐘舵��
-    const key = `projects[${index}].expanded`;
-    this.setData({
-      [key]: !expanded
-    });
-  },
-
-  /**
-   * 瀵艰埅鍒拌疆鐏岀粍璇︽儏椤甸潰
-   */
-  navigateToGroupDetail: function (e) {
-    const projectName = e.currentTarget.dataset.projectName;
-    const groupName = e.currentTarget.dataset.groupName;
-    const groupId = e.currentTarget.dataset.groupId;
-    const status = e.currentTarget.dataset.status;
-    
-    console.log('璺宠浆鍒扮粍璇︽儏椤甸潰锛屽師濮嬬姸鎬�:', status);
-    
-    // 瀵艰埅鍒扮粍璇︽儏椤甸潰锛屽苟浼犻�掑弬鏁�
-    // 娉ㄦ剰锛氶渶瑕佸皢status杞崲涓篿sIrrigating鍙傛暟锛屼互渚垮湪缁勮鎯呴〉闈㈡纭樉绀哄懡浠ょ姸鎬�
-    wx.navigateTo({
-      url: `/pages/groupDetail/groupDetail?projectName=${projectName}&groupName=${groupName}&groupId=${groupId}&status=${status}&isIrrigating=${status === 'irrigating' ? 'true' : 'false'}`
+      planCode: 'IRR-2024-001',
+      startTime: '2024-03-20 08:00',
+      projects: [{
+        id: 1,
+        name: '绀轰緥椤圭洰',
+        groups: [
+          {
+            id: 1,
+            name: '杞亴缁�1',
+            status: 'pending',
+            statusText: '寰呯亴婧�',
+            startTime: '08:00',
+            endTime: '09:00',
+            duration: 60
+          },
+          {
+            id: 2,
+            name: '杞亴缁�2',
+            status: 'in_progress',
+            statusText: '鐏屾簤涓�',
+            startTime: '09:00',
+            endTime: '10:00',
+            duration: 60
+          },
+          {
+            id: 3,
+            name: '杞亴缁�3',
+            status: 'completed',
+            statusText: '宸插畬鎴�',
+            startTime: '10:00',
+            endTime: '11:00',
+            duration: 60
+          }
+        ]
+      }]
     });
   },
 
@@ -282,14 +85,16 @@
    * 涓嬫媺鍒锋柊澶勭悊鍑芥暟
    */
   onPullDownRefresh: function () {
-    // 閲嶆柊鍔犺浇鏁版嵁锛屼絾淇濇寔灞曞紑鐘舵��
-    if (this.data.planId) {
-      this.loadIrrigationDetail(this.data.planId, false);
-    } else {
+    this.setData({
+      isRefreshing: true
+    });
+
+    // 妯℃嫙鍒锋柊鏁版嵁
+    setTimeout(() => {
       this.setData({
         isRefreshing: false
       });
-    }
+    }, 1000);
   },
 
   /**
@@ -304,5 +109,15 @@
    */
   onShareAppMessage: function () {
 
+  },
+
+  /**
+   * 瀵艰埅鍒拌疆鐏岀粍璇︽儏椤甸潰
+   */
+  navigateToGroupDetail: function (e) {
+    const { projectName, groupName, groupId, status } = e.currentTarget.dataset;
+    wx.navigateTo({
+      url: `/pages/groupDetail/groupDetail?projectName=${projectName}&groupName=${groupName}&groupId=${groupId}&status=${status}`
+    });
   }
 }) 
\ No newline at end of file

--
Gitblit v1.8.0