xiaohaizhao 2 miesięcy temu
rodzic
commit
24497a72ca

+ 14 - 3
CRM/order/detail.js

@@ -101,16 +101,20 @@ Page({
     
     // 退单按钮:所有未退单的订单都可以退单
     if (orderData.status !== '已退单' && orderData.status !== '已关闭' && orderData.status !== '已取消') {
+      tabbarList.push({
+        icon: "icon-tabkaipiaoxinxi",
+        label: "付款"
+      });
       tabbarList.push({
         icon: "icon-tabxiangxixinxi1",
         label: "退单"
       });
     }
     
-    // 删除按钮:未出货、未安装的订单可删除
-    if (orderData.status === '待出库') {
+    // 删除按钮:未出货、未付款的订单可删除
+    if (orderData.status === '待出库' && orderData.ispaid !== 1) {
       tabbarList.push({
-        icon: "icon-tabxiangxixinxi1",
+        icon: "icon-guanlian-shanchu",
         label: "删除"
       });
     }
@@ -122,6 +126,13 @@ Page({
   // 底部按钮点击事件
   tabbarOnClick(e) {
     switch (e.detail.label) {
+      case '付款':
+        // 使用付款组件中的新建功能
+        const paymentRecordComponent = this.selectComponent('#PaymentRecord');
+        if (paymentRecordComponent) {
+          paymentRecordComponent.addPayment();
+        }
+        break;
       case '退单':
         // 显示退单原因模态框
         this.setData({

+ 30 - 0
CRM/order/detail.scss

@@ -95,4 +95,34 @@
       }
     }
   }
+}
+
+/* 退单模态框样式 */
+.refund-modal-content {
+  padding: 20rpx 30rpx;
+
+  .textarea {
+    width: 100%;
+    height: 200rpx;
+    padding: 20rpx;
+    border: 1rpx solid #e8e8e8;
+    border-radius: 8rpx;
+    font-size: 28rpx;
+    line-height: 1.5;
+    resize: none;
+    box-sizing: border-box;
+    background-color: #f9f9f9;
+
+    &:focus {
+      border-color: #385CDF;
+      background-color: #fff;
+    }
+  }
+
+  .refund-tips {
+    margin-top: 16rpx;
+    font-size: 24rpx;
+    color: #999;
+    text-align: right;
+  }
 }

+ 8 - 4
CRM/order/detail.wxml

@@ -45,8 +45,8 @@
 
 <view style="height: 20rpx;" />
 <Yl_FunTabs list='{{tabsList}}' active='{{tabsActive}}' bind:onChenge="tabsChange">
-  <OrderDetails slot='订单商品' id='OrderDetails' order-id="{{detail.sa_custorderid}}" />
-  <PaymentRecord slot='付款记录' id='PaymentRecord' order-id="{{detail.sa_custorderid}}" />
+  <OrderDetails slot='订单商品' id='OrderDetails' order-id="{{detail.sa_custorderid}}" order-status="{{detail.status}}" />
+  <PaymentRecord slot='付款记录' id='PaymentRecord' order-id="{{detail.sa_custorderid}}" order-status="{{detail.status}}" />
   <Yl_Attachment slot='附件' id='Yl_Attachment' ownertable="sa_custorder" ownerid="{{sa_custorderid}}" />
 </Yl_FunTabs>
 
@@ -55,10 +55,14 @@
 <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 show="{{ showRefundModal }}" title="填写退单原因" show-cancel-button bind:confirm="confirmRefund" bind:cancel="cancelRefund" confirm-button-color="#385CDF" cancel-button-color="#999" use-slot>
+  <view class="refund-modal-content">
+    <textarea class="textarea" value="{{ refundReason }}" placeholder="请输入退单原因" bind:input="onRefundReasonInput" placeholder-style="color: #999; font-size: 26rpx;" />
+  </view>
 </van-dialog>
 
+
+
 <!-- 删除确认弹窗 -->
 <van-dialog
   show="{{ showDeleteConfirm }}"

+ 40 - 0
CRM/order/modules/orderDetails/index.js

@@ -10,6 +10,10 @@ Component({
     orderId: {
       type: String,
       value: ''
+    },
+    orderStatus: {
+      type: String,
+      value: ''
     }
   },
   data: {
@@ -75,6 +79,15 @@ Component({
     },
     // 打开添加商品面板
     addProduct() {
+      // 已退单状态不能添加商品
+      if (this.data.orderStatus === '已退单') {
+        wx.showToast({
+          title: '已退单订单不能添加商品',
+          icon: 'none'
+        });
+        return;
+      }
+      
       // 直接跳转到产品选择页面
       wx.navigateTo({
         url: `/CRM/customer/modules/orderCreate/productSelect/index?params=${JSON.stringify({
@@ -100,6 +113,15 @@ Component({
     },
     // 处理选择商品回调
     handleSelect(detail) {
+      // 已退单状态不能添加商品
+      if (this.data.orderStatus === '已退单') {
+        wx.showToast({
+          title: '已退单订单不能添加商品',
+          icon: 'none'
+        });
+        return;
+      }
+      
       if (detail && detail.list) {
         const orderId = this.data.sa_custorderid;
         if (!orderId) {
@@ -191,6 +213,15 @@ Component({
     },
     // 处理字段编辑
     onFieldBlur(e) {
+      // 已退单状态不能编辑商品
+      if (this.data.orderStatus === '已退单') {
+        wx.showToast({
+          title: '已退单订单不能编辑商品',
+          icon: 'none'
+        });
+        return;
+      }
+      
       const index = e.currentTarget.dataset.index;
       const field = e.currentTarget.dataset.field;
       const value = e.detail.value;
@@ -312,6 +343,15 @@ Component({
     },
     // 删除商品
     deleteProduct(e) {
+      // 已退单状态不能删除商品
+      if (this.data.orderStatus === '已退单') {
+        wx.showToast({
+          title: '已退单订单不能删除商品',
+          icon: 'none'
+        });
+        return;
+      }
+      
       const index = e.currentTarget.dataset.index;
       const item = this.data.list[index];
 

+ 7 - 7
CRM/order/modules/orderDetails/index.wxml

@@ -1,6 +1,6 @@
 <view class="head">
   <view class="count">产品明细</view>
-  <view class="expand">
+  <view class="expand" wx:if="{{orderStatus !== '已退单'}}">
     <navigator url="#" class="but" bindtap="addProduct">
       <van-icon name="plus" />
     </navigator>
@@ -11,7 +11,7 @@
   <view class="card-item" wx:for="{{list}}" wx:key="index">
     <view class="card-header">
       <view class="product-name">商品编码:{{item.itemno || '--'}}</view>
-      <view class="product-actions">
+      <view class="product-actions" wx:if="{{orderStatus !== '已退单'}}">
         <van-icon name="delete" bindtap="deleteProduct" data-index="{{index}}" />
       </view>
     </view>
@@ -26,24 +26,24 @@
       <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" />
+          <input class="input" type="digit" value="{{item.qty}}" data-index="{{index}}" data-field="qty" bindblur="onFieldBlur" disabled="{{orderStatus === '已退单'}}" />
         </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" />
+          <input class="input" type="digit" value="{{item.discountrate || 1}}" data-index="{{index}}" data-field="discountrate" bindblur="onFieldBlur" disabled="{{orderStatus === '已退单'}}" />
         </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" />
+          <input class="input" type="digit" value="{{item.price || 0}}" data-index="{{index}}" data-field="price" bindblur="onFieldBlur" disabled="{{orderStatus === '已退单'}}" />
         </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" />
+          <input class="input" type="digit" value="{{(item.price || 0) * (item.qty || 0)}}" data-index="{{index}}" data-field="amount" bindblur="onFieldBlur" disabled="{{orderStatus === '已退单'}}" />
         </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 />
+        <textarea class="textarea" placeholder="请输入备注" value="{{item.remarks || ''}}" data-index="{{index}}" data-field="remarks" bindblur="onFieldBlur" disabled="{{orderStatus === '已退单'}}" auto-height />
       </view>
     </view>
   </view>

+ 272 - 0
CRM/order/modules/paymentCreate/create.js

@@ -0,0 +1,272 @@
+const _Http = getApp().globalData.http,
+  currency = require("../../../../utils/currency"),
+  CNY = value => currency(value, {
+    symbol: "¥",
+    precision: 2
+  }).format();
+
+Page({
+  data: {
+    loading: false,
+    disabled: true,
+    showAll: false,
+    sa_custorderid: '',
+    orderInfo: {},
+    form: [{
+      label: "订单编号",
+      error: false,
+      errMsg: "",
+      type: "text",
+      value: "",
+      placeholder: "订单编号",
+      valueName: "sonum",
+      required: false,
+      checking: "base",
+      disabled: true
+    },
+    {
+      label: "客户",
+      error: false,
+      errMsg: "",
+      type: "text",
+      value: "",
+      placeholder: "客户名称",
+      valueName: "name",
+      required: false,
+      checking: "base",
+      disabled: true
+    },
+    {
+      label: "收款日期",
+      error: false,
+      errMsg: "",
+      type: "date",
+      value: "",
+      placeholder: "请选择收款日期",
+      valueName: "billdate",
+      required: true,
+      checking: "base"
+    },
+    {
+      label: "收款金额",
+      error: false,
+      errMsg: "",
+      type: "digit",
+      value: "",
+      placeholder: "请输入收款金额(正数或负数)",
+      valueName: "amount",
+      required: true,
+      checking: "base"
+    },
+    {
+      label: "收款类别",
+      error: false,
+      errMsg: "",
+      type: "radio",
+      value: "订金",
+      radioList: [{
+        id: "订金",
+        name: "订金"
+      },
+      {
+        id: "货款",
+        name: "货款"
+      },
+      {
+        id: "冲账",
+        name: "冲账"
+      },
+      {
+        id: "退款",
+        name: "退款"
+      }
+      ],
+      valueName: "typemx",
+      required: true,
+      checking: "base"
+    },
+    {
+      label: "备注",
+      error: false,
+      errMsg: "",
+      type: "textarea",
+      value: "",
+      placeholder: "请输入备注",
+      valueName: "remarks",
+      required: false,
+      checking: "base"
+    }
+    ],
+    content: {
+      sa_custorderid: 0,
+      sys_enterprise_cashbillid: 0,
+      billdate: "",
+      typemx: "",
+      amount: 0,
+      remarks: ""
+    }
+  },
+  onLoad(options) {
+    if (options.sa_custorderid) {
+      this.setData({
+        "content.sa_custorderid": options.sa_custorderid,
+        sa_custorderid: options.sa_custorderid
+      });
+      this.getOrderInfoFromPage();
+    }
+
+    // 设置默认收款日期为当天
+    const today = new Date().toISOString().split('T')[0];
+    let form = this.data.form;
+    form.forEach(item => {
+      if (item.valueName === 'billdate') {
+        item.value = today;
+        this.setData({
+          "content.billdate": today
+        });
+      }
+    });
+    this.setData({
+      form
+    });
+  },
+  // 从页面获取订单信息
+  getOrderInfoFromPage() {
+    try {
+      // 通过路由路径查找订单详情页面
+      const orderDetailPage = getCurrentPages().find(v => v.__route__ == 'CRM/order/detail');
+      if (orderDetailPage && orderDetailPage.data.detail) {
+        const orderData = orderDetailPage.data.detail;
+        this.setData({
+          orderInfo: orderData
+        });
+
+        // 更新表单数据
+        let form = this.data.form;
+        form.forEach(item => {
+          if (item.valueName === 'sonum') {
+            item.value = orderData.sonum || '';
+          }
+          if (item.valueName === 'name') {
+            item.value = orderData.name || '';
+          }
+        });
+        this.setData({
+          form
+        });
+      }
+    } catch (error) {
+      console.error("获取订单信息失败", error);
+    }
+  },
+  // 提交收款单
+  submit() {
+    this.setData({
+      loading: true
+    });
+
+    let formData = this.selectComponent("#Form").submit();
+    if (!formData) {
+      this.setData({
+        loading: false
+      });
+      return;
+    }
+
+    // 验证金额
+    const amount = parseFloat(formData.amount);
+    if (isNaN(amount) || amount === 0) {
+      wx.showToast({
+        title: '请输入有效的收款金额',
+        icon: 'none'
+      });
+      this.setData({
+        loading: false
+      });
+      return;
+    }
+
+    // 构建请求参数
+    let content = {
+      sa_custorderid: this.data.content.sa_custorderid,
+      sys_enterprise_cashbillid: 0,
+      billdate: formData.billdate,
+      typemx: formData.typemx,
+      amount: amount,
+      remarks: formData.remarks || ""
+    };
+
+    console.log("创建收款单参数", content);
+
+    // 调用创建收款单API
+    _Http.basic({
+      id: "2026032016115701",
+      content
+    }).then(res => {
+      console.log('创建收款单结果:', res);
+      this.setData({
+        loading: false
+      });
+      if (res.code === 1) {
+        // 获取订单详情页面
+        const orderDetailPage = getCurrentPages().find(v => v.__route__ == 'CRM/order/detail');
+        if (orderDetailPage) {
+          // 更新付款记录列表
+          orderDetailPage.selectComponent('#PaymentRecord').getList(content.sa_custorderid, true);
+          // 调用详情页面的获取详情方法更新付款状态
+          orderDetailPage.getDetail();
+        }
+        // 返回上一页
+        wx.navigateBack({
+          delta: 1,
+          success: () => {
+            // 显示成功提示
+            wx.showToast({
+              title: '创建收款单成功',
+              icon: 'none'
+            });
+          }
+        });
+      } else {
+        wx.showToast({
+          title: res.msg || '创建收款单失败',
+          icon: 'none'
+        });
+      }
+    }).catch(err => {
+      console.error('创建收款单失败:', err);
+
+      this.setData({
+        loading: false
+      });
+
+      wx.showToast({
+        title: '网络错误',
+        icon: 'none'
+      });
+    });
+  },
+  interrupt({
+    detail
+  }) {
+    // 处理中断逻辑
+  },
+  /* 表单必填项是否完成 */
+  onConfirm({
+    detail
+  }) {
+    this.setData({
+      disabled: detail
+    });
+  },
+  onChange(e) {
+    this.setData({
+      showAll: e.detail
+    });
+  },
+  closePage() {
+    wx.navigateBack({
+      delta: 1
+    });
+  }
+});

+ 7 - 0
CRM/order/modules/paymentCreate/create.json

@@ -0,0 +1,7 @@
+{
+  "usingComponents": {
+    "Yl_Field": "../../../../components/Yl_Field/index",
+    "Yl_Headline": "../../../../components/Yl_Headline/index",
+    "van-button": "@vant/weapp/button/index"
+  }
+}

+ 18 - 0
CRM/order/modules/paymentCreate/create.scss

@@ -0,0 +1,18 @@
+.new-footer {
+  position: fixed;
+  bottom: 0;
+  left: 0;
+  right: 0;
+  padding: 20rpx 30rpx;
+  background-color: #fff;
+  box-shadow: 0 -2rpx 10rpx rgba(0, 0, 0, 0.1);
+  z-index: 999;
+}
+
+.new-submit {
+  width: 100% !important;
+  height: 80rpx !important;
+  line-height: 80rpx !important;
+  border-radius: 8rpx !important;
+  font-size: 32rpx !important;
+}

+ 7 - 0
CRM/order/modules/paymentCreate/create.wxml

@@ -0,0 +1,7 @@
+<Yl_Headline title='创建收款单' type='switch' switchLabel='仅显示必填信息' switch='{{showAll}}' bind:callBack='onChange' />
+<Yl_Field id='Form' form='{{form}}' showAll='{{!showAll}}' bind:onConfirm='onConfirm' bind:interrupt="interrupt" />
+
+<view style="height: 150rpx;" />
+<view class="new-footer">
+  <van-button custom-class='new-submit' color='#3874F6' disabled='{{disabled || loading}}' loading='{{loading}}' bind:tap='submit'>确定</van-button>
+</view>

+ 27 - 11
CRM/order/modules/paymentRecord/index.js

@@ -10,6 +10,10 @@ Component({
     orderId: {
       type: String,
       value: ''
+    },
+    orderStatus: {
+      type: String,
+      value: ''
     }
   },
   data: {
@@ -32,17 +36,13 @@ Component({
         content.pageNumber = 1;
         this.setData({ loading: true });
       }
-      // 这里使用订单详情API,因为付款记录通常是订单的一部分
+      // 使用新的付款记录API
       _Http.basic({
-        "id": "2026031410293201",
+        "id": "2026032016050501",
         content: {
-          nocache: true,
-          pageNumber: 1,
-          pageSize: 1,
-          where: {
-            condition: `sa_custorderid = ${content.sa_custorderid}`,
-            tableid: 2484
-          }
+          sa_custorderid: content.sa_custorderid,
+          pageNumber: content.pageNumber,
+          pageSize: content.pageSize
         }
       }).then(res => {
         this.setData({ loading: false });
@@ -55,10 +55,10 @@ Component({
           // 格式化金额数据
           const formattedData = res.data.map(item => ({
             ...item,
-            showPayAmount: CNY(item.payamount || 0)
+            showPayAmount: CNY(item.amount || 0)
           }))
           this.setData({
-            list: formattedData,
+            list: init ? formattedData : this.data.list.concat(formattedData),
             "content.pageNumber": res.pageNumber + 1,
             "content.pageSize": res.pageSize,
             "content.pageTotal": res.pageTotal,
@@ -67,6 +67,22 @@ Component({
           })
         }
       })
+    },
+    /* 跳转到创建收款单页面 */
+    addPayment() {
+      // 已退单状态不能添加付款记录
+      if (this.data.orderStatus === '已退单') {
+        wx.showToast({
+          title: '已退单订单不能添加付款记录',
+          icon: 'none'
+        });
+        return;
+      }
+      
+      const sa_custorderid = this.data.orderId || this.data.sa_custorderid;
+      wx.navigateTo({
+        url: `/CRM/order/modules/paymentCreate/create?sa_custorderid=${sa_custorderid}`
+      });
     }
   }
 })

+ 4 - 1
CRM/order/modules/paymentRecord/index.json

@@ -1,4 +1,7 @@
 {
   "usingComponents": {
+    "van-icon": "@vant/weapp/icon/index",
+    "van-dialog": "@vant/weapp/dialog/index",
+    "van-picker": "@vant/weapp/picker/index"
   }
-}
+}

+ 80 - 2
CRM/order/modules/paymentRecord/index.scss

@@ -1,6 +1,41 @@
+.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;
+      }
+  }
+}
+
 .payment-record {
-  background-color: #f5f5f5;
+  background-color: #F4F5F7;
   padding: 20rpx;
+  margin-top: -20rpx;
 
   .text-red {
     color: #ff0000;
@@ -8,12 +43,16 @@
 
   .card-item {
     background-color: #fff;
-    border-radius: 12rpx;
+    border-radius: 8rpx;
+    box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.05);
     padding: 24rpx;
     margin-bottom: 20rpx;
 
     .card-header {
       font-size: 32rpx;
+      font-weight: bold;
+      color: #333;
+      margin-bottom: 16rpx;
     }
 
     .exp {
@@ -37,4 +76,43 @@
     padding: 20rpx 0;
     font-size: 24rpx;
   }
+
+  .form-item {
+    margin-bottom: 24rpx;
+    display: flex;
+    align-items: center;
+
+    .label {
+      font-size: 24rpx;
+      color: #666;
+      margin-right: 20rpx;
+      white-space: nowrap;
+      width: 100rpx;
+    }
+
+    .input {
+      flex: 1;
+      height: 60rpx;
+      padding: 0 10rpx;
+      border: 1rpx solid #e8e8e8;
+      border-radius: 4rpx;
+      font-size: 24rpx;
+      color: #333;
+      background-color: #f9f9f9;
+      box-sizing: border-box;
+    }
+
+    .textarea {
+      flex: 1;
+      padding: 20rpx;
+      border: 1rpx solid #e8e8e8;
+      border-radius: 4rpx;
+      font-size: 24rpx;
+      color: #333;
+      background-color: #f9f9f9;
+      box-sizing: border-box;
+      resize: none;
+      min-height: 120rpx;
+    }
+  }
 }

+ 14 - 4
CRM/order/modules/paymentRecord/index.wxml

@@ -1,11 +1,21 @@
+<view class="head">
+  <view class="count">付款记录</view>
+  <view class="expand" wx:if="{{orderStatus !== '已退单'}}">
+    <navigator url="#" class="but" bindtap="addPayment">
+      <van-icon name="plus" />
+    </navigator>
+  </view>
+</view>
+
 <view class="payment-record">
   <view class="card-item" wx:for="{{list}}" wx:key="index">
     <view class="card-header">
-      付款时间:{{item.paytime || '--'}}
+      收款时间:{{item.billdate || '--'}}
     </view>
-    <view class="exp">付款金额:{{item.showPayAmount || '--'}}</view>
-    <view class="exp">付款方式:{{item.paymode || '--'}}</view>
-    <view class="exp">微信支付订单:{{item.wechatpayorder || '--'}}</view>
+    <view class="exp">收款金额:{{item.showPayAmount || '--'}}</view>
+    <view class="exp">收款类型:{{item.typemx || '--'}}</view>
+    <view class="exp">收款备注:{{item.remarks || '--'}}</view>
+    <view class="exp">收款人:{{item.createby || '--'}}</view>
   </view>
 
   <view wx:if="{{loading}}" class="loading">

+ 2 - 1
app.json

@@ -127,7 +127,8 @@
         "customer/modules/followRecord/create",
         "lead/modules/followRecord/create",
         "customer/modules/orderCreate/create",
-        "customer/modules/orderCreate/productSelect/index"
+        "customer/modules/orderCreate/productSelect/index",
+        "order/modules/paymentCreate/create"
       ]
     }
   ],

+ 1 - 1
project.private.config.json

@@ -27,7 +27,7 @@
         {
           "name": "CRM/order/detail",
           "pathName": "CRM/order/detail",
-          "query": "id=2271713",
+          "query": "id=2271628",
           "scene": null,
           "launchMode": "default"
         },