zhaoxiaohai vor 2 Jahren
Ursprung
Commit
119898d212

+ 10 - 0
packageA/forecast/detail.js

@@ -166,5 +166,15 @@ Page({
             }
         })
     },
+    toReportForms(e) {
+        const {
+            item
+        } = e.currentTarget.dataset;
+        let isEdit = this.data.myProject;
+        item.sa_salesforecastmodelid = this.data.sa_salesforecastmodelid;
+        wx.navigateTo({
+            url: `./reportForms?item=${JSON.stringify(item)}&isEdit=${isEdit}`,
+        })
+    },
     onShareAppMessage() {}
 })

+ 2 - 2
packageA/forecast/detail.wxml

@@ -4,7 +4,7 @@
     <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}}" />
+                <project item="{{item}}" data-item="{{item}}" catchtap="toReportForms" />
             </van-cell-group>
             <view slot="right" class="slide">
                 <van-button custom-class='but' color="#FF3B30" bindtap="deleteProject" data-item="{{item}}">删除</van-button>
@@ -12,7 +12,7 @@
         </van-swipe-cell>
     </block>
     <block wx:else>
-        <project wx:for="{{list}}" item="{{item}}" wx:key="item.billnum" />
+        <project wx:for="{{list}}" item="{{item}}" data-item="{{item}}" wx:key="item.billnum" bindtap="toReportForms" />
     </block>
     <My_empty wx:if="{{list.length==0}}" />
 </My_listBox>

+ 35 - 0
packageA/forecast/modules/product/index.js

@@ -0,0 +1,35 @@
+Component({
+    properties: {
+        list: Array,
+        getResult: Function,
+        result: Array
+    },
+    options: {
+        addGlobalClass: true
+    },
+    data: {
+        show: false
+    },
+    methods: {
+        onChange({
+            detail
+        }) {
+            this.setData({
+                result: detail
+            })
+        },
+        onClose() {
+            this.setData({
+                show: false
+            })
+        },
+        handleReturn() {
+            if (!this.data.result.length) return;
+            this.triggerEvent("getResult", this.data.result)
+            this.setData({
+                show: false,
+                result: []
+            })
+        }
+    }
+})

+ 9 - 0
packageA/forecast/modules/product/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"
+    }
+}

+ 58 - 0
packageA/forecast/modules/product/index.scss

@@ -0,0 +1,58 @@
+.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: 80rpx;
+    border-bottom: 2rpx solid #ddd;
+    box-sizing: border-box;
+    padding-left: 30rpx;
+    overflow: hidden;
+}
+
+.label-class {
+    width: 85%;
+    line-height: 80rpx;
+    margin-left: 30rpx;
+    padding-left: 0;
+    font-size: 28rpx;
+    font-family: PingFang SC-Regular, PingFang SC;
+    color: #000000;
+}
+
+
+
+.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;
+    }
+}

+ 17 - 0
packageA/forecast/modules/product/index.wxml

@@ -0,0 +1,17 @@
+<van-popup show="{{ show }}" position="bottom" custom-style="height:100%;" round closeable bind:close="onClose">
+    <view class="header">选择产品类别</view>
+    <view style="height: 90rpx;" />
+    <van-checkbox-group value="{{ result }}" bindchange="onChange">
+        <navigator url="#" wx:for="{{list}}" wx:key="item.itemclassnum">
+            <van-checkbox shape="square" name="{{item.itemclassnum}}" custom-class='checkbox' icon-class='icon-class' label-class='label-class'>
+                <view class="label">{{item.itemclassname}}</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>

+ 1 - 1
packageA/forecast/modules/projectList/index.js

