Browse Source

调整 调整套数的逻辑

xiaohaizhao 11 months ago
parent
commit
b9742de846

+ 39 - 14
packageA/activity/bindingProduct/index.js

@@ -25,10 +25,10 @@ Page({
     searchList: [],
     dialogShow: false,
     submitQty: 1,
+    packagetypemxrows: [],
     modification: false, //是否为修改套餐数量
   },
   onLoad(options) {
-    console.log(options)
     if (options.params) {
       let params = JSON.parse(options.params);
       if (!params.content.pageNumber || !params.content.pageTotal) {
@@ -49,13 +49,32 @@ Page({
         })
         let packageList = []
         try {
-          packageList = res.data.find(v => v.value == params.content.packagetype).subvalues
-        } catch (error) {}
+          let packagetypemxrows = [];
+
+          if (options.packagetypemxrows) {
+            this.data.packagetypemxrows = JSON.parse(options.packagetypemxrows);
+            packagetypemxrows = this.data.packagetypemxrows.map(v => v.packagetypemx);
+          }
+          packageList = res.data.find(v => v.value == params.content.packagetype).subvalues;
+          if (packagetypemxrows.length != 0) {
+            if (options.butText == '调整套数') {
+              packageList = packagetypemxrows
+              this.setData({
+                "submitQty": this.data.packagetypemxrows[0].packagetypeqty
+              })
+            } else {
+              packageList = packageList.filter(v => !packagetypemxrows.includes(v))
+            }
+          }
+        } catch (error) {
+          console.error("error", error)
+        }
         let getListPa = "";
         if (options.getListPa) {
           getListPa = JSON.parse(options.getListPa);
           getListPa.content.pageNumber = 1;
           getListPa.content.pageSize = 9999;
+          getListPa.content.onlyquery = 1;
           getListPa.content.where = {
             packagetypemx: ''
           }
@@ -114,21 +133,22 @@ Page({
     }.bind(this)
   },
   async getList(init = false) {
-    wx.showLoading({
-      title: '加载中...',
-      mask: true
-    })
     //init 用于初始化分页
     if (init.detail != undefined) init = init.detail;
     let params = this.data.params;
     if (init) params.content.pageNumber = 1
     params.content.pageSize = 9999;
     if (params.content.pageNumber > params.content.pageTotal) return;
-
     let res = {},
-      submitQty = 1,
       CompleteCustomization = false,
       modification = false;
+    if (params.content.where.packagetypemx == '') return this.setData({
+      loading: false
+    })
+    wx.showLoading({
+      title: '加载中...',
+      mask: true
+    })
     if (this.data.getListPa) {
       this.data.getListPa.content.where.packagetypemx = params.content.where.packagetypemx;
       res = await _Http.basic(this.data.getListPa);
@@ -156,8 +176,6 @@ Page({
     }).format();
     let newPrice = this.data.newPrice,
       oldPrice = this.data.oldPrice;
-
-    if (res.data.length) submitQty = res.data[0].qty ? res.data[0].qty / res.data[0].orderminqty : 1;
     res.data = res.data.map(value => {
       if (value.attinfos.length != 0) {
         value.attinfos = file.fileList(value.attinfos)
@@ -187,7 +205,6 @@ Page({
       'params.content.pageNumber': res.pageNumber + 1,
       'params.content.pageTotal': res.pageTotal,
       'params.content.total': res.total,
-      submitQty,
       modification,
       list: res.pageNumber == 1 ? res.data : this.data.list.concat(res.data),
       loading: false
@@ -198,6 +215,13 @@ Page({
     this.setData({
       "params.content.where.packagetypemx": e.detail.name
     })
+    try {
+      this.setData({
+        "submitQty": this.data.packagetypemxrows.find(v => v.packagetypemx == e.detail.name).packagetypeqty || 1
+      })
+    } catch (error) {
+
+    }
     this.getList(true)
   },
   changeQtySte({
@@ -231,7 +255,7 @@ Page({
       })
     }
 
-    if (this.data.modification) {
+    /* if (this.data.modification) {
       wx.showModal({
         title: '提示',
         content: '您已添加过此套餐,是否需要重新调整套数?',
@@ -245,7 +269,8 @@ Page({
       })
     } else {
       handle()
-    }
+    } */
+    handle()
 
     function handle() {
       that.setData({

+ 1 - 1
packageA/activity/bindingProduct/index.wxml

@@ -2,7 +2,7 @@
 <template is="skeleton" wx:if="{{loading}}" />
 
 <van-search class="search" value="{{ condition }}" shape="round" placeholder="请输入搜索关键词" bind:search='startSearch' bind:clear='onClear' />
-<van-tabs wx:if="{{packageList.length>1}}" active="{{ params.content.where.packagetypemx }}" color='var(--assist)' title-active-color='var(--assist)' bind:change="tabsChange">
+<van-tabs wx:if="{{packageList.length}}" active="{{ params.content.where.packagetypemx }}" color='var(--assist)' title-active-color='var(--assist)' bind:change="tabsChange">
 	<van-tab wx:for="{{packageList}}" wx:key="index" title="{{item}}" name='{{item}}' />
 </van-tabs>
 <custom id="Custom" isOldPrice='{{true}}' />

+ 1 - 1
packageA/orderForm/detail.wxml

@@ -65,7 +65,7 @@
 </view>
 <view style="height: 20rpx;" />
 <Yl_FunTabs list='{{tabsList}}' active='{{tabsActive}}' bind:onChenge="tabsChange">
-    <Product slot='产品明细' privacyFieldC='{{privacyFieldC}}' id='Product' disabled="{{detail.status!='新建'}}" packagetype='{{detail.packagetype}}' sa_order_v='{{detail.sa_order_v}}' bind:returnProductCount='getProductCount' />
+    <Product slot='产品明细' privacyFieldC='{{privacyFieldC}}' packagetypemxrows="{{detail.packagetypemxrows}}" id='Product' disabled="{{detail.status!='新建'}}" packagetype='{{detail.packagetype}}' sa_order_v='{{detail.sa_order_v}}' bind:returnProductCount='getProductCount' />
     <Yl_Attachment slot='附件' id='Yl_Attachment' ownertable="sa_order" ownerid="{{detail.sa_orderid}}" disabled="{{detail.status!='新建'}}" />
     <Progress slot='订单进度' id='Progress' hidePrice='{{hidePrice.hidePrice("订单进度",privacyFieldC)}}' />
     <Consignment slot='出库单' id='Consignment' />

+ 27 - 1
packageA/orderForm/modules/product/index.js

@@ -26,6 +26,10 @@ Component({
         packagetype: {
             type: String
         },
+        packagetypemxrows: {
+            type: Array,
+            value: []
+        }
     },
     data: {
         content: {
@@ -177,7 +181,7 @@ Component({
                                 packagetypemx: "",
                             }
                         }
-                    }) + "&butText=添加套餐&getListPa=" + JSON.stringify({
+                    }) + `&butText=添加套餐&packagetypemxrows=${JSON.stringify(this.data.packagetypemxrows)}&getListPa=` + JSON.stringify({
                         "id": "20221109093902",
                         content: this.data.content
                     }),
@@ -219,6 +223,28 @@ Component({
             }
 
         },
+        /* 去修改 */
+        editProduct() {
+            wx.navigateTo({
+                url: '/packageA/activity/bindingProduct/index?params=' + JSON.stringify({
+                    "id": 20230107182302,
+                    "version": 1,
+                    "content": {
+                        nocache: true,
+                        sa_orderid, //订单ID
+                        packagetype: this.data.packagetype,
+                        "where": {
+                            "condition": "",
+                            packagetypemx: "",
+                        }
+                    }
+                }) + `&butText=调整套数&packagetypemxrows=${JSON.stringify(this.data.packagetypemxrows)}&getListPa=` + JSON.stringify({
+                    "id": "20221109093902",
+                    content: this.data.content
+                }),
+            });
+            getApp().globalData.handleSelect = this.handleInsert.bind(this);
+        },
         /* 处理新增产品 */
         handleSelect(detail) {
             let that = this;

+ 5 - 2
packageA/orderForm/modules/product/index.wxml

@@ -1,7 +1,10 @@
 <view class="head">
   <view class="count">产品明细</view>
-  <view class="expand">
-    <navigator wx:if="{{!disabled}}" url="#" class="but" bindtap="addProduct">
+  <view wx:if="{{!disabled}}" class="expand">
+    <navigator wx:if="{{packagetypemxrows.length}}" style="text-align: center;" url="#" class="but" bindtap="editProduct">
+      调整套数
+    </navigator>
+    <navigator url="#" class="but" bindtap="addProduct">
       <van-icon name="plus" />
     </navigator>
   </view>

+ 14 - 0
project.private.config.json

@@ -10,6 +10,20 @@
   "condition": {
     "miniprogram": {
       "list": [
+        {
+          "name": "packageA/orderForm/detail",
+          "pathName": "packageA/orderForm/detail",
+          "query": "id=343043",
+          "launchMode": "default",
+          "scene": null
+        },
+        {
+          "name": "packageA/orderForm/index",
+          "pathName": "packageA/orderForm/index",
+          "query": "",
+          "launchMode": "default",
+          "scene": null
+        },
         {
           "name": "套餐订单",
           "pathName": "packageA/orderForm/detail",