xiaohaizhao 3 лет назад
Родитель
Сommit
b950c894e5

+ 24 - 36
packageA/project/addAndEdit.js

@@ -3,11 +3,13 @@ let _Http = getApp().globalData.http,
 
 Page({
     data: {
+        loading: false,
         repetitionShow: false,
         repetitionList: [],
         isSubmit: false,
-        "sa_projectid": 0,
+        sa_projectid: 0,
         showAll: false,
+        disabled: true,
         form: [{
                 label: "项目名称",
                 error: false,
@@ -167,7 +169,6 @@ Page({
                 required: false
             }
         ],
-        disabled: true,
         countDown: "", //查重倒计时
     },
     onLoad(options) {
@@ -291,7 +292,6 @@ Page({
             projectname: data.projectname,
             address: data.address
         });
-
         if (query.total != 0) {
             wx.showToast({
                 title: `查询到${query.total}条疑似重复项目信息`,
@@ -307,14 +307,15 @@ Page({
         }
     },
     handleSubmit(tag = false) {
+        this.setData({
+            loading: true
+        })
         let data = this.selectComponent("#Form").submit();
-        if (data.region.length != 0) {
-            data.province = data.region[0]
-            data.city = data.region[1]
-            data.county = data.region[2]
-        };
+        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[1][0] || 0
+        data.sa_brandid = data.sa_brandid ? data.sa_brandid[1][0] : 0;
         delete(data.region);
         _Http.basic({
             "id": 20221020144202,
@@ -323,16 +324,16 @@ Page({
                 ...data
             }
         }).then(res => {
-            console.log("新建项目", res)
-            if (res.msg != '成功') return wx.showToast({
-                title: res.msg,
-                icon: "none"
+            this.setData({
+                loading: false
             })
+            console.log("新建项目", res)
             wx.showToast({
-                title: '保存成功',
-                icon: "none"
+                title: res.msg != '成功' ? res.msg : "保存成功",
+                icon: "none",
+                mask: true
             })
-
+            if (res.msg != '成功') return;
             //绑定疑似重复标签
             if (tag) _Http.basic({
                 "id": 20220929090901,
@@ -344,29 +345,16 @@ Page({
             })
 
             setTimeout(() => {
-                getCurrentPages().forEach(v => {
-                    if (v.getList) v.getList(true);
-                    if (['packageA/project/index', 'packageA/project/search'].includes(v.__route__)) {
-                        if (this.data.sa_projectid == 0) {
-                            v.data.list.push(res.data)
-                        } else {
-                            let i = v.data.list.findIndex(value => value.sa_projectid == this.data.sa_projectid);
-                            if (i != -1) v.data.list[i] = res.data;
-                        }
-                        v.setData({
-                            list: v.data.list
-                        })
-                    } else if (v.__route__ == 'packageA/project/detail') {
-                        wx.navigateBack()
-                        v.getDetail();
-                    }
-                })
-                if (this.data.sa_projectid == 0) {
+                let page = getCurrentPages()[getCurrentPages().length - 2];
+                if (page.__route__ == 'packageA/project/index') {
                     wx.redirectTo({
-                        url: '/packageA/project/detail?sa_projectid=' + res.data.sa_projectid,
+                        url: '/packageA/project/detail?id=' + res.data.sa_projectid,
                     })
+                } else if (page.__route__ == 'packageA/project/detail') {
+                    wx.navigateBack()
+                    page.getDetail();
                 }
-            }, tag ? 500 : 300)
+            }, 500)
         })
     }
 

+ 2 - 2
packageA/project/addAndEdit.wxml

@@ -2,8 +2,8 @@
 <Yl_field id='Form' form='{{form}}' showAll='{{!showAll}}' bind:onConfirm='onConfirm' bind:interrupt='interrupt' />
 <view style="height: 112rpx;" />
 <view class="new-footer" style="padding-bottom: 12rpx;">
-    <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>
+    <van-button custom-class='new-submit query' disabled='{{countDown || loading}}' bindclick='queryRepetition'>{{countDown?countDown+'S':"查重"}}</van-button>
+    <van-button custom-class='new-submit' disabled='{{disabled || loading}}' loading='{{loading}}' bindclick='submit'>提交</van-button>
 </view>
 <!-- 查重 -->
 <van-popup show="{{ repetitionShow }}" custom-class='popup' round position="bottom" custom-style="height: 100%;" bind:close="repClose">

+ 38 - 32
packageA/project/delete.js

@@ -1,14 +1,13 @@
 const _Http = getApp().globalData.http;
 
+let sa_projectid = null;
 Page({
     data: {
         deletereason: "",
-        sa_projectid: 0,
+        loading: false,
     },
     onLoad(options) {
-        this.setData({
-            sa_projectid: options.id
-        })
+        sa_projectid = options.id;
     },
     onInput(e) {
         this.setData({
@@ -16,35 +15,42 @@ Page({
         })
     },
     handleDetele() {
-        _Http.basic({
-            "id": 20221020144302,
-            "content": {
-                "sa_projectids": [this.data.sa_projectid],
-                "deletereason": this.data.deletereason
-            },
-        }).then(res => {
-            console.log("作废", res);
-            if (res.msg != '成功') return wx.showToast({
-                title: res.data,
-                icon: "none"
-            });
-            wx.showToast({
-                title: '作废成功',
-                icon: "none"
-            })
-            setTimeout(() => {
-                getCurrentPages().forEach(v => {
-                    if (['packageA/project/detail'].includes(v.__route__)) {
-                        wx.navigateBack();
-                    } else if (['packageA/project/index', 'packageA/project/search'].includes(v.__route__)) {
-                        v.setData({
-                            list: v.data.list.filter(s => s.sa_projectid != this.data.sa_projectid),
-                            'content.total': v.data.content.total - 1
+        let that = this;
+        wx.showModal({
+            title: '提示',
+            content: '是否确认作废改项目?',
+            complete: ({
+                confirm
+            }) => {
+                if (confirm) {
+                    that.setData({
+                        loading: true
+                    })
+                    _Http.basic({
+                        "id": 20221020144302,
+                        "content": {
+                            "sa_projectids": [sa_projectid],
+                            "deletereason": that.data.deletereason
+                        },
+                    }).then(res => {
+                        console.log("作废", res);
+                        that.setData({
+                            loading: false
                         })
-                    }
-                });
-                wx.navigateBack();
-            }, 300)
+                        wx.showToast({
+                            title: res.msg != '成功' ? res.data : '作废成功',
+                            icon: "none",
+                            mask: true
+                        });
+                        if (res.msg == '成功') setTimeout(() => {
+                            wx.navigateBack({
+                                delta: 2
+                            });
+                        }, 300)
+                    })
+                }
+            }
         })
+
     }
 })

+ 1 - 1
packageA/project/delete.wxml

@@ -8,5 +8,5 @@
 </view>
 
 <view class="footer">
-    <van-button custom-class='custom' deletereason disabled='{{!deletereason}}' bindclick="handleDetele">提交</van-button>
+    <van-button custom-class='custom' deletereason disabled='{{!deletereason ||loading}}' loading='{{loading}}' bindclick="handleDetele">提交</van-button>
 </view>

+ 25 - 21
packageA/project/detail.js

@@ -60,7 +60,7 @@ Page({
     },
     onLoad(options) {
         this.setData({
-            sa_projectid: options.sa_projectid,
+            sa_projectid: options.id,
             isAdmin: wx.getStorageSync('auth').wproject.options.some(v => v == "admin"), //是否具有管理权限
             options: wx.getStorageSync('auth').wproject.options, //权限列表
         });
@@ -85,13 +85,6 @@ Page({
                 this.getGroup();
                 this.selectComponent("#TaskTabs").getList();
             }
-            let page = getCurrentPages()[getCurrentPages().length - 2];
-            if (page.__route__ == 'packageA/project/index') {
-                page.data.list.find(v => v.sa_projectid == res.data.sa_projectid).status = res.data.status;
-                page.setData({
-                    list: page.data.list
-                })
-            };
             this.partialRenewal(init);
         })
     },
@@ -391,7 +384,7 @@ Page({
                 icon: "none",
                 mask: true
             })
-            if (res.data != '失败') setTimeout(() => this.getDetail, 500)
+            if (res.data != '失败') this.getDetail();
         })
     },
     //局部数据更新 tabs
@@ -452,22 +445,13 @@ Page({
                         userid: arr[0]
                     }
                 }).then(res => {
-                    console.log("更换负责人", res)
-                    if (res.msg != '成功') return wx.showToast({
-                        title: res.data,
-                        icon: "none"
-                    });
                     wx.showToast({
-                        title: '更换成功',
+                        title: res.msg != '成功' ? res.data : '更换成功',
                         icon: "none",
                         mask: true
                     });
-                    setTimeout(() => {
-                        that.getDetail();
-                        getCurrentPages().forEach(v => {
-                            if (['packageA/project/index'].includes(v.__route__)) v.getList(true)
-                        });
-                        that.getGroup();
+                    if (res.msg == '成功') setTimeout(() => {
+                        that.getDetail(true);
                         wx.navigateBack();
                     }, 300)
                 })
@@ -481,5 +465,25 @@ Page({
     //更新团队成员
     getGroup() {
         this.selectComponent("#Group").getList();
+    },
+    onUnload() {
+        const page = getCurrentPages().find(v => v.__route__ == 'packageA/project/index');
+        if (!page) return;
+        let content = JSON.parse(JSON.stringify(page.data.content));
+        content.pageSize = (content.pageNumber - 1) * content.pageSize;
+        content.pageNumber = 1;
+        _Http.basic({
+            id: 20221020143502,
+            content
+        }).then(res => {
+            console.log("更新项目商机列表", res);
+            if (res.msg == '成功') {
+                page.data.list = res.data;
+                page.data.content.total = res.total;
+                page.setListHeight();
+                page.getTags();
+            }
+
+        })
     }
 })

+ 8 - 15
packageA/project/index.js

@@ -75,9 +75,7 @@ Page({
     onSearch({
         detail
     }) {
-        this.setData({
-            "content.where.condition": detail
-        });
+        this.data.content.where.condition = detail;
         this.getList(true);
 
     },
@@ -105,19 +103,15 @@ Page({
                 title: res.msg,
                 icon: "none"
             })
-
+            content.pageNumber = res.pageNumber + 1;
+            content.pageTotal = res.pageTotal;
+            content.total = res.total;
+            content.sort = res.sort;
             res.data = res.data.map(v => {
                 v.progress = v.stage / v.totalstage * 100;
                 return v
             })
-
-            this.setData({
-                'content.pageNumber': res.pageNumber + 1,
-                'content.pageTotal': res.pageTotal,
-                'content.total': res.total,
-                'content.sort': res.sort,
-                list: res.pageNumber == 1 ? res.data : this.data.list.concat(res.data)
-            });
+            this.data.list = res.pageNumber == 1 ? res.data : this.data.list.concat(res.data)
             this.setListHeight();
             this.getTags();
         })
@@ -134,14 +128,13 @@ Page({
                 ownerids
             }
         }).then(res => {
-            console.log("标签", res)
             for (let key in res.data) {
                 let index = list.findIndex(v => v.sa_projectid == key);
                 list[index].tags = res.data[key]
             };
-            console.log(list)
             this.setData({
-                list
+                list,
+                content: this.data.content
             })
         })
     },

+ 1 - 1
packageA/project/modules/contract/index.js

@@ -74,7 +74,7 @@ Component({
         }) {
             let type = 'type4';
             let page = getCurrentPages()[getCurrentPages().length - 1];
-            if (detail.name != '居间协议') type = page.selectComponent("#Tags").data.datatag.some(v => v == '直销') ? 'type3' : 'type2';
+            if (detail.name != '居间协议') type = page.selectComponent("#Tags").data.systemtag.some(v => v == '直销') ? 'type3' : 'type2';
             wx.navigateTo({
                 url: `/packageA/contract/add/${type}/index?project=${JSON.stringify([page.data.detail.projectname,[page.data.detail.sa_projectid]])}&sa_projectid=${this.data.sa_projectid}`,
             })

+ 1 - 1
packageA/project/modules/list/index.wxml

@@ -1,4 +1,4 @@
-<navigator url="/packageA/project/detail?sa_projectid={{item.sa_projectid}}" class="project-item" wx:for="{{list}}" wx:key="sa_projectid">
+<navigator url="/packageA/project/detail?id={{item.sa_projectid}}" class="project-item" wx:for="{{list}}" wx:key="sa_projectid">
     <view class="chart">
         <view class="circle">
             <view class="circle_left ab" style="{{render.leftRate(item.progress)}}" />

+ 5 - 2
packageA/project/modules/opponent/index.js

@@ -45,6 +45,7 @@ Component({
             wx.navigateTo({
                 url: '/packageA/select/setclient/select?params=' + JSON.stringify({
                     "content": {
+                        nocache: true,
                         "isExport": false,
                         "where": {
                             "condition": "",
@@ -57,7 +58,9 @@ Component({
             });
             getApp().globalData.handleSelect = this.handleSelect.bind(this);
         },
-        handleSelect({item}) {
+        handleSelect({
+            item
+        }) {
             let that = this;
             wx.showModal({
                 title: '提示',
@@ -70,7 +73,7 @@ Component({
                         "content": {
                             sa_project_competeid: 0,
                             "sa_projectid": that.data.sa_projectid, //工程项目表ID
-                            "sa_competitorid":item.sa_competitorid, //竞争对手ID
+                            "sa_competitorid": item.sa_competitorid, //竞争对手ID
                             "important": 0, //主要威胁 0/1
                         }
                     }).then(res => {