<%@ 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;
		function doSubmit(obj){//回调函数，在编辑和保存动作时，供openDialog调用提交表单。
            if(obj == 1){
                $('#flag').val('yes');
            }else{
                $('#flag').val('no');
            }
		  if(validateForm.form()){
              if($("#workCatalogueItemStocks tr").length==0){
                  top.layer.alert('请添加申请物品！', {icon: 0});
                  return;
              }
			  $("#inputForm").submit();
			  return true;
		  }
	
		  return false;
		}
		$(document).ready(function() {
			validateForm = $("#inputForm").validate({
				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);
					}
				}
			});
            laydate.render({
                elem: '#createDate', //目标元素。由于laydate.js封装了一个轻量级的选择器引擎，因此elem还允许你传入class、tag但必须按照这种方式 '#id .class'
                event: 'focus' //响应事件。如果没有传入event，则按照默认的click
            });
            laydate.render({
                elem: '#acceptDate', //目标元素。由于laydate.js封装了一个轻量级的选择器引擎，因此elem还允许你传入class、tag但必须按照这种方式 '#id .class'
                event: 'focus' //响应事件。如果没有传入event，则按照默认的click
            });
            $("#attachment_btn").click(function () {
                $("#attachment_file").click();
            });

            $('.icheckbox_square-green').css('top','10px');
            $($('.icheckbox_square-green')[0]).css('top','0');
		});
        function insertTitle(tValue){
            var list = "${workStock.workAttachments}";
            var size = (list.split('url')).length-1;
            var files = $("#attachment_file")[0].files;            for(var i = 0;i<files.length;i++) {                var file = files[i];
            var attachmentId = "";
            var attachmentFlag = "106";
            console.log(file);
            var timestamp=new Date().getTime();

            var storeAs = "attachment-file/workStock/"+timestamp+"/"+file['name'];
            var uploadPath="http://gangwan-app.oss-cn-hangzhou.aliyuncs.com/"+storeAs;/*将这段字符串存到数据库即可*/
            var divId = "_attachment";
            $("#addFile"+divId).show();
            multipartUploadWithSts(storeAs, file,attachmentId,attachmentFlag,uploadPath,divId,size);}
        }

        function addRow(list, idx, tpl, row){
            var idx1 = $("#workCatalogueItemStocks tr").length;
            if(list == '#workCatalogueItemStocks' && idx1 < 100){
                bornTemplete(list, idx, tpl, row, idx1);
            }
        }
        function addRow2(list, idx, tpl, row){
            var idx2 = $("#workItemStocks tr").length;
            if(list == '#workItemStocks' && idx2 < 100){
                bornTemplete(list, idx, tpl, row, idx2);
            }
        }
        function bornTemplete(list, idx, tpl, row, idx1){
            $(list).append(Mustache.render(tpl, {
                idx: idx, delBtn: true, row: row,
                order:idx1 + 1
            }));
            $(list+idx).find("select").each(function(){
                $(this).val($(this).attr("data-value"));
            });
            $(list+idx).find("input[type='checkbox'], input[type='radio']").each(function(){
                var ss = $(this).attr("data-value").split(',');
                for (var i=0; i<ss.length; i++){
                    if($(this).val() == ss[i]){
                        $(this).attr("checked","checked");
                    }
                }
            });
        }
        function delRow(obj, prefix) {
            var id = $(prefix+"_id");
            var delFlag = $(prefix+"_delFlag");
            if (id.val() == ""){
                $(obj).parent().parent().remove();
            }else if(delFlag.val() == "0"){
                delFlag.val("1");
                $(obj).html("&divide;").attr("title", "撤回删除");
                $(obj).parent().parent().addClass("error");
                $(obj).parent().parent().addClass("hide");
            }else if(delFlag.val() == "1"){
                delFlag.val("0");
                $(obj).html("&times;").attr("title", "删除");
                $(obj).parent().parent().removeClass("error");
            }
           /* var idx1 = $("#workCatalogueItemStocks tr").length; //tr 总数
            for (var i = 0; i < idx1; i++) {
                $("#workCatalogueItemStocks tr").eq(i).find("td").eq(1).html(i + 1);
            }

            var idx2 = $("#workItemStocks tr").length; //tr 总数
            for(var i = 0;i < idx2;i++){
                $("#workItemStocks tr").eq(i).find("td").eq(1).html(i + 1);
            }*/
        }
        function setPNumber(obj){
            $.ajax({
                type:'post',
                url:'${ctx}/workinvoice/workInvoice/getPNumberr',
                data:{
                    "obj":obj
                },
                success:function(data){
                    var d = JSON.parse(data);
                    $("#pNumber").val(d.pNumber);
                }
            })
        }

        function setRow(obj){
            $.ajax({
                type:'post',
                url:'${ctx}/workstock/workStock/getRow',
                data:{
                    "obj":obj
                },
                success:function(data){
                    var d = JSON.parse(data);
                    addRow('#workCatalogueItemStocks',workCatalogueItemStocksRowIdx, workCatalogueItemStocksTpl);workCatalogueItemStocksRowIdx = workCatalogueItemStocksRowIdx + 1;
                    //console.log("---------"+data.companyType+"---------"+data.companyIndustry+"---------"+data.areaName);
                    //console.log("---------"+workCatalogueItemStocksRowIdx+"---------"+workCatalogueItemStocksTpl);
                    var row = workCatalogueItemStocksRowIdx - 1 ;
                    $("#"+"workCatalogueItemStocks"+row+"_name").val(d.name);
                    $("#"+"workCatalogueItemStocks"+row+"_number").val(d.number);
                    $("#"+"workCatalogueItemStocks"+row+"_type").val(d.type);
                    $("#"+"workCatalogueItemStocks"+row+"_model").val(d.model);
                    $("#"+"workCatalogueItemStocks"+row+"_primaryUnit").val(d.primaryUnit);
                }
            })
        }

        function setRow2(obj){
            $.ajax({
                type:'post',
                url:'${ctx}/workstock/workStock/getRow',
                data:{
                    "obj":obj
                },
                success:function(data){
                    var d = JSON.parse(data);
                    addRow2('#workItemStocks', workItemStocksRowIdx, workItemStocksTpl);workItemStocksRowIdx = workItemStocksRowIdx + 1;
                    var row = workItemStocksRowIdx - 1 ;
                    $("#"+"workItemStocks"+row+"_name").val(d.name);
                    $("#"+"workItemStocks"+row+"_number").val(d.number);
                    $("#"+"workItemStocks"+row+"_type").val(d.type);
                    $("#"+"workItemStocks"+row+"_model").val(d.model);
                    $("#"+"workItemStocks"+row+"_primaryUnit").val(d.primaryUnit);
                    $("#"+"workItemStocks"+row+"_catalogueItemId").val(d.catalogueItemId);

                }
            })
        }
        function  print() {
            top.layer.alert('打印功能待开发', {icon: 0});
        }
	</script>
