Browse Source

销售订单 业务员创建订单逻辑更改

xiaohaizhao 2 years ago
parent
commit
a768b40c5e
3 changed files with 185 additions and 173 deletions
  1. 165 156
      packageA/orderForm/add/add.js
  2. 19 16
      packageA/orderForm/add/add.wxml
  3. 1 1
      packageA/orderForm/index.js

+ 165 - 156
packageA/orderForm/add/add.js

@@ -1,165 +1,174 @@
 const _Http = getApp().globalData.http;
 
 Page({
-	data: {
-		agency: {
-			sys_enterpriseid: 0
-		},
-		skeletonShow: false,
-		loading: false,
-		sa_brandid: null,
-		tradefield: null,
-		brandList: [],
-		domainList: [],
-		type: "标准订单",
-	},
-	onLoad(options) {
-		this.setData({
-			type: options.type || '标准订单',
-			sa_projectid: options.sa_projectid || 0,
-			sa_contractid: options.sa_contractid || 0,
-			userrole: wx.getStorageSync('userrole')
-		})
-		this.getBrand();
-		this.getDomain();
-	},
-	/* 获取品牌 */
-	getBrand() {
-		_Http.basic({
-			"id": 20220924163702,
-			"content": {
-				"pageSize": 999,
-			}
-		}).then(res => {
-			console.log("查询品牌", res)
-			if (res.data.length) this.setData({
-				brandList: res.data,
-				sa_brandid: res.data[0].sa_brandid
-			});
-		})
-	},
-	/* 选择品牌 */
-	onSelectBrand(e) {
-		let {
-			item
-		} = e.currentTarget.dataset;
-		if (this.data.sa_brandid == item.sa_brandid) return;
-		this.setData({
-			sa_brandid: item.sa_brandid
-		})
-	},
-	/* 获取领域 */
-	getDomain() {
-		_Http.basic({
-			"id": 20221223141802,
-			"content": {
-				"pageNumber": 1,
-				"pageSize": 99999,
-				"where": {
-					"condition": ""
-				}
-			}
-		}).then(res => {
-			console.log("获取领域", res)
-			if (res.data.length) this.setData({
-				domainList: res.data,
-				tradefield: res.data[0].tradefield,
-				skeletonShow: false
-			});
-		})
-	},
-	/* 选择领域 */
-	onSelect(e) {
-		let {
-			item
-		} = e.currentTarget.dataset;
-		if (this.data.tradefield == item.tradefield) return;
-		this.setData({
-			tradefield: item.tradefield
-		})
-	},
-	submit() {
-		if (this.data.userrole == '业务员' && !this.data.agency.sys_enterpriseid) {
-			let that = this;
-			wx.showModal({
-				title: '提示',
-				content: '您还未选择经销商!是否立即前往',
-				complete: (res) => {
-					if (res.confirm) that.selectAgency()
-				}
-			})
-			return;
-		};
-		if (this.data.loading) return;
-		this.setData({
-			loading: true
-		})
-		_Http.basic({
-			"id": 20221108111402,
-			content: {
-				sa_orderid: 0,
-				sa_accountclassid: 0,
-				rec_contactsid: 0,
-				pay_enterpriseid: 0,
-				sa_contractid: this.data.sa_contractid,
-				sa_projectid: this.data.sa_projectid,
-				"sa_brandid": this.data.sa_brandid, //品牌ID
-				"type": this.data.type, //订单类型
-				"tradefield": this.data.tradefield, //必选
-				sys_enterpriseid: this.data.agency.sys_enterpriseid
-			}
-		}).then(res => {
-			this.setData({
-				loading: false
-			})
-			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)
-		})
-	},
-	/* 业务员逻辑 ↓ */
-	selectAgency() {
-		wx.navigateTo({
-			url: `/select/agent/index?params=${JSON.stringify({
-							"id": 20220920083901,
+    data: {
+        agency: {
+            sys_enterpriseid: 0
+        },
+        skeletonShow: false,
+        loading: false,
+        sa_brandid: null,
+        tradefield: null,
+        brandList: [],
+        domainList: [],
+        type: "标准订单",
+    },
+    onLoad(options) {
+        this.setData({
+            type: options.type || '标准订单',
+            sa_projectid: options.sa_projectid || 0,
+            sa_contractid: options.sa_contractid || 0,
+            userrole: wx.getStorageSync('userrole')
+        })
+        if (this.data.userrole == '经销商') {
+            this.getBrand();
+            this.getDomain();
+        }
+    },
+    /* 获取品牌 */
+    getBrand(id) {
+        let content = {
+            nocache: true,
+            "pageSize": 999,
+        }
+        if (id) content.sys_enterpriseid = id;
+        _Http.basic({
+            "id": 20220924163702,
+            content
+        }).then(res => {
+            console.log("查询品牌", res)
+            if (res.data.length) this.setData({
+                brandList: res.data,
+                sa_brandid: res.data[0].sa_brandid
+            });
+        })
+    },
+    /* 选择品牌 */
+    onSelectBrand(e) {
+        let {
+            item
+        } = e.currentTarget.dataset;
+        if (this.data.sa_brandid == item.sa_brandid) return;
+        this.setData({
+            sa_brandid: item.sa_brandid
+        })
+    },
+    /* 获取领域 */
+    getDomain(id) {
+        let content = {
+            nocache: true,
+            "pageNumber": 1,
+            "pageSize": 99999,
+            "where": {
+                "condition": ""
+            }
+        };
+        if (id) content.sys_enterpriseid = id;
+        _Http.basic({
+            "id": 20221223141802,
+            content
+        }).then(res => {
+            console.log("获取领域", res)
+            if (res.data.length) this.setData({
+                domainList: res.data,
+                tradefield: res.data[0].tradefield,
+                skeletonShow: false
+            });
+        })
+    },
+    /* 选择领域 */
+    onSelect(e) {
+        let {
+            item
+        } = e.currentTarget.dataset;
+        if (this.data.tradefield == item.tradefield) return;
+        this.setData({
+            tradefield: item.tradefield
+        })
+    },
+    submit() {
+        if (this.data.userrole == '业务员' && !this.data.agency.sys_enterpriseid) {
+            let that = this;
+            wx.showModal({
+                title: '提示',
+                content: '您还未选择经销商!是否立即前往',
+                complete: (res) => {
+                    if (res.confirm) that.selectAgency()
+                }
+            })
+            return;
+        };
+        if (this.data.loading) return;
+        this.setData({
+            loading: true
+        })
+        _Http.basic({
+            "id": 20221108111402,
+            content: {
+                sa_orderid: 0,
+                sa_accountclassid: 0,
+                rec_contactsid: 0,
+                pay_enterpriseid: 0,
+                sa_contractid: this.data.sa_contractid,
+                sa_projectid: this.data.sa_projectid,
+                "sa_brandid": this.data.sa_brandid, //品牌ID
+                "type": this.data.type, //订单类型
+                "tradefield": this.data.tradefield, //必选
+                sys_enterpriseid: this.data.agency.sys_enterpriseid
+            }
+        }).then(res => {
+            this.setData({
+                loading: false
+            })
+            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)
+        })
+    },
+    /* 业务员逻辑 ↓ */
+    selectAgency() {
+        wx.navigateTo({
+            url: `/select/agent/index?params=${JSON.stringify({
+							"id": 20230219195002,
 							"content": {
-								nocache:true,
+                                nocache:true,
+                                "ismanage": "0",
 								"where": {
-										"condition": "",
-										"type":1,
-										"typemx":this.data.type=='标准订单'?"经销商合作协议":""
+                                    "condition": ""
 								}
 							}
 					})}&radio=true`,
-		})
-		getApp().globalData.handleSelect = this.setAgency.bind(this);
-	},
-	/* 设置经销商 */
-	setAgency({
-		item
-	}) {
-		let that = this;
-		wx.showModal({
-			title: '提示',
-			content: `是否确定选择"${item.enterprisename}"作为指定经销商?`,
-			complete: (res) => {
-				if (res.confirm) {
-					that.setData({
-						agency: item
-					})
-					wx.navigateBack()
-				}
-			}
-		})
-	}
+        })
+        getApp().globalData.handleSelect = this.setAgency.bind(this);
+    },
+    /* 设置经销商 */
+    setAgency({
+        item
+    }) {
+        let that = this;
+        wx.showModal({
+            title: '提示',
+            content: `是否确定选择"${item.enterprisename}"作为指定经销商?`,
+            complete: (res) => {
+                if (res.confirm) {
+                    that.setData({
+                        agency: item
+                    })
+                    that.getBrand(item.sys_enterpriseid)
+                    that.getDomain(item.sys_enterpriseid)
+                    wx.navigateBack()
+                }
+            }
+        })
+    }
 })

+ 19 - 16
packageA/orderForm/add/add.wxml

@@ -1,22 +1,7 @@
 <import src="add.skeleton.wxml" />
 <template is="skeleton" wx:if="{{skeletonShow}}" />
 
-<view class="groud">
-    <view class="label">
-        选择品牌
-    </view>
-    <view class="content">
-        <van-button custom-class='but {{item.sa_brandid==sa_brandid?"active":""}}' wx:for="{{brandList}}" wx:key="sa_brandid" data-item="{{item}}" bindtap="onSelectBrand">{{item.brandname}}</van-button>
-    </view>
-</view>
-<view class="groud">
-    <view class="label">
-        选择领域
-    </view>
-    <view class="content">
-        <van-button custom-class='but {{item.tradefield==tradefield?"active":""}}' wx:for="{{domainList}}" wx:key="sys_enterprise_tradefieldid" data-item="{{item}}" bindtap="onSelect">{{item.tradefield}}</van-button>
-    </view>
-</view>
+
 <navigator wx:if="{{userrole!='经销商'}}" url="#" class="groud" bindtap="selectAgency">
     <view class="label jxs">
         指定经销商:
@@ -32,6 +17,24 @@
         点击选择经销商
     </view>
 </navigator>
+<view class="groud" wx:if="{{brandList.length}}">
+    <view class="label">
+        选择品牌
+    </view>
+    <view class="content">
+        <van-button custom-class='but {{item.sa_brandid==sa_brandid?"active":""}}' wx:for="{{brandList}}" wx:key="sa_brandid" data-item="{{item}}" bindtap="onSelectBrand">{{item.brandname}}</van-button>
+    </view>
+</view>
+<view class="groud" wx:if="{{domainList.length}}">
+    <view class="label">
+        选择领域
+    </view>
+    <view class="content">
+        <van-button custom-class='but {{item.tradefield==tradefield?"active":""}}' wx:for="{{domainList}}" wx:key="sys_enterprise_tradefieldid" data-item="{{item}}" bindtap="onSelect">{{item.tradefield}}</van-button>
+    </view>
+</view>
+
+
 <!-- 底部 -->
 <view style="height: 150rpx;" />
 <view class="footer">

+ 1 - 1
packageA/orderForm/index.js

@@ -4,7 +4,7 @@ import currency from "../../utils/currency";
 Page({
     data: {
         loading: true,
-        active: 1,
+        active: 0,
         amount: 0,
         "content": {
             nocache: true,