添加删除功能到灌溉计划页面,用户可通过点击删除按钮确认删除相应的轮灌计划;更新样式以增强用户体验。
| New file | 
|  |  |  | 
|---|
|  |  |  | <?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> | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | }, | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 点击删除按钮 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | 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({ | 
|---|
|  |  |  | 
|---|
|  |  |  | <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> | 
|---|
|  |  |  | 
|---|
|  |  |  | background-color: #1890FF !important; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | .delete-button { | 
|---|
|  |  |  | background-color: #ff4d4f !important; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | .stop-button { | 
|---|
|  |  |  | background-color: #ff4d4f !important; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | opacity: 0.8 !important; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | .delete-button-hover { | 
|---|
|  |  |  | opacity: 0.8 !important; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | .stop-button-hover { | 
|---|
|  |  |  | opacity: 0.8 !important; | 
|---|
|  |  |  | } | 
|---|