Procházet zdrojové kódy

转化项目添加查重

xiaohaizhao před 1 rokem
rodič
revize
6e37ba5293

+ 1 - 0
packageA/project/addAndEdit.js

@@ -249,6 +249,7 @@ Page({
         this.setData({
             form: this.data.form.filter(v => !remove.includes(v.label)).map(v => {
                 if (required.includes(v.label)) v.required = true;
+                if (v.valueName == 'projectname') v.interrupt = false;
                 return v
             }),
             siteid: wx.getStorageSync('userMsg').siteid,

+ 195 - 29
packageA/saleClue/change.js

@@ -1,5 +1,5 @@
-const _Http = getApp().globalData.http,
-    getTime = require("../../utils/getTime");
+let _Http = getApp().globalData.http,
+    count = null;
 
 Page({
     data: {
@@ -13,7 +13,9 @@ Page({
                 placeholder: "项目名称",
                 valueName: "projectname",
                 checking: "base",
-                required: true
+                required: true,
+                interrupt: true,
+                permit: true, //无视errMsg 运行提交
             }, {
                 label: "项目类型",
                 error: false,
@@ -248,59 +250,223 @@ Page({
             })
         })
     },
+    async interrupt(e) {
+        let {
+            data,
+            form,
+            temporary
+        } = e.detail;
+        if (data.label == "项目名称") {
+            if (data.value) {
+                const result = await this.selectComponent("#projectname").queryList(data.value);
+                if (result) {
+                    data.errMsg = '疑似重复';
+                    form[0] = data;
+                    this.setData({
+                        form
+                    })
+                } else {
+                    if (data.errMsg) {
+                        data.errMsg = '';
+                        form[0] = data;
+                        this.setData({
+                            form
+                        })
+                    }
+                }
+            } else {
+                if (data.errMsg) {
+                    data.errMsg = '';
+                    form[0] = data;
+                    this.setData({
+                        form
+                    })
+                }
+            }
+        }
+    },
     setHY() {
         let required = ["预计签约时间", "项目等级", "详细地址", "项目规模"],
             remove = ["项目预算(万元)", "总投资额(万元)", "造价(万元)"];
         this.setData({
             form: this.data.form.filter(v => !remove.includes(v.label)).map(v => {
                 if (required.includes(v.label)) v.required = true;
+                if (v.valueName == 'projectname') v.interrupt = false;
                 return v
-            })
+            }),
+            siteid: wx.getStorageSync('userMsg').siteid,
         })
     },
-    submit() {
-        let content = {
-            ...this.data.content,
-            ...this.selectComponent("#Form").submit()
-        };
-        content.sa_brandid = content.sa_brandid ? content.sa_brandid[1][0] : 0;
-        content.city = content.region[1] || "";
-        content.county = content.region[2] || "";
-        content.province = content.region[0] || "";
 
-        if (content.scale.length != 0) {
-            if (content.scale == 0) {
+    /* 查询是否重复 */
+    async queryRepetition(e) {
+        let data = this.selectComponent("#Form").query();
+        /* if (data.projectname == '') return wx.showToast({
+            title: `您还未填写项目名称`,
+            icon: "none"
+        }); */
+        data.province = data.region[0] || "";
+        data.city = data.region[1] || "";
+        data.county = data.region[2] || "";
+        let res = await this.handleQueryRepetition({
+            sa_projectid: this.data.sa_projectid,
+            ...data
+        });
+        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({
-                    loading: false
-                })
-                wx.showToast({
-                    title: '项目规模不可为0',
-                    icon: "none"
+                    countDown: ""
                 })
-                return;
-            };
-
-            if (content.unitname == "") {
+            } else {
+                countDown--;
                 this.setData({
-                    loading: false
+                    countDown
+                })
+            }
+        }, 1000)
+        if (res.total == 0) {
+            wx.showToast({
+                title: '未查询到疑似重复的项目信息',
+                icon: "none"
+            })
+            this.data.repetitionShow = false;
+        } else {
+            wx.showToast({
+                title: `查询到${res.total}条疑似重复项目信息`,
+                icon: "none"
+            })
+            this.setData({
+                repetitionShow: true,
+                repetitionList: res.data
+            })
+        }
+    },
+    repClose() {
+        if (this.data.isSubmit) {
+            let that = this;
+            wx.showModal({
+                title: '提示',
+                content: `是否继续创建项目`,
+                complete: (res) => {
+                    if (res.confirm) that.handleSubmit(true);
+                }
+            })
+        }
+        this.setData({
+            repetitionShow: false,
+            isSubmit: false
+        })
+    },
+    /* 处理查重 */
+    handleQueryRepetition(content) {
+        return _Http.basic({
+            "id": 20221208184202,
+            content
+        })
+    },
+    async submit() {
+        let data = this.selectComponent("#Form").submit(),
+            that = this;
+        data.province = data.region[0] || "";
+        data.city = data.region[1] || "";
+        data.county = data.region[2] || "";
+        let query = await this.handleQueryRepetition({
+            sa_projectid: this.data.sa_projectid,
+            ...data
+        });
+        if (query.total != 0) {
+            if (this.data.siteid == 'HY') {
+                wx.showModal({
+                    title: '提示',
+                    content: '该项目疑似重复,是否确认创建项目',
+                    complete: (res) => {
+                        if (res.confirm) that.handleSubmit(true);
+                    }
                 })
+            } else {
                 wx.showToast({
-                    title: '还未选择项目规模单位',
+                    title: `查询到${query.total}条疑似重复项目信息`,
                     icon: "none"
                 })
-                return;
+                this.setData({
+                    repetitionShow: true,
+                    repetitionList: query.data,
+                    isSubmit: true
+                })
             }
+        } else {
+            this.handleSubmit();
+        }
+    },
+    handleSubmit(tag = false) {
+        this.setData({
+            loading: true
+        })
+        let data = {
+            ...this.data.content,
+            ...this.selectComponent("#Form").submit()
+        };
+        data.province = data.region[0] || "";
+        data.city = data.region[1] || "";
+        data.county = data.region[2] || "";
+        data.tradefields = [data.tradefields];
+        data.sa_brandid = data.sa_brandid ? data.sa_brandid[1][0] : 0;
+
+        if (data.scale.length != 0 && data.scale == 0) {
+            this.setData({
+                loading: false
+            })
+            wx.showToast({
+                title: '项目规模不可为0',
+                icon: "none"
+            })
+            return;
+        }
+
+        if (data.unitname == "") {
+            this.setData({
+                loading: false
+            })
+            wx.showToast({
+                title: '还未选择项目规模单位',
+                icon: "none"
+            })
+            return;
         }
+
+        delete(data.region);
         _Http.basic({
-            "id": "20221124154902",
-            content
+            "id": 20221124154902,
+            content: data
         }).then(res => {
+            this.setData({
+                loading: false
+            })
             console.log("转化", res)
             wx.showToast({
                 title: res.msg != '成功' ? res.msg : '转化成功',
                 icon: "none"
             })
             if (res.msg != '成功') return;
+            //绑定疑似重复标签
+            if (tag) _Http.basic({
+                "id": 20220929090901,
+                "content": {
+                    "ownertable": "sa_project",
+                    "ownerid": res.data.sa_projectid,
+                    "datatag": ["疑似重复"]
+                }
+            })
             setTimeout(() => {
                 wx.navigateBack()
                 getCurrentPages().forEach(item => {

+ 3 - 1
packageA/saleClue/change.json

@@ -1,4 +1,6 @@
 {
-    "usingComponents": {},
+    "usingComponents": {
+        "projectname": "/packageA/project/modules/projectname/index"
+    },
     "navigationBarTitleText": "转化项目"
 }

+ 62 - 0
packageA/saleClue/change.scss

@@ -20,4 +20,66 @@
         color: #FFFFFF;
         margin-right: 30rpx;
     }
+}
+
+
+
+.popup {
+    .title {
+        position: sticky;
+        height: 80rpx;
+        line-height: 80rpx;
+        width: 100%;
+        text-align: center;
+        border-bottom: 1rpx solid #ddd;
+        font-weight: 600;
+        color: #333;
+        top: 0;
+        background-color: #fff;
+
+        .icon {
+            position: absolute;
+            right: 28rpx;
+            top: 22rpx;
+            color: #999;
+        }
+    }
+
+    .enterprise {
+        width: 100%;
+        box-sizing: border-box;
+        padding-left: 30rpx;
+        padding-right: 10rpx;
+        padding-bottom: 10rpx;
+        border-bottom: 1rpx solid #ddd;
+        margin-top: 10rpx;
+
+        .tag-box {
+            margin-top: 10rpx;
+
+            .tag {
+                height: 40rpx;
+                font-size: 20rpx;
+                font-family: PingFang SC-Regular, PingFang SC;
+                padding: 0 12rpx;
+                margin-right: 8rpx;
+            }
+        }
+
+        &_title {
+            line-height: 40rpx;
+            font-size: 28rpx;
+            font-family: PingFang SC-Bold, PingFang SC;
+            font-weight: bold;
+            color: #333333;
+        }
+
+        .exp {
+            line-height: 34rpx;
+            font-size: 24rpx;
+            font-family: PingFang SC-Regular, PingFang SC;
+            color: #666666;
+            margin-top: 8rpx;
+        }
+    }
 }

+ 24 - 1
packageA/saleClue/change.wxml

@@ -2,7 +2,30 @@
 <Yl_field id='Form' form='{{form}}' showAll='{{!showAll}}' bind:onConfirm='onConfirm' bind:interrupt="interrupt" />
 <view style="height: 100rpx;" />
 <view class="new-footer">
+    <van-button custom-class='new-submit query' disabled='{{countDown ||disabled|| loading}}' bindclick='queryRepetition'>{{countDown?countDown+'S':"查重"}}</van-button>
     <van-button custom-class='new-submit' disabled='{{disabled}}' bindclick='submit'>提交</van-button>
 </view>
 
-<!-- type='switch' switchLabel='仅显示必填信息' switch='{{showAll}}' -->
+<!-- 查重 -->
+<van-popup show="{{ repetitionShow }}" custom-class='popup' round position="bottom" custom-style="height: 100%;" bind:close="repClose">
+    <view class="title">
+        查重
+        <van-icon custom-class='icon' size='40rpx' name="cross" bindtap="repClose" />
+    </view>
+    <navigator url="#" class="enterprise" wx:for="{{repetitionList}}" wx:key="sa_projectid">
+        <view class="enterprise_title">{{item.projectname}}</view>
+        <view class="tag-box">
+            <van-tag custom-class='tag' wx:for="{{item.tag_sys}}" wx:key="index" wx:for-item='tag' color='#3874f6' text-color='#fff' round>{{tag}}</van-tag>
+            <van-tag custom-class='tag' wx:for="{{item.tag}}" wx:key="index" wx:for-item='tag' color='#FA8C16' text-color='#fff' round>{{tag}}</van-tag>
+        </view>
+        <view class="exp">项目状态:{{item.status ||' --'}}</view>
+        <view class="exp">项目编号:{{item.projectnum ||' --'}}</view>
+        <view class="exp">项目地址:{{item.address ||' --'}}</view>
+        <view class="exp">项目类型:{{item.projecttype ||' --'}}</view>
+        <view class="exp">领域:{{item.tradefield||' --'}}</view>
+        <view class="exp">品牌:{{item.brandname||' --'}}</view>
+        <view class="exp">负责人:{{item.leader[0].name||' --'}}</view>
+        <view class="exp">手机号:{{item.phonenumber||" --"}}</view>
+    </navigator>
+</van-popup>
+<projectname id="projectname" siteid='{{siteid}}' />

+ 7 - 0
project.private.config.json

@@ -8,6 +8,13 @@
     "condition": {
         "miniprogram": {
             "list": [
+                {
+                    "name": "packageA/project/addAndEdit",
+                    "pathName": "packageA/project/addAndEdit",
+                    "query": "",
+                    "launchMode": "default",
+                    "scene": null
+                },
                 {
                     "name": "项目商机",
                     "pathName": "packageA/project/index",