chenrui %!s(int64=2) %!d(string=hai) anos
pai
achega
2f29e021fa
Modificáronse 2 ficheiros con 89 adicións e 44 borrados
  1. 86 41
      pages/vinAnalyse/fitProductlist.vue
  2. 3 3
      pages/vinAnalyse/search.vue

+ 86 - 41
pages/vinAnalyse/fitProductlist.vue

@@ -1,7 +1,18 @@
 <template>
 	<view class="modal-box">
 		<view class="searchBox">
-			<view class="searchBox_l"><u-search placeholder="请输入产品编码/产品名称" v-model="keyword" bg-color="#fff" :action-style="searchStyle"></u-search></view>
+			<view class="searchBox_l">
+				<u-search
+					placeholder="请输入产品编码/产品名称"
+					@change="getSearchCon"
+					@search="getSearchCon"
+					@custom="getSearchCon"
+					@clear="clearSearch"
+					v-model="keyword"
+					bg-color="#fff"
+					:action-style="searchStyle"
+				></u-search>
+			</view>
 			<view class="searchBox_r" @click="sortShow = true">
 				<text>排序</text>
 				<u-icon color="#666666" name="paixu" custom-prefix="iscm-icon"></u-icon>
@@ -9,7 +20,7 @@
 		</view>
 		<view v-if="list.length > 0">
 			<view class="listBox" v-for="(item, i) in list" :key="i">
-				<view class="listBox_l"><image :src="item.images ?item.images :`../../static/${theme}/def_img@2x.png`" width="100%" height="100%"></image></view>
+				<view class="listBox_l"><image :src="item.images ? item.images : `../../static/${theme}/def_img@2x.png`" width="100%" height="100%"></image></view>
 				<view class="listBox_r">
 					<view class="type">{{ item.productCode }}</view>
 					<view class="tit">{{ item.productName }}i</view>
@@ -21,7 +32,7 @@
 						</view>
 						<view>
 							适配无货
-							<text>{{ item.notStockCount || 0}}</text>
+							<text>{{ item.notStockCount || 0 }}</text>
 						</view>
 					</view>
@@ -29,9 +40,9 @@
 			</view>
 			<view style="padding: 20rpx 0;"><u-loadmore :status="status" /></view>
 		</view>
-		
+
 		<view v-else class="emptyStyle"><u-empty :src="`/static/${$config('themePath')}/def_no_data@3x.png`" icon-size="150" text="暂无匹配产品" mode="list"></u-empty></view>
-		
+
 		<!-- 排序弹窗 -->
 		<u-popup v-model="sortShow" mode="right" width="60%">
 			<view class="sortPopup">
