<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/webpage/include/taglib.jsp"%>
<html>
<head>
	<title>物品目录</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
        var validateForm;
        $(document).ready(function() {
            if("${workCatalogueItem.isAssets}" == "1"){
                $("#isAssets1").iCheck('check')
            }else{
                $("#isAssets").iCheck('check')
            }

            if($("#createDate").val()==null || $("#createDate").val()==''){
                $("#createDate").val(getNowFormatDate());
            }

            validateForm = $("#inputForm").validate({
                submitHandler: function(form){
                    loading('正在提交，请稍等...');
                    form.submit();
                },
                rules:{
                },
                messages:{
                },
                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);
                    }
                }
            });

            laydate.render({
                elem: '#createDate', //目标元素。由于laydate.js封装了一个轻量级的选择器引擎，因此elem还允许你传入class、tag但必须按照这种方式 '#id .class'
                format: 'yyyy-MM-dd',
                type : 'date'
            });
        });
        function doSubmit(){//回调函数，在编辑和保存动作时，供openDialog调用提交表单。
			$("#inputForm").attr("action","${ctx}/workcatalogueitem/workCatalogueItem/save");
            if(validateForm.form()){

                $("#inputForm").submit();
                return true;
            }else {
                parent.layer.msg("信息未填写完整!", {icon: 5});
            }
            return false;
        }


        function getNowFormatDate() {
            var date = new Date();
            var seperator1 = "-";
            var seperator2 = ":";
            var month = date.getMonth() + 1;
            var strDate = date.getDate();
            month = (month < 10)?"0"+month:month;
            strDate = (strDate < 10)?"0"+strDate:strDate;
            var currentdate = date.getFullYear() + seperator1 + month + seperator1 + strDate;
            return currentdate;
        }

        function isNumber(val){
            if(val === "" || val ==null){
                return false;
            }
            var regPos = /^\d+(\.\d+)?$/; //非负浮点数
            var regNeg = /^(-(([0-9]+\.[0-9]*[1-9][0-9]*)|([0-9]*[1-9][0-9]*\.[0-9]+)|([0-9]*[1-9][0-9]*)))$/; //负浮点数
            if(regPos.test(val) || regNeg.test(val)){
                return true;
            }else{
                return false;
            }

        }

	</script>
	<style>
		/*超过5个汉字，调整label的长度，以下是配套的*/
		.layui-item .layui-form-label{
			width:90px;
		}
		.form-group .layui-item .layui-input-block,
		.query .layui-input-block {
			margin-left: 116px;
		}
		label.error {
			left:0;
			top:40px;
		}
	</style>
</head>
<body>
<div class="single-form">
	<div class="container">
		<form:form id="inputForm" modelAttribute="workCatalogueItem" action="${ctx}/workcatalogueitem/workCatalogueItem/save" method="post" class="form-horizontal" >
			<form:hidden path="id"/>
			<form:hidden path="removeFlat" value="0"/>
			<div class="form-group layui-row first">
				<div class="form-group-label"><h2>基本信息</h2></div>
				<div class="layui-item layui-col-sm6">
					<label class="layui-form-label"><span class="require-item">*</span>物品名称：</label>
					<div class="layui-input-block">
						<form:input path="name" htmlEscape="false"   id="name"  class="form-control required layui-input" value="${workCatalogueItem.name}"/>
					</div>
				</div>
				<div class="layui-item layui-col-sm6">
					<label class="layui-form-label"><span class="require-item">*</span>物品编号：</label>
					<div class="layui-input-block">
						<form:input path="number" htmlEscape="false"   id="number"  class="form-control required layui-input" value="${workCatalogueItem.number}"/>
					</div>
				</div>
				<div class="layui-item layui-col-sm6">
					<label class="layui-form-label"><span class="require-item">*</span>物品分类：</label>
					<div class="layui-input-block">
						<form:select path="type"  class="form-control required  simple-select">
							<form:option value="" label=""/>
							<form:options items="${fns:getMainDictList('item_type')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
						</form:select>
					</div>
				</div>
				<div class="layui-item layui-col-sm6">
					<label class="layui-form-label"><span class="require-item">*</span>规格型号：</label>
					<div class="layui-input-block">
						<form:input path="model" htmlEscape="false"   id="model"  class="form-control required layui-input" value="${workCatalogueItem.model}"/>
					</div>
				</div>
				<div class="layui-item layui-col-sm6">
					<label class="layui-form-label"><span class="require-item">*</span>计量单位：</label>
					<div class="layui-input-block">
						<form:select path="primaryUnit" class="form-control required  simple-select">
							<form:option value="" label=""/>
							<form:options items="${fns:getMainDictList('full_count_unit')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
						</form:select>
					</div>
				</div>
				<div class="layui-item layui-col-sm6">
					<label class="layui-form-label  double-line">是否固定资产：</label>
					<div class="layui-input-block">
						<input type="radio" class="i-checks" name="isAssets" checked id="isAssets1" value="1">
						<label for="isAssets1">是</label>
						<input type="radio" class="i-checks" name="isAssets" checked id="isAssets" value="0">
						<label for="isAssets">否</label>
					</div>
				</div>
				<div class="layui-item layui-col-sm6">
					<label class="layui-form-label"><span class="require-item">*</span>移除标记：</label>
					<div class="layui-input-block">
						<form:input path="" htmlEscape="false"  readonly="true" id="removeFlat"  class="form-control  layui-input" value="正常"/>
					</div>
				</div>
				<div class="layui-item layui-col-sm6">
					<label class="layui-form-label">创建日期：</label>
					<div class="layui-input-block">
						<input id="createDate" name="createDate" type="text"  maxlength="20" class="laydate-icondate form-control layer-date required layui-input laydate-icon"
							   value="<fmt:formatDate value="${workCatalogueItem.createDate}" pattern="yyyy-MM-dd"/>"/>
					</div>
				</div>
			</div>

			<div class="form-group layui-row page-end"></div>
		</form:form>
	</div>
</div>

</body>
</html>