hccy 下拉生成

<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<link rel="stylesheet" href="<%=request.getContextPath()%>/jqui/css/base/jquery-ui-1.10.4.custom.min.css">
  	<script src="<%=request.getContextPath()%>/jqui/js/jquery-ui-1.10.4.custom.min.js"></script>
	<title>商品管理</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
		$(document).ready(function() {
			
			$("#detail").delegate("input","click",function() {
				detailId = $(this).attr("id")
				if(detailId.indexOf(detailId.match("name"))==32){
					pull(detailId)
				}
			}) 
			
			
			$("#add").click(function() {
				 var id =  uuid(32, 16)
				 console.log(id)
				  var str = '<tr id="'+id+'tr">';
					
                 str = str + '<td><input type = "text" name ="proPrice.barCode" id="'+id+'barCode" value=""/><input type="hidden" name="proPrice.barCode" value="AAA"></td>'
                 str = str + '<input type = "hidden" name ="proPrice.unitNo" id="'+id+'unitNo"/><input type="hidden" name="proPrice.unitNo" value="AACC">'
                 str = str + '<td> <input type="text" name ="proPrice.name" id="'+id+'name" placeholder="请按键盘↓箭头,选择数据!" class="input-xlarge "/><input type="hidden" name="proPrice.name" value="BBB"> '
                 +"<td><select name='proPrice.isMin' class='required input-medium'>"
 				 +"<option value='0'>不是</option>"
 				 +"<option value='1'>是</option><input type='hidden' name='proPrice.isMin' value='CCC'>"
                 str = str + '<td><input type = "number" name ="proPrice.productNumberStr" id="'+id+'productNumberStr"/><input type="hidden" name="proPrice.productNumberStr" value="DDD"></td>'
                 str = str + '<td><input type = "number" name ="proPrice.priceStr" id="'+id+'priceStr"/><input type="hidden" name="proPrice.priceStr" value="EEE"></td>'
                 str = str + '<td><input type = "number" name ="proPrice.stockNumberStr" id="'+id+'stockNumber"/><input type="hidden" name="proPrice.stockNumberStr" value="FFF"></td>'
                 str = str + '</tr>';
                 $("#detail").append(str);
			})
			
			
			//$("#name").focus();
			$("#inputForm").validate({
				rules:{
					
					productNo:{remote:{
						url:"${ctx}/jhoa/base/jhOaProduct/valiteName",
						type:"post",
						data:{
							oldName:"${jhOaProduct.productNo}",
							currentName:function() {
								return $("#productNo").val();
							},
							dbName:"jh_oa_product",
							columnName:"product_no",
							"parentId":function() {
					        	return $("#parentId").val();
							},
					        columnName1:"product_type_id"
						}
					}
					
				},
					
				produtSelfNo:{
						   remote:{
							   url:"${ctx}/jhoa/base/jhOaProduct/valiteName",
							   type:"post",
							   dataType:"json",
							   data:{
								   oldName:"${jhOaProduct.produtSelfNo}",
								   currentName:function() {
							            return $("#produtSelfNo").val();
							        },
							        dbName:"jh_oa_product",
							        columnName:"produt_self_no",
							        "parentId":function() {
							        	return $("#parentId").val();
							        },
							        columnName1:"product_type_id"
	  
							   }
						   }
					   }
				},
				
				messages: {
					productNo:{remote:"商品编号已存在"},
					produtSelfNo: {remote: "商品自编码已存在"}
				},
	
				
				submitHandler: function(form){
					loading('正在提交,请稍等...');
					form.submit();
				},
				errorContainer: "#messageBox",
				errorPlacement: function(error, element) {
					$("#messageBox").text("输入有误,请先更正。");
					if (element.is(":checkbox")||element.is(":radio")||element.parent().is(".input-append")){
						error.appendTo(element.parent().parent());
					} else {
						error.insertAfter(element);
					}
				}
			});
			
			

			$("#supplierName").autocomplete({
			      minLength: 0,
			      source: function( request, response ) {
						$.post("${ctx}/jhoa/base/jhOaSupplier/autoMethod", request, function( data ) {
							response(data.items );
						});
					},
			      focus: function( event, ui ) {
			    	  $("#supplierName").val(ui.item.name);
			    	  $("#supplierId").val(ui.item.id);
			        return false;
			      },
			      select: function( event, ui ) {
			    	  $("#supplierName").val(ui.item.name);
			    	  $("#supplierId").val(ui.item.id);
			        return false;
			      },
			      create: function () {
			    	   $(this).data('ui-autocomplete')._renderItem = function (ul, item) {
			    	      return $('<li>')
			    	        .append( "<a>" + item.name + "</a>" )
			    	        .appendTo(ul);
			    	    };
			    	  }
			    });
			 $("#taxRate option[value='${jhOaProduct.taxRate}'] ").attr("selected",true);
			 
		});
		
		function pull(detailId){
			var id = detailId.substring(0,32);
			$("#"+detailId).autocomplete({
			      minLength: 0,
			      source: function( request, response ) {
						$.post("${ctx}/jhoa/unit/jhOaUnit/autoMethod", request, function( data ) {
							response(data.items );
						});
					},
			      focus: function( event, ui ) {
			    	  $("#"+detailId).val(ui.item.name);
			    	  $("#"+id+"unitNo").val(ui.item.id);
			        return false;
			      },
			      select: function( event, ui ) {
			    	  $("#"+detailId).val(ui.item.name);
			    	  $("#"+id+"unitNo").val(ui.item.id);
			        return false;
			      },
			      create: function () {
			    	   $(this).data('ui-autocomplete')._renderItem = function (ul, item) {
			    	      return $('<li>')
			    	        .append( "<a>" + item.name + "</a>" )
			    	        .appendTo(ul);
			    	    };
			    	  }
			    });
			
			
			
		}
		
		
		
		function uuid(len, radix) {
		    var chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.split('');
		    var uuid = [], i;
		    radix = radix || chars.length;
		 
		    if (len) {
		      // Compact form
		      for (i = 0; i < len; i++) uuid[i] = chars[0 | Math.random()*radix];
		    } else {
		      // rfc4122, version 4 form
		      var r;
		 
		      // rfc4122 requires these characters
		      uuid[8] = uuid[13] = uuid[18] = uuid[23] = '-';
		      uuid[14] = '4';
		 
		      // Fill in random data.  At i==19 set the high bits of clock sequence as
		      // per rfc4122, sec. 4.1.5
		      for (i = 0; i < 36; i++) {
		        if (!uuid[i]) {
		          r = 0 | Math.random()*16;
		          uuid[i] = chars[(i == 19) ? (r & 0x3) | 0x8 : r];
		        }
		      }
		    }
		 
		    return uuid.join('');
		}
	</script>
