zhaoxiaohai 2 years ago
parent
commit
3f3dbd5307

+ 2 - 1
packageA/orderForm/add/add.js

@@ -99,7 +99,8 @@ Page({
             console.log("创建标准订单", res);
             wx.showToast({
                 title: res.msg != '成功' ? res.msg : '创建成功',
-                icon: "none"
+                icon: "none",
+                mask: true
             });
             if (res.msg == '成功') setTimeout(() => {
                 wx.redirectTo({

+ 85 - 38
packageA/orderForm/add/float/index.js

@@ -6,6 +6,10 @@ Component({
             name: '标准订单'
         }, {
             name: '项目订单'
+        }, {
+            name: '促销订单'
+        }, {
+            name: '工具订单'
         }],
         actionShow: false,
     },
@@ -30,20 +34,45 @@ Component({
                     /* 前去挑选合同 */
                     wx.navigateTo({
                         url: `/select/contract/index?params=${JSON.stringify({
-              "id": 20230103150802,
-              "content": {
-                  "pageNumber": 1,
-                  "pageTotal": 1,
-                  "total": null,
-                  "pageSize": 20,
-                  "where": {
-                      "condition": ""
-                  }
-              }
-          })}&radio=false`,
+                            "id": 20230103150802,
+                            "content": {
+                                nocache: true,
+                                "pageNumber": 1,
+                                "pageTotal": 1,
+                                "total": null,
+                                "pageSize": 20,
+                                "where": {
+                                    "condition": ""
+                                }
+                            }
+                        })}&radio=false`
                     })
                     getApp().globalData.handleSelect = this.addProjectOrder.bind(this);
                     break;
+                case '促销订单':
+                    /* 前去挑选合同 */
+                    wx.navigateTo({
+                        url: `/select/activity/index?params=${JSON.stringify({
+                            "id": 20220103140003,
+                            "content": {
+                                "version": 1,
+                                "nocache": true,
+                                "pageNumber": 1,
+                                "pageTotal": 1,
+                                "where": {
+                                    "condition": ""
+                                },
+                                "sort": []
+                            }
+                        })}&radio=false`
+                    })
+                    getApp().globalData.handleSelect = this.addActivityOrder.bind(this);
+                    break;
+                case '工具订单':
+                    wx.navigateTo({
+                        url: '/packageA/orderForm/add/add?type=工具订单',
+                    })
+                    break;
             }
             this.onCancel();
         },
@@ -53,39 +82,57 @@ Component({
                 actionShow: false
             })
         },
+        /* 创建项目订单 */
         addProjectOrder(e) {
             wx.showModal({
                 title: '提示',
                 content: `是否确认创建“${e.item.billno}”相关“${e.item.projectname}”项目订单?`,
                 complete: (res) => {
-                    if (res.confirm) {
-                        wx.navigateTo({
-                            url: `/packageA/orderForm/add/add?type=项目订单&sa_contractid=${e.item.sa_contractid}&sa_projectid=${ e.item.sa_projectid}`,
-                        })
-                    }
-                    /* _Http.basic({
-                                           "id": 20230103141402,
-                                           "content": {
-                                               sa_orderid: 0,
-                                               "sa_contractid": e.item.sa_contractid, //合同ID,
-                                               "sa_projectid": e.item.sa_projectid, //工程项目表ID,
-                                           }
-                                       }).then(res => {
-                                           console.log("创建商品订单", res)
-                                           wx.showToast({
-                                               title: res.msg != '成功' ? res.msg : '创建成功',
-                                               icon: "none"
-                                           });
-                                           if (res.msg == '成功') setTimeout(() => {
-                                               wx.redirectTo({
-                                                   url: '/packageA/orderForm/detail?id=' + res.data.sa_orderid,
-                                               });
-                                               let page = getCurrentPages().find(v => v.__route__ == 'packageA/orderForm/index');
-                                               if (page) page.getList(true);
-                                           }, 500)
-                                       }) */
+                    if (res.confirm) wx.redirectTo({
+                        url: `/packageA/orderForm/add/add?type=项目订单&sa_contractid=${e.item.sa_contractid}&sa_projectid=${ e.item.sa_projectid}`,
+                    })
                 }
             })
-        }
+        },
+        addActivityOrder({
+            item
+        }) {
+            console.log(item)
+            wx.showModal({
+                title: '提示',
+                content: `是否确定创建“${item.promname}”促销订单`,
+                complete: (s) => {
+                    if (s) _Http.basic({
+                        "id": 20221108111402,
+                        content: {
+                            sa_orderid: 0,
+                            sa_accountclassid: item.sa_accountclassid,
+                            rec_contactsid: 0,
+                            pay_enterpriseid: 0,
+                            sa_contractid: 0,
+                            sa_projectid: 0,
+                            sa_promotionid: item.sa_promotionid,
+                            "sa_brandid": item.sa_brandid, //品牌ID
+                            "type": '促销订单', //订单类型
+                            "tradefield": item.tradefield, //必选
+                        }
+                    }).then(res => {
+                        console.log("创建促销订单", res);
+                        wx.showToast({
+                            title: res.msg != '成功' ? res.msg : '创建成功',
+                            icon: "none",
+                            mask: true
+                        });
+                        if (res.msg == '成功') setTimeout(() => {
+                            wx.redirectTo({
+                                url: '/packageA/orderForm/detail?id=' + res.data.sa_orderid,
+                            });
+                            let page = getCurrentPages().find(v => v.__route__ == 'packageA/orderForm/index');
+                            if (page) page.getList(true);
+                        }, 500)
+                    })
+                }
+            })
+        },
     }
 })

+ 247 - 235
packageA/orderForm/modules/product/index.js

@@ -1,185 +1,197 @@
 const _Http = getApp().globalData.http,
-    file = require("../../../../utils/FormatTheAttachment");
+	file = require("../../../../utils/FormatTheAttachment");
 let queue = [],
-    downCounter = null;
+	downCounter = null;
 Component({
-    properties: {
-        disabled: Boolean, //禁用
-    },
-    data: {
-        sa_orderid: 0,
-        "content": {
-            nocache: true,
-            "pageNumber": 1,
-            pageTotal: 1,
-            total: null
-        }
-    },
-    lifetimes: {
-        detached: function () {
-            if (downCounter) {
-                clearTimeout(downCounter);
-                this.changeItem(queue)
-            }
-        },
-    },
-    methods: {
-        /* 获取产品列表 */
-        getList(id, init) {
-            let content = this.data.content;
-            content.sa_orderid = id;
+	properties: {
+		disabled: Boolean, //禁用
+	},
+	data: {
+		sa_orderid: 0,
+		"content": {
+			nocache: true,
+			"pageNumber": 1,
+			pageTotal: 1,
+			total: null
+		}
+	},
+	lifetimes: {
+		detached: function () {
+			if (downCounter) {
+				clearTimeout(downCounter);
+				this.changeItem(queue)
+			}
+		},
+	},
+	methods: {
+		/* 获取产品列表 */
+		getList(id, init) {
+			let content = this.data.content;
+			content.sa_orderid = id;
 
-            if (init) content.pageNumber = 1;
-            _Http.basic({
-                "id": "20221109093902",
-                content
-            }).then(res => {
-                console.log("订货清单列表", res)
-                if (res.msg != '成功') return wx.showToast({
-                    title: res.msg,
-                    icon: "none"
-                })
-                res.data = res.data.map(value => {
-                    if (value.attinfos.length != 0) {
-                        value.attinfos = file.fileList(value.attinfos)
-                        let image = value.attinfos.find(v => v.fileType == "image");
-                        value.cover = image ? image.cover : "";
-                    }
-                    return value;
-                })
-                let page = getCurrentPages().find(v => v.__route__ == 'packageA/orderForm/detail').data.detail;
-                let base = {
-                    sa_orderid: page.sa_orderid,
-                    sys_enterpriseid: page.sys_enterpriseid,
-                    sa_contractid: page.sa_contractid,
-                    type: page.type,
-                };
-                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_orderid: id,
-                    base
-                })
-            })
-        },
-        /* 统一交期 */
-        dateChange(e) {
-            let that = this;
-            wx.showModal({
-                title: '提示',
-                content: `是否确定将当前产品列表交期统一设置为:${e.detail.value}`,
-                complete: (res) => {
-                    if (res.confirm) _Http.basic({
-                        "id": 20230104143802,
-                        "content": {
-                            "sa_orderid": that.data.sa_orderid,
-                            "needdate": e.detail.value
-                        }
-                    }).then(res => {
-                        console.log('统一设置交期', res)
-                        wx.showToast({
-                            title: res.msg == '成功' ? '设置成功' : res.msg,
-                            icon: "none"
-                        })
-                        if (res.msg == '成功') that.setData({
-                            list: that.data.list.map(v => {
-                                v.needdate = e.detail.value;
-                                return v
-                            })
-                        })
-                    })
-                }
-            })
-        },
-        /* 修改 */
-        changeProduct({
-            detail
-        }) {
-            let obj = detail,
-                index = this.data.list.findIndex(v => v.itemid == detail.itemid),
-                data = this.data.list[index],
-                calculatePrice = data.qty != obj.qty;
-            if (data.qty == obj.qty && data.remarks == obj.remarks && data.needdate == obj.needdate) return;
-            _Http.basic({
-                "id": 20221109093602,
-                "content": {
-                    ...this.data.base,
-                    "items": [detail]
-                }
-            }).then(res => {
-                console.log("产品修改", res)
-                if (res.msg != '成功') {
-                    wx.showToast({
-                        title: res.msg,
-                        icon: "none"
-                    });
-                    obj = data;
-                };
-                data = {
-                    ...data,
-                    ...obj
-                };
-                if (res.msg == '成功' && calculatePrice) {
-                    let page = getCurrentPages()[getCurrentPages().length - 1];
-                    if (page) {
-                        let amount = page.data.detail.amount - data.amount;
-                        data.amount = ((data.qty - 0) * (data.price - 0)).toFixed(2);
-                        amount = (amount + (data.amount - 0)).toFixed(2);
-                        page.setData({
-                            "detail.amount": amount - 0
-                        })
-                    }
-                }
-                this.setData({
-                    [`list[${index}]`]: data
-                })
-            })
-        },
-        /* 删除 */
-        deleteItem({
-            detail
-        }) {
-            let that = this;
-            wx.showModal({
-                title: '提示',
-                content: `是否确认删除“${detail.itemname}”?`,
-                complete: (res) => {
-                    if (res.confirm) _Http.basic({
-                        "id": 20221109093702,
-                        "content": {
-                            sa_orderid: detail.sa_orderid,
-                            "sa_orderitemsids": [
-                                detail.sa_orderitemsid
-                            ]
-                        }
-                    }).then(s => {
-                        if (s.msg != '成功') return wx.showToast({
-                            title: res.msg,
-                            icon: "none"
-                        });
-                        that.setData({
-                            list: that.data.list.filter(v => v.sa_orderitemsid != detail.sa_orderitemsid)
-                        });
-                        /* 更新金额 */
-                        let page = getCurrentPages()[getCurrentPages().length - 1];
-                        let amount = (page.data.detail.amount - detail.amount).toFixed(2);
-                        if (page) page.setData({
-                            "detail.amount": amount - 0
-                        })
-                    })
-                }
-            })
-        },
-        /* 去添加产品 */
-        addProduct() {
-            let detail = getCurrentPages().find(v => v.__route__ == 'packageA/orderForm/detail').data.detail;
-            console.log(detail)
-            wx.navigateTo({
-                url: `/select/product/index?params=${JSON.stringify({
-					"id": detail.type=='项目订单'?20230103155002:20221109153502,
+			if (init) content.pageNumber = 1;
+			_Http.basic({
+				"id": "20221109093902",
+				content
+			}).then(res => {
+				console.log("订货清单列表", res)
+				if (res.msg != '成功') return wx.showToast({
+					title: res.msg,
+					icon: "none"
+				})
+				res.data = res.data.map(value => {
+					if (value.attinfos.length != 0) {
+						value.attinfos = file.fileList(value.attinfos)
+						let image = value.attinfos.find(v => v.fileType == "image");
+						value.cover = image ? image.cover : "";
+					}
+					return value;
+				})
+				let page = getCurrentPages().find(v => v.__route__ == 'packageA/orderForm/detail').data.detail;
+				let base = {
+					sa_orderid: page.sa_orderid,
+					sys_enterpriseid: page.sys_enterpriseid,
+					sa_contractid: page.sa_contractid,
+					type: page.type,
+				};
+				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_orderid: id,
+					base
+				})
+			})
+		},
+		/* 统一交期 */
+		dateChange(e) {
+			let that = this;
+			wx.showModal({
+				title: '提示',
+				content: `是否确定将当前产品列表交期统一设置为:${e.detail.value}`,
+				complete: (res) => {
+					if (res.confirm) _Http.basic({
+						"id": 20230104143802,
+						"content": {
+							"sa_orderid": that.data.sa_orderid,
+							"needdate": e.detail.value
+						}
+					}).then(res => {
+						console.log('统一设置交期', res)
+						wx.showToast({
+							title: res.msg == '成功' ? '设置成功' : res.msg,
+							icon: "none"
+						})
+						if (res.msg == '成功') that.setData({
+							list: that.data.list.map(v => {
+								v.needdate = e.detail.value;
+								return v
+							})
+						})
+					})
+				}
+			})
+		},
+		/* 修改 */
+		changeProduct({
+			detail
+		}) {
+			let obj = detail,
+				index = this.data.list.findIndex(v => v.itemid == detail.itemid),
+				data = this.data.list[index],
+				calculatePrice = data.qty != obj.qty;
+			if (data.qty == obj.qty && data.remarks == obj.remarks && data.needdate == obj.needdate) return;
+			_Http.basic({
+				"id": 20221109093602,
+				"content": {
+					...this.data.base,
+					"items": [detail]
+				}
+			}).then(res => {
+				console.log("产品修改", res)
+				if (res.msg != '成功') {
+					wx.showToast({
+						title: res.msg,
+						icon: "none"
+					});
+					obj = data;
+				};
+				data = {
+					...data,
+					...obj
+				};
+				if (res.msg == '成功' && calculatePrice) {
+					let page = getCurrentPages()[getCurrentPages().length - 1];
+					if (page) {
+						let amount = page.data.detail.amount - data.amount;
+						data.amount = ((data.qty - 0) * (data.price - 0)).toFixed(2);
+						amount = (amount + (data.amount - 0)).toFixed(2);
+						page.setData({
+							"detail.amount": amount - 0
+						})
+					}
+				}
+				this.setData({
+					[`list[${index}]`]: data
+				})
+			})
+		},
+		/* 删除 */
+		deleteItem({
+			detail
+		}) {
+			let that = this;
+			wx.showModal({
+				title: '提示',
+				content: `是否确认删除“${detail.itemname}”?`,
+				complete: (res) => {
+					if (res.confirm) _Http.basic({
+						"id": 20221109093702,
+						"content": {
+							sa_orderid: detail.sa_orderid,
+							"sa_orderitemsids": [
+								detail.sa_orderitemsid
+							]
+						}
+					}).then(s => {
+						if (s.msg != '成功') return wx.showToast({
+							title: res.msg,
+							icon: "none"
+						});
+						that.setData({
+							list: that.data.list.filter(v => v.sa_orderitemsid != detail.sa_orderitemsid)
+						});
+						/* 更新金额 */
+						let page = getCurrentPages()[getCurrentPages().length - 1];
+						let amount = (page.data.detail.amount - detail.amount).toFixed(2);
+						if (page) page.setData({
+							"detail.amount": amount - 0
+						})
+					})
+				}
+			})
+		},
+		/* 去添加产品 */
+		addProduct() {
+			let detail = getCurrentPages().find(v => v.__route__ == 'packageA/orderForm/detail').data.detail;
+			let id = ''
+			switch (detail.type) {
+				case '项目订单':
+					id = 20230103155002
+					break;
+				case '促销订单':
+					id = 20230107182302
+					break;
+				default:
+					//标准、工具
+					id = 20221109153502
+					break;
+			}
+			wx.navigateTo({
+				url: `/select/product/index?params=${JSON.stringify({
+					"id":id,
 					"content": {
 						nocache:true,
 						"sa_orderid": this.data.sa_orderid, //订单ID
@@ -192,61 +204,61 @@ Component({
 						}
 					}
 				})}`
-            });
-            getApp().globalData.handleSelect = this.handleSelect.bind(this);
-        },
-        /* 处理新增产品 */
-        handleSelect(detail) {
-            let that = this;
-            wx.showModal({
-                title: '提示',
-                content: `是否确认添加${detail.result.length}件商品?`,
-                complete: (res) => {
-                    if (res.confirm) _Http.basic({
-                        "id": 20221109093602,
-                        "content": {
-                            ...that.data.base,
-                            "items": detail.list.map(v => {
-                                return {
-                                    sa_orderitemsid: 0,
-                                    "itemid": v.itemid, //商品ID
-                                    "qty": 1, //数量
-                                }
-                            })
-                        }
-                    }).then(s => {
-                        console.log('新增产品', s)
-                        wx.showToast({
-                            title: s.msg == '成功' ? '添加成功' : s.msg,
-                            icon: "none"
-                        });
-                        if (s.msg == '成功') setTimeout(() => {
-                            that.getList(that.data.sa_orderid, true);
-                            wx.navigateBack();
-                            that.updateThePrice();
-                        }, 300)
-                    })
-                }
-            });
-        },
-        /* 使用接口更新总价 */
-        updateThePrice() {
-            _Http.basic({
-                "id": 20230105101102,
-                "content": {
-                    "sa_orderid": this.data.sa_orderid
-                },
-            }).then(res => {
-                console.log("获取列表总价", res)
-                if (res.msg != '成功') return wx.showToast({
-                    title: `产品总价更新失败`,
-                    icon: "none"
-                });
-                let page = getCurrentPages()[getCurrentPages().length - 1];
-                if (page) page.setData({
-                    "detail.amount": res.data.amount - 0
-                })
-            })
-        }
-    }
+			});
+			getApp().globalData.handleSelect = this.handleSelect.bind(this);
+		},
+		/* 处理新增产品 */
+		handleSelect(detail) {
+			let that = this;
+			wx.showModal({
+				title: '提示',
+				content: `是否确认添加${detail.result.length}件商品?`,
+				complete: (res) => {
+					if (res.confirm) _Http.basic({
+						"id": 20221109093602,
+						"content": {
+							...that.data.base,
+							"items": detail.list.map(v => {
+								return {
+									sa_orderitemsid: 0,
+									"itemid": v.itemid, //商品ID
+									"qty": 1, //数量
+								}
+							})
+						}
+					}).then(s => {
+						console.log('新增产品', s)
+						wx.showToast({
+							title: s.msg == '成功' ? '添加成功' : s.msg,
+							icon: "none"
+						});
+						if (s.msg == '成功') setTimeout(() => {
+							that.getList(that.data.sa_orderid, true);
+							wx.navigateBack();
+							that.updateThePrice();
+						}, 300)
+					})
+				}
+			});
+		},
+		/* 使用接口更新总价 */
+		updateThePrice() {
+			_Http.basic({
+				"id": 20230105101102,
+				"content": {
+					"sa_orderid": this.data.sa_orderid
+				},
+			}).then(res => {
+				console.log("获取列表总价", res)
+				if (res.msg != '成功') return wx.showToast({
+					title: `产品总价更新失败`,
+					icon: "none"
+				});
+				let page = getCurrentPages()[getCurrentPages().length - 1];
+				if (page) page.setData({
+					"detail.amount": res.data.amount - 0
+				})
+			})
+		}
+	}
 })