From 032f821c77485c1178de18f78092ddedd25d2fb2 Mon Sep 17 00:00:00 2001
From: zuoxiao <zuoxiao>
Date: 星期三, 09 四月 2025 15:26:58 +0800
Subject: [PATCH] 添加删除功能到灌溉计划页面,用户可通过点击删除按钮确认删除相应的轮灌计划;更新样式以增强用户体验。

---
 pages/irrigation/irrigation.js   |   45 +++++++++++++++++++++++++++++++++++++++++++++
 images/delete_bt.svg             |    1 +
 pages/irrigation/irrigation.wxml |    4 ++++
 pages/irrigation/irrigation.wxss |    8 ++++++++
 4 files changed, 58 insertions(+), 0 deletions(-)

diff --git a/images/delete_bt.svg b/images/delete_bt.svg
new file mode 100644
index 0000000..faf0fc6
--- /dev/null
+++ b/images/delete_bt.svg
@@ -0,0 +1 @@
+<?xml version="1.0" encoding="UTF-8"?><svg width="24" height="24" viewBox="0 0 48 48" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M9 10V44H39V10H9Z" fill="none" stroke="#fff" stroke-width="4" stroke-linejoin="round"/><path d="M20 20V33" stroke="#fff" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"/><path d="M28 20V33" stroke="#fff" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"/><path d="M4 10H44" stroke="#fff" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"/><path d="M16 10L19.289 4H28.7771L32 10H16Z" fill="none" stroke="#fff" stroke-width="4" stroke-linejoin="round"/></svg>
\ No newline at end of file
diff --git a/pages/irrigation/irrigation.js b/pages/irrigation/irrigation.js
index 61b0f3e..e4adbc2 100644
--- a/pages/irrigation/irrigation.js
+++ b/pages/irrigation/irrigation.js
@@ -239,6 +239,51 @@
       }
     });
   },
+
+  /**
+   * 鐐瑰嚮鍒犻櫎鎸夐挳
+   */
+  onDelete: function (e) {
+    const id = e.currentTarget.dataset.id;
+    wx.showModal({
+      title: '纭鍒犻櫎',
+      content: '纭畾瑕佸垹闄よ杞亴璁″垝鍚楋紵',
+      success: (res) => {
+        if (res.confirm) {
+          // 璋冪敤鍒犻櫎鎺ュ彛
+          post({
+            url: '/wx/plan/deletePlan',
+            data: {
+              planId: id,
+              operatorId: app.globalData.clientId
+            },
+            isShowLoding: true
+          }).then(res => {
+            if (res.success) {
+              wx.showToast({
+                title: '鍒犻櫎鎴愬姛',
+                icon: 'success'
+              });
+              // 鍒锋柊鏁版嵁
+              this.loadIrrigationData();
+            } else {
+              wx.showToast({
+                title: res.msg || '鍒犻櫎澶辫触',
+                icon: 'none'
+              });
+            }
+          }).catch(err => {
+            console.error('鍒犻櫎澶辫触锛�', err);
+            wx.showToast({
+              title: '鍒犻櫎澶辫触',
+              icon: 'none'
+            });
+          });
+        }
+      }
+    });
+  },
+  
   //缁堟杞亴璁″垝
    postStop(planID){
     post({
diff --git a/pages/irrigation/irrigation.wxml b/pages/irrigation/irrigation.wxml
index 6f42faa..93bcaaf 100644
--- a/pages/irrigation/irrigation.wxml
+++ b/pages/irrigation/irrigation.wxml
@@ -63,6 +63,10 @@
             <view class="action-section" catchtap="stopPropagation" wx:if="{{item.status !== '4'}}">
               <block wx:if="{{item.status === '1'}}">
                 <view class="action-buttons">
+                  <button class="action-button delete-button" hover-class="delete-button-hover" bindtap="onDelete" data-id="{{item.id}}">
+                    <image src="/images/delete_bt.svg" mode="aspectFit"></image>
+                    <text>鍒犻櫎</text>
+                  </button>
                   <button class="action-button publish-button" hover-class="publish-button-hover" bindtap="onPublish" data-id="{{item.id}}">
                     <image src="/images/publish-icon.svg" mode="aspectFit"></image>
                     <text>鍙戝竷</text>
diff --git a/pages/irrigation/irrigation.wxss b/pages/irrigation/irrigation.wxss
index 5a4e019..2d5116d 100644
--- a/pages/irrigation/irrigation.wxss
+++ b/pages/irrigation/irrigation.wxss
@@ -257,6 +257,10 @@
   background-color: #1890FF !important;
 }
 
+.delete-button {
+  background-color: #ff4d4f !important;
+}
+
 .stop-button {
   background-color: #ff4d4f !important;
 }
@@ -319,6 +323,10 @@
   opacity: 0.8 !important;
 }
 
+.delete-button-hover {
+  opacity: 0.8 !important;
+}
+
 .stop-button-hover {
   opacity: 0.8 !important;
 }

--
Gitblit v1.8.0