xiaohaizhao 2 месяцев назад
Родитель
Сommit
97ecc92de8

+ 184 - 1
CRM/order/detail.js

@@ -23,7 +23,11 @@ Page({
         model: "#Yl_Attachment"
       }],
     tabsActive: 0,
-    currentComponent: "OrderDetails"
+    currentComponent: "OrderDetails",
+    tabbarList: [],
+    showRefundModal: false,
+    refundReason: '',
+    showDeleteConfirm: false
   },
   onLoad(options) {
     if (options.id) {
@@ -84,9 +88,188 @@ Page({
         this.setData({
           detail: formattedData
         });
+        // 生成操作按钮列表
+        this.generateTabbarList(orderData);
         // 加载商品明细
         this.partialRenewal();
       }
     })
+  },
+  // 生成操作按钮列表
+  generateTabbarList(orderData) {
+    const tabbarList = [];
+    
+    // 退单按钮:所有未退单的订单都可以退单
+    if (orderData.status !== '已退单' && orderData.status !== '已关闭' && orderData.status !== '已取消') {
+      tabbarList.push({
+        icon: "icon-tabxiangxixinxi1",
+        label: "退单"
+      });
+    }
+    
+    // 删除按钮:未出货、未安装的订单可删除
+    if (orderData.status === '待出库') {
+      tabbarList.push({
+        icon: "icon-tabxiangxixinxi1",
+        label: "删除"
+      });
+    }
+    
+    this.setData({
+      tabbarList: tabbarList
+    });
+  },
+  // 底部按钮点击事件
+  tabbarOnClick(e) {
+    switch (e.detail.label) {
+      case '退单':
+        // 显示退单原因模态框
+        this.setData({
+          showRefundModal: true,
+          refundReason: ''
+        });
+        break;
+      case '删除':
+        // 显示删除确认弹窗
+        this.setData({
+          showDeleteConfirm: true
+        });
+        break;
+      default:
+        break;
+    }
+  },
+  // 处理退单原因输入
+  onRefundReasonInput(e) {
+    this.setData({
+      refundReason: e.detail.value
+    });
+  },
+  // 确认退单
+  confirmRefund() {
+    const { refundReason, sa_custorderid } = this.data;
+    
+    // 验证退单原因是否为空
+    if (!refundReason) {
+      wx.showToast({
+        title: '请输入退单原因',
+        icon: 'none'
+      });
+      return;
+    }
+    
+    // 构建请求参数
+    const content = {
+      sa_custorderid: sa_custorderid,
+      voidreason: refundReason
+    };
+    
+    // 调用退单接口
+    _Http.basic({
+      id: "2026031416194201",
+      content
+    }).then(res => {
+      console.log('退单结果:', res);
+      
+      // 关闭模态框
+      this.setData({
+        showRefundModal: false,
+        refundReason: ''
+      });
+      
+      if (res.code === 1) {
+        // 显示成功提示
+        wx.showToast({
+          title: '退单成功',
+          icon: 'none'
+        });
+        
+        // 刷新详情页
+        this.getDetail();
+      } else {
+        wx.showToast({
+          title: res.msg || '退单失败',
+          icon: 'none'
+        });
+      }
+    }).catch(err => {
+      console.error('退单失败:', err);
+      
+      // 关闭模态框
+      this.setData({
+        showRefundModal: false,
+        refundReason: ''
+      });
+      
+      wx.showToast({
+        title: '网络错误',
+        icon: 'none'
+      });
+    });
+  },
+  // 取消退单
+  cancelRefund() {
+    this.setData({
+      showRefundModal: false,
+      refundReason: ''
+    });
+  },
+  // 确认删除
+  confirmDelete() {
+    const { sa_custorderid } = this.data;
+    
+    // 构建请求参数
+    const content = {
+      sa_custorderid: sa_custorderid
+    };
+    
+    // 调用删除接口
+    _Http.basic({
+      id: "2026031414454901",
+      content
+    }).then(res => {
+      console.log('删除结果:', res);
+      
+      // 关闭确认弹窗
+      this.setData({
+        showDeleteConfirm: false
+      });
+      
+      if (res.code === 1) {
+        // 显示成功提示
+        wx.showToast({
+          title: '删除成功',
+          icon: 'none'
+        });
+        
+        // 跳转到订单列表页面
+        wx.navigateBack({
+          delta: 1
+        });
+      } else {
+        wx.showToast({
+          title: res.msg || '删除失败',
+          icon: 'none'
+        });
+      }
+    }).catch(err => {
+      console.error('删除失败:', err);
+      
+      // 关闭确认弹窗
+      this.setData({
+        showDeleteConfirm: false
+      });
+      
+      wx.showToast({
+        title: '网络错误',
+        icon: 'none'
+      });
+    });
+  },
+  // 取消删除
+  cancelDelete() {
+    this.setData({
+      showDeleteConfirm: false
+    });
   }
 });

