123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993 |
- <%@ page import="java.util.Date" %>
- <%@ page contentType="text/html;charset=UTF-8" %>
- <%@ include file="/WEB-INF/views/include/taglib.jsp" %>
- <html>
- <head>
- <title>优惠券管理</title>
- <meta name="decorator" content="default"/>
- <style>
- .coupon-wrap {
- border: 1px solid #aaa;
- padding: 20px 20px 0;
- margin-bottom: 20px;
- }
- .couponType {
- margin-right: 15px;
- }
- </style>
- <script type="text/javascript">
- $(document).ready(function () {
- var dateList = [];
- if (${not empty useDateList}) {
- <c:forEach items="${useDateList}" var="date" varStatus="index">
- dateList.push("${date}");
- </c:forEach>
- }
- $("#inputForm").validate({
- submitHandler: function (form) {
- if (imageList1.length > 0) {
- var productInfo1 = JSON.stringify(imageList1);
- $('#productInfo1').val(productInfo1);
- }
- if (imageList2.length > 0) {
- var productInfo2 = JSON.stringify(imageList2);
- $('#productInfo2').val(productInfo2);
- }
- if (imageList3.length > 0) {
- var productInfo3 = JSON.stringify(imageList3);
- $('#productInfo3').val(productInfo3);
- }
- if (imageList4.length > 0) {
- var productInfo4 = JSON.stringify(imageList4);
- $('#productInfo4').val(productInfo4);
- }
- var couponType1 = $("#couponType1").val();
- var shopId1 = $("#shopId1").val();
- if (couponType1 == 3) {
- if (shopId1 == "" || shopId1 == null) {
- alert("店铺券供应商不能为空 !");
- return false;
- }
- }
- var month = $("#month").val();
- // 判断月份 ...
- if (month == null || month == "") {
- alert("请选择生效时间! ");
- return false;
- }
- var endMonth = $("#endMonth").val();
- if (endMonth < month) {
- $.jBox.alert('优惠月份设置错误','提示');
- return false;
- }
- var vipId = $("#id").val();
- if (!vipId && dateList.indexOf(month)>=0){
- alert("已存在该月优惠券,请修改月份!");
- return false;
- }
- var couponAmount1 = $("#couponAmount1").val() * 1;
- var touchPrice1 = $("#touchPrice1").val() * 1;
- if (couponAmount1 == "") {
- alertx("【优惠券1】优惠券金额不能为空");
- return false;
- }
- if (touchPrice1 == "") {
- alertx("【优惠券1】优惠条件不能为空");
- return false;
- }
- if (couponAmount1 >= touchPrice1) {
- alertx("【优惠券1】优惠券金额必须小于优惠条件金额");
- return false;
- }
- var couponAmount2 = $("#couponAmount2").val() * 1;
- var touchPrice2 = $("#touchPrice2").val() * 1;
- if (couponAmount2 == "") {
- alertx("【优惠券2】优惠券金额不能为空");
- return false;
- }
- if (touchPrice2 == "") {
- alertx("【优惠券2】优惠条件不能为空");
- return false;
- }
- if (couponAmount2 >= touchPrice2) {
- alertx("【优惠券2】优惠券金额必须小于优惠条件金额");
- return false;
- }
- var couponAmount3 = $("#couponAmount3").val() * 1;
- var touchPrice3 = $("#touchPrice3").val() * 1;
- if (couponAmount3 == "") {
- alertx("【优惠券3】优惠券金额不能为空");
- return false;
- }
- if (touchPrice3 == "") {
- alertx("【优惠券3】优惠条件不能为空");
- return false;
- }
- if (couponAmount3 >= touchPrice3) {
- alertx("【优惠券3】优惠券金额必须小于优惠条件金额");
- return false;
- }
- var couponAmount4 = $("#couponAmount4").val() * 1;
- var touchPrice4 = $("#touchPrice4").val() * 1;
- if (couponAmount4 == "") {
- alertx("【优惠券4】优惠券金额不能为空");
- return false;
- }
- if (touchPrice4 == "") {
- alertx("【优惠券4】优惠条件不能为空");
- return false;
- }
- if (couponAmount4 >= touchPrice4) {
- alertx("【优惠券4】优惠券金额必须小于优惠条件金额");
- return false;
- }
- 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);
- }
- }
- });
- });
- </script>
- </head>
- <body>
- <ul class="nav nav-tabs">
- <li><a href="${ctx}/vip/cmCoupon/">超级会员专属优惠券</a></li>
- <li class="active"><a href="${ctx}/vip/cmCoupon/form?id=${cmVipCoupon.id}&endTime=${cmVipCoupon.endTime}">${not empty cmVipCoupon.id?'编辑':'添加'}</a>
- </li>
- </ul><br>
- <form:form id="inputForm" modelAttribute="svipcouponForm" action="${ctx}/vip/cmCoupon/save" method="post" class="form-horizontal">
- <sys:message content="${message}"/>
- <form:hidden path="id" value="${cmVipCoupon.id}"/>
- <div class="control-group">
- <label class="control-label"><font color="red">*</font>优惠月份:</label>
- <div class="controls">
- <form:input path="month" type="text" maxlength="20" class="input-medium Wdate" value="${useTime}"
- onclick="WdatePicker({dateFmt:'yyyy-MM',isShowClear:false});"/> ——
- <form:input path="endMonth" type="text" maxlength="20" class="input-medium Wdate" value="${endMonth}" disabled="true"
- onclick="WdatePicker({dateFmt:'yyyy-MM',isShowClear:false});"/>
- </div>
- </div>
- <div class="coupon-wrap" id="couponWrap1">
- <div class="control-group">
- <label class="control-label"><font color="red">*</font><b>优惠券1:</b></label>
- <div class="controls">
- <form:radiobutton path="couponType1" class="couponType" label="请选择" value="" checked="true"></form:radiobutton>
- <form:radiobutton path="couponType1" class="couponType" label="活动券" value="0"></form:radiobutton>
- <form:radiobutton path="couponType1" class="couponType" label="品类券" value="1" onclick="cType(1)"></form:radiobutton>
- <form:radiobutton path="couponType1" class="couponType" label="店铺券" value="3" onclick="cType(1)"></form:radiobutton>
- </div>
- </div>
- <form:hidden path="couponId1" id="couponId1"/>
- <div class="control-group coupon-line l0" ${svipcouponForm.couponType1 ne '3' ? 'style="display:none"':''}>
- <label class="control-label"><font color="red">*</font>供应商:</label>
- <div class="controls">
- <a href="javascript:void(0);" onclick="showSelectShop(1)" id="chooseShop1">请选择供应商</a>
- <form:hidden path="shopId1" id="shopId1"/>
- <table class="contentTableShop table table-striped table-bordered table-condensed" hidden="hidden">
- <thead></thead>
- <tbody class="hotSearchShop"></tbody>
- </table>
- </div>
- </div>
- <div class="control-group coupon-line l1" ${empty svipcouponForm.couponId1 ? 'style="display:none"':''}>
- <label class="control-label"><font color="red">*</font>优惠券金额:</label>
- <div class="controls">
- <form:input path="couponAmount1" htmlEscape="false" maxlength="20" class="input-xlarge required"/>
- </div>
- </div>
- <div class="control-group coupon-line l2" ${empty svipcouponForm.couponId1 ? 'style="display:none"':''}>
- <label class="control-label"><font color="red">*</font>优惠条件:</label>
- <div class="controls"> 订单商品总额满
- <form:input path="touchPrice1" htmlEscape="false" maxlength="20" class="input-medium required"/>
- </div>
- </div>
- <div class="control-group coupon-line l3" ${svipcouponForm.couponType1 ne '1' ? 'style="display:none"':''}>
- <label class="control-label"><font color="red">*</font>优惠品类:</label>
- <div class="controls">
- <form:radiobutton path="categoryType1" value="1" label="产品"/>
- <form:radiobutton path="categoryType1" value="2" label="仪器"/>
- </div>
- </div>
- <div class="control-group coupon-line l4" ${svipcouponForm.couponType1 ne '0' ? 'style="display:none"':''}>
- <label class="control-label"><font color="red">*</font>优惠商品:</label>
- <div class="controls">
- <form:radiobutton path="productType1" value="1" label="全商城商品" onclick="productShow(value,1)"/>
- <form:radiobutton path="productType1" value="2" label="指定商品" onclick="productShow(value,1)"/>
- </div>
- </div>
- <div class="productData1" hidden="hidden">
- <form:hidden path="productInfo1" id="productInfo1"/>
- <div class="control-group">
- <input class="btn del" style="width: 50px" onclick="batchDeletion(1)" value="删除"/>
- <input class="btn btn-primary" style="width: 50px" onclick="showSelectProduct(1)" value="添加"/>
- <br><br>
- <table class="contentTableProduct table table-striped table-bordered table-condensed" hidden="hidden">
- <thead></thead>
- <tbody class="hotSearchProduct"></tbody>
- </table>
- </div>
- </div>
- </div>
- <div class="coupon-wrap" id="couponWrap2">
- <div class="control-group">
- <label class="control-label"><font color="red">*</font><b>优惠券2:</b></label>
- <div class="controls">
- <form:radiobutton path="couponType2" class="couponType" label="请选择" value="" checked="true"></form:radiobutton>
- <form:radiobutton path="couponType2" class="couponType" label="活动券" value="0"></form:radiobutton>
- <form:radiobutton path="couponType2" class="couponType" label="品类券" value="1" onclick="cType(2)"></form:radiobutton>
- <form:radiobutton path="couponType2" class="couponType" label="店铺券" value="3" onclick="cType(2)"></form:radiobutton>
- </div>
- </div>
- <form:hidden path="couponId2" id="couponId2"/>
- <div class="control-group coupon-line l0" ${svipcouponForm.couponType2 ne '3' ? 'style="display:none"':''}>
- <label class="control-label"><font color="red">*</font>供应商:</label>
- <div class="controls">
- <a href="javascript:void(0);" onclick="showSelectShop(2)" id="chooseShop2">请选择供应商</a>
- <form:hidden path="shopId2" id="shopId2"/>
- <table class="contentTableShop table table-striped table-bordered table-condensed" hidden="hidden">
- <thead></thead>
- <tbody class="hotSearchShop"></tbody>
- </table>
- </div>
- </div>
- <div class="control-group coupon-line l1" ${empty svipcouponForm.couponId2 ? 'style="display:none"':''}>
- <label class="control-label"><font color="red">*</font>优惠券金额:</label>
- <div class="controls">
- <form:input path="couponAmount2" htmlEscape="false" maxlength="20" class="input-xlarge required"/>
- </div>
- </div>
- <div class="control-group coupon-line l2" ${empty svipcouponForm.couponId2 ? 'style="display:none"':''}>
- <label class="control-label"><font color="red">*</font>优惠条件:</label>
- <div class="controls"> 订单商品总额满
- <form:input path="touchPrice2" htmlEscape="false" maxlength="20" class="input-medium required"/>
- </div>
- </div>
- <div class="control-group coupon-line l3" ${svipcouponForm.couponType2 ne '1' ? 'style="display:none"':''}>
- <label class="control-label"><font color="red">*</font>优惠品类:</label>
- <div class="controls">
- <form:radiobutton path="categoryType2" value="1" label="产品"/>
- <form:radiobutton path="categoryType2" value="2" label="仪器"/>
- </div>
- </div>
- <div class="control-group coupon-line l4" ${svipcouponForm.couponType2 ne '0' ? 'style="display:none"':''}>
- <label class="control-label"><font color="red">*</font>优惠商品:</label>
- <div class="controls">
- <form:radiobutton path="productType2" value="1" label="全商城商品" onclick="productShow(value,2)"/>
- <form:radiobutton path="productType2" value="2" label="指定商品" onclick="productShow(value,2)"/>
- </div>
- </div>
- <div class="productData2" hidden="hidden">
- <form:hidden path="productInfo2" id="productInfo2"/>
- <div class="control-group">
- <input class="btn del" style="width: 50px" onclick="batchDeletion(2)" value="删除"/>
- <input class="btn btn-primary" style="width: 50px" onclick="showSelectProduct(2)" value="添加"/>
- <br><br>
- <table class="contentTableProduct table table-striped table-bordered table-condensed" hidden="hidden">
- <thead></thead>
- <tbody class="hotSearchProduct"></tbody>
- </table>
- </div>
- </div>
- </div>
- <div class="coupon-wrap" id="couponWrap3">
- <div class="control-group">
- <label class="control-label"><font color="red">*</font><b>优惠券3:</b></label>
- <div class="controls">
- <form:radiobutton path="couponType3" class="couponType" label="请选择" value="" checked="true"></form:radiobutton>
- <form:radiobutton path="couponType3" class="couponType" label="活动券" value="0"></form:radiobutton>
- <form:radiobutton path="couponType3" class="couponType" label="品类券" value="1" onclick="cType(3)"></form:radiobutton>
- <form:radiobutton path="couponType3" class="couponType" label="店铺券" value="3" onclick="cType(3)"></form:radiobutton>
- </div>
- </div>
- <form:hidden path="couponId3" id="couponId3"/>
- <div class="control-group coupon-line l0" ${svipcouponForm.couponType3 ne '3' ? 'style="display:none"':''}>
- <label class="control-label"><font color="red">*</font>供应商:</label>
- <div class="controls">
- <a href="javascript:void(0);" onclick="showSelectShop(3)" id="chooseShop3">请选择供应商</a>
- <form:hidden path="shopId3" id="shopId3"/>
- <table class="contentTableShop table table-striped table-bordered table-condensed" hidden="hidden">
- <thead></thead>
- <tbody class="hotSearchShop"></tbody>
- </table>
- </div>
- </div>
- <div class="control-group coupon-line l1" ${empty svipcouponForm.couponId3 ? 'style="display:none"':''}>
- <label class="control-label"><font color="red">*</font>优惠券金额:</label>
- <div class="controls">
- <form:input path="couponAmount3" htmlEscape="false" maxlength="20" class="input-xlarge required"/>
- </div>
- </div>
- <div class="control-group coupon-line l2" ${empty svipcouponForm.couponId3 ? 'style="display:none"':''}>
- <label class="control-label"><font color="red">*</font>优惠条件:</label>
- <div class="controls"> 订单商品总额满
- <form:input path="touchPrice3" htmlEscape="false" maxlength="20" class="input-medium required"/>
- </div>
- </div>
- <div class="control-group coupon-line l3" ${svipcouponForm.couponType3 ne '1' ? 'style="display:none"':''}>
- <label class="control-label"><font color="red">*</font>优惠品类:</label>
- <div class="controls">
- <form:radiobutton path="categoryType3" value="1" label="产品"/>
- <form:radiobutton path="categoryType3" value="2" label="仪器"/>
- </div>
- </div>
- <div class="control-group coupon-line l4" ${svipcouponForm.couponType3 ne '0' ? 'style="display:none"':''}>
- <label class="control-label"><font color="red">*</font>优惠商品:</label>
- <div class="controls">
- <form:radiobutton path="productType3" value="1" label="全商城商品" onclick="productShow(value,3)"/>
- <form:radiobutton path="productType3" value="2" label="指定商品" onclick="productShow(value,3)"/>
- </div>
- </div>
- <div class="productData3" hidden="hidden">
- <form:hidden path="productInfo3" id="productInfo3"/>
- <div class="control-group">
- <input class="btn del" style="width: 50px" onclick="batchDeletion(3)" value="删除"/>
- <input class="btn btn-primary" style="width: 50px" onclick="showSelectProduct(3)" value="添加"/>
- <br><br>
- <table class="contentTableProduct table table-striped table-bordered table-condensed" hidden="hidden">
- <thead></thead>
- <tbody class="hotSearchProduct"></tbody>
- </table>
- </div>
- </div>
- </div>
- <div class="coupon-wrap" id="couponWrap4">
- <div class="control-group">
- <label class="control-label"><font color="red">*</font><b>优惠券4:</b></label>
- <div class="controls">
- <form:radiobutton path="couponType4" class="couponType" label="请选择" value="" checked="true"></form:radiobutton>
- <form:radiobutton path="couponType4" class="couponType" label="活动券" value="0"></form:radiobutton>
- <form:radiobutton path="couponType4" class="couponType" label="品类券" value="1" onclick="cType(1)"></form:radiobutton>
- <form:radiobutton path="couponType4" class="couponType" label="店铺券" value="3" onclick="cType(1)"></form:radiobutton>
- </div>
- </div>
- <form:hidden path="couponId4" id="couponId4"/>
- <div class="control-group coupon-line l0" ${svipcouponForm.couponType4 ne '3' ? 'style="display:none"':''}>
- <label class="control-label"><font color="red">*</font>供应商:</label>
- <div class="controls">
- <a href="javascript:void(0);" onclick="showSelectShop(4)" id="chooseShop4">请选择供应商</a>
- <form:hidden path="shopId4" id="shopId4"/>
- <table class="contentTableShop table table-striped table-bordered table-condensed" hidden="hidden">
- <thead></thead>
- <tbody class="hotSearchShop"></tbody>
- </table>
- </div>
- </div>
- <div class="control-group coupon-line l1" ${empty svipcouponForm.couponId4 ? 'style="display:none"':''}>
- <label class="control-label"><font color="red">*</font>优惠券金额:</label>
- <div class="controls">
- <form:input path="couponAmount4" htmlEscape="false" maxlength="20" class="input-xlarge required"/>
- </div>
- </div>
- <div class="control-group coupon-line l2" ${empty svipcouponForm.couponId4 ? 'style="display:none"':''}>
- <label class="control-label"><font color="red">*</font>优惠条件:</label>
- <div class="controls"> 订单商品总额满
- <form:input path="touchPrice4" htmlEscape="false" maxlength="20" class="input-medium required"/>
- </div>
- </div>
- <div class="control-group coupon-line l3" ${svipcouponForm.couponType4 ne '1' ? 'style="display:none"':''}>
- <label class="control-label"><font color="red">*</font>优惠品类:</label>
- <div class="controls">
- <form:radiobutton path="categoryType4" value="1" label="产品"/>
- <form:radiobutton path="categoryType4" value="2" label="仪器"/>
- </div>
- </div>
- <div class="control-group coupon-line l4" ${svipcouponForm.couponType4 ne '0' ? 'style="display:none"':''}>
- <label class="control-label"><font color="red">*</font>优惠商品:</label>
- <div class="controls">
- <form:radiobutton path="productType4" value="1" label="全商城商品" onclick="productShow(value,4)"/>
- <form:radiobutton path="productType4" value="2" label="指定商品" onclick="productShow(value,4)"/>
- </div>
- </div>
- <div class="productData4" hidden="hidden">
- <form:hidden path="productInfo4" id="productInfo4"/>
- <div class="control-group">
- <input class="btn del" style="width: 50px" onclick="batchDeletion(4)" value="删除"/>
- <input class="btn btn-primary" style="width: 50px" onclick="showSelectProduct(4)" value="添加"/>
- <br><br>
- <table class="contentTableProduct table table-striped table-bordered table-condensed" hidden="hidden">
- <thead></thead>
- <tbody class="hotSearchProduct"></tbody>
- </table>
- </div>
- </div>
- </div>
- <div class="form-actions">
- <input id="btnSubmit" class="btn btn-primary" type="submit" value="保 存"/>
- <input id="btnCancel" class="btn" type="button" value="返 回" onclick="history.go(-1)"/>
- </div>
- </form:form>
- <script type="text/javascript">
- $(".contentTableShop thead").html('<tr><th>供应商名称</th><th>供应商简称</th><th>联系人</th><th>手机号</th><th>操作</th></tr>');
- $(".contentTableProduct thead").html('<tr><th style="width:20px;"><input class="check-all" type="checkbox" onclick="clickAllSelect(this)"/>全选</th>' +
- '<th>商品图片</th><th>商品名称</th><th>供应商</th><th>网站状态</th><th>小程序状态</th><th>排序</th><th>添加时间</th><th>操作</th></tr>');
- var productIds1 = '';
- var productIds2 = '';
- var productIds3 = '';
- var productIds4 = '';
- var imageList1 = [];
- var imageList2 = [];
- var imageList3 = [];
- var imageList4 = [];
- //店铺券供应商回显
- if (${not empty svipcouponForm.shop1}) {
- var shop = {
- "shopId": "${svipcouponForm.shop1.shopID}",
- "name": "${svipcouponForm.shop1.name}",
- "sname": "${svipcouponForm.shop1.sname}",
- "linkMan": "${svipcouponForm.shop1.linkMan}",
- "contractMobile": "${svipcouponForm.shop1.contractMobile}"
- }
- appendShopOrderHead(shop, 1);
- }
- if (${not empty svipcouponForm.shop2}) {
- var shop = {
- "shopId": "${svipcouponForm.shop2.shopID}",
- "name": "${svipcouponForm.shop2.name}",
- "sname": "${svipcouponForm.shop2.sname}",
- "linkMan": "${svipcouponForm.shop2.linkMan}",
- "contractMobile": "${svipcouponForm.shop2.contractMobile}"
- }
- appendShopOrderHead(shop, 2);
- }
- if (${not empty svipcouponForm.shop3}) {
- var shop = {
- "shopId": "${svipcouponForm.shop3.shopID}",
- "name": "${svipcouponForm.shop3.name}",
- "sname": "${svipcouponForm.shop3.sname}",
- "linkMan": "${svipcouponForm.shop3.linkMan}",
- "contractMobile": "${svipcouponForm.shop3.contractMobile}"
- }
- appendShopOrderHead(shop, 3);
- }
- if (${not empty svipcouponForm.shop4}) {
- var shop = {
- "shopId": "${svipcouponForm.shop4.shopID}",
- "name": "${svipcouponForm.shop4.name}",
- "sname": "${svipcouponForm.shop4.sname}",
- "linkMan": "${svipcouponForm.shop4.linkMan}",
- "contractMobile": "${svipcouponForm.shop4.contractMobile}"
- }
- appendShopOrderHead(shop, 4);
- }
- //产品回显
- if (${not empty svipcouponForm.associateList1}) {
- <c:forEach items="${svipcouponForm.associateList1}" var="associate" varStatus="index">
- imageList1.push({
- id: "${associate.id}",
- productId: "${empty associate.productId ? "":associate.productId}",
- image: "${associate.image}",
- productName: "${associate.productName}",
- shopName: "${associate.shopName}",
- sort: "${associate.sort}",
- pcStatus: "${associate.pcStatus}",
- appletsStatus: "${associate.appletsStatus}",
- addTime: "<fmt:formatDate value="${associate.addTime}" pattern="yyyy-MM-dd HH:mm:ss"/>"
- });
- </c:forEach>
- if (imageList1.length > 0) {
- $('#couponWrap1').find('.contentTableProduct').show();
- batchSaveSort(1);
- productShow(2,1);
- }
- }
- if (${not empty svipcouponForm.associateList2}) {
- <c:forEach items="${svipcouponForm.associateList2}" var="associate" varStatus="index">
- imageList2.push({
- id: "${associate.id}",
- productId: "${empty associate.productId ? "":associate.productId}",
- image: "${associate.image}",
- productName: "${associate.productName}",
- shopName: "${associate.shopName}",
- sort: "${associate.sort}",
- pcStatus: "${associate.pcStatus}",
- appletsStatus: "${associate.appletsStatus}",
- addTime: "<fmt:formatDate value="${associate.addTime}" pattern="yyyy-MM-dd HH:mm:ss"/>"
- });
- </c:forEach>
- if (imageList2.length > 0) {
- $('#couponWrap2').find('.contentTableProduct').show();
- batchSaveSort(2);
- productShow(2,2);
- }
- }
- if (${not empty svipcouponForm.associateList3}) {
- <c:forEach items="${svipcouponForm.associateList3}" var="associate" varStatus="index">
- imageList3.push({
- id: "${associate.id}",
- productId: "${empty associate.productId ? "":associate.productId}",
- image: "${associate.image}",
- productName: "${associate.productName}",
- shopName: "${associate.shopName}",
- sort: "${associate.sort}",
- pcStatus: "${associate.pcStatus}",
- appletsStatus: "${associate.appletsStatus}",
- addTime: "<fmt:formatDate value="${associate.addTime}" pattern="yyyy-MM-dd HH:mm:ss"/>"
- });
- </c:forEach>
- if (imageList3.length > 0) {
- $('#couponWrap3').find('.contentTableProduct').show();
- batchSaveSort(3);
- productShow(2,3);
- }
- }
- if (${not empty svipcouponForm.associateList4}) {
- <c:forEach items="${svipcouponForm.associateList4}" var="associate" varStatus="index">
- imageList4.push({
- id: "${associate.id}",
- productId: "${empty associate.productId ? "":associate.productId}",
- image: "${associate.image}",
- productName: "${associate.productName}",
- shopName: "${associate.shopName}",
- sort: "${associate.sort}",
- pcStatus: "${associate.pcStatus}",
- appletsStatus: "${associate.appletsStatus}",
- addTime: "<fmt:formatDate value="${associate.addTime}" pattern="yyyy-MM-dd HH:mm:ss"/>"
- });
- </c:forEach>
- if (imageList4.length > 0) {
- $('#couponWrap4').find('.contentTableProduct').show();
- batchSaveSort(4);
- productShow(2,4);
- }
- }
- $("body").on("change", ".couponType", function () {
- var value = $(this).parent().find('input.couponType:checked').val() * 1;
- $(this).parents(".coupon-wrap").find(".coupon-line").hide();
- if (0 === value) {
- $(this).parents(".coupon-wrap").find(".coupon-line.l1").show();
- $(this).parents(".coupon-wrap").find(".coupon-line.l2").show();
- $(this).parents(".coupon-wrap").find(".coupon-line.l4").show();
- } else if (1 === value) {
- $(this).parents(".coupon-wrap").find(".coupon-line.l1").show();
- $(this).parents(".coupon-wrap").find(".coupon-line.l2").show();
- $(this).parents(".coupon-wrap").find(".coupon-line.l3").show();
- } else if (3 === value) {
- $(this).parents(".coupon-wrap").find(".coupon-line.l0").show();
- $(this).parents(".coupon-wrap").find(".coupon-line.l1").show();
- $(this).parents(".coupon-wrap").find(".coupon-line.l2").show();
- }
- });
- function cType(id) {
- $("#couponWrap" + id).find(".productData" + id).hide();
- }
- // 点击添加供应商
- function showSelectShop(id) {
- var url = "${ctx}/coupon/cmCoupon/toAddShop";
- var title = '';
- title = "选择供应商";
- top.$.jBox("iframe:" + url, {
- iframeScrolling: 'yes',
- width: $(top.document).width() - 400,
- height: $(top.document).height() - 160,
- persistent: true,
- title: title,
- buttons: {"确定": '1', "取消": '-1'},
- submit: function (v, h, f) {
- //确定
- var $jboxFrame = top.$('#jbox-iframe');
- var $mainFrame = top.$('#mainFrame');
- if ('1' == v && 1 == $jboxFrame.size() && 1 == $mainFrame.size()) {
- var items = $jboxFrame[0].contentWindow.getCheckedItems();
- console.log(items);
- appendShopOrderHead(items, id);
- }
- return true;
- }
- });
- }
- function productShow(value, id) {
- if (value == 2) {
- $(".productData" + id).show();
- } else {
- $(".productData" + id).hide();
- }
- }
- //点击添加
- function showSelectProduct(id) {
- var url = "${ctx}/coupon/cmCoupon/toAddProduct?productIds=";
- if (id * 1 === 1) {
- url += productIds1;
- }
- if (id * 1 === 2) {
- url += productIds2;
- }
- if (id * 1 === 3) {
- url += productIds3;
- }
- if (id * 1 === 4) {
- url += productIds4;
- }
- var title = '';
- title = "选择商品";
- top.$.jBox("iframe:" + url, {
- iframeScrolling: 'yes',
- width: $(top.document).width() - 400,
- height: $(top.document).height() - 160,
- persistent: true,
- title: title,
- buttons: {"确定": '1', "取消": '-1'},
- submit: function (v, h, f) {
- //确定
- var $jboxFrame = top.$('#jbox-iframe');
- var $mainFrame = top.$('#mainFrame');
- if ('1' == v && 1 == $jboxFrame.size() && 1 == $mainFrame.size()) {
- var items = $jboxFrame[0].contentWindow.getCheckedItems();
- console.log(items);
- console.log(items[0]);
- for (var i = 0; i < items.length; i++) {
- console.log(items[i]);
- if (id * 1 === 1) {
- imageList1.push(items[i]);
- }
- if (id * 1 === 2) {
- imageList2.push(items[i]);
- }
- if (id * 1 === 3) {
- imageList3.push(items[i]);
- }
- if (id * 1 === 4) {
- imageList4.push(items[i]);
- }
- $("#couponWrap" + id).find(".contentTableProduct").show();
- $(".del").removeAttr("disabled");
- batchSaveSort(id);
- }
- ;
- }
- return true;
- }
- });
- }
- //一键排序
- function batchSaveSort(id) {
- if (id * 1 === 1) {
- imageList1.sort(sort);
- insertHtmlProduct(imageList1, id);
- }
- if (id * 1 === 2) {
- imageList2.sort(sort);
- insertHtmlProduct(imageList2, id);
- }
- if (id * 1 === 3) {
- imageList3.sort(sort);
- insertHtmlProduct(imageList3, id);
- }
- if (id * 1 === 4) {
- imageList4.sort(sort);
- insertHtmlProduct(imageList4, id);
- }
- }
- //根据sort值 从小到大排序
- function sort(a, b) {
- return a.sort - b.sort;
- }
- //相关图片列表数据
- function appendProductOrderHead(data, index, id) {
- var html = '<tr id ="ai' + index + '">' +
- '<td>' +
- '<input class="check-item" type="checkbox" name="info" value="' + index + '"/>' + (index + 1) +
- '</td>' +
- '<td>' +
- '<img src="' + data.image + '" width="60px" border="none" title="启用">' +
- '</td>' +
- '<td>' +
- data.productName +
- '</td>' +
- '<td>' +
- data.shopName +
- '</td>' +
- '<td>' +
- (data.pcStatus == 1 ? (
- '<font color="green">已启用</font>' +
- '<a href="javascript:void(0);" onclick="updatePcStatus(0,' + index + ',' + id + ');" >' +
- '停用</a>'
- ) : (
- '<font color="red">已停用</font>' +
- '<a href="javascript:void(0)" onclick="updatePcStatus(1,' + index + ',' + id + ');">' +
- '启用</a>'
- )) +
- '</td>' +
- '<td>' +
- (data.appletsStatus == 1 ? (
- '<font color="green">已启用</font>' +
- '<a href="javascript:void(0);" onclick="updateAppletsStatus(0,' + index + ',' + id + ');" >' +
- '停用</a>'
- ) : (
- '<font color="red">已停用</font>' +
- '<a href="javascript:void(0)" onclick="updateAppletsStatus(1,' + index + ',' + id + ');">' +
- '启用</a>'
- )) +
- '</td>' +
- '<td>' +
- '<input name="sort" style="width:50px;" value="' + data.sort + '" onkeyup="onlynum(this)" onchange="changeSort(' + index + ',this,' + id + ')"></td>' +
- '</td>' +
- '<td>' +
- (data.addTime == '' ? (
- '<fmt:formatDate value="<%=new Date()%>" pattern="yyyy-MM-dd HH:mm:ss"/>'
- ) : (
- data.addTime
- )) +
- '</td>' +
- '<td>' +
- '<a href="javascript:;" onclick="delect(' + index + ',' + id + ')">删除</a>' +
- '</td>' +
- '</tr>';
- return html;
- }
- function insertHtmlProduct(list, id) {
- var html = '';
- tempIds = '';
- if (list && list.length > 0) {
- list.forEach(function (item, index) {
- html += appendProductOrderHead(item, index, id);
- tempIds += "," + item.productId;
- });
- }
- if (id * 1 === 1) {
- productIds1 = tempIds;
- }
- if (id * 1 === 2) {
- productIds2 = tempIds;
- }
- if (id * 1 === 3) {
- productIds3 = tempIds;
- }
- if (id * 1 === 4) {
- productIds4 = tempIds;
- }
- $("#couponWrap" + id).find(".hotSearchProduct").html(html);
- }
- function changeSort(index, sortThis, id) {
- var sort = sortThis.value;
- if (sort > 0) {
- var image;
- if (id * 1 === 1) {
- image = imageList1[index];
- }
- if (id * 1 === 2) {
- image = imageList2[index];
- }
- if (id * 1 === 3) {
- image = imageList3[index];
- }
- if (id * 1 === 4) {
- image = imageList4[index];
- }
- if (image) {
- image.sort = sort;
- }
- }
- }
- function updatePcStatus(status, index, id) {
- var image;
- if (id * 1 === 1) {
- image = imageList1[index];
- }
- if (id * 1 === 2) {
- image = imageList2[index];
- }
- if (id * 1 === 3) {
- image = imageList3[index];
- }
- if (id * 1 === 4) {
- image = imageList4[index];
- }
- if (image) {
- confirmx(status == 0 ? '确定停用吗?' : '确定启用吗?', function () {
- image.pcStatus = status;
- batchSaveSort(id);
- });
- }
- }
- function updateAppletsStatus(status, index, id) {
- var image;
- if (id * 1 === 1) {
- image = imageList1[index];
- }
- if (id * 1 === 2) {
- image = imageList2[index];
- }
- if (id * 1 === 3) {
- image = imageList3[index];
- }
- if (id * 1 === 4) {
- image = imageList4[index];
- }
- if (image) {
- confirmx(status == 0 ? '确定停用吗?' : '确定启用吗?', function () {
- image.appletsStatus = status;
- batchSaveSort(id);
- });
- }
- }
- /**
- * 批量删除
- */
- function batchDeletion(id) {
- var index = -1;
- var i = 1;
- return confirmx("确定删除吗?", function () {
- $('input[name="info"]:checked').each(function () {
- var thisIndex = $(this).val();
- if (index >= 0 && index < thisIndex) {
- thisIndex = thisIndex - i;
- i++;
- } else {
- index = thisIndex;
- }
- var image, tempList;
- if (id * 1 === 1) {
- image = imageList1[index];
- if (image.productId != '') {
- productIds1 = productIds1.replace(image.productId, "");
- }
- imageList1.splice(thisIndex, 1);
- tempList = imageList1;
- }
- if (id * 1 === 2) {
- image = imageList2[index];
- if (image.productId != '') {
- productIds2 = productIds2.replace(image.productId, "");
- }
- imageList2.splice(thisIndex, 1);
- tempList = imageList2;
- }
- if (id * 1 === 3) {
- image = imageList3[index];
- if (image.productId != '') {
- productIds3 = productIds3.replace(image.productId, "");
- }
- imageList3.splice(thisIndex, 1);
- tempList = imageList3;
- }
- if (id * 1 === 4) {
- image = imageList4[index];
- if (image.productId != '') {
- productIds4 = productIds4.replace(image.productId, "");
- }
- imageList4.splice(thisIndex, 1);
- tempList = imageList4;
- }
- insertHtmlProduct(tempList, id);
- if (tempList.length == 0) {
- $("#couponWrap" + id).find('.contentTableProduct').hide();
- $(".del").attr("disabled", "disabled");
- }
- });
- });
- }
- function appendShopOrderHead(data, id) {
- var html = '<tr>' +
- '<td>' +
- data.name +
- '</td>' +
- '<td>' +
- data.sname +
- '</td>' +
- '<td>' +
- data.linkMan +
- '</td>' +
- '<td>' +
- data.contractMobile +
- '</td>' +
- '<td>' +
- '<a href="javascript:;" onclick="delectShop(' + id + ')">删除</a>' +
- '</td>' +
- '</tr>';
- $("#couponWrap" + id).find(".hotSearchShop").html(html);
- $("#chooseShop" + id).hide();
- $("#couponWrap" + id).find(".contentTableShop").show();
- $("#shopId" + id).val(data.shopId);
- }
- function delectShop(id) {
- return confirmx("确定删除吗?", function () {
- $("#chooseShop" + id).show();
- $("#couponWrap" + id).find(".contentTableShop").hide();
- $("#shopId" + id).val("");
- });
- }
- /**
- * 删除操作
- */
- function delect(index, id) {
- return confirmx("确定删除吗?", function () {
- var image;
- if (id * 1 === 1) {
- image = imageList1[index];
- if (image.productId != '') {
- productIds1 = productIds1.replace(image.productId, "");
- }
- imageList1.splice(index, 1);
- insertHtmlProduct(imageList1, id);
- if (imageList1.length == 0) {
- $("#couponWrap" + id).find('#contentTableProduct').hide();
- $(".del").attr("disabled", "disabled");
- }
- }
- if (id * 1 === 2) {
- image = imageList2[index];
- if (image.productId != '') {
- productIds2 = productIds2.replace(image.productId, "");
- }
- imageList2.splice(index, 1);
- insertHtmlProduct(imageList2, id);
- if (imageList2.length == 0) {
- $("#couponWrap" + id).find('#contentTableProduct').hide();
- $(".del").attr("disabled", "disabled");
- }
- }
- if (id * 1 === 3) {
- image = imageList3[index];
- if (image.productId != '') {
- productIds3 = productIds3.replace(image.productId, "");
- }
- imageList3.splice(index, 1);
- insertHtmlProduct(imageList3, id);
- if (imageList3.length == 0) {
- $("#couponWrap" + id).find('#contentTableProduct').hide();
- $(".del").attr("disabled", "disabled");
- }
- }
- if (id * 1 === 4) {
- image = imageList4[index];
- if (image.productId != '') {
- productIds4 = productIds4.replace(image.productId, "");
- }
- imageList4.splice(index, 1);
- insertHtmlProduct(imageList4, id);
- if (imageList4.length == 0) {
- $("#couponWrap" + id).find('#contentTableProduct').hide();
- $(".del").attr("disabled", "disabled");
- }
- }
- });
- }
- function clickAllSelect(ckb) {
- var isChecked = ckb.checked;
- $(".check-item").attr('checked', isChecked);
- }
- /**
- * @param obj
- * jquery控制input只能输入数字
- */
- function onlynum(obj) {
- obj.value = obj.value.replace(/[^\d]/g, ""); //清除"数字"以外的字符
- }
- </script>
- </body>
- </html>
|