Browse Source

交期受规则管控

xiaohaizhao 1 year ago
parent
commit
6488518c7c

+ 10 - 24
packageA/orderForm/modules/product/index.js

@@ -1,6 +1,7 @@
 const _Http = getApp().globalData.http,
     file = require("../../../../utils/FormatTheAttachment"),
     currency = require("../../../../utils/currency");
+
 let queue = [],
     downCounter = null,
     sa_orderid = 0,
@@ -48,11 +49,15 @@ Component({
                     icon: "none"
                 })
                 res.data = res.data.map(v => {
-                    if (v.attinfos.length != 0) {
-                        v.attinfos = file.fileList(v.attinfos)
-                        let image = v.attinfos.find(v => v.fileType == "image");
-                        v.cover = image ? image.cover : "";
-                    };
+                    try {
+                        if (v.attinfos.length != 0) {
+                            v.attinfos = file.fileList(v.attinfos)
+                            let image = v.attinfos.find(v => v.fileType == "image");
+                            v.cover = image ? image.cover : "";
+                        };
+                    } catch (error) {
+
+                    }
                     v.defaultprice = CNY(v.defaultprice)
                     v.marketprice = CNY(v.marketprice)
                     v.defaultamount = CNY(v.defaultamount)
@@ -243,25 +248,6 @@ Component({
         },
         /* 使用接口更新总价 */
         updateThePrice() {
-            // _Http.basic({
-            //     "id": 20230105101102,
-            //     "content": {
-            //         sa_orderid
-            //     },
-            // }).then(res => {
-            //     console.log("修改列表总价", res)
-            //     if (res.msg != '成功') return wx.showToast({
-            //         title: `产品总价更新失败`,
-            //         icon: "none"
-            //     });
-            //     let page = getCurrentPages()[getCurrentPages().length - 1];
-            //     if (page) {
-            //         this.setData({
-            //             "detail.defaultamount": CNY(res.data.amount)
-            //         })
-            //         page.setLogisticsMsg();
-            //     }
-            // })
             let page = getCurrentPages().find(v => v.__route__ == 'packageA/orderForm/detail');
             page.getDetail();
         }

+ 87 - 10
packageA/orderForm/modules/product/list/index.js

@@ -1,5 +1,8 @@
 import currency from "../../../../../utils/currency";
-
+let {
+	formatTime
+} = require("../../../../../utils/getTime")
+const _Http = getApp().globalData.http;
 Component({
 	properties: {
 		list: {
@@ -15,6 +18,9 @@ Component({
 			type: Boolean
 		}
 	},
+	data: {
+		popupShow: false
+	},
 	options: {
 		addGlobalClass: true
 	},
@@ -53,19 +59,90 @@ Component({
 				deliverydate: data.deliverydate || ""
 			})
 		},
-		changeDate(e) {
+		async calculate(e) {
+			this.isEdit()
+			if (this.data.disabled) return;
 			let {
-				data
+				item
 			} = e.currentTarget.dataset;
-			this.triggerEvent("changeProduct", {
-				sa_orderitemsid: data.sa_orderitemsid,
-				itemid: data.itemid,
-				qty: data.qty,
-				remarks: data.remarks,
-				needdate: e.detail.value || "",
-				deliverydate: data.deliverydate || ""
+			item.minData = Date.now();
+			if (item.delivery != 0 && item.delivery != "") {
+				let date = Date.now() + (item.delivery * 86400000);
+				item.minDate = await exclusion(formatTime(new Date(date), "-").split(" ")[0]);
+
+				this.setData({
+					changeDate: item,
+					popupShow: true
+				})
+
+				function exclusion(begindate) {
+					return new Promise((resolve) => {
+						_Http.basic({
+							"id": 20231008134404,
+							"content": {
+								"isExport": 0,
+								"isnext": '0',
+								"pageNumber": 1,
+								"pageSize": 100,
+								"where": {
+									begindate,
+									"enddate": formatTime(new Date(date + (31 * 86400000)), "-").split(" ")[0]
+								}
+							},
+						}).then(res => {
+							console.log("查询节假日", begindate, res)
+							if (res.data.some(v => v.date == begindate)) {
+								function day() {
+									date += 86400000;
+									if (res.data.some(v => v.date == formatTime(new Date(date), "-").split(" ")[0])) {
+										day()
+									} else {
+										resolve(date)
+									}
+								}
+								day()
+							} else {
+								resolve(date)
+							}
+						})
+					})
+				}
+			} else {
+				this.setData({
+					changeDate: item,
+					popupShow: true
+				})
+			}
+		},
+		closePopup() {
+			this.setData({
+				popupShow: false,
+				changeDate: null
 			})
 		},
+		onConfirm({
+			detail
+		}) {
+			let data = this.data.changeDate,
+				that = this;
+			let needdate = formatTime(new Date(detail), "-").split(' ')[0];
+			wx.showModal({
+				content: `是否确定期望交期为${needdate}日`,
+				title: '提示',
+				success: (result) => {
+					that.triggerEvent("changeProduct", {
+						sa_orderitemsid: data.sa_orderitemsid,
+						itemid: data.itemid,
+						qty: data.qty,
+						remarks: data.remarks,
+						needdate,
+						deliverydate: data.deliverydate || ""
+					})
+					that.closePopup();
+				},
+			})
+
+		},
 		deleteProduct(e) {
 			this.triggerEvent("deleteItem", e.currentTarget.dataset.item)
 		},

+ 1 - 0
packageA/orderForm/modules/product/list/index.json

@@ -1,5 +1,6 @@
 {
     "component": true,
     "usingComponents": {
+        "van-datetime-picker": "@vant/weapp/datetime-picker/index"
     }
 }

+ 11 - 3
packageA/orderForm/modules/product/list/index.wxml

@@ -58,12 +58,17 @@
         <view wx:if="{{item.delivery!=0}}" class="row">
             <view>
                 <view class="label">期望交期:</view>
-                <picker disabled='{{disabled}}' bindtap="isEdit" mode="date" data-data="{{item}}" bindchange='changeDate'>
+                <view class="input" style="width: 240rpx;display: flex;justify-content: center;" data-item="{{item}}" bindtap="calculate">
+                    <text wx:if="{{item.needdate }}">{{item.needdate}}</text>
+                    <text wx:else style="color: #999;">期望交期</text>
+                </view>
+
+                <!-- <picker disabled='{{disabled}}' bindtap="isEdit" start="{{item.start}}" end="{{item.end}}" mode="date" data-data="{{item}}" bindchange='changeDate'>
                     <view class="input" style="width: 240rpx;display: flex;justify-content: center;">
                         <text wx:if="{{item.needdate }}">{{item.needdate}}</text>
                         <text wx:else style="color: #999;">期望交期</text>
                     </view>
-                </picker>
+                </picker> -->
             </view>
             <view class="money">
                 回复交期:{{item.deliverydate || ' --'}}
@@ -74,4 +79,7 @@
 <block wx:if="{{list.length==0}}">
     <Yl_Empty />
     <view style="height: 150rpx;" />
-</block>
+</block>
+<van-popup show="{{ popupShow }}" position="bottom" bind:click-overlay="closePopup" z-index='999999999'>
+    <van-datetime-picker type="date" value="{{ changeDate.minDate }}" min-date="{{ changeDate.minDate }}" bind:confirm='onConfirm' bind:cancel='closePopup' />
+</van-popup>

+ 18 - 0
project.private.config.json

@@ -141,6 +141,24 @@
           "query": "",
           "launchMode": "default",
           "scene": null
+        },
+        {
+          "name": "销售订单",
+          "pathName": "packageA/orderForm/index",
+          "query": "",
+          "launchMode": "default",
+          "scene": null
+        },
+        {
+          "name": "ddxq",
+          "pathName": "packageA/orderForm/detail",
+          "query": "id=52161",
+          "launchMode": "default",
+          "scene": null,
+          "partialCompile": {
+            "enabled": true,
+            "pages": []
+          }
         }
       ]
     }