zhaoxiaohai 3 лет назад
Родитель
Сommit
488266e608

+ 56 - 1
packageA/salesForecasting/detail.js

@@ -22,6 +22,9 @@ Page({
         tabbarList: [{
             icon: "icon-genjin",
             label: "跟进"
+        }, {
+            icon: "icon-guanlian-bianji",
+            label: "添加项目"
         }, {
             icon: "icon-shanchu",
             label: "作废"
@@ -157,6 +160,41 @@ Page({
     onReachBottom() {
         this.partialRenewal();
     },
+    /* 添加项目 */
+    handleSelectProject(sa_projectids) {
+        let that = this;
+        wx.showModal({
+            title: '提示',
+            content: `是否确认添加项目`,
+            complete: ({
+                confirm
+            }) => {
+                if (confirm) _Http.basic({
+                    "id": 20220913154403,
+                    "version": 1,
+                    "content": {
+                        "sa_salesforecastmodelid": that.data.detail.sa_salesforecastmodelid,
+                        "sa_salesforecastbillid": that.data.sa_salesforecastbillid,
+                        sa_projectids
+                    }
+                }).then(res => {
+                    console.log("添加项目", res)
+                    wx.showToast({
+                        title: res.msg == '成功' ? '添加成功' : res.msg,
+                        icon: "none"
+                    });
+                    wx.navigateBack();
+                    if (res.msg != '成功') return;
+                    that.setData({
+                        tabsActive: that.data.tabsList.findIndex(v => v.label == '项目产品清单')
+                    });
+                    setTimeout(() => {
+                        that.selectComponent('#Project').getList(that.data.sa_salesforecastbillid);
+                    }, 300)
+                })
+            }
+        })
+    },
     //详情按钮回调
     tabbarOnClick({
         detail
@@ -165,7 +203,24 @@ Page({
         switch (detail.label) {
             case "跟进":
                 wx.navigateTo({
-                    url: `/packageA/setclient/modules/trace/add/index?ownertable=sa_salesforecastbill&ownerid=${data.sa_salesforecastbillid}`,
+                    url: `/packageA/setclient/modules/trace/add/index?ownertable=sa_salesforecastbill&ownerid=${this.data.sa_salesforecastbillid}`,
+                })
+                break;
+            case "添加项目":
+                wx.navigateTo({
+                    url: `/packageA/select/project/select?params=${JSON.stringify({
+                            "id": 20220906154803,
+                            "version":1,
+                            "content": {
+                                nocache:true,
+                                "sa_salesforecastbillid":this.data.sa_salesforecastbillid,
+                                pageNumber:1,
+                                pageTotal:1,
+                                "where":{
+                                    "condition":""
+                                }
+                            }
+                    })}`,
                 })
                 break;
             case "作废":

+ 4 - 5
packageA/salesForecasting/modules/project/index.js

@@ -1,6 +1,7 @@
 const _Http = getApp().globalData.http;
 Component({
     data: {
+        viewIndex: 0,
         sa_salesforecastbillid: 0,
         "content": {
             nocache: true,
@@ -48,9 +49,6 @@ Component({
                 })
                 this.setData({
                     list: res.pageNumber == 1 ? res.data : this.data.list.concat(res.data),
-                    "content.pageNumber": res.pageNumber + 1,
-                    "content.pageSize": res.pageSize,
-                    "content.pageTotal": res.pageTotal,
                     "content.total": res.total,
                     sa_salesforecastbillid: id
                 });
@@ -59,7 +57,7 @@ Component({
                         'param.content.where.sa_projectid': res.data[0].sa_projectid,
                         'param.content.sa_salesforecastbillid': id,
                     })
-                    this.getProduct();
+                    this.getProduct(true);
                 }
             })
         },
@@ -84,7 +82,8 @@ Component({
         /* 切换tab */
         onChange(e) {
             this.setData({
-                sa_projectid: e.detail.name
+                sa_projectid: e.detail.name,
+                viewIndex: e.detail.index,
             });
             this.getProduct(true);
         }

+ 5 - 4
packageA/salesForecasting/modules/project/index.scss

@@ -1,10 +1,11 @@
 @import "../../../setclient/modules/address/head.scss";
 
-.count{
-    font-size: 30rpx !important;
+.head .count {
+    font-size: 24rpx;
+    color: #666;
 }
 
-.tabs {
+/* .tabs {
     background-color: #F4F5F7 !important;
     background: #F4F5F7 !important;
-}
+} */

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

@@ -2,7 +2,7 @@
     <van-tab title="{{item.projectname}}" wx:for="{{list}}" wx:key="index" name='{{item.sa_projectid}}' />
 </van-tabs>
 <view class="head">
-    <view class="count"><text wx:if="{{list.length==1}}" style="margin-right: 15rpx;">{{list[0].projectname}}</text>金额:<text style="color: #FF3B30;">¥99999999</text></view>
+    <view class="count"><text style="margin-right: 15rpx; font-size: 30rpx;font-weight: 600; color: #333;">{{list[viewIndex].projectname}}</text>预测金额:<text style="color: #FF3B30;">¥99999999</text></view>
     <view class="expand">
         <navigator url="#" class="but" bindtap="addProduct">
             <van-icon name="plus" />

+ 80 - 4
packageA/salesForecasting/modules/project/list/index.js

@@ -1,11 +1,87 @@
 Component({
     properties: {
-        list: Array
+        list: Array,
+        deleteItem: Function,
+        changeQueue: Function, //修改队列
+        disabled: Boolean
     },
-    data: {
-
+    options: {
+        addGlobalClass: true
     },
     methods: {
-
+        onBlur(e) {
+            let {
+                index,
+                name
+            } = e.currentTarget.dataset,
+                detail = name == 'outqty' ? e.detail.value - 0 : (e.detail.value - 0).toFixed(2),
+                item = this.data.list[index];
+            switch (name) {
+                case "outqty":
+                    item.outqty = detail;
+                    //改变数量 现数量*现价
+                    item.outamount = (item.price * item.outqty).toFixed(2);
+                    break;
+                case "discountrate":
+                    if (detail >= 100) {
+                        item.discountrate = 100
+                    } else if (detail <= 0) {
+                        item.discountrate = 1
+                    } else {
+                        item.discountrate = detail;
+                    }
+                    //改变折扣 重新计算现价和总价
+                    item.price = (item.marketprice * (item.discountrate / 100) - 0).toFixed(2);
+                    item.outamount = (item.price * item.outqty).toFixed(2);
+                    console.log(item.price)
+                    break;
+                case "price":
+                    if (detail >= item.marketprice) {
+                        item.price = item.marketprice
+                    } else if (detail <= 0) {
+                        item.discountrate = 1;
+                        item.price = (item.marketprice * (item.discountrate / 100) - 0).toFixed(2);
+                    } else {
+                        item.price = detail;
+                    }
+                    //改变现价 重新计算总价和折扣
+                    item.outamount = (item.price * item.outqty).toFixed(2);
+                    item.discountrate = this.getPercent(item.price, item.marketprice).toFixed(2);
+                    break;
+            }
+            this.setData({
+                [`list[${index}]`]: item
+            })
+            let obj = {};
+            ["sa_quotedprice_itemsid", "itemid", "oldprice", "price", "discountrate", "outqty"].forEach(v => obj[v] = item[v]);
+            obj.discountrate = (obj.discountrate / 100).toFixed(4);
+            if (name != 'outqty') obj.price = 0;
+            this.triggerEvent("changeQueue", obj)
+        },
+        /* 计算百分比 */
+        getPercent(num, total) {
+            num = parseFloat(num);
+            total = parseFloat(total);
+            if (isNaN(num) || isNaN(total)) {
+                return "-";
+            }
+            return total <= 0 ? "0%" : Math.round((num / total) * 10000) / 100;
+        },
+        deleteProduct(e) {
+            const {
+                sa_quotedprice_itemsid,
+                itemname
+            } = e.currentTarget.dataset.item,
+                that = this;
+            wx.showModal({
+                title: '提示',
+                content: `是否确认删除“${itemname}”?`,
+                complete: ({
+                    confirm
+                }) => {
+                    if (confirm) that.triggerEvent("deleteItem", [sa_quotedprice_itemsid]);
+                }
+            })
+        },
     }
 })

+ 125 - 0
packageA/salesForecasting/modules/project/list/index.scss

@@ -0,0 +1,125 @@
+.product-item {
+    background-color: #fff;
+    box-sizing: border-box;
+    border-bottom: 1rpx solid #DDDDDD;
+    margin-bottom: 20rpx;
+
+    .product {
+        padding: 20rpx 30rpx;
+        box-sizing: border-box;
+
+        .mian {
+            position: relative;
+            display: flex;
+            width: 100%;
+            box-sizing: border-box;
+
+            .img {
+                flex-shrink: 0;
+                width: 112rpx;
+                height: 112rpx;
+                border-radius: 16rpx;
+                margin-right: 20rpx;
+                overflow: hidden;
+            }
+
+            .dec {
+                flex: 1;
+                width: 0;
+                min-height: 128rpx;
+                height: 100%;
+                font-size: 24rpx;
+                font-family: PingFang SC-Regular, PingFang SC;
+                color: #999999;
+
+                .title {
+                    width: 90%;
+                    height: 40rpx;
+                    font-size: 28rpx;
+                    font-weight: 600;
+                    color: #333333;
+                }
+
+                .subfield {
+                    display: flex;
+                    margin-top: 8rpx;
+                    height: 34rpx;
+                    line-height: 34rpx;
+
+                    text {
+                        display: inline-block;
+                        width: 48%;
+                    }
+                }
+
+            }
+
+            .delete {
+                position: absolute;
+                width: 68rpx;
+                height: 68rpx;
+                line-height: 68rpx;
+                right: -30rpx;
+                top: -20rpx;
+                text-align: center;
+                font-size: 32rpx;
+                color: #999;
+            }
+        }
+    }
+
+    .bot {
+        width: 690rpx;
+        height: 100rpx;
+        border-top: 1rpx solid #ddd;
+        margin: 0 auto;
+
+        .row {
+            display: flex;
+            width: 100%;
+            margin-top: 20rpx;
+
+            view {
+                display: flex;
+                height: 58rpx;
+                align-items: center;
+
+                .label {
+                    width: 144rpx;
+                    font-size: 24rpx;
+                    font-family: PingFang SC-Regular, PingFang SC;
+                    color: #666666;
+                    text-align-last: justify;
+                }
+            }
+
+            .input {
+                height: 58rpx;
+                background: #FFFFFF;
+                border-radius: 8rpx;
+                border: 1rpx solid #CCCCCC;
+                font-size: 28rpx;
+                font-family: PingFang SC-Regular, PingFang SC;
+                color: #333333;
+                line-height: 44px;
+                text-align: center;
+            }
+
+            .money {
+                flex: 1;
+                display: flex;
+                font-size: 24rpx;
+                font-family: PingFang SC-Medium, PingFang SC;
+                color: #666666;
+                justify-content: flex-end;
+                margin-right: 20rpx;
+
+                text {
+                    font-size: 28rpx;
+                    color: #FF3B30;
+                    font-weight: 600;
+                }
+            }
+        }
+    }
+}

+ 46 - 3
packageA/salesForecasting/modules/project/list/index.wxml

@@ -1,3 +1,46 @@
-<view wx:for="{{list}}">
-    {{index}}
-</view>
+<view class="product-item" wx:for="{{list}}" wx:key="item.sa_quotedprice_itemsid">
+    <navigator class="product" url="#">
+        <view class="mian">
+            <view class="img" data-file="{{item.attinfos}}" catchtap="viewImage">
+                <van-image width="100%" height="100%" src="{{item.cover}}" use-loading-slot use-error-slot lazy-load>
+                    <van-loading slot="loading" type="spinner" size="20" vertical />
+                    <text slot="error" style="font-size: 24rpx;">暂无图片</text>
+                </van-image>
+            </view>
+            <view class="dec">
+                <view class="title line-1">
+                    {{item.itemname}}
+                </view>
+                <view class="subfield">
+                    编号:{{item.itemno}}
+                </view>
+                <view class="subfield">
+                    <text class="line-1" style="margin-right: 6rpx;">品牌:{{item.brandName}}</text>
+                    <text class="line-1">产品类别:{{item.className}}</text>
+                </view>
+                <view class="subfield">
+                    <text class="line-1" style="margin-right: 6rpx;">规格:{{item.spec||' --'}}</text>
+                    <text class="line-1">型号:{{item.model||' --'}}</text>
+                </view>
+                <view class="subfield">
+                    <text class="line-1" style="margin-right: 6rpx;">牌价:{{item.marketprice||' --'}}</text>
+                </view>
+            </view>
+            <view class="delete" data-item="{{item}}" catchtap="deleteProduct">
+                <text class="iconfont icon-guanlian-shanchu" />
+            </view>
+        </view>
+    </navigator>
+    <view class="bot">
+        <view class="row">
+            <view style="margin-right: 40rpx;">
+                <view class="label">数量({{item.unitname}}):</view>
+                <input class="input" style="width: 180rpx;" type="digit" disabled="{{disabled}}" value="{{item.outqty}}" data-name="outqty" data-index="{{index}}" bindblur="onBlur" />
+            </view>
+            <view class="money">
+                金额:<text>¥{{item.outamount}}</text>
+            </view>
+        </view>
+    </view>
+</view>
+<My_empty wx:if="{{list.length==0}}" />

+ 1 - 1
packageA/select/project/select.js

@@ -2,7 +2,7 @@ const _Http = getApp().globalData.http,
     getHeight = require("../../../utils/getRheRemainingHeight");
 Page({
     data: {
-        item: {},
+        item: null,
         result: [],
         params: {},
         radio: false,

+ 1 - 1
packageA/select/project/select.wxml

@@ -14,7 +14,7 @@
                 <view class="exp line-1">
                     项目编号:{{item.projectnum}}
                 </view>
-                <view class="exp line-1" wx:if="{{item.province}}">
+                <view class="exp line-1">
                     项目地址:{{item.province+item.city+item.county+item.address}}
                 </view>
             </view>