ground_detail.html 8.88 KB
<!--上架 -  详情页 - wwb-->
<!doctype html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		<link rel="import" href="./detail_tpl.html" id="ground_detail_tpl"/>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link href="../../css/mui.min.css" rel="stylesheet" />
		<link href="../../css/themes.css" rel="stylesheet" />
		<link href="../../css/check.css"  rel="stylesheet"/>
		<link href="../../css/index_view.css" rel="stylesheet" />
		
	</head>

	<body>
		<div class="mui-content detailRow">
			<form class="mui-input-group" id="detailContent" style="background:none;">
				<ul class="mui-table-view" style="margin-bottom:12px;">
					<li class="mui-table-view-cell mui-collapse">
						<a class="mui-navigate-right" href="#">产品信息</a>
						<div class="mui-collapse-content">
							
						</div>
					</li>
				</ul>
			</form>
			
		</div>
		
		<script src="../../js/mui.min.js"></script>
		<script src="../../js/jquery.min.js"></script>
		<script src="../../js/template-web.js" type="text/javascript" charset="utf-8"></script>
		<script src="../../js/utils.js" type="text/javascript" charset="utf-8"></script>
		<script src="../../js/common.js" type="text/javascript" charset="utf-8"></script>
		<script src="../../js/request.js" type="text/javascript" charset="utf-8"></script>
		<script type="text/javascript">
			function clicked(){
				common.openwin('../commonPages/qrcode',true,{ titleText: '扫码上架' })
			}
			var acceptoodsVo = [];//定义实际货位的列表集合
			/*获取二维码返回值*/
			function scaned(t, r, f) {
				console.log(r);//返回二维码读取的数据
				var list = acceptoodsVo;
				if(r && Array.isArray(list) && list.length >0){
					var locationCode = list.filter(function(item){
						return item.positionName == r;
					})[0];
					if(locationCode){
						mui.alert('扫描成功!','提示','确定',function (e) {
							//jQuery(".realReceiveStore").val(locationCode.id); 
							document.getElementsByClassName('realReceiveStore')[0].value = locationCode.id;
						},'div')
					}else{
						mui.alert('扫描的货位码不在实际货位码可选集合中,请重新扫描!','提示','确定',function (e) {},'div')
					}
				}
			}

			(function($,$$) {
				var utils = new Utils();
				utils.appendModule('#ground_detail_tpl');
				
				function showData(data){
					var html = template('detail_tpl', data);
					document.getElementById('detailContent').innerHTML = html;
				}
				
				/* 过滤还有备选货位的数据 */
				 function filterDatas(datas,upFinishType){
					 
					var list  = datas.list;
					if(upFinishType != "1" && list.length && list.length > 0){//未上架
						for(var i = 0,len = list.length;i<len;i++){
							if(!list[i].upParentId){//指示货位
								list[i].realNum = list[i].realReceiveQuantiry;
							}
						}
					}
					return datas;
				} 
				
				$.plusReady(function(){
					$.init({
						beforeback: function() {
					        var list = plus.webview.currentWebview().opener();  
					        mui.fire(list, 'pagefresh',{ selectTabs: details.selectTabs === 1 ? 0: 1, query: details.query }); 
					        return true;  
				    	}
					})
					
					var self = plus.webview.currentWebview();
					var details = JSON.parse(self.details);//获得参数
					
					var upParentId = details.upParentId;
					console.log(JSON.stringify(details.selectTabs) );
					var postData = {
						distributeCode: details.distributeCode,
						upFinishType: details.upFinishType,
						id: details.id
					};
					var detailData = {};
					var url = '/a/shelfInfo/shelfInfoList',
						titleUrl = '/a/shelfInfo/shelfInfoTitle',
						groundUrl = '/a/checkacceptdetail/finish';
					plus.nativeUI.showWaiting('加载中...');
					mui.ajaxRequest(titleUrl,{
						type: 'POST',
						data: { distributeCode: postData.distributeCode },
						success: function(data){
							console.log(JSON.stringify(data))
							if(data.code === 200){
								for(var key in data.data){
									detailData[key] = data.data[key];
								}
								mui.ajaxRequest(url,{
									type: 'POST',
									data: postData,
									success: function(data){
										console.log(JSON.stringify(data))
										plus.nativeUI.closeWaiting();
										if(data.code === 200){
											
											detailData.list = data.data.list;
											if(data.data.list && data.data.list[0] && data.data.list[0].acceptoodsVo){
												acceptoodsVo = data.data.list[0].acceptoodsVo;
											}
											
											console.log('detailData********************************')
											
											var _detailData = filterDatas(detailData,details.upFinishType);
											showData(_detailData);
											if(details.upFinishType === '0'){
												var groundBtn = '<button type="button" id="ground" class="mui-btn mui-btn-warning mui-btn-block" style="margin-bottom: 20px;" data-loading-text = "提交中" data-loading-icon-position="right">确认上架</button>'
												document.querySelector('.detailRow').insertAdjacentHTML("beforeEnd",groundBtn);
											}
										}else{
											mui.toast(data.msg,{ type: 'div' });
										}
									},
									error: function(xhr,type,errorThrown){
										console.log(xhr.responseText)
			                		}
								});
							}else{
								mui.toast(data.msg,{ type: 'div' });
							}
							
						},
						error: function(xhr,type,errorThrown){
							console.log(xhr.responseText)
                		}
					})
					
					// 上架
					console.log(details.upFinishType)
					if(details.upFinishType === '0'){
						var ground = (document.querySelector('#ground'));
						$('.detailRow').on('tap','#ground',function(e){
							document.activeElement.blur(); // 隐藏软键盘
							var edit = document.querySelectorAll('.goodsInfo');
							var id = detailData.list[0].id;
							
							
							if(edit[0] && edit.length > 0){
								var detailListVo = [],submitData = {};
								mui.each(edit,function(index,item){
									var postData = {};
									var $$input = $$(item).find('input.realNum'),realNum = 0;
									if($$input[0]){
										realNum = $$input.val()-0; 
									}
									var realReceiveStore =item.querySelector('.realReceiveStore').value;
									
									postData.id = id;
									postData.realNum = realNum;
									postData.productBatchNo = detailData.list[0].productBatchNo;
									postData.realReceiveStore = realReceiveStore;
									postData.upParentId = detailData.list[index].upParentId?detailData.list[index].upParentId:"";
									detailListVo.push(postData);
								});
								submitData.detailListVo = detailListVo;
								submitData.distributeCode = details.distributeCode;
								console.log(submitData)
							}
							var btnArray = ['否', '是'];
							mui.confirm('是否确认上架?', '操作提示', btnArray, function(e) {
								if (e.index == 1) {
									mui.ajaxRequest(groundUrl,{
				                		type: 'POST',
				                		data: submitData,
				                		contentType: "application/json",
				                		showWaiting: true,
				                		success: function(data){
				                			if(data.code === 200){
				                				//mui.toast('上架成功',{ type: 'div' });
												mui.alert(data.data);
				                				var page =  plus.webview.getWebviewById('ground_not_list');
												mui.fire(page,'pagefresh',{ selectTab: '1' });
												common.gotowin('acc_not_list',{  });
												plus.webview.currentWebview().close();
				                			}else{
				                				mui.alert(data.msg)
				                			}
				                		},
				                		error: function(xhr,type,errorThrown){
											console.log(xhr.responseText)
				                		}
				            		});
								}
							},'div')
						});
					}
					
					//绑定输入实际上架数验证
					$$('#detailContent').on('keyup','.realNum',function(){
						
						var _this = this,$$this = $$(this);
						var id = _this.dataset.id,realReceiveQuantiry = _this.dataset.realreceivequantiry-0,oldValue = _this.dataset.oldvalue-0;
						_this.value = _this.value.replace(/\D/g,'')-0;
						var count = 0;
						var eles = mui(".mui-input-row input[data-id='"+id+"']"),len = eles.length;
						eles.each(function (e) {
						  count += this.value-0;
						});
						if(count > realReceiveQuantiry){
							if(len == 2){
								var text1 = "该药品存在“补货指示货位”和“备选上架货位”,两货位实际上架数量相加不能大于指示数量"+realReceiveQuantiry+"!";
								mui.alert(text1,'提示','确定',function (e) {
									_this.value = oldValue;
								},'div')
							}else{
								var text1 = "实际上架数量不能大于指示数量"+realReceiveQuantiry+"!";
								mui.alert(text1,'提示','确定',function (e) {
									_this.value = oldValue;
								},'div')
							}
						}
					});
					
					
				})
			})(mui,jQuery);
		
		</script>
	</body>

</html>