<%@ 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 == 2){
                $("#flag").val("no");
            }else{
                $("#flag").val("yes");
            }
            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();
            });
        });
        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){
                tpl = tpl.replace("workCatalogueItemStocks[0].type","workCatalogueItemStocks["+idx1+"].type");
                tpl = tpl.replace("workCatalogueItemStocks[0].primaryUnit","workCatalogueItemStocks["+idx1+"].primaryUnit");

                tpl = tpl.replace("not","not\" style=\"display:none;disabled:true;");
                tpl = tpl.replace("yes\" style=\"display:none;disabled:true;\"","yes");

                tpl = tpl.replace("stop","stop\" style=\"display:none;disabled:true;");
                tpl = tpl.replace("should\" style=\"display:none;disabled:true;\"","should");

                tpl = tpl.replace("one","one\" style=\"display:none;disabled:true;");
                tpl = tpl.replace("two\" style=\"display:none;disabled:true;\"","two");

                tpl = tpl.replace("three","three\" style=\"display:none;disabled:true;");
                tpl = tpl.replace("four\" style=\"display:none;disabled:true;\"","four");

                tpl = tpl.replace("five","five\" style=\"display:none;disabled:true;");
                tpl = tpl.replace("six\" style=\"display:none;disabled:true;\"","six");

                bornTemplete(list, idx, tpl, row, idx1);
            }
        }
        function addRows(list, idx, tpl, row){
            var idx1 = $("#workCatalogueItemStocks tr").length;
            if(list == '#workCatalogueItemStocks' && idx1 < 100){
                console.log("idx1--------"+idx1);
                tpl = tpl.replace("workCatalogueItemStocks[0].type","workCatalogueItemStocks["+idx1+"].type");
                tpl = tpl.replace("workCatalogueItemStocks[0].primaryUnit","workCatalogueItemStocks["+idx1+"].primaryUnit");

                tpl = tpl.replace("yes","yes\" style=\"display:none;disabled:true;");
                tpl = tpl.replace("not\" style=\"display:none;disabled:true;\"","not\"");

                tpl = tpl.replace("should","should\" style=\"display:none;disabled:true;");
                tpl = tpl.replace("stop\" style=\"display:none;disabled:true;\"","stop\"");

                tpl = tpl.replace("two","two\" style=\"display:none;disabled:true;");
                tpl = tpl.replace("one\" style=\"display:none;disabled:true;\"","one\"");

                tpl = tpl.replace("four","four\" style=\"display:none;disabled:true;");
                tpl = tpl.replace("three\" style=\"display:none;disabled:true;\"","three\"");

                tpl = tpl.replace("six","six\" style=\"display:none;disabled:true;");
                tpl = tpl.replace("five\" style=\"display:none;disabled:true;\"","five\"");

                bornTemplete(list, idx, tpl, row, idx1);
            }
        }
        function addRow2(list, idx, tpl, row){
            var idx2 = $("#workItemStocks tr").length;
            if(list == '#workItemStocks' && idx2 < 100){
                tpl = tpl.replace("workItemStocks[0].isAssets","workItemStocks["+idx2+"].isAssets");
                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){
            console.log(_obj);
            for (var i=0; i<_obj.length; i++) {
                console.log("------_obj-------" + _obj[i]);
                console.log("-----id----" + _obj[i].id);
                $.ajax({
                    type:'post',
                    url:'${ctx}/workstock/workStock/getRow',
                    data:{
                        "obj":_obj[i].id
                    },
                    success:function(data){
                        var d = JSON.parse(data);
                        addRows('#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+"_types").val(d.types);
                        $("#"+"workCatalogueItemStocks"+row+"_model").val(d.model);
                        $("#"+"workCatalogueItemStocks"+row+"_primaryUnit").val(d.primaryUnit);
                        //var a = "${fns:getMainDictLabel(d.primaryUnit, 'full_count_unit', '')}"
                        $("#"+"workCatalogueItemStocks"+row+"_primaryUnits").val(d.primaryUnits);  <%--${fns:getDictLabel(d.primaryUnit, 'full_count_unit', '')}--%>
                    }
                })
            }
        }

        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);
                    var a = "${fns:getMainDictLabel("1", 'full_count_unit', '')}"
                    $("#"+"workItemStocks"+row+"_type").val(d.types);
                    $("#"+"workItemStocks"+row+"_model").val(d.model);
                    $("#"+"workItemStocks"+row+"_primaryUnit").val(d.primaryUnits);
                    $("#"+"workItemStocks"+row+"_catalogueItemId").val(d.catalogueItemId);

                }
            })
        }
	</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">
					<form:input path="createBy.name" htmlEscape="false" readonly="true" class="form-control required layui-input"/>
				</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">
						<form:input path="number" id="number" htmlEscape="false" readonly="true" class="form-control layui-input"/>
						<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 class="laydate-icondate layui-input form-control layer-date laydate-icon"
						   id="createDate" name="createDate" readonly="true"
						   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">
					<form:input path="officeName" htmlEscape="false" readonly="true"  class="form-control layui-input"/>
				</div>
			</div>
			<div class="layui-item layui-col-sm12 with-textarea">
				<label class="layui-form-label">申请事由：</label>
				<div class="layui-input-block">
					<form:textarea path="reason" htmlEscape="false" rows="4"  maxlength="255"  class="form-control "/>
				</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:gridselectstock3 url="${ctx}/workscrap/workScrap/selectitems" id="zzz" name="" sign="1" value=""  title="选择物品" labelName=""
									  labelValue="" isSingle="false" cssClass="form-control layui-input required" fieldLabels="物品" fieldKeys="name" searchLabel="物品名称" searchKey="name" ></sys:gridselectstock3>
			</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 width="130px">物品分类</th>
						<th>规格型号</th>
						<th width="100px">计量单位</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" name="workCatalogueItemStocks[${index.index}].count" type="text" value="${workCatalogueItemStocks.count}"  class="form-control number required"/>
								</td>
								<td>
									<input id="workCatalogueItemStocks${index.index}_detail" 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>
														<div class="one" style="display:none;disabled:true;">
															<input id="workCatalogueItemStocks{{idx}}_name" name="workCatalogueItemStocks[{{idx}}].name" type="text" value="{{row.name}}"  readonly="true" class="form-control required"/>
														</div>
														<div class="two">
															<input id="workCatalogueItemStocks{{idx}}_name" name="workCatalogueItemStocks[{{idx}}].name" type="text" value="{{row.name}}"  class="form-control required"/>
														</div>
													 </td>
													 <td>
														<div class="three" style="display:none;disabled:true;">
														<input id="workCatalogueItemStocks{{idx}}_number" name="workCatalogueItemStocks[{{idx}}].number" type="text" value="{{row.number}}" readonly="true" class="form-control"/>
														</div>
														<div class="four">
															<input id="workCatalogueItemStocks{{idx}}_number" name="workCatalogueItemStocks[{{idx}}].number" type="text" value="{{row.number}}" class="form-control"/>
														</div>
													 </td>
 													<td>
 														<div class="not" style="display:none;disabled:true;">
															<input id="workCatalogueItemStocks{{idx}}_types" type="text" value="{{row.type}}" readonly="true" class="form-control "/>
															<input id="workCatalogueItemStocks{{idx}}_type" name="workCatalogueItemStocks[{{idx}}].type" type="hidden" value="{{row.type}}" readonly="true" class="form-control "/>
														</div>
														<div class="yes">
															<form:select id="workCatalogueItemStocks${index.index}_type" path="workCatalogueItemStocks[0].type" class="form-control">
																<form:option value="" label="请选择"/>
																<form:options items="${fns:getMainDictList('item_type')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
															</form:select>
														</div>
													 </td>
													 <td>
														<div class="five" style="display:none;disabled:true;">
														<input id="workCatalogueItemStocks{{idx}}_model" name="workCatalogueItemStocks[{{idx}}].model" type="text" value="{{row.model}}" readonly="true"class="form-control"/>
														</div>
														<div class="six">
															<input id="workCatalogueItemStocks{{idx}}_model" name="workCatalogueItemStocks[{{idx}}].model" type="text" value="{{row.model}}"  class="form-control"/>
														</div>
													 </td>
													 <td>
														<div class="stop" style="display:none;disabled:true;">
															<input id="workCatalogueItemStocks{{idx}}_primaryUnits" type="text" value="{{row.primaryUnit}}" readonly="true" class="form-control "/>
															<input id="workCatalogueItemStocks{{idx}}_primaryUnit" name="workCatalogueItemStocks[{{idx}}].primaryUnit" type="hidden" value="{{row.type}}" readonly="true" class="form-control "/>
														</div>
														<div class="should">
														<form:select id="workCatalogueItemStocks${index.index}_primaryUnit" path="workCatalogueItemStocks[0].primaryUnit" class="form-control">
															<form:option value="" label="请选择"/>
															<form:options items="${fns:getMainDictList('full_count_unit')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
														</form:select>
														</div>
													 </td>
													 <td>
														<input id="workCatalogueItemStocks{{idx}}_count" name="workCatalogueItemStocks[{{idx}}].count" type="text" value="{{row.count}}" class="form-control number 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 width="100px"><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 "/>
								</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 "/>
								</td>
								<td>
									<input id="workItemStocks${index.index}_count" name="workItemStocks[${index.index}].count" type="text" value="${workItemStocks.count}" class="form-control required"/>
								</td>
								<td>
									<input id="workItemStocks${index.index}_price" name="workItemStocks[${index.index}].price" type="text" value="${workItemStocks.price}" class="form-control "/>
								</td>
								<td>
									<input id="workItemStocks${index.index}_totalPrice" name="workItemStocks[${index.index}].totalPrice" type="text" value="${workItemStocks.totalPrice}" class="form-control "/>
								</td>
								<td>
									<input id="workItemStocks${index.index}_contractName" name="workItemStocks[${index.index}].contractName" type="text" value="${workItemStocks.contractName}" class="form-control "/>
								</td>
								<td>
									<input id="workItemStocks${index.index}_supplierName" name="workItemStocks[${index.index}].supplierName" type="text" value="${workItemStocks.supplierName}" class="form-control "/>
								</td>
								<td>
										&lt;%&ndash;<input id="workItemStocks${index.index}_isAssets" name="workItemStocks[${index.index}].isAssets" type="text" value="${workItemStocks.isAssets}" class="form-control required"/>&ndash;%&gt;
									<form:select id="workItemStocks${index.index}_isAssets" path="workItemStocks[${index.index}].isAssets" class="form-control required">
										<form:option value="" label="请选择"/>
										<form:options items="${fns:getDictList('is_assets')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
									</form:select>
								</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" 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"/>--%>
                                        	<form:select id="workItemStocks${index.index}_isAssets" path="workItemStocks[0].isAssets" class="form-control required">
															<form:option value="" label="请选择"/>
															<form:options items="${fns:getDictList('is_assets')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
														</form:select>
                                   		 </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>
				<script type="text/javascript">
                    var workCatalogueItemStocksRowIdx = 0, workCatalogueItemStocksTpl = $("#workCatalogueItemStocksTpl").html().replace(/(\/\/\<!\-\-)|(\/\/\-\->)/g,"");
                    var workItemStocksRowIdx = 0, workItemStocksTpl = $("#workItemStocksTpl").html().replace(/(\/\/\<!\-\-)|(\/\/\-\->)/g,"");
                    if($("#id").val()){
                        workCatalogueItemStocksRowIdx = ${fn:length(workStock.workCatalogueItemStocks)};
                        workItemStocksRowIdx = ${fn:length(workStock.workItemStocks)};
                    }
				</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">
					<form:input id="" path="" htmlEscape="false" readonly="true" class="form-control layui-input"/>
						<%--<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">
					<form:input id="" path="" htmlEscape="false" readonly="true" class="form-control layui-input"/>
				</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">
						<form:textarea path="remarks" htmlEscape="false" rows="4"  maxlength="255"  class="form-control "/>
					</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 page-end"></div>
	</div>
</div>
</div>
</form:form>
</div>
</div>
</body>
</html>