</head>

<body>
<div class="single-form">
	<div class="container">
		<form:form id="inputForm" modelAttribute="workStock" enctype="multipart/form-data"  action ="${ctx}/workstock/workStock/saveAudit" method="post" class="form-horizontal">
			<form:hidden path="id"/>
			<form:hidden path="home"/>
			<form:hidden path="act.taskId"/>
			<form:hidden path="act.taskName"/>
			<form:hidden path="act.taskDefKey"/>
			<form:hidden path="act.procInsId"/>
			<form:hidden path="act.procDefId"/>
			<form:hidden id="flag" path="act.flag"/>
						<div class="form-group layui-row first lw16">
							<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">
									<input htmlEscape="false" readonly="true" class="form-control required layui-input" value="${workStock.createBy.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">
									<div class="input-group">
										<input htmlEscape="false" readonly="true" class="form-control required layui-input" value="${workStock.number}"/>
										<span class="input-group-btn">
											<label class="form-status"><c:choose><c:when test="${ empty workStock.status}">新添</c:when><c:otherwise>${fns:getDictLabel(workStock.status, 'audit_state','')}</c:otherwise>	</c:choose></label>
										</span>
									</div>
								</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">
									<input htmlEscape="false" readonly="true" class="form-control required layui-input" value="<fmt:formatDate value="${workStock.createDate}" pattern="yyyy-MM-dd"/>"/>
								</div>
							</div>
							<div class="layui-item layui-col-sm6">
								<label class="layui-form-label">所属部门：</label>
								<div class="layui-input-block">
									<input htmlEscape="false" readonly="true" class="form-control required layui-input" value="${workStock.officeName}"/>
								</div>
							</div>
							<div class="layui-item layui-col-sm12 with-textarea">
								<label class="layui-form-label">申请事由：</label>
								<div class="layui-input-block">
									<textarea  htmlEscape="false" rows="4"  readonly="true"  class="form-control ">${workStock.reason}</textarea>
								</div>
							</div>
						</div>

						<div class="form-group layui-row">
							<div class="form-group-label"><h2>物品申请明细</h2></div>
							<div class="layui-item nav-btns">
								<%--<a class="nav-btn nav-btn-add" onclick="addRow('#workCatalogueItemStocks', workCatalogueItemStocksRowIdx, workCatalogueItemStocksTpl);workCatalogueItemStocksRowIdx = workCatalogueItemStocksRowIdx + 1;" title="新增"><i class="fa fa-plus"></i>&nbsp;新增物品</a>

								<sys:gridselectstock2 url="${ctx}/workscrap/workScrap/selectitems" id="zzz" name="" sign="1" value=""  title="选择物品" labelName=""
													  labelValue="" cssClass="form-control layui-input required" fieldLabels="物品" fieldKeys="name" searchLabel="物品名称" searchKey="name" ></sys:gridselectstock2>--%>
							</div>
							<div class="layui-item layui-col-xs12 form-table-container">
								<table id="contentTable1" class="table table-bordered table-condensed can-edit">
									<thead>
									<tr>
										<th><span class="require-item">*</span>物品名称</th>
										<th>物品编号</th>
										<th>物品分类</th>
										<th>规格型号</th>
										<th>计量单位</th>
										<th><span class="require-item">*</span>数量</th>
										<th>描述</th>
										<%--<th width="150px">操作</th>--%>
									</tr>
									</thead>
									<tbody id="workCatalogueItemStocks">
									<c:if test="${not empty workStock.workCatalogueItemStocks}">
										<c:forEach items="${workStock.workCatalogueItemStocks}" var="workCatalogueItemStocks" varStatus="index">
											<tr id="workCatalogueItemStocks${index.index}">
												<td class="hide">
													<input id="workCatalogueItemStocks${index.index}_id" name="workCatalogueItemStocks[${index.index}].id" type="hidden" value="${workCatalogueItemStocks.id}"/>
													<input id="workCatalogueItemStocks${index.index}_delFlag" name="workCatalogueItemStocks[${index.index}].delFlag" type="hidden" value="0"/>
												</td>
												<td>
													<input id="workCatalogueItemStocks${index.index}_name" name="workCatalogueItemStocks[${index.index}].name" type="text" value="${workCatalogueItemStocks.name}" readonly="true" class="form-control "/>
												</td>
												<td>
													<input id="workCatalogueItemStocks${index.index}_number" name="workCatalogueItemStocks[${index.index}].number" type="text" value="${workCatalogueItemStocks.number}" readonly="true" class="form-control "/>
												</td>
												<td>
														<%--<input id="workCatalogueItemStocks${index.index}_type" name="workCatalogueItemStocks[${index.index}].type" type="text" value="${workCatalogueItemStocks.type}" readonly="true" class="form-control "/>--%>
														<%--<form:select id="workCatalogueItemStocks${index.index}_type" path="workCatalogueItemStocks[${index.index}].type" readonly="true" class="form-control">
                                                            <form:option value="" label="请选择"/>
                                                            <form:options items="${fns:getDictList('item_type')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
                                                        </form:select>--%>

													<input id="" name="" type="text" value="${fns:getMainDictLabel(workCatalogueItemStocks.type, 'item_type', '')}" readonly="true" class="form-control "/>
													<input id="workCatalogueItemStocks${index.index}_type" name="workCatalogueItemStocks[${index.index}].type" type="hidden" value="${workCatalogueItemStocks.type}" readonly="true" class="form-control "/>
												</td>
												<td>
													<input id="workCatalogueItemStocks${index.index}_model" name="workCatalogueItemStocks[${index.index}].model" type="text" readonly="true" value="${workCatalogueItemStocks.model}"  class="form-control "/>
												</td>
												<td>
														<%--<input id="workCatalogueItemStocks${index.index}_primaryUnit" name="workCatalogueItemStocks[${index.index}].primaryUnit" type="text" value="${workCatalogueItemStocks.primaryUnit}" readonly="true"   class="form-control "/>--%>
														<%--<form:select id="workCatalogueItemStocks${index.index}_primaryUnit" path="workCatalogueItemStocks[${index.index}].primaryUnit" readonly="true" class="form-control">
                                                            <form:option value="" label="请选择"/>
                                                            <form:options items="${fns:getDictList('full_count_unit')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
                                                        </form:select>--%>
													<input id="" name="" type="text" value="${fns:getMainDictLabel(workCatalogueItemStocks.primaryUnit, 'full_count_unit', '')}" readonly="true" class="form-control "/>
													<input id="workCatalogueItemStocks${index.index}_primaryUnit" name="workCatalogueItemStocks[${index.index}].primaryUnit" value="${workCatalogueItemStocks.primaryUnit}" type="hidden"  readonly="true" class="form-control "/>
												</td>
												<td>
													<input id="workCatalogueItemStocks${index.index}_count" readonly="true" name="workCatalogueItemStocks[${index.index}].count" type="text" value="${workCatalogueItemStocks.count}"  class="form-control "/>
												</td>
												<td>
													<input id="workCatalogueItemStocks${index.index}_detail" readonly="true" name="workCatalogueItemStocks[${index.index}].detail" type="text" value="${workCatalogueItemStocks.detail}"  class="form-control "/>
												</td>
												<%--<td class="text-center op-td">
													<span class="op-btn op-btn-delete" onclick="delRow(this, '#workCatalogueItemStocks${index.index}')" title="删除"><i class="glyphicon glyphicon-remove"></i>&nbsp;删除</span>
												</td>--%>
											</tr>
										</c:forEach>
									</c:if>
									</tbody>
								</table>
								<script type="text/template" id="workCatalogueItemStocksTpl">//<!--
												<tr id="workCatalogueItemStocks{{idx}}">
													<td class="hide">
														<input id="workCatalogueItemStocks{{idx}}_id" name="workCatalogueItemStocks[{{idx}}].id" type="hidden" value="{{row.id}}"/>
														<input id="workCatalogueItemStocks{{idx}}_delFlag" name="workCatalogueItemStocks[{{idx}}].delFlag" type="hidden" value="0"/>
													</td>
													<td>
														<input id="workCatalogueItemStocks{{idx}}_name" name="workCatalogueItemStocks[{{idx}}].name" type="text" value="{{row.name}}" class="form-control required"/>
													 </td>
													 <td>
														<input id="workCatalogueItemStocks{{idx}}_number" name="workCatalogueItemStocks[{{idx}}].number" type="text" value="{{row.number}}" class="form-control"/>
													 </td>
 													<td>
														<input id="workCatalogueItemStocks{{idx}}_type" name="workCatalogueItemStocks[{{idx}}].type" type="text" value="{{row.type}}"  class="form-control "/>
													 </td>
													 <td>
														<input id="workCatalogueItemStocks{{idx}}_model" name="workCatalogueItemStocks[{{idx}}].model" type="text" value="{{row.model}}"  class="form-control"/>
													 </td>
													 <td>
														<input id="workCatalogueItemStocks{{idx}}_primaryUnit" name="workCatalogueItemStocks[{{idx}}].primaryUnit" type="text" value="{{row.primaryUnit}}"  class="form-control "/>
													 </td>
													 <td>
														<input id="workCatalogueItemStocks{{idx}}_count" name="workCatalogueItemStocks[{{idx}}].count" type="text" value="{{row.count}}" class="form-control required"/>
													 </td>
													 <td>
														<input id="workCatalogueItemStocks{{idx}}_detail" name="workCatalogueItemStocks[{{idx}}].detail" type="text" value="{{row.detail}}" class="form-control"/>
													 </td>

													<td class="text-center op-td" id="workCatalogueItemStocks{{idx}}_td">
														{{#delBtn}}<span class="op-btn op-btn-delete" onclick="delRow(this, '#workCatalogueItemStocks{{idx}}')" title="删除"><i class="glyphicon glyphicon-remove"></i>&nbsp;删除</span>{{/delBtn}}
													</td>
												</tr>//-->
								</script>
							</div>
						</div>

			<div class="form-group layui-row lw16">
				<div class="form-group-label"><h2>物品验收明细</h2></div>
				<div class="layui-item nav-btns">
						<%--<sys:gridselectstock2 url="${ctx}/workscrap/workScrap/selectitems" id="xxx" name="" sign="2" value=""  title="选择物品" labelName=""
                                              labelValue="" cssClass="form-control layui-input required" fieldLabels="物品" fieldKeys="name" searchLabel="物品名称" searchKey="name" ></sys:gridselectstock2>--%>
				</div>

				<div class="layui-item layui-col-xs12 form-table-container">
					<table id="contentTable2" class="table table-bordered table-condensed can-edit">
						<thead>
						<tr>
							<th><span class="require-item">*</span>物品编号</th>
							<th>物品名称</th>
							<th>物品分类</th>
							<th>规格型号</th>
							<th>计量单位</th>
							<th><span class="require-item">*</span>数量</th>
							<th>单价</th>
							<th>合计</th>
							<th>采购合同</th>
							<th>供应商</th>
							<th><span class="require-item">*</span>是否固定资产</th>
								<%--<th width="150px">操作</th>--%>
						</tr>
						</thead>
						<tbody id="workItemStocks">
						<c:if test="${not empty workStock.workItemStocks}">
							<c:forEach items="${workStock.workItemStocks}" var="workItemStocks" varStatus="index">
								<tr id="workItemStocks${index.index}">
									<td class="hide">
										<input id="workItemStocks${index.index}_id" name="workItemStocks[${index.index}].id" type="hidden" value="${workItemStocks.id}"/>
										<input id="workItemStocks${index.index}_delFlag" name="workItemStocks[${index.index}].delFlag" type="hidden" value="0"/>
									</td>
									<td>
										<input id="workItemStocks${index.index}_number" name="workItemStocks[${index.index}].number" type="text" value="${workItemStocks.number}" readonly="true" class="form-control "/>
									</td>
									<td>
										<input id="workItemStocks${index.index}_name" name="workItemStocks[${index.index}].name" type="text" value="${workItemStocks.name}" readonly="true" class="form-control "/>
										<input id="workItemStocks${index.index}_catalogueItemId" name="workItemStocks[${index.index}].catalogueItemId" type="hidden" value="${workItemStocks.catalogueItemId}"  class="form-control "/>
									</td>
									<td>
										<input id="workItemStocks${index.index}_type" name="workItemStocks[${index.index}].type" type="text" value="${workItemStocks.type}" readonly="true" class="form-control "/>
									</td>
									<td>
										<input id="workItemStocks${index.index}_model" name="workItemStocks[${index.index}].model" type="text" value="${workItemStocks.model}" readonly="true" class="form-control "/>
									</td>
									<td>
										<%--<input id="workItemStocks${index.index}_primaryUnit" name="workItemStocks[${index.index}].primaryUnit" type="text" value="${workItemStocks.primaryUnit}" readonly="true" class="form-control "/>--%>
										<input id="" name="" type="text" value="${fns:getMainDictLabel(workItemStocks.primaryUnit, 'full_count_unit', '')}" readonly="true" class="form-control "/>
										<input id="workItemStocks${index.index}_primaryUnit" name="workItemStocks[${index.index}].primaryUnit" value="${workItemStocks.primaryUnit}" type="hidden"  readonly="true" class="form-control "/>
									</td>
									<td>
										<input id="workItemStocks${index.index}_count" name="workItemStocks[${index.index}].count" type="text" value="${workItemStocks.count}" readonly="true" class="form-control required"/>
									</td>
									<td>
										<input id="workItemStocks${index.index}_price" name="workItemStocks[${index.index}].price" type="text" value="${workItemStocks.price}" readonly="true" class="form-control "/>
									</td>
									<td>
										<input id="workItemStocks${index.index}_totalPrice" name="workItemStocks[${index.index}].totalPrice" type="text" value="${workItemStocks.totalPrice}" readonly="true" class="form-control "/>
									</td>
									<td>
										<input id="workItemStocks${index.index}_contractName" name="workItemStocks[${index.index}].contractName" type="text" value="${workItemStocks.contractName}" readonly="true" class="form-control "/>
										<input id="workItemStocks${index.index}_contractId" name="workItemStocks[${index.index}].contractId" type="hidden" value="${workItemStocks.contractId}" readonly="true" class="form-control "/>
									</td>
									<td>
										<input id="workItemStocks${index.index}_supplierName" name="workItemStocks[${index.index}].supplierName" type="text" value="${workItemStocks.supplierName}" readonly="true" class="form-control "/>
									</td>
									<td>
										<input id="workItemStocks${index.index}_isAssets" name=" " type="text" value="${fns:getDictLabel(workItemStocks.isAssets, 'is_assets', '')}" readonly="true" class="form-control required"/>
										<input id=" " name="workItemStocks[${index.index}].isAssets" value="${workItemStocks.isAssets}" type="hidden"  readonly="true" class="form-control "/>
									</td>
										<%--<td class="text-center op-td">
                                            <span class="op-btn op-btn-delete" onclick="delRow(this, '#workItemStocks${index.index}')" title="删除"><i class="glyphicon glyphicon-remove"></i>&nbsp;删除</span>
                                        </td>--%>
								</tr>
							</c:forEach>
						</c:if>
						</tbody>
					</table>
					<script type="text/template" id="workItemStocksTpl">//<!--
                                    <tr id="workItemStocks{{idx}}">
                                        <td class="hide">
                                            <input id="workItemStocks{{idx}}_id" name="workItemStocks[{{idx}}].id" type="hidden" value="{{row.id}}"/>
                                            <input id="workItemStocks{{idx}}_delFlag" name="workItemStocks[{{idx}}].delFlag" type="hidden" value="0"/>
                                        </td>
                                    	<td>
                                        	<input id="workItemStocks{{idx}}_number" name="workItemStocks[{{idx}}].number" type="text" value="{{row.number}}"  readonly="true"  class="form-control required"/>
                                   		 </td>
										<td>
                                        	<input id="workItemStocks{{idx}}_name" name="workItemStocks[{{idx}}].name" type="text" value="{{row.name}}"  readonly="true"  class="form-control"/>
                                        	<input id="workItemStocks{{idx}}_catalogueItemId" name="workItemStocks[{{idx}}].catalogueItemId" type="text" value="{{row.catalogueItemId}}" type="hidden"  class="form-control"/>
                                   		 </td>
                                   		 <td>
                                        	<input id="workItemStocks{{idx}}_type" name="workItemStocks[{{idx}}].type" type="text" value="{{row.type}}"  readonly="true"  class="form-control "/>
                                   		 </td>
                                   		 <td>
                                        	<input id="workItemStocks{{idx}}_model" name="workItemStocks[{{idx}}].model" type="text" value="{{row.model}}"  readonly="true"  class="form-control "/>
                                   		 </td>
                                   		 <td>
                                        	<input id="workItemStocks{{idx}}_primaryUnit" name="workItemStocks[{{idx}}].primaryUnit" type="text" value="{{row.primaryUnit}}"  readonly="true"  class="form-control "/>
                                   		 </td>
                                   		 <td>
                                        	<input id="workItemStocks{{idx}}_count" name="workItemStocks[{{idx}}].count" type="text" value="{{row.count}}"   class="form-control required"/>
                                   		 </td>
                                   		 <td>
                                        	<input id="workItemStocks{{idx}}_price" name="workItemStocks[{{idx}}].price" type="text" value="{{row.price}}"   class="form-control "/>
                                   		 </td>
                                   		 <td>
                                        	<input id="workItemStocks{{idx}}_totalPrice" name="workItemStocks[{{idx}}].totalPrice" type="text" value="{{row.totalPrice}}"    class="form-control "/>
                                   		 </td>
                                   		 <td>
                                        	<input id="workItemStocks{{idx}}_contractName" name="workItemStocks[{{idx}}].contractName" type="text" value="{{row.contractName}}"   class="form-control "/>
                                   		 </td>
                                   		  <td>
                                        	<input id="workItemStocks{{idx}}_supplierName" name="workItemStocks[{{idx}}].supplierName" type="text" value="{{row.supplierName}}" class="form-control "/>
                                   		 </td>
                                   		  <td>
                                        	<input id="workItemStocks{{idx}}_isAssets" name="workItemStocks[{{idx}}].isAssets" type="text" value="{{row.isAssets}}" class="form-control required"/>
                                   		 </td>

                                        <td class="text-center op-td" id="workItemStocks{{idx}}_td">
                                            {{#delBtn}}<span class="op-btn op-btn-delete" onclick="delRow(this, '#workItemStocks{{idx}}')" title="删除"><i class="glyphicon glyphicon-remove"></i>&nbsp;删除</span>{{/delBtn}}
                                        </td>
                                    </tr>//-->
					</script>
				</div>
			</div>

						<div class="form-group layui-row lw16">
							<div class="form-group-label"><h2>固定资产编码</h2></div>
							<div class="layui-item nav-btns">
								<a class="nav-btn nav-btn-add" onclick="print()" title="打印"><i class=""></i>&nbsp;打印</a>
								<%--<sys:gridselectstock2 url="${ctx}/workscrap/workScrap/selectitems" id="xxx" name="" sign="2" value=""  title="选择物品" labelName=""
													  labelValue="" cssClass="form-control layui-input required" fieldLabels="物品" fieldKeys="name" searchLabel="物品名称" searchKey="name" ></sys:gridselectstock2>--%>
							</div>

							<div class="layui-item layui-col-xs12 form-table-container">
								<table id="contentTable3" class="table table-bordered table-condensed can-edit">
									<thead>
									<tr>
										<th width="20px"> <input type="checkbox" class="i-checks"></th>
										<th>物品名称</th>
										<th>物品编号</th>
										<th>物品分类</th>
										<th>规格型号</th>
										<th>计量单位</th>
										<th>固定资产编号</th>
									</tr>
									</thead>
									<tbody id="workItemStockAssets">
									<c:if test="${not empty workStock.workItemStockAssets}">
										<c:forEach items="${workStock.workItemStockAssets}" var="workItemStockAssets" varStatus="index">
											<tr id="workItemStockAssets${index.index}">
													<td> <input type="checkbox" id="${workItemStockAssets.id}" style="top: 100%" class="i-checks form-control "></td>
												<td class="hide">
													<input id="workItemStockAssets${index.index}_id" name="workItemStockAssets[${index.index}].id" type="hidden" value="${workItemStockAssets.id}"/>
													<input id="workItemStockAssets${index.index}_delFlag" name="workItemStockAssets[${index.index}].delFlag" type="hidden" value="0"/>
												</td>
												<td>
													<input id="workItemStockAssets${index.index}_name" name="workItemStockAssets[${index.index}].name" type="text" value="${workItemStockAssets.name}" readonly="true" class="form-control "/>
												</td>
												<td>
													<input id="workItemStockAssets${index.index}_number" name="workItemStockAssets[${index.index}].number" type="text" value="${workItemStockAssets.number}" readonly="true" class="form-control "/>
												</td>
												<td>
													<input id="workItemStockAssets${index.index}_type" name="workItemStockAssets[${index.index}].type" type="text" value="${workItemStockAssets.type}" readonly="true" class="form-control "/>
												</td>
												<td>
													<input id="workItemStockAssets${index.index}_model" name="workItemStockAssets[${index.index}].model" type="text" value="${workItemStockAssets.model}" readonly="true" class="form-control "/>
												</td>
												<td>
													<%--<input id="workItemStockAssets${index.index}_primaryUnit" name="workItemStockAssets[${index.index}].primaryUnit" type="text" value="${workItemStockAssets.primaryUnit}" readonly="true" class="form-control "/>--%>
													<input id="" name="" type="text" value="${fns:getMainDictLabel(workItemStockAssets.primaryUnit, 'full_count_unit', '')}" readonly="true" class="form-control "/>
													<input id="workItemStockAssets${index.index}_primaryUnit" name="workItemStockAssets[${index.index}].primaryUnit" value="${workItemStockAssets.primaryUnit}" type="hidden"  readonly="true" class="form-control "/>
												</td>
												<td>
													<input id="workItemStockAssets${index.index}_assetsNumber" name="workItemStockAssets[${index.index}].assetsNumber" type="text" value="${workItemStockAssets.assetsNumber}" readonly="true" class="form-control required"/>
												</td>

												<td>
													<input id="workItemStockAssets${index.index}_count" name="workItemStockAssets[${index.index}].count" type="hidden" value="${workItemStockAssets.count}" readonly="true" class="form-control required"/>
												</td>
												<td>
													<input id="workItemStockAssets${index.index}_contractId" name="workItemStockAssets[${index.index}].contractId" type="hidden" value="${workItemStockAssets.contractId}" readonly="true" class="form-control required"/>
												</td>
												<td>
													<input id="workItemStockAssets${index.index}_catalogueItemId" name="workItemStockAssets[${index.index}].catalogueItemId" type="hidden" value="${workItemStockAssets.catalogueItemId}" readonly="true" class="form-control required"/>
												</td>
												<%--<td class="text-center op-td">
													<span class="op-btn op-btn-delete" onclick="delRow(this, '#workItemStocks${index.index}')" title="删除"><i class="glyphicon glyphicon-remove"></i>&nbsp;删除</span>
												</td>--%>
											</tr>
										</c:forEach>
									</c:if>
									</tbody>
								</table>
								<script type="text/javascript">
                                    var workCatalogueItemStocksRowIdx = 0, workCatalogueItemStocksTpl = $("#workCatalogueItemStocksTpl").html().replace(/(\/\/\<!\-\-)|(\/\/\-\->)/g,"");
                                    var workItemStocksRowIdx = 0, workItemStocksTpl = $("#workItemStocksTpl").html().replace(/(\/\/\<!\-\-)|(\/\/\-\->)/g,"");
                                    var workItemStockAssetsRowIdx = 0/*workItemStockAssetsTpl = $("#workItemStockAssetsTpl").html().replace(/(\/\/\<!\-\-)|(\/\/\-\->)/g,"")*/;

                                    if($("#id").val()){
                                        workCatalogueItemStocksRowIdx = ${fn:length(workStock.workCatalogueItemStocks)};
                                        workItemStocksRowIdx = ${fn:length(workStock.workItemStocks)};
                                        workItemStockAssetsRowIdx = ${fn:length(workStock.workItemStockAssets)};
                                    }
								</script>

							</div>

							<div class="layui-item layui-col-sm6">
								<label class="layui-form-label"><span class="require-item">*</span>验收日期：</label>
								<div class="layui-input-block">
									<input htmlEscape="false" readonly="true" class="form-control required layui-input" value="<fmt:formatDate value="${workStock.acceptDate}" pattern="yyyy-MM-dd"/>"/>
									<%--<input id="acceptDate" name="acceptDate" type="text" maxlength="20" class="laydate-icondate form-control layer-date layui-input laydate-icon"
										   value="<fmt:formatDate value="${workStock.acceptDate}" pattern="yyyy-MM-dd"/>"/>--%>
								</div>
							</div>
							<div class="layui-item layui-col-sm6">
								<label class="layui-form-label">验收人：</label>
								<div class="layui-input-block">
									<input htmlEscape="false" readonly="true" class="form-control required layui-input" value="${workStock.acceptName}"/>
								</div>
							</div>

						</div>
						<div class="form-group layui-row first lw16">
							<div class="form-group-label"><h2></h2></div>
							<div class="layui-item layui-col-sm12 with-textarea">
								<label class="layui-form-label">备注信息：</label>
								<div class="layui-input-block">
									<textarea  htmlEscape="false" rows="4" readonly="true"    class="form-control ">${workStock.remarks}</textarea>
								</div>
							</div>
						</div>

						<div class="form-group layui-row">
							<div class="form-group-label"><h2>附件信息</h2></div>
							<div class="layui-item nav-btns">
								<%--<a id="attachment_btn" class="nav-btn nav-btn-add" title="添加附件"><i class="fa fa-plus"></i>&nbsp;添加附件</a>--%>
							</div>
							<div id="addFile_attachment" style="display: none" class="upload-progress">
								<span id="fileName_attachment" ></span>
								<b><span id="baifenbi_attachment" ></span></b>
								<div class="progress">
									<div id="jindutiao_attachment" class="progress-bar" style="width: 0%" aria-valuenow="0">
									</div>
								</div>
							</div>
							<input id="attachment_file" type="file" name="attachment_file" multiple="multiple" style="display: none;" onChange="if(this.value)insertTitle(this.value);"/>
							<span id="attachment_title"></span>
							<div class="layui-item layui-col-xs12" style="padding:0 16px;">
								<table id="listAttachment" class="table table-bordered table-condensed details">
									<thead>
									<tr>
											<%-- <th>序号</th>--%>
										<th>文件预览</th>
										<th>上传人</th>
										<th>上传时间</th>
										<th width="180px">操作</th>
									</tr>
									</thead>
									<tbody id="file_attachment">
									<c:forEach items="${workStock.workAttachments}" var = "workClientAttachment" varStatus="status">
										<tr>
												<%-- <td>${status.index + 1}</td>--%>
											<c:choose>
												<c:when test="${fn:containsIgnoreCase(workClientAttachment.attachmentName,'jpg')
                                                           or fn:containsIgnoreCase(workClientAttachment.attachmentName,'png')
                                                           or fn:containsIgnoreCase(workClientAttachment.attachmentName,'gif')
                                                           or fn:containsIgnoreCase(workClientAttachment.attachmentName,'bmp')
                                                           or fn:containsIgnoreCase(workClientAttachment.attachmentName,'jpeg')}">
													<td><img src="${workClientAttachment.url}" width="50" height="50" onclick="openDialogView('预览','${ctx}/sys/picturepreview/picturePreview?url=${workClientAttachment.url}','90%','90%')" alt="${workClientAttachment.attachmentName}">
												</c:when>
												<c:otherwise>
													<c:choose>
														<c:when test="${fn:containsIgnoreCase(workClientAttachment.attachmentName,'pdf')}">
															<td><a class="attention-info" href="javascript:void(0)" onclick="preview('预览','${workClientAttachment.url}','90%','90%','1')">${workClientAttachment.attachmentName}</a></td>
														</c:when>
														<c:otherwise>
															<td><a class="attention-info" href="javascript:void(0)" onclick="preview('预览','${workClientAttachment.url}','90%','90%')">${workClientAttachment.attachmentName}</a></td>
														</c:otherwise>
													</c:choose>
												</c:otherwise>
											</c:choose>
											<td>${workClientAttachment.createBy.name}</td>
											<td><fmt:formatDate value="${workClientAttachment.createDate}" type="both"/></td>
											<td class="op-td">
												<div class="op-btn-box" >
													<a href="javascript:location.href='${ctx}/workfullmanage/workFullManage/downLoadAttach?file='+encodeURIComponent(encodeURIComponent('${workClientAttachment.url}'));" class="op-btn op-btn-download"><i class="fa fa-download"></i>&nbsp;下载</a>
													<%--<c:if test="${workClientAttachment.createBy.id eq fns:getUser().id}">
														<a href="javascript:void(0)" onclick="deleteFileFromAliyun(this,'${ctx}/sys/workattachment/deleteFileFromAliyun?url=${workClientAttachment.url}&id=${workClientAttachment.id}&type=2','addFile_attachment','_attachment')" class="op-btn op-btn-delete" ><i class="fa fa-trash"></i>&nbsp;删除</a>
													</c:if>--%>
												</div>
											</td>
										</tr>
									</c:forEach>
									</tbody>
								</table>
							</div>
						</div>

						<div class="form-group layui-row">
							<div class="form-group-label"><h2>审批意见</h2></div>
							<div class="layui-item layui-col-sm12 with-textarea">
								<label class="layui-form-label">审批意见：</label>
								<div class="layui-input-block">
									<form:textarea path="act.comment" class="form-control" rows="4" maxlength="127" />
									<input type="file" name="upload_files" style="display: none;">
								</div>
							</div>
						</div>

						<div class="form-group layui-row">
							<div class="form-group-label"><h2>审批流程</h2></div>
							<div class="layui-item layui-col-xs12 form-table-container" >
								<act:flowChart procInsId="${workStock.act.procInsId}"/>
								<act:histoicFlow procInsId="${workStock.act.procInsId}"/>
							</div>
						</div>
						<div class="form-group layui-row page-end"></div>
					</div>
				</div>
			</div>
		</form:form>
	</div>
</div>
</body>
</html>
