|
@@ -0,0 +1,618 @@
|
|
|
+<%@ 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>
|
|
|
+ .formCheck{
|
|
|
+ margin-left: 20px !important;
|
|
|
+ }
|
|
|
+ </style>
|
|
|
+ <script type="text/javascript">
|
|
|
+ $(document).ready(function() {
|
|
|
+ //$("#name").focus();
|
|
|
+ $("#inputForm").validate({
|
|
|
+ submitHandler: function(form){
|
|
|
+ if (imageList.length > 0) {
|
|
|
+ var productInfo = JSON.stringify(imageList);
|
|
|
+ $('#productInfo').val(productInfo);
|
|
|
+ }
|
|
|
+ if (userList.length > 0) {
|
|
|
+ var userInfo = JSON.stringify(userList);
|
|
|
+ $("#userInfo").val(userInfo);
|
|
|
+ }
|
|
|
+ var couponAmount = $("#couponAmount").val()*1;
|
|
|
+ var touchPrice = $("#touchPrice").val()*1;
|
|
|
+ if (couponAmount >= touchPrice) {
|
|
|
+ alertx("优惠券金额必须小于优惠条件金额");
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ var startNowFlag = $("#startNowFlag").val();
|
|
|
+ var permanentFlag = $("#permanentFlag").val();
|
|
|
+ var startTime = $("#startTime").val();
|
|
|
+ var endTime = $("#endTime").val();
|
|
|
+ if (startNowFlag === 1) {
|
|
|
+ startTime = new Date();
|
|
|
+ }
|
|
|
+ if (permanentFlag === 0 && startTime >= endTime) {
|
|
|
+ alertx("结束时间不能早于开始时间");
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ });
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param obj
|
|
|
+ * jquery控制input只能输入数字
|
|
|
+ */
|
|
|
+ function onlynum(obj) {
|
|
|
+ obj.value = obj.value.replace(/[^\d]/g, ""); //清除"数字"以外的字符
|
|
|
+ }
|
|
|
+ </script>
|
|
|
+</head>
|
|
|
+<body>
|
|
|
+ <ul class="nav nav-tabs">
|
|
|
+ <li><a href="${ctx}/hehe/cmHeheCoupon/?couponType=${cmHeheCoupon.couponType}">优惠券列表</a></li>
|
|
|
+ <li class="active"><a href="${ctx}/hehe/cmHeheCoupon/form?id=${cmHeheCoupon.id}&couponType=${cmHeheCoupon.couponType}">${not empty cmHeheCoupon.id?'编辑':'添加'}</a></li>
|
|
|
+ </ul><br/>
|
|
|
+ <form:form id="inputForm" modelAttribute="cmHeheCoupon" action="${ctx}/hehe/cmHeheCoupon/save" method="post" class="form-horizontal">
|
|
|
+ <form:hidden path="id"/>
|
|
|
+ <form:hidden path="productInfo"/>
|
|
|
+ <form:hidden path="userInfo"/>
|
|
|
+ <form:hidden path="couponType"/>
|
|
|
+ <sys:message content="${message}"/>
|
|
|
+ <div class="control-group">
|
|
|
+ <label class="control-label"><font color="red">*</font>优惠券名称:</label>
|
|
|
+ <div class="controls">
|
|
|
+ <form:input path="name" htmlEscape="false" maxlength="30" placeholder="30个汉字以内" class="input-xlarge required"/>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div class="control-group">
|
|
|
+ <label class="control-label"><font color="red">*</font>优惠券金额:</label>
|
|
|
+ <div class="controls">
|
|
|
+ <input type="number" id="couponAmount" name="couponAmount" value="${cmHeheCoupon.couponAmount}" min="0" required> 元
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div class="control-group">
|
|
|
+ <label class="control-label"><font color="red">*</font>优惠条件:</label>
|
|
|
+ <div class="controls">
|
|
|
+ 订单商品总额满
|
|
|
+ <input type="number" id="touchPrice" name="touchPrice" value="${cmHeheCoupon.touchPrice}" min="0" required> 元
|
|
|
+<%-- <form:checkbox path="noThresholdFlag" label="无门槛" onclick="changeCondition(this,'touchPrice')" cssStyle="margin-left: 20px" value="${cmHeheCoupon.noThresholdFlag eq null?0:cmHeheCoupon.noThresholdFlag}"/>--%>
|
|
|
+ <input type="checkbox" id="noThresholdFlag" name="noThresholdFlag" class="formCheck" value="${cmHeheCoupon.noThresholdFlag eq 1?1:0}" ${cmHeheCoupon.noThresholdFlag eq 1 ? "checked" : ""} onclick="changeCondition(this,'touchPrice')" />无门槛
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div class="control-group">
|
|
|
+ <label class="control-label"><font color="red">*</font>上架时间:</label>
|
|
|
+ <div class="controls">
|
|
|
+ <input id="startTime" name="startTime" type="text" readonly="readonly" maxlength="20" class="input-medium Wdate required"
|
|
|
+ value="<fmt:formatDate value="${cmHeheCoupon.startTime}" pattern="yyyy-MM-dd HH:mm:ss"/>"
|
|
|
+ onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm',isShowClear:false});"/>
|
|
|
+<%-- <form:checkbox path="startNowFlag" label="立即上架" onclick="changeCondition(this,'startTime')" cssStyle="margin-left: 20px" value="${cmHeheCoupon.startNowFlag eq null?0:cmHeheCoupon.startNowFlag}"/>--%>
|
|
|
+ <input type="checkbox" id="startNowFlag" name="startNowFlag" class="formCheck" value="${cmHeheCoupon.startNowFlag eq 1?1:0}" ${cmHeheCoupon.startNowFlag eq 1 ? "checked" : ""} onclick="changeCondition(this,'startTime')" />立即上架
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div class="control-group">
|
|
|
+ <label class="control-label"><font color="red">*</font>下架时间:</label>
|
|
|
+ <div class="controls">
|
|
|
+ <input id="endTime" name="endTime" type="text" readonly="readonly" maxlength="20" class="input-medium Wdate required"
|
|
|
+ value="<fmt:formatDate value="${cmHeheCoupon.endTime}" pattern="yyyy-MM-dd HH:mm:ss"/>"
|
|
|
+ onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm',isShowClear:false});"/>
|
|
|
+<%-- <form:checkbox path="permanentFlag" label="永久" onclick="changeCondition(this,'endTime')" cssStyle="margin-left: 20px" value="${cmHeheCoupon.permanentFlag eq null?0:cmHeheCoupon.permanentFlag}"/>--%>
|
|
|
+ <input type="checkbox" id="permanentFlag" name="permanentFlag" class="formCheck" value="${cmHeheCoupon.permanentFlag eq 1?1:0}" ${cmHeheCoupon.permanentFlag eq 1 ? "checked" : ""} onclick="changeCondition(this,'endTime')" />永久
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div class="control-group">
|
|
|
+ <label class="control-label"><font color="red">*</font>领取期限:</label>
|
|
|
+ <div class="controls">
|
|
|
+ <input type="number" id="receivePeriod" name="receivePeriod" onkeyup="onlynum(this)" value="${cmHeheCoupon.receivePeriod}" min="1" required> 天
|
|
|
+<%-- <form:checkbox path="receiveFlag" label="同上下架时间" onclick="changeCondition(this,'receivePeriod')" cssStyle="margin-left: 20px" value="${cmHeheCoupon.receiveFlag eq null?0:cmHeheCoupon.receiveFlag}"/>--%>
|
|
|
+ <input type="checkbox" id="receiveFlag" name="receiveFlag" class="formCheck" value="${cmHeheCoupon.receiveFlag eq 1?1:0}" ${cmHeheCoupon.receiveFlag eq 1 ? "checked" : ""} onclick="changeCondition(this,'receivePeriod')" />同上下架时间
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div class="control-group">
|
|
|
+ <label class="control-label"><font color="red">*</font>使用期限:</label>
|
|
|
+ <div class="controls">
|
|
|
+ <input type="number" id="usePeriod" name="usePeriod" value="${cmHeheCoupon.usePeriod}" min="1" required> 天
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div class="control-group">
|
|
|
+ <label class="control-label"><font color="red">*</font>优惠商品:</label>
|
|
|
+ <div class="controls">
|
|
|
+ <form:radiobutton path="productType" value="1" label="全商城商品" onclick="productShow()" checked ="${empty cmHeheCoupon.productType ? true:false}"/>
|
|
|
+ <form:radiobutton path="productType" value="2" label="指定商品" onclick="productShow()"/>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div class="productData" hidden="hidden">
|
|
|
+ <div class="control-group">
|
|
|
+ <input class="btn" id="productDel" style="width: 50px" onclick="productBatchDeletion()" value="删除"/>
|
|
|
+ <input class="btn btn-primary" style="width: 70px" onclick="batchSaveProductSort()" value="一键排序"/>
|
|
|
+ <input class="btn btn-primary" style="width: 50px" onclick="productShowSelect()" value="添加"/>
|
|
|
+ <br><br>
|
|
|
+ <table id="productTable" class="table table-striped table-bordered table-condensed" hidden="hidden">
|
|
|
+ <thead>
|
|
|
+ <tr>
|
|
|
+ <th style="width:20px;"><input class="check-all" type="checkbox" onclick="clickAllSelect(this,1);"/> 全选
|
|
|
+ </th>
|
|
|
+ <th>商品图片</th>
|
|
|
+ <th>商品名称</th>
|
|
|
+ <th>供应商</th>
|
|
|
+ <th>状态</th>
|
|
|
+ <th>排序</th>
|
|
|
+ <th>添加时间</th>
|
|
|
+ <th>操作</th>
|
|
|
+ </tr>
|
|
|
+ </thead>
|
|
|
+ <tbody id="productTbody"></tbody>
|
|
|
+ </table>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <c:if test="${cmHeheCoupon.couponType eq 2}">
|
|
|
+ <div class="control-group">
|
|
|
+ <label class="control-label"><font color="red">*</font>用户列表:</label>
|
|
|
+ </div>
|
|
|
+ <div class="userData">
|
|
|
+ <div class="control-group">
|
|
|
+ <input class="btn" id="userDel" style="width: 50px" onclick="userBatchDeletion()" value="删除"/>
|
|
|
+ <input class="btn btn-primary" style="width: 50px" onclick="userShowSelect()" value="添加"/>
|
|
|
+ <br><br>
|
|
|
+ <table id="userTable" class="table table-striped table-bordered table-condensed" hidden="hidden">
|
|
|
+ <thead>
|
|
|
+ <tr>
|
|
|
+ <th style="width:20px;"><input class="check-all" type="checkbox" onclick="clickAllSelect(this,2);"/> 全选
|
|
|
+ </th>
|
|
|
+ <th>微信昵称</th>
|
|
|
+ <th>手机号</th>
|
|
|
+ <th>身份</th>
|
|
|
+ <th>添加时间</th>
|
|
|
+ <th>操作</th>
|
|
|
+ </tr>
|
|
|
+ </thead>
|
|
|
+ <tbody id="userTbody"></tbody>
|
|
|
+ </table>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </c:if>
|
|
|
+
|
|
|
+ <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>
|
|
|
+
|
|
|
+ function changeCondition(obj, name) {
|
|
|
+ var val = obj.value;
|
|
|
+ if (val === '1') {
|
|
|
+ obj.value = '0';
|
|
|
+ val = '0';
|
|
|
+ } else {
|
|
|
+ obj.value = '1';
|
|
|
+ val = '1';
|
|
|
+ }
|
|
|
+ var inputObj = $("#" + name);
|
|
|
+ if (name.indexOf("Time") !== -1) {
|
|
|
+ //修改时间
|
|
|
+ if (val === '1') {
|
|
|
+ inputObj.attr('onclick', '');
|
|
|
+ inputObj.removeClass('required');
|
|
|
+ } else {
|
|
|
+ inputObj.attr('onclick', "WdatePicker({dateFmt:'yyyy-MM-dd HH:mm',isShowClear:false})");
|
|
|
+ inputObj.addClass('required');
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ if (val === '1') {
|
|
|
+ inputObj.attr('readonly', true);
|
|
|
+ inputObj.attr('required', false);
|
|
|
+ } else {
|
|
|
+ inputObj.attr('readonly', false);
|
|
|
+ inputObj.attr('required', true);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ var productIds = '';
|
|
|
+ var imageList = [];
|
|
|
+
|
|
|
+ var userIds = '';
|
|
|
+ var userList = [];
|
|
|
+
|
|
|
+ $(function () {
|
|
|
+ <c:forEach items="${productList}" var="product" varStatus="index">
|
|
|
+ imageList.push({
|
|
|
+ id: "${product.id}",
|
|
|
+ productId: "${empty product.productId ? "":product.productId}",
|
|
|
+ image: "${product.image}",
|
|
|
+ productName: "${product.productName}",
|
|
|
+ shopName: "${product.shopName}",
|
|
|
+ sort: "${product.sort}",
|
|
|
+ status: "${product.status}",
|
|
|
+ addTime: "<fmt:formatDate value="${product.addTime}" pattern="yyyy-MM-dd HH:mm:ss"/>"
|
|
|
+ });
|
|
|
+ </c:forEach>
|
|
|
+ <c:forEach items="${userList}" var="user" varStatus="index">
|
|
|
+ userList.push({
|
|
|
+ userId: "${user.userId}",
|
|
|
+ nickName: "${user.nickName}",
|
|
|
+ mobile: "${user.mobile}",
|
|
|
+ userIdentity: "${user.userIdentity}",
|
|
|
+ addTime: "<fmt:formatDate value="${user.addTime}" pattern="yyyy-MM-dd HH:mm:ss"/>"
|
|
|
+ });
|
|
|
+ </c:forEach>
|
|
|
+
|
|
|
+ if (imageList.length > 0) {
|
|
|
+ $('#productTable').show();
|
|
|
+ batchSaveProductSort();
|
|
|
+ }
|
|
|
+ if (userList.length > 0) {
|
|
|
+ $('#userTable').show();
|
|
|
+ batchSaveUserSort();
|
|
|
+ }
|
|
|
+
|
|
|
+ initInputDisplay();
|
|
|
+ productShow();
|
|
|
+ });
|
|
|
+
|
|
|
+ //商品添加
|
|
|
+ function productShowSelect() {
|
|
|
+ var url = "${ctx}/hehe/cmHeheCoupon/toAddProduct?productIds=" + productIds;
|
|
|
+ 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]);
|
|
|
+ imageList.push(items[i]);
|
|
|
+ $('#productTable').show();
|
|
|
+ $("#productDel").removeAttr("disabled");
|
|
|
+ batchSaveProductSort();
|
|
|
+ };
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ //用户添加
|
|
|
+ function userShowSelect() {
|
|
|
+ var url = "${ctx}/hehe/cmHeheCoupon/toAddUser?userIds=" + userIds;
|
|
|
+ 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]);
|
|
|
+ userList.push(items[i]);
|
|
|
+ $('#userTable').show();
|
|
|
+ $("#userDel").removeAttr("disabled");
|
|
|
+ batchSaveUserSort();
|
|
|
+ };
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ function initInputDisplay() {
|
|
|
+ var noThresholdFlag = $("#noThresholdFlag").val();
|
|
|
+ var startNowFlag = $("#startNowFlag").val();
|
|
|
+ var permanentFlag = $("#permanentFlag").val();
|
|
|
+ var receiveFlag = $("#receiveFlag").val();
|
|
|
+
|
|
|
+ if (noThresholdFlag === '1') {
|
|
|
+ $("#touchPrice").attr('readonly', true);
|
|
|
+ $("#touchPrice").attr('required', false);
|
|
|
+ } else {
|
|
|
+ $("#touchPrice").attr('readonly', false);
|
|
|
+ $("#touchPrice").attr('required', true);
|
|
|
+ }
|
|
|
+ if (receiveFlag === '1') {
|
|
|
+ $("#receivePeriod").attr('readonly', true);
|
|
|
+ $("#receivePeriod").attr('required', false);
|
|
|
+ } else {
|
|
|
+ $("#receivePeriod").attr('readonly', false);
|
|
|
+ $("#receivePeriod").attr('required', true);
|
|
|
+ }
|
|
|
+ if (startNowFlag === '1') {
|
|
|
+ $("#startTime").attr('onclick', '');
|
|
|
+ $("#startTime").removeClass('required');
|
|
|
+ } else {
|
|
|
+ $("#startTime").attr('onclick', "WdatePicker({dateFmt:'yyyy-MM-dd HH:mm',isShowClear:false})");
|
|
|
+ $("#startTime").addClass('required');
|
|
|
+ }
|
|
|
+ if (permanentFlag === '1') {
|
|
|
+ $("#endTime").attr('onclick', '');
|
|
|
+ $("#endTime").removeClass('required');
|
|
|
+ } else {
|
|
|
+ $("#endTime").attr('onclick', "WdatePicker({dateFmt:'yyyy-MM-dd HH:mm',isShowClear:false})");
|
|
|
+ $("#endTime").addClass('required');
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 一键排序
|
|
|
+ */
|
|
|
+ function batchSaveProductSort() {
|
|
|
+ imageList.sort(sort);
|
|
|
+ productInsertHtml(imageList);
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 一键排序
|
|
|
+ */
|
|
|
+ function batchSaveUserSort() {
|
|
|
+ userInsertHtml(userList);
|
|
|
+ }
|
|
|
+
|
|
|
+ //根据sort值 从小到大排序
|
|
|
+ function sort(a, b) {
|
|
|
+ return a.sort - b.sort;
|
|
|
+ }
|
|
|
+
|
|
|
+ //相关图片列表数据
|
|
|
+ function appendProduct(data, index) {
|
|
|
+ var html = '<tr id ="ai' + index + '">' +
|
|
|
+ '<td>' +
|
|
|
+ '<input class="product-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.status == 1 ? (
|
|
|
+ '<font color="green">已启用</font> ' +
|
|
|
+ '<a href="javascript:void(0);" onclick="updateStatus(0,' + index + ');" >' +
|
|
|
+ '停用</a>'
|
|
|
+ ) : (
|
|
|
+ '<font color="red">已停用</font> ' +
|
|
|
+ '<a href="javascript:void(0)" onclick="updateStatus(1,' + index + ');">' +
|
|
|
+ '启用</a>'
|
|
|
+ )) +
|
|
|
+ '</td>' +
|
|
|
+ '</td>' +
|
|
|
+ '<td>' +
|
|
|
+ '<input name="sort" style="width:50px;" value="' + data.sort + '" onkeyup="onlynum(this)" onchange="changeSort(' + index + ',this)"></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="productDelete(' + index + ')">删除</a>' +
|
|
|
+ '</td>' +
|
|
|
+ '</tr>';
|
|
|
+ return html;
|
|
|
+ }
|
|
|
+
|
|
|
+ //相关用户列表数据
|
|
|
+ function appendUser(data, index) {
|
|
|
+ var html = '<tr id ="ai' + index + '">' +
|
|
|
+ '<td>' +
|
|
|
+ '<input class="user-check-item" type="checkbox" name="info" value="' + index + '"/>' + (index + 1) +
|
|
|
+ '</td>' +
|
|
|
+ '<td>' +
|
|
|
+ data.nickName +
|
|
|
+ '</td>' +
|
|
|
+ '<td>' +
|
|
|
+ data.mobile +
|
|
|
+ '</td>' +
|
|
|
+ '<td>' +
|
|
|
+ (data.userIdentity === 1 ? '普通用户':'分销者') +
|
|
|
+ '</td>' +
|
|
|
+ '<td>' +
|
|
|
+ (data.addTime == '' ? (
|
|
|
+ '<fmt:formatDate value="<%=new Date()%>" pattern="yyyy-MM-dd HH:mm:ss"/>'
|
|
|
+ ) : (
|
|
|
+ data.addTime
|
|
|
+ )) +
|
|
|
+ '</td>' +
|
|
|
+ '<td>' +
|
|
|
+ '<a href="javascript:;" onclick="userDelete(' + index + ')">删除</a>' +
|
|
|
+ '</td>' +
|
|
|
+ '</tr>';
|
|
|
+ return html;
|
|
|
+ }
|
|
|
+
|
|
|
+ function productInsertHtml(list) {
|
|
|
+ var html = '';
|
|
|
+ productIds = '';
|
|
|
+ list.forEach(function (item, index) {
|
|
|
+ html += appendProduct(item, index);
|
|
|
+ productIds += "," + item.productId;
|
|
|
+ });
|
|
|
+ $("#productTbody").html(html);
|
|
|
+ }
|
|
|
+
|
|
|
+ function userInsertHtml(list) {
|
|
|
+ var html = '';
|
|
|
+ userIds = '';
|
|
|
+ list.forEach(function (item, index) {
|
|
|
+ html += appendUser(item, index);
|
|
|
+ userIds += "," + item.userId;
|
|
|
+ });
|
|
|
+ $("#userTbody").html(html);
|
|
|
+ }
|
|
|
+
|
|
|
+ function changeSort(index, sortThis) {
|
|
|
+ var sort = sortThis.value;
|
|
|
+ if (sort <= 0) {
|
|
|
+
|
|
|
+ }
|
|
|
+ var image = imageList[index];
|
|
|
+ image.sort = sort;
|
|
|
+ }
|
|
|
+
|
|
|
+ function updateStatus(status, index) {
|
|
|
+ var image = imageList[index];
|
|
|
+ confirmx(status == 0 ? '确定停用吗?' : '确定启用吗?', function () {
|
|
|
+ image.status = status;
|
|
|
+ batchSaveProductSort();
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ function clickAllSelect(ckb, type) {
|
|
|
+ var isChecked = ckb.checked;
|
|
|
+ if (type === 1) {
|
|
|
+ $(".product-check-item").attr('checked', isChecked);
|
|
|
+ } else {
|
|
|
+ $(".user-check-item").attr('checked', isChecked);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 商品删除操作
|
|
|
+ */
|
|
|
+ function productDelete(index) {
|
|
|
+ return confirmx("确定删除吗?", function () {
|
|
|
+ var image = imageList[index];
|
|
|
+ if (image.productId != '') {
|
|
|
+ productIds = productIds.replace(image.productId,"");
|
|
|
+ }
|
|
|
+ imageList.splice(index, 1);
|
|
|
+ productInsertHtml(imageList);
|
|
|
+ if (imageList.length == 0) {
|
|
|
+ $('#productTable').hide();
|
|
|
+ $("#productDel").attr("disabled", "disabled");
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 用户删除操作
|
|
|
+ */
|
|
|
+ function userDelete(index) {
|
|
|
+ return confirmx("确定删除吗?", function () {
|
|
|
+ var user = userList[index];
|
|
|
+ if (user.userId != '') {
|
|
|
+ userIds = userIds.replace(user.userId,"");
|
|
|
+ }
|
|
|
+ userList.splice(index, 1);
|
|
|
+ userInsertHtml(userList);
|
|
|
+ if (userList.length == 0) {
|
|
|
+ $('#userTable').hide();
|
|
|
+ $("#userDel").attr("disabled", "disabled");
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 批量删除商品
|
|
|
+ */
|
|
|
+ function productBatchDeletion() {
|
|
|
+ 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 = imageList[thisIndex];
|
|
|
+ if (image.productId != '') {
|
|
|
+ productIds = productIds.replace(image.productId, "");
|
|
|
+ }
|
|
|
+ imageList.splice(thisIndex, 1);
|
|
|
+ productInsertHtml(imageList);
|
|
|
+ if (imageList.length == 0) {
|
|
|
+ $('#productTable').hide();
|
|
|
+ $("#productDel").attr("disabled", "disabled");
|
|
|
+ }
|
|
|
+ });
|
|
|
+ });
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 批量删除用户
|
|
|
+ */
|
|
|
+ function userBatchDeletion() {
|
|
|
+ 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 user = userList[thisIndex];
|
|
|
+ if (user.userId != '') {
|
|
|
+ userIds = userIds.replace(user.userId, "");
|
|
|
+ }
|
|
|
+ userList.splice(thisIndex, 1);
|
|
|
+ userInsertHtml(userList);
|
|
|
+ if (userList.length == 0) {
|
|
|
+ $('#userTable').hide();
|
|
|
+ $("#userDel").attr("disabled", "disabled");
|
|
|
+ }
|
|
|
+ });
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ function productShow() {
|
|
|
+ var productType = $("input[name='productType']:checked").val();
|
|
|
+ if (productType == 2){
|
|
|
+ $(".productData").show();
|
|
|
+ }else {
|
|
|
+ $(".productData").hide();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+</script>
|
|
|
+</body>
|
|
|
+</html>
|