xiaohaizhao 2 miesięcy temu
rodzic
commit
d817fba18e

+ 7 - 0
CRM/customer/detail.js

@@ -55,6 +55,13 @@ Page({
           label: "开单",
           label: "开单",
           icon: "icon-tabgenjinjilu"
           icon: "icon-tabgenjinjilu"
         }]
         }]
+        // 只有意向或成交状态的客户可以操作跟进
+        if (res.data[0].status == "意向" || res.data[0].status == "成交") {
+          tabbarList.push({
+            label: "新建跟进",
+            icon: "icon-tabgenjinjilu"
+          })
+        }
         // 意向客户可无效
         // 意向客户可无效
         if (res.data[0].status == "意向") {
         if (res.data[0].status == "意向") {
           tabbarList.push({
           tabbarList.push({

+ 1 - 1
CRM/customer/detail.wxml

@@ -43,7 +43,7 @@
 
 
 <view style="height: 20rpx;" />
 <view style="height: 20rpx;" />
 <Yl_FunTabs list='{{tabsList}}' active='{{tabsActive}}' bind:onChenge="tabsChange">
 <Yl_FunTabs list='{{tabsList}}' active='{{tabsActive}}' bind:onChenge="tabsChange">
-  <FollowRecord slot='跟进记录' id='FollowRecord' customer-id="{{detail.sa_customersid}}" />
+  <FollowRecord slot='跟进记录' id='FollowRecord' customer-id="{{detail.sa_customersid}}" customer-status="{{detail.status}}" />
   <Order slot='订单' id='Order' customer-id="{{detail.sa_customersid}}" />
   <Order slot='订单' id='Order' customer-id="{{detail.sa_customersid}}" />
   <WorkOrder slot='工单' id='WorkOrder' customer-id="{{detail.sa_customersid}}" />
   <WorkOrder slot='工单' id='WorkOrder' customer-id="{{detail.sa_customersid}}" />
   <WarrantyCard slot='保修卡' id='WarrantyCard' customer-id="{{detail.sa_customersid}}" />
   <WarrantyCard slot='保修卡' id='WarrantyCard' customer-id="{{detail.sa_customersid}}" />

+ 21 - 3
CRM/customer/modules/followRecord/index.js

@@ -1,7 +1,16 @@
 const _Http = getApp().globalData.http;
 const _Http = getApp().globalData.http;
 
 
 Component({
 Component({
-  properties: {},
+  properties: {
+    customerId: {
+      type: String,
+      value: ''
+    },
+    customerStatus: {
+      type: String,
+      value: ''
+    }
+  },
   data: {
   data: {
     "id": "20220930121501",
     "id": "20220930121501",
     content: {
     content: {
@@ -15,7 +24,7 @@ Component({
   methods: {
   methods: {
     getList(id, init) {
     getList(id, init) {
       let content = this.data.content;
       let content = this.data.content;
-      content.sa_customersid = id || this.data.sa_customersid;
+      content.sa_customersid = id || this.data.customerId || this.data.sa_customersid;
       content.ownerid = content.sa_customersid;
       content.ownerid = content.sa_customersid;
       if (init) content.pageNumber = 1;
       if (init) content.pageNumber = 1;
       _Http.basic({
       _Http.basic({
@@ -38,8 +47,17 @@ Component({
       })
       })
     },
     },
     add() {
     add() {
+      const { customerStatus, sa_customersid } = this.data;
+      // 只有意向或成交状态的客户可以操作跟进
+      if (customerStatus !== '意向' && customerStatus !== '成交') {
+        wx.showToast({
+          title: '只有意向或成交状态的客户可以操作跟进',
+          icon: 'none'
+        });
+        return;
+      }
       wx.navigateTo({
       wx.navigateTo({
-        url: `/CRM/customer/modules/followRecord/create?ownerid=${this.data.sa_customersid}`
+        url: `/CRM/customer/modules/followRecord/create?ownerid=${sa_customersid}`
       });
       });
     }
     }
   }
   }

+ 1 - 1
CRM/customer/modules/followRecord/index.wxml

@@ -1,6 +1,6 @@
 <view class="head">
 <view class="head">
   <view class="count">跟进记录</view>
   <view class="count">跟进记录</view>
-  <view class="expand">
+  <view class="expand" wx:if="{{customerStatus == '意向' || customerStatus == '成交'}}">
     <navigator url="#" class="but" bindtap="add">
     <navigator url="#" class="but" bindtap="add">
       <van-icon name="plus" />
       <van-icon name="plus" />
     </navigator>
     </navigator>

+ 0 - 3
CRM/customer/modules/orderCreate/create.wxml

@@ -26,9 +26,6 @@
             <text>品号:{{item.itemno || '--'}}</text>
             <text>品号:{{item.itemno || '--'}}</text>
             <text>型号:{{item.model || '--'}}</text>
             <text>型号:{{item.model || '--'}}</text>
           </view>
           </view>
-          <view class="product-desc">
-            <text>原价:{{item.originalPrice || item.price}}元</text>
-          </view>
           <view class="product-edit">
           <view class="product-edit">
             <view class="edit-item">
             <view class="edit-item">
               <view class="label">单价:</view>
               <view class="label">单价:</view>

+ 15 - 20
CRM/order/modules/orderDetails/index.js

@@ -60,7 +60,7 @@ Component({
         })
         })
         // 格式化金额数据
         // 格式化金额数据
         const formattedData = res.data.map(item => {
         const formattedData = res.data.map(item => {
-          const amount = (item.price || 0) * (item.qty || 0);
+          const amount = (item.price || 0) * (item.discountrate || 1) * (item.qty || 0);
           return {
           return {
             ...item,
             ...item,
             showPrice: CNY(item.price || 0),
             showPrice: CNY(item.price || 0),
@@ -229,17 +229,12 @@ Component({
       const list = [...this.data.list];
       const list = [...this.data.list];
       const item = list[index];
       const item = list[index];
 
 
-      // 获取原价,默认为当前价格
-      const originalPrice = item.oldprice || item.price || 0;
-
       // 处理不同字段的编辑
       // 处理不同字段的编辑
       switch (field) {
       switch (field) {
         case 'price':
         case 'price':
           item.price = parseFloat(value) || 0;
           item.price = parseFloat(value) || 0;
-          // 根据原价和新单价计算折扣
-          if (originalPrice > 0) {
-            item.discountrate = parseFloat((item.price / originalPrice).toFixed(4));
-          }
+          // 重新计算金额
+          item.amount = parseFloat((item.price * (item.discountrate || 1) * item.qty).toFixed(2));
           break;
           break;
         case 'discountrate':
         case 'discountrate':
           // 确保折扣值有效,默认为1(100%)
           // 确保折扣值有效,默认为1(100%)
@@ -247,25 +242,23 @@ Component({
           // 折扣不能小于0
           // 折扣不能小于0
           discount = Math.max(0, discount);
           discount = Math.max(0, discount);
           item.discountrate = discount;
           item.discountrate = discount;
-          // 根据原价和新折扣计算单价
-          item.price = parseFloat((originalPrice * discount).toFixed(2));
+          // 重新计算金额
+          item.amount = parseFloat((item.price * discount * item.qty).toFixed(2));
           break;
           break;
         case 'qty':
         case 'qty':
           let qty = parseInt(value) || 1;
           let qty = parseInt(value) || 1;
           // 数量不能为0
           // 数量不能为0
           qty = Math.max(1, qty);
           qty = Math.max(1, qty);
           item.qty = qty;
           item.qty = qty;
+          // 重新计算金额
+          item.amount = parseFloat((item.price * (item.discountrate || 1) * qty).toFixed(2));
           break;
           break;
         case 'amount':
         case 'amount':
           // 根据新金额计算单价
           // 根据新金额计算单价
           const newAmount = parseFloat(value) || 0;
           const newAmount = parseFloat(value) || 0;
           item.amount = newAmount;
           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));
-            }
+          if (item.qty > 0 && (item.discountrate || 1) > 0) {
+            item.price = parseFloat((newAmount / item.qty / (item.discountrate || 1)).toFixed(2));
           }
           }
           break;
           break;
         case 'remarks':
         case 'remarks':
@@ -273,8 +266,10 @@ Component({
           break;
           break;
       }
       }
 
 
-      // 重新计算金额,保留两位小数
-      item.amount = parseFloat((item.price * item.qty).toFixed(2));
+      // 确保 discountrate 存在
+      if (item.discountrate === undefined || item.discountrate === null) {
+        item.discountrate = 1;
+      }
 
 
       // 立即更新页面显示
       // 立即更新页面显示
       this.setData({
       this.setData({
@@ -303,8 +298,8 @@ Component({
           sa_custorderitemsid: item.sa_custorderitemsid,
           sa_custorderitemsid: item.sa_custorderitemsid,
           sys_enterprise_itemid: item.sys_enterprise_itemid || item.itemid,
           sys_enterprise_itemid: item.sys_enterprise_itemid || item.itemid,
           qty: item.qty,
           qty: item.qty,
-          oldprice: item.oldprice || item.price,
-          discountrate: item.discountrate,
+          oldprice: item.price, // 使用当前价格作为原价
+          discountrate: item.discountrate || 1,
           price: item.price,
           price: item.price,
           amount: item.amount,
           amount: item.amount,
           remarks: item.remarks || ""
           remarks: item.remarks || ""

+ 0 - 1
CRM/order/modules/orderDetails/index.wxml

@@ -21,7 +21,6 @@
         <text>商品型号:{{item.model || '--'}}</text>
         <text>商品型号:{{item.model || '--'}}</text>
         <text>单位:{{item.unitname || '--'}}</text>
         <text>单位:{{item.unitname || '--'}}</text>
         <text>已出库数量:{{item.outqty || '--'}}</text>
         <text>已出库数量:{{item.outqty || '--'}}</text>
-        <text>原价:{{item.oldprice || item.price || 0}}元</text>
       </view>
       </view>
       <view class="product-edit">
       <view class="product-edit">
         <view class="edit-item">
         <view class="edit-item">