瀏覽代碼

销售预测

zhaoxiaohai 2 年之前
父節點
當前提交
2ad87cfdd3

+ 153 - 49
packageA/forecast/detail.js

@@ -1,66 +1,170 @@
-// packageA/forecast/detail.js
+const getHeight = require("../../utils/getRheRemainingHeight"),
+    _Http = getApp().globalData.http;
 Page({
 
     /**
      * 页面的初始数据
      */
     data: {
-
+        myProject: false,
+        list: [],
+        total: null,
+        projectList: null,
+        sa_salesforecastmodelid: null,
+        "content": {
+            "nocache": true,
+            "sa_salesforecastbillid": null,
+            "pageNumber": 1,
+            "pageSize": 20,
+            "pageTotal": 1,
+            "where": {
+                "condition": ""
+            }
+        },
     },
-
-    /**
-     * 生命周期函数--监听页面加载
-     */
     onLoad(options) {
+        this.setData({
+            'content.sa_salesforecastbillid': options.id,
+            'sa_salesforecastmodelid': options.mId
+        })
+        this.getList();
+        if (options.my) this.setData({
+            myProject: true
+        })
 
     },
-
-    /**
-     * 生命周期函数--监听页面初次渲染完成
-     */
-    onReady() {
-
+    /* 添加项目 */
+    addProjece() {
+        _Http.basic({
+            "id": 20220906154803,
+            "version": 1,
+            "content": {
+                "nocache": true,
+                pageSize: 9999,
+                "sa_salesforecastbillid": this.data.content.sa_salesforecastbillid,
+                "where": {
+                    "condition": ""
+                }
+            }
+        }).then(res => {
+            if (res.msg != '成功') return wx.showToast({
+                title: res.data,
+                icon: "none"
+            })
+            this.setData({
+                projectList: res.data
+            });
+            this.selectComponent("#Plist").setData({
+                show: true
+            })
+        })
     },
-
-    /**
-     * 生命周期函数--监听页面显示
-     */
-    onShow() {
-
+    getList(init = false) {
+        if (init.detail != undefined) init = init.detail;
+        if (init) this.setData({
+            ['content.pageNumber']: 1
+        })
+        if (this.data.content.pageNumber > this.data.content.pageTotal) return;
+        return _Http.basic({
+            "id": 20220916115203,
+            "version": 1,
+            content: this.data.content
+        }).then(res => {
+            console.log("列表", res)
+            this.selectComponent('#ListBox').RefreshToComplete();
+            if (res.msg != '成功') return wx.showToast({
+                title: res.data,
+                icon: "none"
+            })
+            this.setData({
+                'content.pageNumber': res.pageNumber + 1,
+                'content.pageTotal': res.pageTotal,
+                list: res.pageNumber == 1 ? res.data : this.data.list.concat(res.data),
+                total: res.total
+            })
+        })
     },
-
-    /**
-     * 生命周期函数--监听页面隐藏
-     */
-    onHide() {
-
+    /* 得到结果创建项目 */
+    getResult({
+        detail
+    }) {
+        _Http.basic({
+            "id": 20220916134103,
+            "version": 1,
+            "content": {
+                "sa_salesforecastmodelid": this.data.sa_salesforecastmodelid,
+                "sa_salesforecastbillid": this.data.content.sa_salesforecastbillid,
+                "sa_projectids": detail
+            }
+        }).then(res => {
+            if (res.msg != '成功') return wx.showToast({
+                title: res.data,
+                icon: "none"
+            })
+            this.getList(true)
+        })
     },
-
-    /**
-     * 生命周期函数--监听页面卸载
-     */
-    onUnload() {
-
+    /* 开始搜索 */
+    startSearch({
+        detail
+    }) {
+        this.setData({
+            'content.where.condition': detail.trim()
+        });
+        this.getList(true);
     },
-
-    /**
-     * 页面相关事件处理函数--监听用户下拉动作
-     */
-    onPullDownRefresh() {
-
+    cancelSearch() {
+        this.setData({
+            'content.where.condition': ""
+        });
+        this.getList(true);
     },
-
-    /**
-     * 页面上拉触底事件的处理函数
-     */
-    onReachBottom() {
-
+    onReady() {
+        //滚动区域高度
+        getHeight.getHeight('#Search', this).then(res => this.setData({
+            scrollHeight: res
+        }))
     },
-
-    /**
-     * 用户点击右上角分享
-     */
-    onShareAppMessage() {
-
-    }
+    onClose(event) {
+        const {
+            instance
+        } = event.detail;
+        instance.close();
+    },
+    /* 删除提报 */
+    deleteProject(e) {
+        const {
+            item
+        } = e.currentTarget.dataset, that = this;
+        wx.showModal({
+            title: "提示",
+            content: `是否确认删除${item.projectname}`,
+            success({
+                confirm
+            }) {
+                if (confirm) _Http.basic({
+                    "id": 20220908134803,
+                    "version": 1,
+                    "content": {
+                        "sa_salesforecastbillid": item.sa_salesforecastbillid
+                    }
+                }).then(res => {
+                    console.log(res)
+                    if (res.msg != '成功') return wx.showToast({
+                        title: res.data,
+                        icon: "none"
+                    })
+                    let arr = that.data.list.filter(v => v.sa_salesforecastbillid != item.sa_salesforecastbillid);
+                    that.setData({
+                        list: arr
+                    })
+                    wx.showToast({
+                        title: '删除成功',
+                        icon: 'none'
+                    })
+                })
+            }
+        })
+    },
+    onShareAppMessage() {}
 })

+ 6 - 2
packageA/forecast/detail.json

@@ -1,4 +1,8 @@
 {
-    "usingComponents": {},
-    "navigationBarTitleText": "创建提报"
+    "usingComponents": {
+        "project": "./modules/project/index",
+        "van-swipe-cell": "@vant/weapp/swipe-cell/index",
+        "projectList": "./modules/projectList/index"
+    },
+    "navigationBarTitleText": "提报列表"
 }

+ 40 - 1
packageA/forecast/detail.scss

@@ -1 +1,40 @@
-/* packageA/forecast/detail.wxss */
+page {
+    overflow: hidden;
+}
+
+.total {
+    width: 100vw;
+    height: 56rpx;
+    line-height: 56rpx;
+    text-align: center;
+    font-family: PingFang SC-Regular, PingFang SC;
+    color: #999999;
+    font-size: 24rpx;
+}
+
+.slide {
+    height: 100%;
+    .but {
+        height: 100%;
+    }
+}
+
+.footer {
+    position: fixed;
+    bottom: 0;
+    width: 100vw;
+    background-color: #ffffff;
+    text-align: center;
+    padding: 20rpx 0;
+
+    .but {
+        width: 500rpx;
+        height: 90rpx;
+        background: #3874F6;
+        border-radius: 100rpx;
+        font-size: 28rpx;
+        font-family: PingFang SC-Bold, PingFang SC;
+        font-weight: bold;
+        color: #FFFFFF;
+    }
+}

+ 22 - 2
packageA/forecast/detail.wxml

@@ -1,2 +1,22 @@
-<!--packageA/forecast/detail.wxml-->
-<text>packageA/forecast/detail.wxml</text>
+<van-search id='Search' value="{{ condition }}" shape="round" background="var(--primary)" bind:search='startSearch' bind:clear='cancelSearch' placeholder="搜索" />
+<My_listBox id='ListBox' height='{{scrollHeight}}' bind:getlist='getList'>
+    <view class="total">总共{{total}}个</view>
+    <block wx:if="{{myProject}}">
+        <van-swipe-cell wx:for="{{list}}" wx:key="item.billnum" right-width="{{ 60 }}" id="swipe-cell" async-close bind:close="onClose">
+            <van-cell-group>
+                <project item="{{item}}" />
+            </van-cell-group>
+            <view slot="right" class="slide">
+                <van-button custom-class='but' color="#FF3B30" bindtap="deleteProject" data-item="{{item}}">删除</van-button>
+            </view>
+        </van-swipe-cell>
+    </block>
+    <block wx:else>
+        <project wx:for="{{list}}" item="{{item}}" wx:key="item.billnum" />
+    </block>
+    <My_empty wx:if="{{list.length==0}}" />
+</My_listBox>
+<view class="footer" wx:if="{{myProject}}">
+    <van-button custom-class='but' bindtap="addProjece">添加项目</van-button>
+</view>
+<projectList id='Plist' list='{{projectList}}' showList='{{projectList}}' bindgetResult="getResult" />

+ 20 - 1
packageA/forecast/index.js

@@ -49,7 +49,26 @@ Page({
             })
         })
     },
-
+    toDetail(e) {
+        let id = e.currentTarget.dataset.item.sa_salesforecastmodelid;
+        _Http.basic({
+            "id": 20220916134103,
+            "version": 1,
+            "content": {
+                "sa_salesforecastmodelid": id,
+                "sa_salesforecastbillid": 0,
+                "sa_projectids": []
+            }
+        }).then(res => {
+            if (res.msg != '成功') return wx.showToast({
+                title: res.data,
+                icon: "none"
+            })
+            wx.navigateTo({
+                url: `./detail?id=${res.data[0].sa_salesforecastbillid}&mId=${id}&my=true`,
+            })
+        })
+    },
     /**
      * 生命周期函数--监听页面初次渲染完成
      */

+ 1 - 1
packageA/forecast/index.wxml

@@ -11,7 +11,7 @@
             <view class="explain line-1">提报要求:{{item.baseonproject=='1'?'按项目及产品类别预测':'按产品类别预测'}}</view>
         </view>
         <view class="handle">
-            <navigator url="./detail?id={{item.sa_salesforecastmodelid}}">
+            <navigator url="#" data-item="{{item}}" bindtap="toDetail">
                 <van-icon size='24rpx' name="add-o" /> 创建/编辑提报
             </navigator>
             <navigator url="./record?id={{item.sa_salesforecastmodelid}}">

+ 26 - 0
packageA/forecast/modules/project/index.js

@@ -0,0 +1,26 @@
+// packageA/forecast/modules/projectList/index.js
+Component({
+    /**
+     * 组件的属性列表
+     */
+    properties: {
+        item: Object
+    },
+    options: {
+        addGlobalClass: true
+    },
+
+    /**
+     * 组件的初始数据
+     */
+    data: {
+
+    },
+
+    /**
+     * 组件的方法列表
+     */
+    methods: {
+
+    }
+})

+ 4 - 0
packageA/forecast/modules/project/index.json

@@ -0,0 +1,4 @@
+{
+    "component": true,
+    "usingComponents": {}
+}

+ 37 - 0
packageA/forecast/modules/project/index.scss

@@ -0,0 +1,37 @@
+.item {
+    position: relative;
+    width: 100vw;
+    height: 192rpx;
+    padding: 20rpx 30rpx;
+    background-color: #ffffff;
+    border-bottom: 1rpx solid #dddddd;
+    box-sizing: border-box;
+
+
+    .line-1 {
+        line-height: 36rpx;
+        font-size: 24rpx;
+        font-family: PingFang SC-Regular, PingFang SC;
+        font-weight: 400;
+        color: #999999;
+    }
+
+    .title {
+        max-width: 550rpx;
+        height: 40rpx;
+        line-height: 40rpx;
+        font-size: 28rpx;
+        font-family: PingFang SC-Regular, PingFang SC;
+        color: #000000;
+        margin-bottom: 6rpx;
+    }
+
+    .tag {
+        position: absolute;
+        top: 20rpx;
+        right: 30rpx;
+        height: 48rpx;
+        padding: 0 15rpx;
+        border-radius: 8rpx;
+    }
+}

+ 7 - 0
packageA/forecast/modules/project/index.wxml

@@ -0,0 +1,7 @@
+<navigator url="#" class="item">
+    <view class="title line-1">项目:{{item.projectname}}</view>
+    <view class="line-1">项目编号:{{item.projectnum}}</view>
+    <view class="line-1">项目地址:</view>
+    <view class="line-1">产品类别数量:{{item.itemcount}}</view>
+    <van-tag plain wx:if="{{item.itemcount==0}}" custom-class='tag'>未编辑</van-tag>
+</navigator>

+ 62 - 0
packageA/forecast/modules/projectList/index.js

@@ -0,0 +1,62 @@
+// packageA/modules/projectList/index.js
+Component({
+    /**
+     * 组件的属性列表
+     */
+    properties: {
+        list: Array,
+        showList: Array,
+        getResult: Function
+    },
+    options: {
+        addGlobalClass: true
+    },
+    /**
+     * 组件的初始数据
+     */
+    data: {
+        show: false,
+        result: []
+    },
+    /**
+     * 组件的方法列表
+     */
+    methods: {
+        onChange({
+            detail
+        }) {
+            this.setData({
+                result: detail
+            })
+        },
+        onClose() {
+            this.setData({
+                show: false
+            })
+        },
+        startSearch({
+            detail
+        }) {
+            if (!detail.trim()) return this.setData({
+                showList: this.data.list
+            })
+            let showList = this.data.list.filter(v => `${v.projectname},${v.projectnum},${v.address}`.includes(detail.trim()));
+            this.setData({
+                showList
+            })
+        },
+        onClear() {
+            this.setData({
+                showList: this.data.list
+            })
+        },
+        handleReturn() {
+            this.triggerEvent("getResult", this.data.result)
+
+            this.setData({
+                show: false,
+                result: []
+            })
+        }
+    }
+})

+ 9 - 0
packageA/forecast/modules/projectList/index.json

@@ -0,0 +1,9 @@
+{
+    "component": true,
+    "usingComponents": {
+        "van-checkbox": "@vant/weapp/checkbox/index",
+        "van-checkbox-group": "@vant/weapp/checkbox-group/index",
+        "van-cell": "@vant/weapp/cell/index",
+        "van-cell-group": "@vant/weapp/cell-group/index"
+    }
+}

+ 68 - 0
packageA/forecast/modules/projectList/index.scss

@@ -0,0 +1,68 @@
+.header {
+    height: 90rpx;
+    line-height: 90rpx;
+    width: 100vw;
+    text-align: center;
+    font-size: 28rpx;
+    font-family: PingFang SC-Bold, PingFang SC;
+    font-weight: bold;
+    color: #333333;
+    border-bottom: 1rpx solid #dddddd;
+    box-sizing: border-box;
+    position: fixed;
+    top: 0;
+}
+
+.checkbox {
+    height: 160rpx;
+    border-bottom: 2rpx solid #ddd;
+    box-sizing: border-box;
+    padding-left: 30rpx;
+    overflow: hidden;
+}
+
+.label-class {
+    width: 85%;
+    height: 100%;
+    margin-left: 30rpx;
+    padding-left: 0;
+}
+
+
+.label {
+    margin-top: 20rpx;
+    font-size: 28rpx;
+    font-family: PingFang SC-Regular, PingFang SC;
+    color: #000000;
+    margin-bottom: 10rpx;
+}
+
+.check-text {
+    font-size: 24rpx;
+    font-family: PingFang SC-Regular, PingFang SC;
+    color: #999999;
+}
+
+.footer {
+    position: fixed;
+    display: flex;
+    align-items: center;
+    justify-content: space-around;
+    height: 110rpx;
+    width: 100vw;
+    bottom: 0;
+    font-size: 28rpx;
+    font-family: PingFang SC-Regular, PingFang SC;
+    color: #000000;
+
+    .but {
+        width: 400rpx;
+        height: 90rpx;
+        background: #3874F6;
+        border-radius: 100rpx;
+        font-family: PingFang SC-Bold, PingFang SC;
+        font-weight: bold;
+        color: #FFFFFF;
+        line-height: 44px;
+    }
+}

+ 20 - 0
packageA/forecast/modules/projectList/index.wxml

@@ -0,0 +1,20 @@
+<van-popup show="{{ show }}" position="bottom" custom-style="height:100%;" round closeable bind:close="onClose">
+    <view class="header">选择项目</view>
+    <view style="height: 90rpx;" />
+    <van-search value="{{ value }}" shape="round" placeholder="请输入搜索关键词" bind:search='startSearch' bind:clear='onClear' />
+    <van-checkbox-group value="{{ result }}" bindchange="onChange">
+        <navigator url="#" wx:for="{{showList}}" wx:key="item.sa_projectid">
+            <van-checkbox shape="square" name="{{item.sa_projectid}}" custom-class='checkbox' icon-class='icon-class' label-class='label-class'>
+                <view class="label line-1">项目:{{item.projectname}}</view>
+                <view class="check-text line-1">项目编号:{{item.projectnum}}</view>
+                <view class="check-text line-1">项目地址:{{item.address}}</view>
+            </van-checkbox>
+        </navigator>
+    </van-checkbox-group>
+    <My_empty wx:if="{{showList.length==0}}" />
+    <view class="footer">
+        <view>已选择:{{result.length}}个</view>
+        <van-button custom-class='but' bindtap="handleReturn" disabled='{{!result.length}}'>确认添加</van-button>
+    </view>
+    <view style="height: 110rpx;" />
+</van-popup>

+ 10 - 0
packageA/forecast/record.js

@@ -28,6 +28,16 @@ Page({
         this.getList();
         this.getShowArr();
     },
+    /* 去详情 */
+    toDetail(e) {
+        console.log(e)
+        const {
+            item
+        } = e.currentTarget.dataset;
+        wx.navigateTo({
+            url: './detail?id=' + item.sa_salesforecastbillid,
+        })
+    },
     /* 开始搜索 */
     startSearch({
         detail

+ 5 - 5
packageA/forecast/record.wxml

@@ -6,11 +6,9 @@
     </view>
 </view>
 
-<view class="total">
-    总共{{total}}个
-</view>
+<view class="total">总共{{total}}个</view>
 
-<navigator url="#" class="list-box" wx:for="{{list}}">
+<navigator url="#" class="list-box" wx:for="{{list}}" bindtap="toDetail" data-item="{{item}}">
     <view class="circle">{{item.name[0]}}</view>
     <view class="content">
         <view class="title">
@@ -22,4 +20,6 @@
     <view class="right">
         <van-icon name="arrow" color='#CCCCCC' />
     </view>
-</navigator>
+</navigator>
+
+<My_empty wx:if="{{list.length==0}}" />