| <!DOCTYPE HTML> | 
| <html xmlns:th="http://www.thymeleaf.org"> | 
| <head> | 
| <meta charset="utf-8"> | 
| <META HTTP-EQUIV="Pragma" CONTENT="no-cache"> | 
| <meta name="renderer" content="webkit|ie-comp|ie-stand"> | 
| <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> | 
| <meta name="viewport" | 
|     content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" /> | 
| <meta http-equiv="Cache-Control" content="no-siteapp" /> | 
| <!-- 本框架基本脚本和样式 --> | 
| <script type="text/javascript" | 
|     th:src="@{/js/plugin/jquery-2.1.4.min.js}"></script> | 
| <script type="text/javascript" th:src="@{/js/systools/MBase.js}"></script> | 
| </head> | 
| <body> | 
|     <div class="ibox-content"> | 
|         <form class="form-horizontal" id="dataform" | 
|             onsubmit="javascripr:return false;"> | 
|   | 
|             <div class="form-group"> | 
|                 <label class="col-sm-2 control-label">出库类型</label> | 
|                     <div class="col-sm-3"> | 
|                         <select class="form-control autoFull" name="type" | 
|                                 id="instoreType" data-filed="name" data-value="name" | 
|                                 th:data-url="@{/admin/dataDictionary/showDataDictionary}" | 
|                                 data-param="{type:'出库类型'}" | 
|                                 datatype="*" nullmsg="出库类型不能为空"> | 
|                             <option value=''>--请选择出库类型--</option> | 
|                         </select> | 
|                         <div class="Validform_checktip"></div> | 
|                     </div> | 
|   | 
|                 <label class="col-sm-2 control-label">出库时间</label> | 
|                 <div class="col-sm-3"> | 
|                     <input autocomplete="off"   type="text" class="form-control datetimepicker" | 
|                                              name="time" readonly="readonly" | 
|                                              th:value="${#dates.format(obj==null?(new java.util.Date().getTime()):obj?.instoreDate ,'yyyy-MM-dd HH:mm:ss')}" | 
|                                              datatype="*" nullmsg="出库日期不能为空" data-formatter="MGrid.getTime"> | 
|                     <div class="Validform_checktip"></div> | 
|                 </div> | 
|             </div> | 
|   | 
|             <div class="form-group"> | 
|                 <label class="col-offset-1 col-sm-2 control-label">出库编号<span | 
|                         class="text-danger">*</span></label> | 
|   | 
|                 <div class="col-sm-3"> | 
|                     <input autocomplete="off"   type="text" th:value="${session.userInfo.suName}" name="makingmanName" class="form-control" readonly="readonly"> | 
|                 </div> | 
|   | 
|                 <label class="col-offset-1 col-sm-2 control-label">出库仓库<span | 
|                         class="text-danger">*</span></label> | 
|                 <div class="col-sm-3"> | 
|                     <select class="form-control autoFull " data-filed="name" data-value="id" | 
|                             name="shopId" id="storeId" | 
|                             th:data-url="@{/admin/warehouse/findShopWarehouse}"> | 
|                         <option value="">--请选择仓库--</option> | 
|                     </select> | 
|                 </div> | 
|             </div> | 
|   | 
|             <div class="form-group"> | 
|                 <label  class="col-sm-2 control-label">出库明细<span class="text-danger">*</span> </label>  | 
|                 <div class="col-sm-3"> | 
|                     <button class="btn btn-success btn-sm" onclick="openPruductList()" | 
|                             type="button">添加明细单 | 
|                     </button> | 
|                 </div> | 
|   | 
|             </div> | 
|             <div class="form-group"> | 
|                 <div class="col-sm-8 col-sm-offset-2"> | 
|                     <table class="table table-striped table-hover table-bordered" id="mgrid" > | 
|                         <thead> | 
|                         <tr> | 
|                             <th>序号</th> | 
|                             <th>产品编号</th> | 
|                             <th>产品名称</th> | 
|                             <th>产品类型</th> | 
|                             <th>存货单位</th> | 
|                             <th>库存量</th> | 
|                             <th>单价</th> | 
|                             <th>批次</th> | 
|                             <th width="120">数量<span class="text-danger">*</span></th> | 
|                             <th>操作</th> | 
|                         </tr> | 
|                         </thead> | 
|                         <tbody id="cpId"> | 
|   | 
|                         </tbody> | 
|   | 
|                     </table> | 
|                 </div> | 
|             </div> | 
|             <div class="form-group "> | 
|                 <div class="col-sm-12 text-center fixed-button"> | 
|                     <a href="javascript:;" onclick="submitOutStore()" | 
|                        class="btn btn-success radius"><i class="fa fa-check"></i> 保存</a>   | 
|                     <a class="btn btn-danger radius" href="javascript:;" | 
|                         onclick="MTools.closeForm()"><i class="fa fa-close"></i> 关闭</a> | 
|                 </div> | 
|             </div> | 
|         </form> | 
|     </div> | 
| </body> | 
|   | 
|   | 
| <script type="text/javascript" th:src="@{/js/systools/MJsBase.js}"></script> | 
| <script  th:inline="javascript"> | 
|     $(".select2").select2({'width':'100%'}); | 
|   | 
|     var selectArr=null; | 
|     var totalGoods=[]; | 
|     var goodsAttr = ''; | 
|     var storeId = 0; | 
|     //初始化操作 | 
|     MTools.autoFullSelect(); | 
|     // readInitData(); | 
|     writeDate(); | 
|     var myForm=MForm.initForm({ | 
|         beforeSubmit:function(){ | 
|             //是否绑定明细 | 
|             var bodyTrs=$("#cpId").find("tr"); | 
|             if(bodyTrs.length==0){ | 
|                 layer.msg("请添加消耗的产品",{icon:2}); | 
|                 return false; | 
|             } | 
|         }, | 
|         invokeUrl:basePath+"/admin/outstore/addOrModify", | 
|         afterSubmit:function(){ | 
|             parent.myGrid.serchData(); | 
|         }, | 
|     }); | 
|     //时间 | 
|     $('.datetimepicker').datetimepicker({ | 
|         //format : "yyyy-mm-dd", | 
|         format : "yyyy-mm-dd hh:ii:ss", | 
|   | 
|     }); | 
|   | 
|     $("#instoreType").change(function () { | 
|         totalGoods = []; | 
|         $("#cpId").html(''); | 
|     }); | 
|   | 
|     function submitOutStore() { | 
|         layer.confirm("提交后将减少产品库存且无法编辑,是否确认提交", function() { | 
|             myForm.submit(); | 
|         }); | 
|     } | 
|   | 
|     function callback(arr) { | 
|         console.log(arr); | 
|         removeDouble(arr); | 
|         writeDate(); | 
|     } | 
|   | 
|     function removeDouble(arr) { | 
|         if (totalGoods == null) { | 
|             totalGoods = arr; | 
|         } else { | 
|             //去重 | 
|             for (var i = 0; i < arr.length; i++) { | 
|                 var isDouble = false; | 
|                 for (var j = 0; j < totalGoods.length; j++) { | 
|                     if (arr[i].id == totalGoods[j].id) { | 
|                         isDouble = true; | 
|                         break; | 
|                     } | 
|                 } | 
|                 //如果不重复 | 
|                 if (!isDouble) { | 
|                     totalGoods[totalGoods.length] = arr[i]; | 
|                 } | 
|             } | 
|         } | 
|     } | 
|   | 
|   | 
|     //初始化产品列表 | 
|     function openPruductList() { | 
|         //获取所选择 的产品属性,传递给选择页面 | 
|         storeId = $("#storeId").val(); | 
|   | 
|         if (storeId == '') { | 
|             layer.msg("请选择仓库", {icon: 2}); | 
|             return false; | 
|         } | 
|         layer.open({ | 
|             type: 2, | 
|             title: "选择产品", | 
|             area: MUI.SIZE_M, | 
|             content: [basePath+'/admin/redirect/hive/store/select-outstore-products-list?storeId='+storeId] | 
|         }); | 
|     } | 
|   | 
|     //填写数据到html | 
|     function writeDate(){ | 
|         console.log(totalGoods); | 
|         var html=""; | 
|         for(var i=0 ; i<totalGoods.length;i++){ | 
|             if(!totalGoods[i].sum){ | 
|                 totalGoods[i].sum=""; | 
|             } | 
|             html+='<tr>' | 
|                     +'<td>'+(i+1)+'</td>' | 
|                     +'<td>'+totalGoods[i].goods.goodsNo+'<input autocomplete="off"   type="hidden" name="outStoreItems['+i+'].storeId" value="'+totalGoods[i].id+'"</td>' | 
|                     +'<td>'+totalGoods[i].goods.name+'<input autocomplete="off"   type="hidden" name="outStoreItems['+i+'].skuId" value="'+totalGoods[i].skuId+'"</td>' | 
|                     +'<td>'+totalGoods[i].goods.goodsSortName+'</td>' | 
|                     +'<td>'+totalGoods[i].goods.unit+'</td>' | 
|                     +'<td>'+totalGoods[i].storeTotal+'</td>' | 
|                     +'<td>'+totalGoods[i].goodsPrice+'</td>' | 
|                     +'<td>'+totalGoods[i].batch+'</td>' | 
|                     +'<td><input autocomplete="off"   name="outStoreItems['+i+'].amount" type="text" min="0" class="" style="width:50px" datatype="price" maxlength="10" errormsg="请输入大于0的值" value=""> <div class="Validform_checktip"></div></td>' | 
|                     +'<td class="center"><a style="text-decoration: none" class="fa fa-trash" onClick="delSelectItem(this,'+totalGoods[i].id+')" href="javascript:;" title="删除"></a></td>' | 
|                     +'</tr>' | 
|         } | 
|         $("#cpId").html(html); | 
|     } | 
|     function delSelectItem(node, id) { | 
|         //根据列表的id找到元素相应下表的元素 | 
|         for (var i = 0; i < totalGoods.length; i++) { | 
|             if (totalGoods[i].id == id) { | 
|                 totalGoods.splice(i, 1); | 
|                 break; | 
|   | 
|             } | 
|         } | 
|         //移除tr | 
|         $(node).closest('tr').remove(); | 
|         $("tbody").find("tr").each(function (i) { | 
|             $(this).find("td").eq(0).html(i + 1); | 
|         }); | 
|     } | 
|   | 
| </script> | 
| </body> | 
| </html> |