</head>
<body>
	<ul class="nav nav-tabs">
		<li><a href="${ctx}/jhoa/base/jhOaProduct/">商品列表</a></li>
		<li class="active"><a href="${ctx}/jhoa/base/jhOaProduct/form?id=${jhOaProduct.id}">商品<shiro:hasPermission name="jhoa:base:jhOaProduct:edit">${not empty jhOaProduct.id?'修改':'添加'}</shiro:hasPermission><shiro:lacksPermission name="jhoa:base:jhOaProduct:edit">查看</shiro:lacksPermission></a></li>
	</ul><br/>
	<form:form id="inputForm" modelAttribute="jhOaProduct" action="${ctx}/jhoa/base/jhOaProduct/save" method="post" class="form-horizontal">
		<form:hidden path="id"/>
		<input type="hidden" name="supplier.id" id="supplierId" value="${jhOaProduct.supplier.id}" /> 
		<sys:message content="${message}"/>
		
		<table class="table-form">
			<tr>
				<td class = "tit">商品类别: </td>
				<td>
					<sys:treeselect id="parent" name="productType.id" value="${jhOaProduct.productType.id}" labelName="productType.name" labelValue="${jhOaProduct.productType.name}"
					title="父级编号" url="/jhoa/base/jhOaProductType/treeData" extId="${productType.id}" cssClass="" allowClear="true"/>
					<span class="help-inline"><font color="red">*</font> </span>
				</td>
				<td class = "tit">商品名称: </td>
				<td>
					<form:input path="productName" htmlEscape="false" maxlength="100" class="input-xlarge required"/>
					<span class="help-inline"><font color="red">*</font> </span>
				</td>
			</tr>
			
			<tr>
				<td class = "tit">产地: </td>
				<td>
					<form:input path="productOrigin" htmlEscape="false" maxlength="255" class="input-xlarge "/>
				</td>
				<td class = "tit">供应商: </td>
				<td>
					<input type="text" name="supplier.name" id="supplierName" 
					placeholder="请按键盘↓箭头,选择数据!" value="${jhOaProduct.supplier.name}" class="input-xlarge"/>
				</td>
			</tr>
			<tr>
				<td class = "tit">包装率: </td>
				<td>
					<form:input path="productSpec" htmlEscape="false" maxlength="200" class="input-xlarge digits"/>
				</td>
				<td class = "tit">保质期(天): </td>
				<td>
					<form:input path="qualityNum" htmlEscape="false" maxlength="4" class="input-xlarge  digits"/>
				</td>
			</tr>
			
			<tr>
				<td class = "tit">商品编号: </td>
				<td>
					<form:input onKeypress="return (/[\d]/.test(String.fromCharCode(event.keyCode)))" path="productNo" htmlEscape="false" minlength="1" maxlength="4" class="input-xlarge"/>
				</td>
				<td class = "tit">商品自编码: </td>
				<td>
					<form:input onKeypress="return (/[\d]/.test(String.fromCharCode(event.keyCode)))" path="produtSelfNo" htmlEscape="false" minlength="6" maxlength="6" class="input-xlarge"/>
				</td>
			</tr>
			
			<tr>
				<td class = "tit">发票类型: </td>
				<td>
					<form:select path="invoiceType" class="input-xlarge ">
					 <option value =" "></option>
					<form:options items="${fns:getDictList('invoice_type')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
				</form:select>
				</td>
				<td class = "tit">税率: </td>
				<td>
					<select id = "taxRate" name = "taxRate">
						<option value="0" <c:if test="${jhOaProduct.taxRate==0 }">selected</c:if> >0 </ption>
						<option value="3" <c:if test="${jhOaProduct.taxRate==3 }">selected</c:if> >3%</option>
						<option value="6" <c:if test="${jhOaProduct.taxRate==6 }">selected</c:if> >6%</option>
						<option value="10" <c:if test="${jhOaProduct.taxRate==10 }">selected</c:if> >10%</option>
						<option value="11" <c:if test="${jhOaProduct.taxRate==11 }">selected</c:if> >11%</option>
						<option value="16" <c:if test="${jhOaProduct.taxRate==16 }">selected</c:if> >16%</option>
						<option value="17" <c:if test="${jhOaProduct.taxRate==17 }">selected</c:if> >17%</option>
					</select>
				</td>
			</tr>
			
			<tr>
				<td class = "tit">排序: </td>
				<td>
					<form:input path="sort" htmlEscape="false" maxlength="11" class="input-xlarge  digits"/>
				</td>
			</tr>
			<tr>
				<td class = "tit">备注: </td>
				<td>
					<form:textarea path="remarks" htmlEscape="false" rows="4" maxlength="255" class="input-xxlarge "/>
				</td>
			</tr>
		</table>		
		
		
		
		
		
		
		<table  class="table table-striped table-bordered table-condensed" style="width:200%" >
              <thead>
                     <tr>
                        <th>商品条形码</th>
						<th>单位名称</th>
						<th>是否最小单位</th>
						<th>最小单位数量</th>
						<th>默认零售价</th>
						<th>商品库存</th>
                        <th>操作</th>
                     </tr>
              </thead>
              <tbody id="detail">
		<c:forEach items="${jppList}" var="jhOaProductPrice">
			<tr>
				<td>
					${jhOaProductPrice.barCode}
				</td>
				<td><a href="${ctx}/jhoa/base/jhOaProductPrice/form?id=${jhOaProductPrice.id}">
					${jhOaProductPrice.name}
					</a>
				</td>
				<td>
					${fns:getDictLabel(jhOaProductPrice.isMin, 'is_min', '')}
				</td>
				<td>
					${jhOaProductPrice.productNumber}
				</td>
				<td>
					${jhOaProductPrice.price}
				</td>
				<td><a href="${ctx}/jhoa/base/jhOaProductPrice/formPrice?id=${jhOaProductPrice.id}">
					${jhOaProductPrice.stockNumber}
					</a>
				</td>
				<td>
				<a href="${ctx}/jhoa/base/jhOaProductPrice/delete?id=${jhOaProductPrice.id}&product.id=${jhOaProductPrice.product.id}" onclick="return confirmx('确认要删除该商品单位吗?', this.href)">删除</a>
				</td>
			</tr>
		</c:forEach>
		</tbody>
            </table>
		<div class="form-actions">
			<shiro:hasPermission name="jhoa:base:jhOaProduct:edit">
			<input id="add" class="btn btn-primary" type="button" value="添加单位详情"/> 
			<input id="btnSubmit" class="btn btn-primary" type="submit" value="保 存"/> </shiro:hasPermission>
			<input id="btnCancel" class="btn" type="button" value="返 回" onclick="history.go(-1)"/>
		</div>
	</form:form>
</body>
</html>

  

 

posted on 2018-11-10 10:38  A江里有只小鱼儿A  阅读(161)  评论(0编辑  收藏  举报