+ 4 - 0
CRM/order/detail.scss

@@ -7,6 +7,10 @@
     color: #ff0000;
   }
 
+  .text-green {
+    color: #52C41A;
+  }
+
   .top {
     display: flex;
     justify-content: space-between;

+ 22 - 1
CRM/order/detail.wxml

@@ -16,7 +16,10 @@
     <view class="row">
       <view class="exp">门店:{{detail.storename || '--'}}</view>
       <view class="exp">订单数量:{{detail.qty || '--'}}</view>
-
+    </view>
+    <view class="row">
+      <view class="exp">付款状态:<text class="{{detail.ispaid == 1 ? 'text-green' : 'text-red'}}">{{detail.ispaid == 1 ? '已收款' : '未收款'}}</text></view>
+      <view class="exp"></view>
     </view>
     <view class="row">
       <view class="exp">订单金额:{{detail.showAmount || '--'}}</view>
@@ -49,6 +52,24 @@
 
 <view style="height: 130rpx;" />
 
+<Yl_Tabbar wx:if="{{tabbarList.length}}" list='{{tabbarList}}' bind:callback="tabbarOnClick" />
+
+<!-- 退单原因模态框 -->
+<van-dialog show="{{ showRefundModal }}" title="填写退单原因" show-cancel-button bind:confirm="confirmRefund" bind:cancel="cancelRefund" confirm-button-color="#385CDF" use-slot>
+  <textarea class="textarea" value="{{ refundReason }}" placeholder="请输入退单原因" bind:input="onRefundReasonInput" placeholder-style="color: #999; font-size: 26rpx;" />
+</van-dialog>
+
+<!-- 删除确认弹窗 -->
+<van-dialog
+  show="{{ showDeleteConfirm }}"
+  title="确认删除"
+  message="确定要删除此订单吗?"
+  show-cancel-button
+  bind:confirm="confirmDelete"
+  bind:cancel="cancelDelete"
+  confirm-button-color="#385CDF"
+/>
+
 <wxs module="set">
   module.exports = {
     color: function (statu) {

+ 4 - 0
CRM/order/index.scss

@@ -6,6 +6,10 @@
     color: #ff0000;
   }
 
+  .text-green {
+    color: #52C41A;
+  }
+
   .item {
     background-color: #fff;
     border-radius: 12rpx;

+ 1 - 1
CRM/order/index.wxml

@@ -44,7 +44,7 @@
             已收款金额:{{item.showPayAmount || '--'}}
           </view>
           <view class="exp">
-            付款状态:<text class="{{item.ispaid == 1 ? '' : 'text-red'}}">{{item.ispaid == 1 ? '已收款' : '未收款'}}</text>
+            付款状态:<text class="{{item.ispaid == 1 ? 'text-green' : 'text-red'}}">{{item.ispaid == 1 ? '已收款' : '未收款'}}</text>
           </view>
         </view>
         <view class="row">

+ 297 - 2
CRM/order/modules/orderDetails/index.js

@@ -38,13 +38,17 @@ Component({
       content.sa_custorderid = id || this.data.orderId || this.data.sa_custorderid;
       if (init) {
         content.pageNumber = 1;
-        this.setData({ loading: true });
+        this.setData({
+          loading: true
+        });
       }
       _Http.basic({
         "id": "2026031414243401",
         content
       }).then(res => {
-        this.setData({ loading: false });
+        this.setData({
+          loading: false
+        });
         console.log("订单明细列表", res)
         if (res.code != 1) return wx.showToast({
           title: res.msg,
@@ -68,6 +72,297 @@ Component({
           "sa_custorderid": content.sa_custorderid
         })
       })
+    },
+    // 打开添加商品面板
+    addProduct() {
+      // 直接跳转到产品选择页面
+      wx.navigateTo({
+        url: `/CRM/customer/modules/orderCreate/productSelect/index?params=${JSON.stringify({
+          "id": "2026031312441901",
+          "content": {
+            "pageNumber": 1,
+            "pageSize": 20,
+            "where": {
+              "tablefilter": {
+                "itemname": null,
+                "itemno": null,
+                "model": null,
+                "guid_price": null,
+                "guid_price_cus": null,
+                "packageqty": null
+              }
+            }
+          }
+        })}&butText=添加商品`
+      });
+      // 设置全局回调函数
+      getApp().globalData.handleSelect = this.handleSelect.bind(this);
+    },
+    // 处理选择商品回调
+    handleSelect(detail) {
+      if (detail && detail.list) {
+        const orderId = this.data.sa_custorderid;
+        if (!orderId) {
+          wx.showToast({
+            title: '订单ID不存在',
+            icon: 'none'
+          });
+          return;
+        }
+
+        // 显示加载提示
+        wx.showLoading({
+          title: '正在添加商品...',
+          mask: true
+        });
+
+        // 准备绑定操作
+        const promises = detail.list.map(item => {
+          return new Promise((resolve, reject) => {
+            // 处理价格字段,去除格式化符号
+            const priceStr = item.guid_price_cus || item.price || "0";
+            const price = parseFloat(priceStr.toString().replace(/[¥,]/g, '')) || 0;
+            const qty = parseInt(item.qty) || 1;
+            const amount = parseFloat((price * qty * 1).toFixed(2));
+
+            // 直接调用绑定商品接口
+            _Http.basic({
+              "id": "2026031415462301", // 绑定商品接口ID
+              content: {
+                sa_custorderid: orderId,
+                sa_custorderitemsid: 0,
+                sys_enterprise_itemid: item.sys_enterprise_itemid || item.itemid,
+                qty: qty,
+                oldprice: price,
+                discountrate: 1,
+                price: price,
+                amount: amount,
+                remarks: item.remarks || ""
+              }
+            }).then(res => {
+              if (res.code != 1) {
+                console.error("绑定商品失败", res);
+              }
+              resolve(res);
+            }).catch(err => {
+              console.error("绑定商品失败", err);
+              resolve(null); // 即使失败也继续处理
+            });
+          });
+        });
+
+        // 使用Promise.all处理所有绑定操作
+        Promise.all(promises).then(() => {
+          // 隐藏加载提示
+          wx.hideLoading();
+
+          // 刷新商品列表
+          this.getList(orderId, true);
+
+          // 显示成功提示
+          setTimeout(() => {
+            wx.showToast({
+              title: '商品添加成功',
+              icon: 'none'
+            });
+          });
+
+          // 返回页面
+          wx.navigateBack();
+        }).catch(() => {
+          // 隐藏加载提示
+          wx.hideLoading();
+
+          // 刷新商品列表
+          this.getList(orderId, true);
+
+          // 显示成功提示
+          setTimeout(() => {
+            wx.showToast({
+              title: '商品添加成功',
+              icon: 'none'
+            });
+          });
+
+          // 返回页面
+          wx.navigateBack();
+        });
+      }
+    },
+    // 处理字段编辑
+    onFieldBlur(e) {
+      const index = e.currentTarget.dataset.index;
+      const field = e.currentTarget.dataset.field;
+      const value = e.detail.value;
+
+      const list = [...this.data.list];
+      const item = list[index];
+
+      // 获取原价,默认为当前价格
+      const originalPrice = item.oldprice || item.price || 0;
+
+      // 处理不同字段的编辑
+      switch (field) {
+        case 'price':
+          item.price = parseFloat(value) || 0;
+          // 根据原价和新单价计算折扣
+          if (originalPrice > 0) {
+            item.discountrate = parseFloat((item.price / originalPrice).toFixed(4));
+          }
+          break;
+        case 'discountrate':
+          // 确保折扣值有效,默认为1(100%)
+          let discount = parseFloat(value) || 1;
+          // 折扣不能小于0
+          discount = Math.max(0, discount);
+          item.discountrate = discount;
+          // 根据原价和新折扣计算单价
+          item.price = parseFloat((originalPrice * discount).toFixed(2));
+          break;
+        case 'qty':
+          let qty = parseInt(value) || 1;
+          // 数量不能为0
+          qty = Math.max(1, qty);
+          item.qty = qty;
+          break;
+        case 'amount':
+          // 根据新金额计算单价
+          const newAmount = parseFloat(value) || 0;
+          item.amount = newAmount;
+          if (item.qty > 0) {
+            item.price = parseFloat((newAmount / item.qty).toFixed(2));
+            // 根据原价和新单价计算折扣
+            if (originalPrice > 0) {
+              item.discountrate = parseFloat((item.price / originalPrice).toFixed(4));
+            }
+          }
+          break;
+        case 'remarks':
+          item.remarks = value;
+          break;
+      }
+
+      // 重新计算金额,保留两位小数
+      item.amount = parseFloat((item.price * item.qty).toFixed(2));
+
+      // 立即更新页面显示
+      this.setData({
+        list
+      });
+
+      // 调用接口更新商品信息
+      this.updateProduct(item);
+    },
+    // 更新商品信息
+    updateProduct(item) {
+      const orderId = this.data.sa_custorderid;
+      if (!orderId || !item.sa_custorderitemsid) return;
+
+      // 显示加载提示
+      wx.showLoading({
+        title: '正在更新商品...',
+        mask: true
+      });
+
+      // 调用绑定商品接口(用于更新)
+      _Http.basic({
+        "id": "2026031415462301", // 绑定商品接口ID
+        content: {
+          sa_custorderid: orderId,
+          sa_custorderitemsid: item.sa_custorderitemsid,
+          sys_enterprise_itemid: item.sys_enterprise_itemid || item.itemid,
+          qty: item.qty,
+          oldprice: item.oldprice || item.price,
+          discountrate: item.discountrate,
+          price: item.price,
+          amount: item.amount,
+          remarks: item.remarks || ""
+        }
+      }).then(res => {
+        // 隐藏加载提示
+        wx.hideLoading();
+        
+        if (res.code === 1) {
+          // 显示成功提示
+          wx.showToast({
+            title: '更新商品成功',
+            icon: 'none'
+          });
+          // 刷新商品列表
+          this.getList(orderId, true);
+        } else {
+          console.error("更新商品失败", res);
+          // 显示失败提示
+          wx.showToast({
+            title: '更新商品失败',
+            icon: 'none'
+          });
+        }
+      }).catch(err => {
+        // 隐藏加载提示
+        wx.hideLoading();
+        
+        console.error("更新商品失败", err);
+        // 显示失败提示
+        wx.showToast({
+          title: '网络错误',
+          icon: 'none'
+        });
+      });
+    },
+    // 删除商品
+    deleteProduct(e) {
+      const index = e.currentTarget.dataset.index;
+      const item = this.data.list[index];
+
+      if (!item.sa_custorderitemsid) {
+        wx.showToast({
+          title: '商品ID不存在',
+          icon: 'none'
+        });
+        return;
+      }
+
+      wx.showModal({
+        title: '提示',
+        content: '确定要删除这个商品吗?',
+        confirmText: '确定',
+        cancelText: '取消',
+        success: (res) => {
+          if (res.confirm) {
+            // 调用删除接口
+            _Http.basic({
+              "id": "2026031416083401", // 删除产品明细接口ID
+              content: {
+                sa_custorderid: item.sa_custorderid,
+                sa_custorderitemsid: item.sa_custorderitemsid
+              }
+            }).then(res => {
+              console.log('删除商品结果:', res);
+              if (res.code === 1) {
+                // 显示成功提示
+                wx.showToast({
+                  title: '删除成功',
+                  icon: 'none'
+                });
+                // 刷新商品列表
+                this.getList(this.data.sa_custorderid, true);
+              } else {
+                wx.showToast({
+                  title: res.msg || '删除失败',
+                  icon: 'none'
+                });
+              }
+            }).catch(err => {
+              console.error('删除商品失败:', err);
+              wx.showToast({
+                title: '网络错误',
+                icon: 'none'
+              });
+            });
+          }
+        }
+      });
     }
   }
 })

+ 170 - 6
CRM/order/modules/orderDetails/index.scss

@@ -1,23 +1,93 @@
+.head {
+  display: flex;
+  align-items: center;
+  width: 100vw;
+  height: 120rpx;
+  padding: 0 20rpx 0 30rpx;
+  box-sizing: border-box;
+
+  .count {
+      font-size: 28rpx;
+      font-family: PingFang SC-Regular, PingFang SC;
+      color: #333333;
+  }
+
+  .expand {
+      flex: 1;
+      display: flex;
+      justify-content: flex-end;
+
+      .but {
+          display: flex;
+          align-items: center;
+          justify-content: center;
+          width: 80rpx;
+          height: 80rpx;
+          background: #FFFFFF;
+          border-radius: 8rpx;
+          border: 2rpx solid #CCCCCC;
+          margin-left: 20rpx;
+          color: #666666;
+      }
+  }
+}
+
+
 .order-details {
-  background-color: #f5f5f5;
+  background-color: #F4F5F7;
   padding: 20rpx;
+  margin-top: -20rpx;
+
+  .add-button {
+    display: flex;
+    align-items: center;
+    justify-content: center;
+    background-color: #fff;
+    border: 2rpx dashed #d9d9d9;
+    border-radius: 8rpx;
+    padding: 40rpx 0;
+    margin-bottom: 20rpx;
+    color: #3874F6;
+    font-size: 28rpx;
+    cursor: pointer;
+    transition: all 0.3s ease;
+
+    &:hover {
+      border-color: #3874F6;
+      background-color: #f0f7ff;
+    }
+
+    van-icon {
+      margin-right: 10rpx;
+    }
+  }
 
   .text-red {
     color: #ff0000;
   }
 
   .card-item {
-    background-color: #fff;
-    border-radius: 12rpx;
-    padding: 24rpx;
     margin-bottom: 20rpx;
+    background-color: #fff;
+    border-radius: 8rpx;
+    box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.05);
+    overflow: hidden;
 
     .card-header {
-      font-size: 32rpx;
+      display: flex;
+      justify-content: space-between;
+      align-items: center;
+      padding: 20rpx;
+      background-color: #e8e8e8;
+      border-bottom: 1rpx solid #d9d9d9;
+      font-size: 30rpx;
+      font-weight: bold;
+      color: #333;
+      flex: 1;
     }
 
     .exp {
-      font-size: 26rpx;
+      font-size: 24rpx;
       color: #666;
       line-height: 1.5;
       margin-top: 8rpx;
@@ -26,6 +96,100 @@
     .exp.full-width {
       width: 100%;
     }
+
+    .product-body {
+      padding: 20rpx;
+    }
+
+    .product-desc {
+      display: flex;
+      flex-wrap: wrap;
+      gap: 20rpx;
+      font-size: 24rpx;
+      color: #666;
+      margin-bottom: 20rpx;
+    }
+
+    .product-edit {
+      display: flex;
+      flex-wrap: wrap;
+      gap: 20rpx;
+      margin-bottom: 20rpx;
+    }
+
+    .edit-item {
+      display: flex;
+      align-items: center;
+      flex: 1;
+      min-width: 45%;
+
+      .label {
+        font-size: 24rpx;
+        color: #666;
+        margin-right: 10rpx;
+        white-space: nowrap;
+      }
+
+      .input {
+        flex: 1;
+        height: 60rpx;
+        padding: 0 10rpx;
+        border: 1rpx solid #e8e8e8;
+        border-radius: 4rpx;
+        font-size: 24rpx;
+        color: #333;
+        background-color: #f9f9f9;
+        max-width: 100%;
+        box-sizing: border-box;
+      }
+    }
+
+    .product-remarks {
+      display: flex;
+      align-items: flex-start;
+      gap: 10rpx;
+      width: 100%;
+      box-sizing: border-box;
+      margin-top: 10rpx;
+
+      .label {
+        font-size: 24rpx;
+        color: #666;
+        margin-top: 10rpx;
+        white-space: nowrap;
+      }
+
+      .textarea {
+        flex: 1;
+        padding: 20rpx;
+        border: 1rpx solid #e8e8e8;
+        border-radius: 4rpx;
+        font-size: 24rpx;
+        color: #333;
+        background-color: #f9f9f9;
+        max-width: 100%;
+        box-sizing: border-box;
+        resize: none;
+        min-height: 120rpx;
+      }
+    }
+
+    .card-actions {
+      margin-top: 16rpx;
+      display: flex;
+      justify-content: flex-end;
+      padding: 0 20rpx 20rpx;
+
+      van-icon {
+        font-size: 32rpx;
+        color: #999;
+        cursor: pointer;
+
+        &:hover {
+          color: #ff4d4f;
+        }
+      }
+    }
   }
 
   .loading {

+ 44 - 11
CRM/order/modules/orderDetails/index.wxml

@@ -1,18 +1,51 @@
+<view class="head">
+  <view class="count">产品明细</view>
+  <view class="expand">
+    <navigator url="#" class="but" bindtap="addProduct">
+      <van-icon name="plus" />
+    </navigator>
+  </view>
+</view>
+
 <view class="order-details">
   <view class="card-item" wx:for="{{list}}" wx:key="index">
     <view class="card-header">
-      商品编码:{{item.itemno || '--'}}
+      <view class="product-name">商品编码:{{item.itemno || '--'}}</view>
+      <view class="product-actions">
+        <van-icon name="delete" bindtap="deleteProduct" data-index="{{index}}" />
+      </view>
+    </view>
+    <view class="product-body">
+      <view class="product-desc">
+        <text>商品名称:{{item.itemname || '--'}}</text>
+        <text>商品型号:{{item.model || '--'}}</text>
+        <text>单位:{{item.unitname || '--'}}</text>
+        <text>已出库数量:{{item.outqty || '--'}}</text>
+        <text>原价:{{item.oldprice || item.price || 0}}元</text>
+      </view>
+      <view class="product-edit">
+        <view class="edit-item">
+          <view class="label">数量:</view>
+          <input class="input" type="digit" value="{{item.qty}}" data-index="{{index}}" data-field="qty" bindblur="onFieldBlur" />
+        </view>
+        <view class="edit-item">
+          <view class="label">折扣:</view>
+          <input class="input" type="digit" value="{{item.discountrate || 1}}" data-index="{{index}}" data-field="discountrate" bindblur="onFieldBlur" />
+        </view>
+        <view class="edit-item">
+          <view class="label">单价:</view>
+          <input class="input" type="digit" value="{{item.price || 0}}" data-index="{{index}}" data-field="price" bindblur="onFieldBlur" />
+        </view>
+        <view class="edit-item">
+          <view class="label">金额:</view>
+          <input class="input" type="digit" value="{{(item.price || 0) * (item.qty || 0)}}" data-index="{{index}}" data-field="amount" bindblur="onFieldBlur" />
+        </view>
+      </view>
+      <view class="product-remarks">
+        <view class="label">备注:</view>
+        <textarea class="textarea" placeholder="请输入备注" value="{{item.remarks || ''}}" data-index="{{index}}" data-field="remarks" bindblur="onFieldBlur" auto-height />
+      </view>
     </view>
-    <view class="exp">商品名称:{{item.itemname || '--'}}</view>
-    <view class="exp">商品型号:{{item.model || '--'}}</view>
-    <view class="exp">单位:{{item.unitname || '--'}}</view>
-    <view class="exp">数量:{{item.qty || '--'}}</view>
-    <view class="exp">折扣:{{item.discountrate || '--'}}</view>
-    <view class="exp">单价:{{item.showPrice || '--'}}</view>
-    <view class="exp">金额:{{item.showAmount || '--'}}</view>
-    <view class="exp">已出库数量:{{item.outqty || '--'}}</view>
-    <view class="exp full-width">备注:{{item.remarks || '--'}}</view>
-    <view class="exp full-width">序列号:{{item.sku || '--'}}</view>
   </view>
 
   <view wx:if="{{loading}}" class="loading">

+ 9 - 2
project.private.config.json

@@ -24,12 +24,19 @@
   "condition": {
     "miniprogram": {
       "list": [
+        {
+          "name": "CRM/order/detail",
+          "pathName": "CRM/order/detail",
+          "query": "id=2271713",
+          "scene": null,
+          "launchMode": "default"
+        },
         {
           "name": "CRM/lead/detail",
           "pathName": "CRM/lead/detail",
           "query": "id=424",
-          "scene": null,
-          "launchMode": "default"
+          "launchMode": "default",
+          "scene": null
         },
         {
           "name": "CRM/customer/detail",