فهرست منبع

增加客户查重条件

zhaoxiaohai 3 سال پیش
والد
کامیت
c667c729b5

+ 90 - 4
packageA/publicCustomer/addAndEditor.js

@@ -1,4 +1,5 @@
-const _Http = getApp().globalData.http;
+let _Http = getApp().globalData.http,
+    count = null;
 
 Page({
     data: {
@@ -137,7 +138,8 @@ Page({
             "sys_enterpriseid": 0, //合作企业档案ID,新增是传0,更新
             "source": "", //客户来源
         },
-        disabled: true
+        disabled: true,
+        countDown: "", //查重倒计时
     },
     setOption(item) {
         let i = this.data.form.findIndex(v => v.valueName == item.valueName);
@@ -184,7 +186,64 @@ Page({
             showAll: detail
         })
     },
-    submit() {
+    /* 查询是否重复 */
+    async queryRepetition(e) {
+        let {
+            enterprisename,
+            taxno,
+            address
+        } = this.selectComponent("#Form").query();
+        if (enterprisename == '') return wx.showToast({
+            title: `您还未填写企业名称`,
+            icon: "none"
+        });
+        let res = await this.handleQueryRepetition({
+            enterprisename,
+            taxno,
+            address
+        });
+        console.log("查询重复", res)
+        if (res.msg != '成功') return wx.showToast({
+            title: res.msg,
+            icon: "none"
+        });
+        this.setData({
+            countDown: 6
+        });
+        count = setInterval(() => {
+            let countDown = this.data.countDown;
+            if (countDown == 0) {
+                clearInterval(count);
+                this.setData({
+                    countDown: ""
+                })
+            } else {
+                countDown--;
+                this.setData({
+                    countDown
+                })
+            }
+        }, 1000)
+        if (res.total == 0) {
+            wx.showToast({
+                title: '未查询到疑似重复的客户信息',
+                icon: "none"
+            })
+        } else {
+            wx.showToast({
+                title: `查询到${res.total}条疑似重复客户信息`,
+                icon: "none"
+            })
+        }
+    },
+    /* 处理查重 */
+    handleQueryRepetition(content) {
+        return _Http.basic({
+            "id": 20221208172002,
+            content
+        })
+    },
+    async submit() {
         let data = this.selectComponent("#Form").submit();
         if (data.region.length != 0) {
             data.province = data.region[0]
@@ -193,6 +252,23 @@ Page({
         };
         data.sa_customerpoolid = data.sa_customerpoolid[1][0]
         delete(data.region);
+
+        let query = await this.handleQueryRepetition({
+            enterprisename: data.enterprisename,
+            taxno: data.taxno,
+            address: data.address
+        });
+        if (query.total != 0) await new Promise((resolve, reject) => {
+            wx.showModal({
+                title: '提示',
+                content: `查询到${query.total}条疑似重复客户信息 是否确认继续新建`,
+                complete: (res) => {
+                    if (res.cancel) reject()
+                    if (res.confirm) resolve(true);
+                }
+            })
+        })
+
         _Http.basic({
             "id": 20221010164302,
             "content": {
@@ -208,6 +284,15 @@ Page({
             wx.showToast({
                 title: '保存成功',
                 icon: "none"
+            });
+            //绑定疑似重复标签
+            if (query.total != 0) _Http.basic({
+                "id": 20220929090901,
+                "content": {
+                    "ownertable": "sa_customers",
+                    "ownerid": res.data.sa_customersid,
+                    "datatag": ["疑似重复"]
+                }
             })
             setTimeout(() => {
                 getCurrentPages().forEach(v => {
@@ -225,7 +310,8 @@ Page({
                 if (pages[pages.length - 2].__route__ == 'packageA/publicCustomer/index') wx.redirectTo({
                     url: '/packageA/publicCustomer/detail?id=' + res.data.sa_customersid,
                 })
-            }, 300)
+            }, query.total != 0 ? 300 : 500);
+
         })
     },
 })

+ 1 - 1
packageA/publicCustomer/addAndEditor.json

@@ -1,4 +1,4 @@
 {
     "usingComponents": {},
-    "navigationBarTitleText": "编辑公海客户"
+    "navigationBarTitleText": "设置公海客户"
 }

+ 6 - 0
packageA/publicCustomer/addAndEditor.scss

@@ -20,4 +20,10 @@
         color: #FFFFFF;
         margin-right: 30rpx;
     }
+
+    .query {
+        border: 1rpx solid #CCCCCC !important;
+        background-color: #fff !important;
+        color: #666666 !important;
+    }
 }

+ 1 - 0
packageA/publicCustomer/addAndEditor.wxml

@@ -2,5 +2,6 @@
 <Yl_field id='Form' form='{{form}}' showAll='{{!showAll}}' bind:onConfirm='onConfirm' />
 <view style="height: 100rpx;" />
 <view class="new-footer">
+    <van-button custom-class='new-submit query' disabled='{{countDown}}' bindclick='queryRepetition'>{{countDown?countDown+'S':"查重"}}</van-button>
     <van-button custom-class='new-submit' disabled='{{disabled}}' bindclick='submit'>提交</van-button>
 </view>

+ 92 - 9
packageA/setclient/addAndEditor.js

@@ -1,4 +1,5 @@
-const _Http = getApp().globalData.http;
+let _Http = getApp().globalData.http,
+    count = null;
 
 Page({
     data: {
@@ -116,7 +117,8 @@ Page({
             "sa_customerpoolid": 0, //客户池(公海池)ID,默认或没有的时候传0
             "source": "", //客户来源
         },
-        disabled: true
+        disabled: true,
+        countDown: "", //查重倒计时
     },
     setOption(item) {
         let i = this.data.form.findIndex(v => v.valueName == item.valueName);
@@ -163,7 +165,65 @@ Page({
             showAll: detail
         })
     },
-    submit() {
+    /* 查询是否重复 */
+    async queryRepetition(e) {
+        let {
+            enterprisename,
+            taxno,
+            address
+        } = this.selectComponent("#Form").query();
+        if (enterprisename == '') return wx.showToast({
+            title: `您还未填写企业名称`,
+            icon: "none"
+        });
+        let res = await this.handleQueryRepetition({
+            enterprisename,
+            taxno,
+            address
+        });
+        console.log("查询重复", res)
+        if (res.msg != '成功') return wx.showToast({
+            title: res.msg,
+            icon: "none"
+        });
+        this.setData({
+            countDown: 6
+        });
+        count = setInterval(() => {
+            let countDown = this.data.countDown;
+            if (countDown == 0) {
+                clearInterval(count);
+                this.setData({
+                    countDown: ""
+                })
+            } else {
+                countDown--;
+                this.setData({
+                    countDown
+                })
+            }
+        }, 1000)
+        if (res.total == 0) {
+            wx.showToast({
+                title: '未查询到疑似重复的客户信息',
+                icon: "none"
+            })
+        } else {
+            wx.showToast({
+                title: `查询到${res.total}条疑似重复客户信息`,
+                icon: "none"
+            })
+        }
+    },
+    /* 处理查重 */
+    handleQueryRepetition(content) {
+        return _Http.basic({
+            "id": 20221208172002,
+            content
+        })
+    },
+
+    async submit() {
         let data = this.selectComponent("#Form").submit();
         if (data.region.length != 0) {
             data.province = data.region[0]
@@ -171,6 +231,23 @@ Page({
             data.county = data.region[2]
         };
         delete(data.region);
+
+        let query = await this.handleQueryRepetition({
+            enterprisename: data.enterprisename,
+            taxno: data.taxno,
+            address: data.address
+        });
+        if (query.total != 0) await new Promise((resolve, reject) => {
+            wx.showModal({
+                title: '提示',
+                content: `查询到${query.total}条疑似重复客户信息 是否确认继续新建`,
+                complete: (res) => {
+                    if (res.cancel) reject()
+                    if (res.confirm) resolve(true);
+                }
+            })
+        })
+
         _Http.basic({
             "id": 20221012163902,
             "content": {
@@ -187,26 +264,32 @@ Page({
                 title: '保存成功',
                 icon: "none"
             })
+            //绑定疑似重复标签
+            if (query.total != 0) _Http.basic({
+                "id": 20220929090901,
+                "content": {
+                    "ownertable": "sa_customers",
+                    "ownerid": res.data.sa_customersid,
+                    "datatag": ["疑似重复"]
+                }
+            })
             setTimeout(() => {
-                wx.navigateBack()
                 getCurrentPages().forEach(v => {
                     switch (v.__route__) {
                         case 'packageA/setclient/index':
                             v.getList(true);
                             break;
-                        case 'packageA/setclient/search':
-                            v.getList(true);
-                            break;
                         case 'packageA/setclient/detail':
                             v.getDetail();
+                            wx.navigateBack()
                             break;
                     }
                 })
                 let pages = getCurrentPages();
-                if (pages[pages.length - 2].__route__ == 'packageA/setclient/index') wx.navigateTo({
+                if (pages[pages.length - 2].__route__ == 'packageA/setclient/index') wx.redirectTo({
                     url: '/packageA/setclient/detail?id=' + res.data.sa_customersid,
                 })
-            }, 300)
+            }, query.total != 0 ? 300 : 500)
         })
     },
 })

+ 6 - 0
packageA/setclient/addAndEditor.scss

@@ -20,4 +20,10 @@
         color: #FFFFFF;
         margin-right: 30rpx;
     }
+
+    .query {
+        border: 1rpx solid #CCCCCC !important;
+        background-color: #fff !important;
+        color: #666666 !important;
+    }
 }

+ 1 - 0
packageA/setclient/addAndEditor.wxml

@@ -2,5 +2,6 @@
 <Yl_field id='Form' form='{{form}}' showAll='{{!showAll}}' bind:onConfirm='onConfirm' />
 <view style="height: 100rpx;" />
 <view class="new-footer">
+    <van-button custom-class='new-submit query' disabled='{{countDown}}' bindclick='queryRepetition'>{{countDown?countDown+'S':"查重"}}</van-button>
     <van-button custom-class='new-submit' disabled='{{disabled}}' bindclick='submit'>提交</van-button>
 </view>

+ 7 - 0
project.private.config.json

@@ -35,6 +35,13 @@
                     "query": "sa_salesforecastbillid=93",
                     "launchMode": "default",
                     "scene": null
+                },
+                {
+                    "name": "公海客户",
+                    "pathName": "packageA/publicCustomer/addAndEditor",
+                    "query": "",
+                    "launchMode": "default",
+                    "scene": null
                 }
             ]
         }