| <!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> | 
|     <!-- 富文本编辑器 --> | 
|     <script type="text/javascript" charset="utf-8" | 
|             th:src="@{/plugin/beditor/ueditor.config.js}"></script> | 
|     <script type="text/javascript" charset="utf-8" | 
|             th:src="@{/plugin/beditor/ueditor.all.js}"> | 
|     </script> | 
|     <script type="text/javascript" charset="utf-8" | 
|             th:src="@{/plugin/beditor/lang/zh-cn/zh-cn.js}"></script> | 
|     <style type="text/css"> | 
|         #projBox { | 
|             max-height: 400px; | 
|             overflow: scroll; | 
|             overflow-x: hidden; | 
|         } | 
|   | 
|     </style> | 
| </head> | 
| <body> | 
| <div class="ibox-content"> | 
|     <form class="form-horizontal" id="dataform" | 
|           onsubmit="javascripr:return false;"> | 
|   | 
|         <input autocomplete="off"   type="hidden" name="id" th:value="${obj?.id}"> | 
|   | 
|         <input autocomplete="off"   type="hidden" name="salePlatform" value="线下"> | 
|         <div class="form-group"> | 
|             <label class="col-sm-2 control-label">商品名称<span | 
|                     class="text-danger">*</span></label> | 
|             <div class="col-sm-3"> | 
|                 <input autocomplete="off"   th:value="${obj?.name}" class="form-control" name="name" | 
|                        dataType="*1-200" nullmsg="商品名称不能为空" errormsg="不能超过200"> | 
|                 <div class="Validform_checktip"></div> | 
|             </div> | 
|             <label class="col-sm-2 control-label">状态<span | 
|                     class="text-danger">*</span></label> | 
|             <div class="col-sm-3"> | 
|                 <select class="form-control  selectFlag" name="staus" nullmsg="状态不能为空" dataType="*" id="staus" | 
|                         data-filed="name" | 
|                         data-value="name" | 
|                         th:data-def="${obj?.staus}" | 
|                         th:data-url="@{/admin/dataDictionary/showDataDictionary}" | 
|                         data-param="{type:'项目状态'}" > | 
|                     <option value=''>请选择项目状态</option> | 
|                 </select> | 
|   | 
|   | 
|   | 
|   | 
|   | 
|                 <div class="Validform_checktip"></div> | 
|             </div> | 
|   | 
|         </div> | 
|   | 
|         <div class="form-group"> | 
|             <label class="col-sm-2 control-label">售价<span | 
|                     class="text-danger">*</span></label> | 
|             <div class="col-sm-3"> | 
|                 <input autocomplete="off"   th:value="${obj?.sealPice}" class="form-control" name="sealPice" | 
|                        id="sealPice" dataType="price" nullmsg="请填写售价" | 
|                        errormsg="售价可为两位小数的正数"> | 
|                 <div class="Validform_checktip"></div> | 
|             </div> | 
|   | 
|             <label class="col-sm-2 control-label">参考价<span | 
|                     class="text-danger">*</span></label> | 
|             <div class="col-sm-3"> | 
|                 <input autocomplete="off"   th:value="${obj?.referencePice}" class="form-control" | 
|                        name="referencePice" dataType="price" nullmsg="请填写参考价" | 
|                        errormsg="参考价可为两位小数的正数"> | 
|                 <div class="Validform_checktip"></div> | 
|             </div> | 
|         </div> | 
|   | 
|   | 
|         <div class="form-group"> | 
|             <label class="col-sm-2 control-label">销量</label> | 
|             <div class="col-sm-3" > | 
|                 <input autocomplete="off"   name="realSealCount" type="text" class="form-control" | 
|                        th:value="${obj?.realSealCount}" | 
|                        dataType="n" ignore="ignore"  nullmsg="请填写销量" errormsg="请填写数字"> | 
|                 <div class="Validform_checktip"></div> | 
|             </div> | 
|   | 
|   | 
|             <label class="col-sm-2 control-label">是否单会员只买一次<span | 
|                     class="text-danger">*</span></label> | 
|             <div class="col-sm-3"> | 
|                 <select class="form-control" name="isOnce" id="isOnce" | 
|                         nullmsg="不能为空,请选择" dataType="*"> | 
|                     <option value=''>--请选择--</option> | 
|                     <option value='是' th:selected="${obj?.isOnce == '是'}">是</option> | 
|                     <option value='否' th:selected="${obj?.isOnce == '否'}">否</option> | 
|                 </select> | 
|                 <div class="Validform_checktip"></div> | 
|             </div> | 
|         </div> | 
|         <div class="form-group"> | 
|   | 
|             <label class="col-sm-2 control-label">分类<span | 
|                     class="text-danger">*</span></label> | 
|             <div class="col-sm-3"> | 
|                 <select class="form-control select2" size="1" name="cateId" | 
|                         id="parentId" dataType="*" nullmsg="请选择分类"> | 
|                     <option value="" selected="selected">--选择分类--</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" name="goodType" | 
|                        th:value="${obj?.goodType}" id="goodType" readonly="readonly"> | 
|             </div> | 
|         </div> | 
|         <div class="form-group"> | 
|             <label class="col-sm-2 control-label">介绍</label> | 
|             <div class="col-sm-3"> | 
|                 <input autocomplete="off"   type="text" class="form-control" name="introduction" maxlength="200" | 
|                        dataType="*1-200" ignore="ignore" errormsg="介绍不能超过200字符" | 
|                        th:value="${obj?.introduction}"> | 
|                 <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="saleOffTime" readonly="readonly" | 
|                        th:value="${#dates.format(obj?.saleOffTime, 'yyyy-MM-dd')}" | 
|                 > | 
|             </div> | 
|         </div> | 
|         <div class="form-group"> | 
|             <label class="col-sm-2 control-label">是否赠送<span | 
|                     class="text-danger">*</span></label> | 
|             <div class="col-sm-3"> | 
|                 <select class="form-control" name="isPresent" id="isPresent" | 
|                         nullmsg="不能为空,请选择" dataType="*"> | 
|                     <option value=''>--请选择--</option> | 
|                     <option value='是' th:selected="${obj?.isPresent == '是'}">是</option> | 
|                     <option value='否' th:selected="${obj?.isPresent == '否'}">否</option> | 
|                 </select> | 
|                 <div class="Validform_checktip"></div> | 
|             </div> | 
|   | 
|   | 
|   | 
|         </div> | 
|   | 
|         <div class="form-group"> | 
|             <div class="validity" style="display: none"> | 
|                 <label class="col-sm-2 control-label">有效期(单位月)<span | 
|                         class="text-danger">*</span></label> | 
|                 <div class="col-sm-3 "> | 
|                     <input autocomplete="off"   type="text" class="form-control" name="validity" | 
|                            ignore="ignore" dataType="*" nullmsg="有效期为必填" id="validity" | 
|                            th:value="${obj?.validity}"> | 
|                     <div class="Validform_checktip"></div> | 
|                 </div> | 
|             </div> | 
|   | 
|         </div> | 
|   | 
|         <div class="form-group"> | 
|             <div class="validity" style="display: none"> | 
|                 <label class="col-sm-2 control-label">是否为套餐卡<span | 
|                         class="text-danger">*</span></label> | 
|                 <div class="col-sm-3 "> | 
|                     <select class="form-control" name="isCourse" onchange="changeCourse(this)" id="isCourse" | 
|                             title="如果选套餐卡则必须填写,最大消耗次数" | 
|                             nullmsg="不能为空请选择" dataType="*"> | 
|                         <option value='Y' th:selected="${obj?.isCourse == '是'}">是</option> | 
|                         <option value='N' th:selected="${obj?.isCourse == '否'}">否</option> | 
|                     </select> | 
|                     <div class="Validform_checktip"></div> | 
|                 </div> | 
|             </div> | 
|             <div id="carUseCountBox"> | 
|                 <label class="col-sm-2 control-label">最大消耗次数</label> | 
|                 <div class="col-sm-3"> | 
|                     <input autocomplete="off"   type="number" class="form-control" name="carUseCount" | 
|                            dataType="n" data-toggle="tooltip" id="carUseCount" ignore='ignore' title="不填或者填0为不限次数" | 
|                            placeholder="不填或者填0为不限次数" | 
|                            th:value="${obj?.carUseCount}"> | 
|                     <div class="Validform_checktip"></div> | 
|                 </div> | 
|             </div> | 
|         </div> | 
|   | 
|         <div class="form-group"> | 
|             <label class="col-sm-2 control-label">最大销售数量</label> | 
|             <div class="col-sm-3"> | 
|                 <input autocomplete="off"   th:value="${obj?.carMaxSaleCount}" class="form-control" id="carMaxSaleCount" | 
|                        name="carMaxSaleCount" data-toggle="tooltip" | 
|                        title="销售数量为商品可销售的最大次数,数量为0则为无限制"  dataType="n" nullmsg="请填写最大销售数量" | 
|                        errormsg="数量为数字"> | 
|                 <div class="Validform_checktip"></div> | 
|             </div> | 
|         </div> | 
|   | 
|   | 
|         <!-- =====绑定商品和项目begin====== --> | 
|         <div id="warp1" th:if="${obj?.goodType ne '项目'}"> | 
|             <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-md-offset-2"> | 
|                     <table class="table table-striped table-hover table-bordered" | 
|                            id="mgrid"> | 
|                         <thead> | 
|                         <tr> | 
|                             <th>序号</th> | 
|                             <th>产品名称</th> | 
|                             <th>产品类型</th> | 
|                             <th>绑定价<span class="text-danger">*</span></th> | 
|                             <th class="isShowNum">数量<span class="text-danger">*</span></th> | 
|                             <th class="isShowStatus">状态<span class="text-danger">*</span></th> | 
|                             <th>操作</th> | 
|                         </tr> | 
|                         </thead> | 
|                         <tbody id="cpId1"> | 
|   | 
|                         </tbody> | 
|   | 
|                     </table> | 
|                 </div> | 
|             </div> | 
|         </div> | 
|   | 
|   | 
|         <div id="warp2" th:if="${obj?.goodType ne '家居产品'}"> | 
|             <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="openProjList()" | 
|                             type="button">添加 | 
|                     </button> | 
|                 </div> | 
|             </div> | 
|             <div class="form-group"> | 
|                 <div class="col-sm-8 col-md-offset-2" id="projBox"> | 
|                     <table class="table table-striped table-hover table-bordered" | 
|                            id="mgrid"> | 
|                         <thead> | 
|                         <tr> | 
|                             <th>序号</th> | 
|                             <th>项目名称</th> | 
|                             <th>项目类型</th> | 
|                             <th width="140px" class="isShowNum">绑定价<span | 
|                                     class="text-danger">*</span></th> | 
|                             <th width="140px" class="isShowNum">次数<span | 
|                                     class="text-danger">*</span></th> | 
|                             <th width="140px" class="isShowNum">单次扣减次数<span | 
|                                     class="text-danger">*</span></th> | 
|                             <th>操作</th> | 
|                         </tr> | 
|                         </thead> | 
|                         <tbody id="projId"> | 
|   | 
|                         </tbody> | 
|   | 
|                     </table> | 
|                 </div> | 
|             </div> | 
|         </div> | 
|   | 
|         <!-- =====绑定商品和项目end===== --> | 
|   | 
|   | 
|         <div class="form-group"> | 
|             <label class="col-sm-2 control-label">上传图片</label> | 
|             <div class="col-sm-4"> | 
|                 <input autocomplete="off"   th:value="${obj?.img}" name="img" id="img" | 
|                        class="form-control  upload-input" type="text" /> <a | 
|                     class="btn btn-primary radius upload-a">选择图片 | 
|             </a> | 
|             </div> | 
|         </div> | 
|   | 
|         <div class="form-group"> | 
|             <label class="col-sm-2 control-label">详细描述</label> | 
|             <div class="col-sm-8"> | 
|                 <script style="width: 100%; height: 500px" id="mobileDetails" | 
|                         name="artcontent" type="text/plain" th:utext="${obj?.description}"></script></div> | 
|         </div> | 
|   | 
|   | 
|         <div class="form-group "> | 
|             <div class="col-sm-12 text-center"> | 
|                 <button onclick="myForm.submit()" class="btn btn-success radius">保存</button> | 
|                      <a href="javascript:;" | 
|                                             onclick="MTools.closeForm()" class="btn btn-danger radius">取消</a> | 
|             </div> | 
|         </div> | 
|   | 
|     </form> | 
|   | 
|   | 
| </div> | 
|   | 
|   | 
| <script type="text/javascript" th:src="@{/js/systools/MJsBase.js}"></script> | 
| <script th:inline="javascript"> | 
|     MUI.initImgUpload(".upload-input"); | 
|     var mobileEditor = UE.getEditor('mobileDetails'); | 
|   | 
|     var obj =/*[[${obj}]]*/ | 
|   | 
|     //定义一个标记记录是否选择了套餐卡 | 
|     var isCourse = true; | 
|   | 
|     //改变是否为套餐卡 | 
|     function changeCourse(node) { | 
|         if ($(node).val() == 'N') { | 
|             isCourse = false; | 
|             $("#carUseCountBox").hide(); | 
|         } else { | 
|             isCourse = true; | 
|             $("#carUseCountBox").show(); | 
|         } | 
|     } | 
|   | 
|   | 
|     $(".select2").select2({ | 
|         'width': '100%' | 
|     }); | 
|     $(function () { | 
|         $("[data-toggle='tooltip']").tooltip(); | 
|     }) | 
|     var goodsAttr = ''; | 
|     //已选择的产品集合 | 
|     var totalGoods = []; | 
|     //已选择的项目集合 | 
|     var totalProducts = []; | 
|     //表单js对象 | 
|     var myForm = null; | 
|     //富文本编辑器对象 | 
|     //var editor=null; | 
|     //定义是否可以编辑 | 
|     var temp =true; | 
|     $(function () { | 
|   | 
|   | 
|         //改变标题 | 
|         parent.layer.title("新增" + $.query.get('goodType'), parent.layer | 
|             .getFrameIndex(window.name)); | 
|   | 
|         //初始化时间格式 | 
|         var initParam = { | 
|             format: "yyyy-mm-dd", //默认显示年与日,如果想显示十分秒:"yyyy-mm-dd hh:ii:ss" | 
|             minView: "2", //"month",只显示年月日的选择,不会再跳转去选择时分秒;如果想要选择时分秒的:"hour" | 
|   | 
|         }; | 
|         MTools.ininDatetimepicker(initParam); | 
|         //初始化select | 
|         MTools.autoFullSelect({ | 
|             selecteder: ".selectFlag" | 
|         }); | 
|         console.log("自动填充"); | 
|         readInitData(); | 
|         writeDate(); | 
|         writeProjDate(); | 
|         //初始化类型 | 
|         initGoodAttr(); | 
|         myForm = MForm.initForm({ | 
|             beforeSubmit: function () { | 
|   | 
|   | 
|                 //是否绑定明细 | 
|                 var bodyTrs = $("#cpId1").find("tr"); | 
|                 var bodyTrs2 = $("#projId").find("tr"); | 
|                 if (bodyTrs.length == 0 && bodyTrs2.length == 0) { | 
|                     layer.msg("请添加明细", { | 
|                         icon: 2 | 
|                     }); | 
|                     return false; | 
|                 } | 
|                 var flag = false; | 
|                 //非疗程卡则必须填写项目绑定次数 | 
|                 console.log('$("#isCourse").val()==' + $("#isCourse").val()) | 
|                 if ($("#isCourse").val() == 'N') { | 
|                     $(".projNumber").each(function () { | 
|                         if ($(this).val() == null || $(this).val() == '') { | 
|                             layer.msg("普通套餐必须填写项目绑定次数", {icon: 2}); | 
|                             flag = true; | 
|                         } | 
|                     }); | 
|                 } | 
|                 if (flag) { | 
|                     return false; | 
|                 } | 
|   | 
|   | 
|             }, | 
|             invokeUrl: basePath + "/admin/shoppinggoods/addOrModify", | 
|             afterSubmit: function () { | 
|                 parent.myGrid.serchData(); | 
|             }, | 
|         }); | 
|   | 
|   | 
|         //初始化商城产品类型列表 | 
|         initFunctionList(); | 
|     }); | 
|   | 
|     function readInitData() { | 
|         //初始化库存列表 | 
|         var projItemsL =/*[[${obj?.assembleGoods}]]*/ | 
|         if (projItemsL) { | 
|             totalGoods=projItemsL; | 
|         } | 
|   | 
|   | 
|         var assembleProj =/*[[${obj?.assembleProj}]]*/ | 
|         if (assembleProj) { | 
|             for (var i = 0; i < assembleProj.length; i++) { | 
|                 var projItem = assembleProj[i]; | 
|                 var proj = projItem.projInfo; | 
|                 if (proj != null && proj != '') { | 
|                     var projInfo = new Object(); | 
|                     var obj = new Object(); | 
|                     //项目本身的属性 | 
|                     obj.projName = projItem.name; | 
|                     obj.projTypeName = projItem.projInfo.projTypeName; | 
|                     obj.id = projItem.projInfo.id; | 
|                     //组合信息 | 
|                     obj.assembleId = projItem.id; | 
|                     //商品id | 
|                     obj.shoppingGoodsId = projItem.shoppingGoodsId; | 
|                     //项目次数 | 
|                     obj.total = projItem.total; | 
|                     //绑定价 | 
|                     obj.price = projItem.price; | 
|                     //单次扣减数量 | 
|                     obj.deductionNum = projItem.deductionNum; | 
|                     console.log(obj); | 
|                     totalProducts[i] = obj; | 
|                 } | 
|             } | 
|         } | 
|     } | 
|   | 
|     function changeGoodType(type) { | 
|         if (type == '家居产品') { | 
|             $(".isShowNum").hide(); | 
|             $(".isShowStatus").show(); | 
|             $("#warp1").show(); | 
|             $("#warp2").hide(); | 
|             goodsAttr = type; | 
|         } | 
|         if (type == '项目') { | 
|             $(".isShowNum").hide(); | 
|             $("#warp2").show(); | 
|             $("#warp1").hide(); | 
|         } | 
|         if (type == '套餐') { | 
|             $("#warp2").show(); | 
|             $("#warp1").show(); | 
|             $(".isShowNum").show(); | 
|             $(".isShowStatus").hide(); | 
|             goodsAttr = '家居产品'; | 
|             //如果是套餐有有效期,且做数据验证,不为空 | 
|             $(".validity").show(); | 
|             $(".validity").attr("ignore", ""); | 
|         } | 
|         $("#goodType").val(type); | 
|     } | 
|   | 
|     function openPruductList() { | 
|         var shopName = "总店"; | 
|         var type = $("#goodType").val(); | 
|         if (type == '') { | 
|             layer.msg("请选择类型", { | 
|                 icon: 2 | 
|             }); | 
|             return false; | 
|         } | 
|         layer.full(layer | 
|             .open({ | 
|                 type: 2, | 
|                 title: "选择产品", | 
|                 area: [MUI.SIZE_L, '400px'], | 
|                 content: [basePath + '/admin/redirect/hive/products/select-sku-list'] | 
|             })); | 
|     } | 
|   | 
|     //添加产品回调 | 
|     function callback(arr) { | 
|         removeDouble(arr, totalGoods); | 
|         writeDate(); | 
|     } | 
|   | 
|     //删除选中的元素 | 
|     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(); | 
|         $("#cpId1").find("tr").each(function (i) { | 
|             $(this).find("td").eq(0).html(i + 1); | 
|         }); | 
|         calculateTotalPrice(); | 
|     } | 
|   | 
|     //填写数据到html | 
|     function writeDate() { | 
|         var html = ""; | 
|         var flagType = $("#goodType").val(); | 
|         for (var i = 0; i < totalGoods.length; i++) { | 
|             if (!totalGoods[i].price) { | 
|                 totalGoods[i].price = ""; | 
|             } | 
|             if (!totalGoods[i].assembleId) { | 
|                 totalGoods[i].assembleId = ""; | 
|             } | 
|             if (!totalGoods[i].total) { | 
|                 totalGoods[i].total = ""; | 
|             } | 
|             var select = '<select class="form-control autoFull" name="assembleGoods[' + i + '].status" nullmsg="状态不能为空" dataType="*"' | 
|                 + 'data-filed="name" data-value="name" data-def="' + totalGoods[i].status + '" data-url=' + basePath + '/admin/dataDictionary/showDataDictionary' | 
|                 + ' data-param="{type:\'产品状态\'}"><option value="">--请选择产品状态--</option> </select>' | 
|                 + '<div class="Validform_checktip"></div>'; | 
|             html += '<tr>' | 
|                 + '<td>' | 
|                 + (i + 1) | 
|                 + '</td>' | 
|                 + '<td>' | 
|                 + totalGoods[i].goods.name | 
|                 + '<input autocomplete="off"   type="hidden" name="assembleGoods[' + i + '].id" value="' + totalGoods[i].assembleId + '"> <input autocomplete="off"   type="hidden" name="assembleGoods[' + i + '].assembleSkuId" value="' + totalGoods[i].goods.id + '"></td>' | 
|                 + '<td>' | 
|                 + totalGoods[i].goods.goodsSortName | 
|                 + '</td>' | 
|                 + '<td><input autocomplete="off"   onblur="calculateTotalPrice()"  min="1" maxlength="8" datatype="price"  id="p' + i + '" nullmsg="绑定价不能为空" errormsg="请填写正数可为两位小数"  class="form-control skuItems" name="assembleGoods[' | 
|                 + i + '].price" value="' + totalGoods[i].price | 
|                 + '"><div class="Validform_checktip"></div></td>' | 
|             if (flagType == '套餐') { | 
|                 html += '<td class="isShowNum" ><input autocomplete="off"   onblur="calculateTotalPrice()" datatype="n" type="number" maxlength="8" errormsg="请填写正数" id="c' + i + '" nullmsg="数量不能为空"  class="form-control " name="assembleGoods[' + i + '].total" value="' + totalGoods[i].total + '"><div class="Validform_checktip"></div></td>'; | 
|             } | 
|             if (flagType == '家居产品') { | 
|                 //显示状态,且数量默认为1 | 
|                 html += '<td>' | 
|                     + select | 
|                     + '<input autocomplete="off"   type="hidden" name="assembleGoods[' + i + '].total" value="1"></td>'; | 
|             } | 
|             if (totalGoods[i].assembleId == null || totalGoods[i].assembleId == '' || temp) { | 
|                 html += '<td class="center"><a style="text-decoration: none" class="fa fa-trash" onClick="delSelectItem(this,' | 
|                     + totalGoods[i].id | 
|                     + ')" href="javascript:;" title="删除"></a></td>'; | 
|             } else { | 
|                 html += '<td class="center"></td>'; | 
|             } | 
|   | 
|             html += '</tr>'; | 
|         } | 
|         $("#cpId1").html(html); | 
|         MTools.autoFullSelect(); | 
|     } | 
|   | 
|     //-------------------------去重方法-begin--------------------------------- | 
|   | 
|     //赋值或者去重复 | 
|     function removeDouble(arr, srcArr) { | 
|         console.log("arr:" + arr); | 
|         console.log(arr); | 
|         console.log("srcArr:" + srcArr); | 
|         console.log(srcArr); | 
|   | 
|         if(goodsAttr=='家居产品'){ | 
|             var obj = new Object(); | 
|             obj.goods = arr[0]; | 
|             srcArr[0] = obj; | 
|             return; | 
|         } | 
|   | 
|         if (srcArr == null) { | 
|             for (var i = 0; i < arr.length; i++) { | 
|                 var obj = new Object(); | 
|                 obj.goods = arr[i]; | 
|                 srcArr[srcArr.length] = obj; | 
|             } | 
|         } else { | 
|             for (var i = 0; i < arr.length; i++) { | 
|                 //去重 | 
|                 var isDouble = false; | 
|                 for (var j = 0; j < srcArr.length; j++) { | 
|                     if (arr[i].id == srcArr[j].id) { | 
|                         isDouble = true; | 
|                         break; | 
|                     } | 
|                 } | 
|                 //如果不重复 | 
|                 if (!isDouble) { | 
|                     var obj = new Object(); | 
|                     obj.goods = arr[i]; | 
|                     srcArr[srcArr.length] = obj; | 
|                 } | 
|             } | 
|         } | 
|     } | 
|   | 
|     //赋值或者去重复 | 
|     function removeDoubleProj(arr, srcArr) { | 
|         if (srcArr == null) { | 
|             srcArr = arr; | 
|         } else { | 
|             for (var i = 0; i < arr.length; i++) { | 
|                 //去重 | 
|                 var isDouble = false; | 
|                 for (var j = 0; j < srcArr.length; j++) { | 
|                     if (arr[i].id == srcArr[j].id) { | 
|                         isDouble = true; | 
|                         break; | 
|                     } | 
|                 } | 
|                 //如果不重复 | 
|                 if (!isDouble) { | 
|                     srcArr[srcArr.length] = arr[i]; | 
|                 } | 
|             } | 
|         } | 
|     } | 
|   | 
|     function initGoodAttr() { | 
|         var getGoodsAttr = $.query.get('goodType'); | 
|         var goodType = obj?obj.goodType:""; | 
|         if (goodType != '') { | 
|             changeGoodType(goodType); | 
|         } else { | 
|             changeGoodType(getGoodsAttr); | 
|         } | 
|     } | 
|   | 
|     //-------------------------公共的去重方法-end--------------------------------- | 
|   | 
|     //---------------------------------项目----------------------------------- | 
|     function openProjList() { | 
|         var type = $("#goodType").val(); | 
|         if (type == '') { | 
|             layer.msg("请选择类型", { | 
|                 icon: 2 | 
|             }); | 
|             return false; | 
|         } | 
|         layer.full(layer | 
|             .open({ | 
|                 type: 2, | 
|                 title: "选择项目", | 
|                 maxmin: true, | 
|                 area: [MUI.SIZE_L, '400px'], | 
|                 content: [basePath + '/admin/redirect/hive/products/select-proj-list?type=' | 
|                 + type] | 
|             })); | 
|     } | 
|   | 
|     //回调 | 
|     function callbackProj(arr) { | 
|         //如果类型为项目的话只能添加一个,因此每次添加都会清楚原来的数据 | 
|         var type = $("#goodType").val(); | 
|         if (type == '项目') { | 
|             if (totalProducts.length > 0 && (arr[0].id != totalProducts[0].id)) { | 
|                 totalProducts = []; | 
|             } | 
|         } | 
|         removeDoubleProj(arr, totalProducts); | 
|         writeProjDate(); | 
|     } | 
|   | 
|     //写项目到表格 | 
|   | 
|     function writeProjDate() { | 
|         var html = ""; | 
|         var flagType = $("#goodType").val(); | 
|         //更新的话,不给出删除列 | 
|         /* var flagId="${obj.id}"; */ | 
|         for (var i = 0; i < totalProducts.length; i++) { | 
|             if (!totalProducts[i].total) { | 
|                 totalProducts[i].total = ""; | 
|             } | 
|             if (!totalProducts[i].assembleId) { | 
|                 totalProducts[i].assembleId = ""; | 
|             } | 
|             if (!totalProducts[i].price) { | 
|                 totalProducts[i].price = ""; | 
|             } | 
|             if (!totalProducts[i].projTypeName) { | 
|                 totalProducts[i].projTypeName = ""; | 
|             } | 
|             if (!totalProducts[i].deductionNum) { | 
|                 totalProducts[i].deductionNum = "1"; | 
|             } | 
|             html += '<tr>' | 
|                 + '<td>' | 
|                 + (i + 1) | 
|                 + '</td>' | 
|                 + '<td>' | 
|                 + totalProducts[i].projName | 
|                 + '<input autocomplete="off"   type="hidden" name="assembleProj[' + i + '].id" value="' + totalProducts[i].assembleId + '"> <input autocomplete="off"   type="hidden" name="assembleProj[' + i + '].assembleProjId" value="' + totalProducts[i].id + '"></td>' | 
|                 + '<td>' + totalProducts[i].projTypeName + '</td>'; | 
|             if (flagType == '套餐') { | 
|                 html += '<td><input autocomplete="off"   onblur="calculateTotalPrice()"  maxlength="8" datatype="price" nullmsg="绑定价不能为空" id="a' + i + '" errormsg="请填写正数可为两位小数" class="form-control  projItem" name="assembleProj[' | 
|                     + i | 
|                     + '].price" value="' | 
|                     + totalProducts[i].price | 
|                     + '">    <div class="Validform_checktip"></div></td>' | 
|                     + '<td><input autocomplete="off"   onblur="calculateTotalPrice()"  datatype="n" type="number" maxlength="8" nullmsg="数量不能为空" ignore="ignore"  errormsg="请填写正数" id="n' + i + '" class="form-control projNumber" name="assembleProj[' + i + '].total" value="' + totalProducts[i].total + '">    <div class="Validform_checktip"></div></td>' | 
|                     + '<td><input autocomplete="off"     datatype="n" type="number" maxlength="8" nullmsg="扣减数量不能为空" ignore="ignore"  errormsg="请填写正数" id="m' + i + '" class="form-control projNumber" name="assembleProj[' + i + '].deductionNum" value="' + totalProducts[i].deductionNum + '">    <div class="Validform_checktip"></div></td>'; | 
|                 ; | 
|             } | 
|   | 
|             if (totalProducts[i].assembleId == null || totalProducts[i].assembleId == '' || temp) { | 
|                 html += '<td class="center" ><a style="text-decoration: none" class="fa fa-trash" onClick="delSelectProjItem(this,' | 
|                     + totalProducts[i].id | 
|                     + ')" href="javascript:;" title="删除"></a></td>' | 
|             } else { | 
|                 html += '<td class="center"></td>'; | 
|             } | 
|   | 
|   | 
|             /* if(flagId==''){ */ | 
|   | 
|             /* } */ | 
|             html += '</tr>' | 
|         } | 
|         $("#projId").html(html); | 
|     } | 
|   | 
|     function delSelectProjItem(node, id) { | 
|         // 根据列表的项目的id找到元素相应下表的元素 | 
|         for (var i = 0; i < totalProducts.length; i++) { | 
|             if (totalProducts[i].id == id) { | 
|                 totalProducts.splice(i, 1); | 
|                 break; | 
|             } | 
|         } | 
|   | 
|         //移除tr | 
|         $(node).closest('tr').remove(); | 
|         $("#projId").find("tr").each(function (i) { | 
|             $(this).find("td").eq(0).html(i + 1); | 
|         }); | 
|   | 
|         calculateTotalPrice(); | 
|     } | 
|   | 
|     /** | 
|      * 初始化商城产品类型:category列表 | 
|      */ | 
|     function initFunctionList() { | 
|         $.AjaxProxy({ | 
|             a: false, | 
|             c: false, | 
|             p: { | 
|                 salePlatform: '线下' | 
|             } | 
|         }).invoke(basePath + "/admin/shoppinggoodscategory/all", function (loj) { | 
|             $("#parentId").createSelectTree(loj.attr("result").rows, { | 
|                 append: true, | 
|                 value: "name", | 
|                 defaultValue: obj ? obj.cateId : "" | 
|             }); | 
|         }); | 
|   | 
|     } | 
|   | 
|     //自动计算总价 | 
|     function calculateTotalPrice() { | 
|         var type = $("#goodType").val(); | 
|         if (type == '套餐') { | 
|             var totalMoney = Number(0); | 
|             //计算绑定的商品总价 | 
|             $(".skuItems").each(function (i) { | 
|                 var index = $(this).attr("id").substring(1, 2); | 
|                 console.log("index=" + index); | 
|                 var p = $(this).val(); | 
|                 var c = $("#c" + index).val(); | 
|                 console.log("c=" + c); | 
|                 if (p != '' && c != '') { | 
|                     //totalMoney=parseFloat(totalMoney)+parseFloat(p); | 
|                     totalMoney = accAdd(parseFloat(totalMoney), parseFloat(accMul(p, c))); | 
|                     console.log("total=" + totalMoney); | 
|                 } | 
|             }); | 
|             //计算套餐项目总价 | 
|             //计算绑定的商品总价 | 
|             $(".projItem").each(function (i) { | 
|                 var index = $(this).attr("id").substring(1, 2); | 
|                 var p = $(this).val(); | 
|                 var c = $("#n" + index).val(); | 
|                 if (p != '' && c != '') { | 
|                     //totalMoney=parseFloat(totalMoney).add(parseFloat(p)); | 
|                     totalMoney = accAdd(parseFloat(totalMoney), parseFloat(accMul(p, c))); | 
|                 } | 
|             }); | 
|             $("#sealPice").val(totalMoney); | 
|             console.log("totalMoney=" + totalMoney); | 
|         } | 
|     } | 
| </script> | 
| </body> | 
| </html> |