Browse Source

业务员选择经销商/客户

xiaohaizhao 2 years ago
parent
commit
61692b4458

+ 1 - 2
packageA/market/detail.wxml

@@ -37,8 +37,7 @@
     选择商品
   </view>
   <view class="product-box">
-    <navigator url="#" class="product {{itemno===item.itemno?'active':''}}" wx:for="{{rows}}" wx:key="itemno" bindtap="changeItemno" data-item="{{item}}">{{item.model}}
-    </navigator>
+    <navigator url="#" class="product {{itemno===item.itemno?'active':''}}" wx:for="{{rows}}" wx:key="itemno" bindtap="changeItemno" data-item="{{item}}">{{item.spec}}</navigator>
   </view>
 </view>
 <van-tabs custom-class='tabs' title-active-color='var(--assist)' color='var(--assist)'>

+ 50 - 14
packageA/market/index.js

@@ -1,5 +1,5 @@
 const _Http = getApp().globalData.http;
-
+let sys_enterpriseid = null;
 Page({
 	data: {
 		istool: 0, //0商品 1工具
@@ -36,6 +36,21 @@ Page({
 		this.getTradefie();
 		this.getOptionTypeSelect();
 	},
+	/* 业务员选择角色 */
+	selsectedRole(e) {
+		wx.navigateTo({
+			url: './selected/index',
+		})
+		getApp().globalData.handleSelect = this.handleRole.bind(this);
+	},
+	handleRole(e) {
+		this.setData({
+			buttonText: e.enterprisename
+		});
+		sys_enterpriseid = e.sys_enterpriseid;
+		this.getBrand();
+		wx.navigateBack();
+	},
 	/* 获取系统分类 */
 	getOptionTypeSelect() {
 		_Http.basic({
@@ -122,18 +137,36 @@ Page({
 	},
 	/* 获取品牌 */
 	getBrand() {
+		let content = {
+			"pageSize": 999,
+		};
+		if (sys_enterpriseid) content.sys_enterpriseid = sys_enterpriseid;
 		_Http.basic({
 			"id": 20220924163702,
-			"content": {
-				"pageSize": 999,
-			}
+			content
 		}).then(res => {
 			console.log("查询品牌", res)
-			if (res.data.length) this.setData({
-				brandList: res.data,
+			if (res.msg != '成功') return wx.showToast({
+				title: res.msg,
+				icon: "none"
 			});
-			this.data.brand = res.data[0];
-			this.getTypeList();
+			if (res.data.length != 0) {
+				this.setData({
+					brandList: res.data,
+				});
+				this.data.brand = res.data[0];
+				this.getTypeList();
+			} else {
+				wx.showToast({
+					title: '未查询到授权品牌',
+					icon: "none"
+				})
+				this.setData({
+					brandList: [],
+					list: [],
+					typeList: []
+				})
+			}
 		})
 	},
 	/* 切换品牌 */
@@ -143,15 +176,17 @@ Page({
 	},
 	/* 获取分类 */
 	getTypeList() {
+		let content = {
+			sa_brandid: this.data.brand.sa_brandid,
+			where: {
+				istool: 0, //默认0,不是工具,1表示工具
+			}
+		}
+		if (sys_enterpriseid) content.sys_enterpriseid = sys_enterpriseid;
 		_Http.basic({
 			"id": "20220922110403",
 			"pageSize": 1000,
-			"content": {
-				"sa_brandid": this.data.brand.sa_brandid,
-				where: {
-					"istool": 0, //默认0,不是工具,1表示工具
-				}
-			}
+			content
 		}).then(res => {
 			console.log("营销类别", res)
 
@@ -183,6 +218,7 @@ Page({
 		content.brandids = [this.data.brand.sa_brandid];
 		content.where.itemclassid = this.data.cType.itemclassid;
 		content.where.tradefield = this.data.tradefieid;
+		if (sys_enterpriseid) content.sys_enterpriseid = sys_enterpriseid;
 		_Http.basic({
 			"id": 20220926142203,
 			content

+ 25 - 1
packageA/market/index.scss

@@ -17,7 +17,31 @@
 	}
 }
 
-.division{
+.division {
 	height: 10rpx;
 	background-color: #F4F5F7;
+}
+
+
+.footer {
+	display: flex;
+	justify-content: center;
+	position: fixed;
+	bottom: 0;
+	width: 100vw;
+	min-height: 130rpx;
+	background-color: #fff;
+	box-shadow: rgba(0, 0, 0, 0.15) 0px 5rpx 15rpx 0px;
+	z-index: 999999999999999;
+
+	.but {
+		width: 690rpx;
+		height: 90rpx;
+		background: #FA8C16;
+		border-radius: 16rpx;
+		font-size: 28rpx;
+		font-weight: 600;
+		color: #FFFFFF;
+		margin-top: 10rpx;
+	}
 }

+ 5 - 3
packageA/market/index.wxml

@@ -13,10 +13,12 @@
 <view class="division" />
 <Yl_ListBox id='ListBox' bind:getlist='getList'>
 	<List list="{{list}}" />
+	<view wx:if="{{userrole=='业务员'}}" style="height: 80rpx;" />
 </Yl_ListBox>
-
 <!-- 筛选条件 -->
 <Yl_Filtrate id='Filtrate' list="{{filter}}" bind:handle="handleFilter" dateRange='{{false}}' />
-
 <!-- 购物车按钮 -->
-<Float wx:if="{{userrole!='业务员'}}" id="Float" pageType="{{istool==0?'Standard':'Tool'}}" />
+<Float wx:if="{{userrole!='业务员'}}" id="Float" pageType="{{istool==0?'Standard':'Tool'}}" />
+<view wx:else class="footer">
+	<van-button custom-class='but' bindtap="selsectedRole">{{buttonText||"选择客户/经销商"}}</van-button>
+</view>

+ 109 - 0
packageA/market/selected/index.js

@@ -0,0 +1,109 @@
+const _Http = getApp().globalData.http;
+
+Page({
+  data: {
+    result: [],
+    content: {
+      "nocache": true,
+      "pageNumber": 1,
+      "pageSize": 20,
+      "total": null,
+      "where": {
+        "condition": "",
+        "type": 7
+      }
+    }
+  },
+  onLoad(options) {
+    this.getList();
+  },
+  tabChange(e) {
+    this.data.content.where.type = e.detail.title == '客户' ? 7 : 5;
+    this.getList(true)
+  },
+  changeResult(e) {
+    const {
+      item
+    } = e.currentTarget.dataset;
+    wx.showModal({
+      title: '提示',
+      content: `是否确认选择${item.enterprisename}?`,
+      complete: ({
+        confirm
+      }) => {
+        if (confirm) getApp().globalData.handleSelect(item);
+      }
+    })
+  },
+  /* 获取列表 */
+  getList(init = false) {
+    //init 用于初始化分页
+    if (init.detail != undefined) init = init.detail;
+    let content = this.data.content;
+    if (init) content.pageNumber = 1;
+    if (content.pageNumber > content.pageTotal) return;
+    _Http.basic({
+      "id": 20220920083901,
+      content
+    }).then(res => {
+      console.log("关联客户列表", res)
+      this.selectComponent('#ListBox').RefreshToComplete();
+      if (res.msg != '成功') return wx.showToast({
+        title: res.data,
+        icon: "none"
+      })
+      this.setData({
+        'content.pageNumber': res.pageNumber + 1,
+        'content.pageTotal': res.pageTotal,
+        'content.total': res.total,
+        list: res.pageNumber == 1 ? res.data : this.data.list.concat(res.data)
+      })
+      this.getTags();
+    })
+  },
+  /* 开始搜索 */
+  startSearch({
+    detail
+  }) {
+    if (detail == this.data.content.where.condition) return;
+    this.setData({
+      'content.where.condition': detail
+    });
+    this.getList(true);
+  },
+  /* 取消搜索 */
+  onClear() {
+    this.setData({
+      'content.where.condition': ""
+    });
+    this.getList(true);
+  },
+  /* 获取标签 */
+  getTags() {
+    let list = this.data.list,
+      ownerids = list.map(v => v.sa_customersid);
+    _Http.basic({
+      "id": 20221018102001,
+      "content": {
+        "ownertable": "sa_customers",
+        ownerids
+      }
+    }).then(res => {
+      console.log("标签", res)
+      if (res.msg != '成功') return;
+      for (let key in res.data) {
+        let index = list.findIndex(v => v.sa_customersid == key);
+        if (index != -1) list[index].tags = res.data[key]
+      };
+      this.setData({
+        list
+      })
+    })
+  },
+  onReady() {
+    this.selectComponent("#ListBox").setHeight(".search", this);
+  },
+  onUnload() {
+    getApp().globalData.handleSelect = null;
+  }
+})

+ 5 - 0
packageA/market/selected/index.json

@@ -0,0 +1,5 @@
+{
+  "usingComponents": {
+    "van-tag": "@vant/weapp/tag/index"
+  }
+}

+ 103 - 0
packageA/market/selected/index.scss

@@ -0,0 +1,103 @@
+page {
+	height: 100vh;
+	overflow: hidden;
+}
+
+.custom-class {
+	border-bottom: 1px solid #ddd;
+}
+
+.total {
+	height: 60rpx;
+	line-height: 60rpx;
+	font-size: 24rpx;
+	font-family: PingFang SC-Regular, PingFang SC;
+	color: #666666;
+	padding-left: 30rpx;
+}
+
+.setclient-list-item {
+	width: 100vw;
+	padding-left: 30rpx;
+	background-color: #fff;
+	box-sizing: border-box;
+
+	.con {
+		display: flex;
+		width: 100%;
+		min-height: 136rpx;
+		border-bottom: 1px solid #EFEFEF;
+		box-sizing: border-box;
+		padding-top: 20rpx;
+
+		.portrait {
+			width: 96rpx;
+			height: 96rpx;
+			background: #E7EEFF;
+			border-radius: 16rpx;
+			font-size: 24rpx;
+			font-family: PingFang SC-Regular, PingFang SC;
+			color: #3874F6;
+			padding: 16rpx 24rpx;
+			box-sizing: border-box;
+			margin-right: 20rpx;
+			flex-shrink: 0;
+		}
+
+		.min-portrait {
+			display: flex;
+			align-items: center;
+			padding: 0 !important;
+			justify-content: center;
+		}
+
+		.mian {
+			flex: 1;
+			width: 0;
+			padding-right: 20rpx;
+			box-sizing: border-box;
+
+			.label {
+				font-size: 28rpx;
+				font-family: PingFang SC-Bold, PingFang SC;
+				font-weight: bold;
+				color: #333333;
+				height: 40rpx;
+				line-height: 40rpx;
+			}
+
+			.tag-box {
+				margin-top: 10rpx;
+
+				.tag {
+					height: 40rpx;
+					font-size: 20rpx;
+					font-family: PingFang SC-Regular, PingFang SC;
+					padding: 0 12rpx;
+					margin-right: 10rpx;
+				}
+			}
+		}
+
+		.checkbox {
+			display: flex;
+			align-items: center;
+			margin-top: -20rpx;
+			margin-right: 10rpx;
+		}
+
+		.extend {
+			display: flex;
+			height: 116rpx;
+			width: 48rpx;
+			margin-right: 30rpx;
+			flex-shrink: 0;
+		}
+	}
+}
+
+.line-1 {
+	overflow: hidden;
+	white-space: nowrap;
+	text-overflow: ellipsis;
+}

+ 31 - 0
packageA/market/selected/index.wxml

@@ -0,0 +1,31 @@
+<van-tabs bindchange="tabChange" color='var(--assist)' custom-class='custom-class'>
+    <van-tab title="客户" />
+    <van-tab title="经销商" />
+</van-tabs>
+<van-search class="search" value="{{ content.where.condition }}" shape="round" placeholder="请输入搜索关键词" bind:search='startSearch' bind:clear='onClear' />
+<Yl_ListBox id='ListBox' bind:getlist='getList'>
+    <view class="total">共{{content.total}}个</view>
+    <navigator class="setclient-list-item" url="#" wx:for="{{list}}" wx:key="sys_enterpriseid" data-item="{{item}}" bindtap="changeResult">
+        <view class="con">
+            <view class="portrait {{item.enterprisename <=2?'min-portrait':''}}">
+                {{handle.getName(item.enterprisename)}}
+            </view>
+            <view class="mian">
+                <view class="label line-1">{{item.enterprisename}}</view>
+                <view class="tag-box">
+                    <van-tag custom-class='tag' color='#E7EEFF' wx:if="{{item.type}}" text-color='#3874F6' round>{{item.type}}</van-tag>
+                    <van-tag custom-class='tag' wx:for="{{item.tags.systemtag}}" wx:for-item='tag' wx:key="index" color='#E7EEFF' text-color='#3874F6' round>{{tag}}</van-tag>
+                    <van-tag custom-class='tag' wx:for="{{item.tags.datatag}}" wx:for-item='tag' wx:key="index" color='#FFEFD9' text-color='#FA8C16' round>{{tag}}</van-tag>
+                </view>
+            </view>
+        </view>
+    </navigator>
+    <My_empty wx:if="{{!list.length}}" />
+</Yl_ListBox>
+<wxs module="handle">
+    module.exports = {
+        getName: function (name) {
+            return name.substring(0, 4)
+        }
+    }
+</wxs>