@@ -51,8 +51,8 @@ Component({
             })
         },
         handleReturn() {
+            if (!this.data.result.length) return;
             this.triggerEvent("getResult", this.data.result)
-
             this.setData({
                 show: false,
                 result: []

+ 204 - 0
packageA/forecast/reportForms.js

@@ -0,0 +1,204 @@
+const _Http = getApp().globalData.http;
+Page({
+    data: {
+        sourceData: null,
+        isEdit: null,
+        ProductList: null,
+        disabled: false,
+        loading: false
+    },
+
+    onLoad(options) {
+        this.setData({
+            sourceData: JSON.parse(options.item),
+            isEdit: options.isEdit == 'true'
+        })
+        wx.setNavigationBarTitle({
+            title: options.isEdit == 'true' ? '预测报表' : '预测填报',
+        })
+        this.getList();
+        this.getProductList();
+    },
+    /* 提交 */
+    submit() {
+        if (this.data.disabled && this.data.loading) return;
+        this.setData({
+            loading: true
+        })
+        _Http.basic({
+            "id": 20220906155003,
+            "version": 1,
+            "content": {
+                "sa_salesforecastmodelid": this.data.sourceData.sa_salesforecastmodelid,
+                "sa_salesforecastbillid": this.data.sourceData.sa_salesforecastbillid,
+                "sa_projectid": this.data.sourceData.sa_projectid,
+                "itemclassinfos": this.data.list
+            }
+        }).then(res => {
+            this.setData({
+                loading: false
+            })
+            wx.showToast({
+                title: res.data,
+                icon: "none"
+            })
+        })
+    },
+    /* 获取列表 */
+    getList() {
+        _Http.basic({
+            "id": 20220906154703,
+            "version": 1,
+            "content": {
+                "nocheca": true,
+                "sa_salesforecastbillid": this.data.sourceData.sa_salesforecastbillid,
+                'pageSize': 9999,
+                "where": {
+                    "condition": ""
+                }
+            }
+        }).then(res => {
+            console.log("详情列表", res)
+            if (res.msg != '成功') return wx.showToast({
+                title: res.data,
+                icon: "none"
+            })
+            for (let i = 0; i < res.data.length; i++) {
+                res.data[i].complete = true
+            }
+            this.setData({
+                list: res.data
+            });
+        })
+    },
+    /* 获取产品列表 */
+    getProductList() {
+        _Http.basic({
+            "id": 20220906154903,
+            "version": 1,
+            "content": {}
+        }).then(res => {
+            console.log("产品列表", res)
+            if (res.msg != '成功') return wx.showToast({
+                title: res.data,
+                icon: "none"
+            })
+            this.setData({
+                ProductList: res.data
+            })
+        })
+    },
+    /* 打开添加产品 */
+    addProduct() {
+        let list = this.data.ProductList.filter(v => !this.data.list.some(value => value.itemclassnum == v.itemclassnum))
+        this.selectComponent('#Product').setData({
+            show: true,
+            list
+        })
+    },
+    /* 得到添加产品 */
+    getResult({
+        detail
+    }) {
+        const list = detail.map(v => {
+            const data = this.data.ProductList.find(value => value.itemclassnum == v);
+            return {
+                "sa_salesforecastid": 0,
+                "itemclassnum": data.itemclassnum,
+                "itemclassname": data.itemclassname,
+                "orderqty": 0,
+                "orderamount": 0,
+                "invoiceqty": 0,
+                "invoiceamount": 0,
+                "outqty": 0,
+                "outamount": 0,
+                "complete": false
+            }
+        })
+        this.setData({
+            list: list.concat(this.data.list)
+        });
+        wx.pageScrollTo({
+            scrollTop: 0,
+        })
+        this.isDisabled();
+    },
+    /* 输入框改变 */
+    inputChange(e) {
+        const {
+            index,
+            name
+        } = e.currentTarget.dataset,
+            value = e.detail.value.trim();
+        this.setData({
+            [`list[${index}].${name}`]: value
+        })
+        if (['orderamount', 'outamount', 'invoiceamount'].includes(name)) {
+            const data = this.data.list[index];
+            this.setData({
+                [`list[${index}].complete`]: data.orderamount != "" && data.outamount != "" && data.invoiceamount != ""
+            })
+        };
+        this.isDisabled();
+    },
+    /* 删除产品 */
+    deleteProduct(e) {
+        const {
+            item
+        } = e.currentTarget.dataset,
+            that = this;
+        wx.showModal({
+            title: "提示",
+            content: `是否确认删除${item.itemclassname}`,
+            success({
+                confirm
+            }) {
+                if (confirm) {
+                    if (item.sa_salesforecastid == 0) {
+                        that.setData({
+                            list: that.data.list.filter(v => v.itemclassnum != item.itemclassnum)
+                        })
+                        wx.showToast({
+                            title: '删除成功',
+                            icon: "none"
+                        })
+                        that.isDisabled();
+                    } else {
+                        _Http.basic({
+                            "id": 20220906155103,
+                            "version": 1,
+                            "content": {
+                                "sa_salesforecastid": item.sa_salesforecastid,
+                                "sa_projectid": item.sa_projectid,
+                                "sa_salesforecastbillid": item.sa_salesforecastbillid
+                            }
+                        }).then(res => {
+                            if (res.msg != '成功') return wx.showToast({
+                                title: res.data,
+                                icon: "none"
+                            });
+                            wx.showToast({
+                                title: '删除成功',
+                                icon: "none"
+                            })
+                            that.setData({
+                                list: that.data.list.filter(v => v.itemclassnum != item.itemclassnum)
+                            })
+                            that.isDisabled();
+                        })
+                    }
+                }
+            }
+        })
+    },
+    /* 判断是否禁用保存按钮 */
+    isDisabled() {
+        console.log(123)
+        let count = 0;
+        this.data.list.forEach(v => v.complete ? count += 1 : '')
+        this.setData({
+            disabled: !(count == this.data.list.length)
+        })
+    },
+    onShareAppMessage() {}
+})

+ 6 - 0
packageA/forecast/reportForms.json

@@ -0,0 +1,6 @@
+{
+    "usingComponents": {
+        "van-sticky": "@vant/weapp/sticky/index",
+        "product": "./modules/product/index"
+    }
+}

+ 120 - 0
packageA/forecast/reportForms.scss

@@ -0,0 +1,120 @@
+.head {
+    width: 100vw;
+    height: 158rpx;
+    background-color: #ffffff;
+    padding: 20rpx 30rpx;
+    box-sizing: border-box;
+    border-bottom: 1px solid #ddd;
+    font-size: 24rpx;
+    font-family: PingFang SC-Regular, PingFang SC;
+    color: #999999;
+
+    .title {
+        font-size: 28rpx;
+        font-family: PingFang SC-Regular, PingFang SC;
+        color: #000000;
+        margin-bottom: 15rpx;
+    }
+}
+
+.nav {
+    width: 100vw;
+    height: 80rpx;
+    display: flex;
+    align-items: center;
+    justify-content: space-between;
+    box-sizing: border-box;
+    padding: 0 30rpx;
+    font-size: 28rpx;
+    font-family: PingFang SC-Regular, PingFang SC;
+    color: #000000;
+}
+
+.item {
+    width: 100vw;
+    padding: 20rpx 30rpx;
+    box-sizing: border-box;
+    margin-bottom: 20rpx;
+    background-color: #fff;
+
+    .title {
+        display: flex;
+        justify-content: space-between;
+        width: 100%;
+        height: 42rpx;
+        font-size: 30rpx;
+        font-family: PingFang SC-Bold, PingFang SC;
+        font-weight: bold;
+        color: #000000;
+
+        text {
+            text-align: right;
+            display: block;
+            width: 80rpx;
+            height: 100%;
+        }
+    }
+
+    .group {
+        display: flex;
+        flex-wrap: wrap;
+        /* justify-content: space-between; */
+        font-size: 24rpx;
+        font-family: PingFang SC-Regular, PingFang SC;
+        color: #666666;
+
+        >view {
+            text {
+                color: red;
+                margin-right: 8rpx;
+            }
+
+            width: 33.33%;
+            margin-top: 20rpx;
+
+            input {
+                width: 216rpx;
+                height: 90rpx;
+                box-sizing: border-box;
+                margin-top: 12rpx;
+                border: 1px solid #BBBBBB;
+                border-radius: 16rpx;
+                font-size: 28rpx;
+                text-align: center;
+            }
+        }
+    }
+}
+
+.footer {
+    position: fixed;
+    bottom: 0;
+    display: flex;
+    align-items: center;
+    justify-content: space-between;
+    padding: 0 30rpx;
+    box-sizing: border-box;
+    width: 100vw;
+    height: 130rpx;
+    background-color: #ffffff;
+    z-index: 8;
+
+    .change {
+        width: 460rpx;
+        height: 90rpx;
+        background: #FA8C16;
+        border-radius: 100rpx;
+        font-size: 28rpx;
+        font-family: PingFang SC-Bold, PingFang SC;
+        font-weight: bold;
+        color: #FFFFFF;
+    }
+
+    .add {
+        font-size: 28rpx;
+        font-family: PingFang SC-Bold, PingFang SC;
+        font-weight: bold;
+        color: #999999;
+        line-height: 44px;
+    }
+}

+ 51 - 0
packageA/forecast/reportForms.wxml

@@ -0,0 +1,51 @@
+<van-sticky>
+    <view class="head">
+        <view class="title line-1">项目:{{sourceData.projectname}}</view>
+        <view class="line-1">项目编号:{{sourceData.projectnum}}</view>
+        <view class="line-1">项目地址:{{sourceData.address}}</view>
+    </view>
+</van-sticky>
+<view class="nav">
+    <text>产品类别</text>
+    <text>共{{list.length}}个</text>
+</view>
+<view class="item" wx:for="{{list}}" wx:key="item.itemclassnum">
+    <view class="title">
+        <view>{{item.itemclassname}}</view>
+        <text wx:if="{{isEdit}}" class="iconfont icon-shanchu" style="color: #999999;" catchtap='deleteProduct' data-item="{{item}}" />
+    </view>
+    <view class="group">
+        <view>
+            <view class="label"><text>*</text>订单金额(万元):</view>
+            <input type="digit" data-index="{{index}}" disabled="{{!isEdit}}" data-name="orderamount" bindinput='inputChange' value="{{item.orderamount}}" />
+        </view>
+        <view>
+            <view class="label"><text>*</text>出货金额(万元):</view>
+            <input type="digit" data-index="{{index}}" disabled="{{!isEdit}}" data-name="outamount" bindinput='inputChange' value="{{item.outamount}}" />
+        </view>
+        <view>
+            <view class="label"><text>*</text>开票金额(万元):</view>
+            <input type="digit" data-index="{{index}}" disabled="{{!isEdit}}" data-name="invoiceamount" bindinput='inputChange' value="{{item.invoiceamount}}" />
+        </view>
+        <view>
+            <view class="label">订货数量(个):</view>
+            <input type="digit" data-index="{{index}}" disabled="{{!isEdit}}" data-name="orderqty" bindinput='inputChange' value="{{item.orderqty}}" />
+        </view>
+        <view>
+            <view class="label">出货数量(个):</view>
+            <input type="digit" data-index="{{index}}" disabled="{{!isEdit}}" data-name="outqty" bindinput='inputChange' value="{{item.outqty}}" />
+        </view>
+        <view>
+            <view class="label">开票数量(个):</view>
+            <input type="digit" data-index="{{index}}" disabled="{{!isEdit}}" data-name="invoiceqty" bindinput='inputChange' value="{{item.invoiceqty}}" />
+        </view>
+    </view>
+</view>
+
+<view class="footer" wx:if="{{isEdit}}">
+    <van-button type="default" plain round custom-class='add' bindtap="addProduct">添加产品</van-button>
+    <van-button custom-class='change' disabled="{{disabled}}" bindtap="submit" loading='{{loading}}' loading-text="保存中...">保存</van-button>
+</view>
+
+<product id='Product' bindgetResult='getResult' />
+<view style="height: 130rpx;" />