@@ -81,12 +92,12 @@ export default {
 			pageSize: 10,
 			noDataText: '暂无数据',
 			status: 'loading',
-			totalNum:0,
-			total:0
+			totalNum: 0,
+			total: 0
 		};
 	},
 	onLoad(options) {
-		this.theme = getApp().globalData.theme
+		this.theme = getApp().globalData.theme;
 		this.shelfSn = options.shelfSn;
 		let ajaxData = {
 			pageNo: this.pageNo,
@@ -95,8 +106,15 @@ export default {
 		};
 		this.loadData(ajaxData);
 		uni.setNavigationBarTitle({
-			title:options.shelfName
-		})
+			title: options.shelfName
+		});
+	},
+	onBackPress(e) {
+		if (this.sortShow) {
+			this.sortShow = false;
+			this.isSortFlag = 0;
+			return true;
+		}
 	},
 	methods: {
 		// 获取数字货架列表
@@ -105,18 +123,18 @@ export default {
 			_this.status = 'loading';
 			reportPage(params).then(res => {
 				if (res.status == 200) {
-					if(this.pageNo>1){
-						this.list = this.list.concat(res.data.list || [])
-					}else{
-						this.list = res.data.list || []
+					if (this.pageNo > 1) {
+						this.list = this.list.concat(res.data.list || []);
+					} else {
+						this.list = res.data.list || [];
 					}
-					this.totalNum = res.data.count || 0
+					this.totalNum = res.data.count || 0;
 				} else {
-					this.list = []
-					this.totalNum = 0
-					this.noDataText = res.message
+					this.list = [];
+					this.totalNum = 0;
+					this.noDataText = res.message;
 				}
-				this.status = "loadmore"
+				this.status = 'loadmore';
 			});
 		},
 		chooseSort(i) {
@@ -131,30 +149,57 @@ export default {
 			};
 			this.loadData(ajaxData);
 		},
-		handelSort() {
-			// if (this.isSortFlag == -1) {
-			// 	uni.showToast({
-			// 		title: '请选择排序方式',
-			// 		icon: 'none',
-			// 		duration: 4000
-			// 	});
-			// } else {
-				var ajaxData = {
+		// 搜索
+		getSearchCon() {
+			var reg = new RegExp('[\\u4E00-\\u9FFF]+', 'g');
+			var ajaxData = null;
+			if (reg.test(this.keyword)) {
+				//包含汉字
+				ajaxData = {
+					pageNo: 1,
+					pageSize: this.pageSize,
 					shelfSn: this.shelfSn,
-					pageNo: this.pageNo,
-					pageSize: this.pageSize
+					productName: this.keyword.trim()
 				};
-				if (this.isSortFlag == 0) {
-					ajaxData.orderBy = 'xvfp.scan_vin_date desc,xp.code asc';
-				} else if (this.isSortFlag == 1) {
-					ajaxData.orderBy = 'xvfp.in_stock_count desc,xp.code asc';
-				} else {
-					ajaxData.orderBy = 'xvfp.not_stock_count desc,xp.code asc';
+			} else {
+				ajaxData = {
+					pageNo: 1,
+					pageSize: this.pageSize,
+					shelfSn: this.shelfSn,
+					productCode: this.keyword.trim()
+				};
+			}
+			this.loadData(ajaxData);
+		},
+		// 清空搜索内容
+		clearSearch() {
+			this.keyword = '';
+			this.reset();
+		},
+		handelSort() {
+			var ajaxData = {
+				shelfSn: this.shelfSn,
+				pageNo: this.pageNo,
+				pageSize: this.pageSize
+			};
+			if (this.keyword) {
+				var reg = new RegExp('[\\u4E00-\\u9FFF]+', 'g');
+				if (reg.test(this.keyword)) {
+					ajaxData.productName=this.keyword.trim();
+				}else{
+					ajaxData.productCode=this.keyword.trim();
 				}
-				this.sortShow=false;
-				this.loadData(ajaxData);
 			}
-		// }
+			if (this.isSortFlag == 0) {
+				ajaxData.orderBy = 'xvfp.scan_vin_date desc,xp.code asc';
+			} else if (this.isSortFlag == 1) {
+				ajaxData.orderBy = 'xvfp.in_stock_count desc,xp.code asc';
+			} else {
+				ajaxData.orderBy = 'xvfp.not_stock_count desc,xp.code asc';
+			}
+			this.sortShow = false;
+			this.loadData(ajaxData);
+		}
 	},
 	//到底部加载更多
 	onReachBottom() {
@@ -261,13 +306,13 @@ export default {
 			color: #333;
 			margin-bottom: 30rpx;
 			font-size: 26rpx;
-			background-color: #e0e0e0;
+			border: 1rpx solid #e0e0e0;
 		}
 		.butBox {
 			margin-top: 100rpx;
 		}
 		.sortChecked {
-			background-color: #999;
+			background-color: #189dff;
 			color: #ffffff;
 		}
 	}

+ 3 - 3
pages/vinAnalyse/search.vue

@@ -119,9 +119,9 @@
 					date: '',
 					beginDate: '',
 					endDate: '',
-					airConditionerFilterFlag:undefined,
-					airFilterFlag:undefined,
-					engineOilFilterFlag:undefined,
+					airConditionerFilterFlag:null,
+					airFilterFlag:null,
+					engineOilFilterFlag:null,
 					vinCode: undefined, 
 					brandName: undefined,//车辆品牌
 					modelName: undefined//车型