xiaohaizhao hace 2 meses
padre
commit
cb6bf050db

+ 4 - 1
CRM/customer/create.js

@@ -170,6 +170,9 @@ Page({
         form
       });
       this.selectComponent("#Form").confirm()
+      wx.setNavigationBarTitle({
+        title: '编辑客户'
+      })
     } else {
       this.getCustomerSourceList();
     }
@@ -249,7 +252,7 @@ Page({
             },
           })
         }
-      }else{
+      } else {
         wx.showToast({
           title: res.msg || "创建失败",
           icon: "none"

+ 27 - 0
CRM/customer/detail.js

@@ -135,6 +135,11 @@ Page({
           url: `/CRM/customer/create?edit=true`
         });
         break;
+      case '新建跟进':
+        wx.navigateTo({
+          url: `/CRM/customer/modules/followRecord/create?ownerid=${this.data.sa_customersid}`
+        });
+        break;
       case '无效':
         // 显示无效对话框
         this.setData({
@@ -240,5 +245,27 @@ Page({
     this.setData({
       showInvalidDialog: false
     });
+  },
+  // 页面关闭事件
+  onUnload() {
+    getCurrentPages().forEach(page => {
+      if (page.__route__ == 'CRM/customer/index') {
+        let content = JSON.parse(JSON.stringify(page.data.content));
+        content.pageSize = (content.pageNumber - 1) * content.pageSize;
+        content.pageNumber = 1;
+        _Http.basic({
+          id: page.data.id,
+          content
+        }).then(res => {
+          console.log("更新列表", res);
+          if (res.code == '1') {
+            page.setData({
+              list: res.data,
+              "content.total": res.total
+            })
+          }
+        })
+      } else {}
+    })
   }
 });

+ 3 - 2
CRM/customer/index.js

@@ -2,6 +2,7 @@ const _Http = getApp().globalData.http;
 
 Page({
   data: {
+    "id": 2026030916100201,
     list: [],
     content: {
       nocache: true,
@@ -34,9 +35,9 @@ Page({
     }
     if (this.data.content.pageNumber > this.data.content.pageTotal) return;
     this.setListHeight();
-    
+
     _Http.basic({
-      "id": 2026030916100201,
+      id: this.data.id,
       content: this.data.content
     }).then(res => {
       console.log("客户列表数据", res);

+ 232 - 0
CRM/customer/modules/followRecord/create.js

@@ -0,0 +1,232 @@
+const _Http = getApp().globalData.http;
+
+Page({
+  data: {
+    loading: false,
+    disabled: true,
+    form: [{
+        label: "跟进日期",
+        error: false,
+        errMsg: "",
+        type: "date",
+        value: new Date().toISOString().split('T')[0],
+        placeholder: "请选择跟进日期",
+        valueName: "followDate",
+        required: true,
+        checking: "base"
+      },
+      {
+        label: "跟进时间",
+        error: false,
+        errMsg: "",
+        type: "time",
+        value: new Date().toTimeString().substring(0, 8),
+        placeholder: "请选择跟进时间",
+        valueName: "followTime",
+        required: true,
+        checking: "base"
+      },
+      {
+        label: "跟进方式",
+        error: false,
+        errMsg: "",
+        type: "radio",
+        value: "",
+        radioList: [],
+        valueName: "type",
+        required: true,
+        checking: "base"
+      },
+      {
+        label: "跟进内容",
+        error: false,
+        errMsg: "",
+        type: "textarea",
+        value: "",
+        placeholder: "请输入跟进内容",
+        valueName: "content",
+        required: true,
+        checking: "base"
+      },
+      {
+        label: "是否无效",
+        error: false,
+        errMsg: "",
+        type: "radio",
+        value: "true",
+        radioList: [{
+            id: "true",
+            name: "有效"
+          },
+          {
+            id: "false",
+            name: "无效"
+          }
+        ],
+        valueName: "isInvalid",
+        required: false,
+        checking: "base",
+        interrupt: true
+      }
+    ],
+    "content": {
+      "sys_datafollowupid": 0,
+      "ownertable": "sa_customers",
+      "ownerid": "",
+      "type": "",
+      "content": "",
+      "target": "",
+      "results": "",
+      "nextplan": "",
+      "dataextend": ""
+    }
+  },
+  onLoad(options) {
+    // 获取客户ID
+    if (options.ownerid) {
+      this.setData({
+        "content.ownerid": options.ownerid
+      });
+    }
+    // 获取跟进方式列表
+    this.getFollowTypeList();
+  },
+  // 获取跟进方式列表
+  getFollowTypeList() {
+    _Http.basic({
+      "classname": "sysmanage.develop.optiontype.optiontype",
+      "method": "optiontypeselect",
+      "content": {
+        "pageNumber": 1,
+        "pageSize": 1000,
+        "typename": "followType",
+        "parameter": {}
+      }
+    }).then(res => {
+      console.log("跟进方式列表", res);
+      if (res.code == 1 && res.data && res.data.length) {
+        let form = this.data.form;
+        let typeField = form.find(v => v.valueName == 'type');
+        typeField.radioList = res.data.map(item => ({
+          id: item.value,
+          name: item.value
+        }));
+        // 默认选择第一个
+        if (typeField.radioList.length > 0) {
+          typeField.value = typeField.radioList[0].id;
+        }
+        this.setData({
+          form
+        });
+      }
+    }).catch(err => {
+      console.error("获取跟进方式列表失败", err);
+    });
+  },
+  submit() {
+    this.setData({
+      loading: true
+    });
+    let formData = this.selectComponent("#Form").submit();
+
+    // 合并跟进日期和时间
+    let followDateTime = formData.followDate + ' ' + formData.followTime;
+
+    // 构建dataextend
+    let dataextend = {
+      followTime: followDateTime,
+      isInvalid: formData.isInvalid === 'false',
+      invalidReason: formData.invalidReason || ""
+    };
+
+    let content = {
+      ...this.data.content,
+      ...formData,
+      dataextend
+    };
+
+    // 删除不需要的字段
+    delete content.followDate;
+    delete content.followTime;
+    delete content.invalidReason;
+
+    _Http.basic({
+      "id": "20220930121601",
+      content
+    }).then(res => {
+      this.setData({
+        loading: false
+      });
+      console.log("保存跟进记录", res);
+      if (res.code == 1) {
+        getCurrentPages().find(v => v.__route__ == 'CRM/customer/detail').partialRenewal(true);
+        wx.navigateBack({
+          success() {
+            wx.showToast({
+              title: "跟进成功",
+              icon: "success"
+            });
+          }
+        });
+      } else {
+        wx.showToast({
+          title: res.msg || '保存失败',
+          icon: 'none'
+        });
+      }
+    }).catch(err => {
+      this.setData({
+        loading: false
+      });
+      console.error("保存跟进记录失败", err);
+      wx.showToast({
+        title: '网络错误',
+        icon: 'none'
+      });
+    });
+  },
+  interrupt({
+    detail
+  }) {
+    if (detail.data.label == '是否无效') {
+      let form = detail.form;
+      const invalidReasonFieldIndex = form.findIndex(v => v.valueName == 'invalidReason');
+      if (detail.data.value == 'false') {
+        if (invalidReasonFieldIndex === -1) {
+          form.push({
+            label: "无效原因",
+            error: false,
+            errMsg: "",
+            type: "textarea",
+            value: "",
+            placeholder: "请输入无效原因",
+            valueName: "invalidReason",
+            required: true,
+            checking: "base"
+          });
+        }
+      } else {
+        if (invalidReasonFieldIndex !== -1) {
+          form.splice(invalidReasonFieldIndex, 1);
+        }
+      }
+
+      this.setData({
+        form
+      });
+    }
+  },
+  /* 表单必填项是否完成 */
+  onConfirm({
+    detail
+  }) {
+    this.setData({
+      disabled: detail
+    });
+  },
+  closePage() {
+    wx.navigateBack({
+      delta: 1
+    });
+  }
+});

+ 5 - 0
CRM/customer/modules/followRecord/create.json

@@ -0,0 +1,5 @@
+{
+  "usingComponents": {
+  },
+  "navigationBarTitleText": "新建跟进记录"
+}

+ 28 - 0
CRM/customer/modules/followRecord/create.scss

@@ -0,0 +1,28 @@
+.new-footer {
+  display: flex;
+  align-items: center;
+  justify-content: flex-end;
+  position: fixed;
+  width: 100vw;
+  height: 130rpx;
+  background: #FFFFFF;
+  box-shadow: 0px -4rpx 16rpx 2rpx rgba(150, 157, 165, 0.16);
+  bottom: 0;
+  z-index: 9999;
+
+  .new-submit {
+    width: 156rpx;
+    height: 90rpx;
+    background: #3874F6;
+    border-radius: 8rpx;
+    font-size: 28rpx;
+    font-family: PingFang SC-Bold, PingFang SC;
+    font-weight: bold;
+    color: #FFFFFF;
+    margin-right: 30rpx;
+  }
+
+  .van-button {
+    margin-right: 20rpx;
+  }
+}

+ 8 - 0
CRM/customer/modules/followRecord/create.wxml

@@ -0,0 +1,8 @@
+<view class="container">
+  <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' disabled='{{disabled || loading}}' loading='{{loading}}' bindtap='submit'>确定</van-button>
+  </view>
+</view>

+ 7 - 1
CRM/customer/modules/followRecord/index.js

@@ -3,6 +3,7 @@ const _Http = getApp().globalData.http;
 Component({
   properties: {},
   data: {
+    "id": "20220930121501",
     content: {
       nocache: true,
       pageNumber: 1,
@@ -18,7 +19,7 @@ Component({
       content.ownerid = content.sa_customersid;
       if (init) content.pageNumber = 1;
       _Http.basic({
-        "id": "20220930121501",
+        id: this.data.id,
         content
       }).then(res => {
         console.log("客户跟进列表", res)
@@ -35,6 +36,11 @@ Component({
           "sa_customersid": content.sa_customersid
         })
       })
+    },
+    add() {
+      wx.navigateTo({
+        url: `/CRM/customer/modules/followRecord/create?ownerid=${this.data.sa_customersid}`
+      });
     }
   }
 })

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

@@ -1,15 +1,14 @@
 <view class="head">
   <view class="count">跟进记录</view>
   <view class="expand">
-    <navigator url="#" class="but">
+    <navigator url="#" class="but" bindtap="add">
       <van-icon name="plus" />
     </navigator>
   </view>
 </view>
 
 <view class="follow-record">
-  <view wx:if="{{list.length == 0}}" class="placeholder">暂无跟进记录</view>
-  <view wx:else class="follow-list">
+  <view class="follow-list">
     <view wx:for="{{list}}" wx:key="index" class="follow-item">
       <view class="follow-header">
         <view class="follow-time">{{item.followTime || item.dataextend.followTime || '--'}}</view>
@@ -26,4 +25,5 @@
       </view>
     </view>
   </view>
-</view>
+</view>
+<Yl_Empty wx:if="{{list.length==0}}" />

+ 2 - 1
app.json

@@ -123,7 +123,8 @@
         "warehouse/index",
         "lead/index",
         "lead/detail",
-        "customer/modules/order/details"
+        "customer/modules/order/details",
+        "customer/modules/followRecord/create"
       ]
     }
   ],