diff --git a/client/js/market/couponList.js b/client/js/market/couponList.js index 56be40b..c7f6ea9 100644 --- a/client/js/market/couponList.js +++ b/client/js/market/couponList.js @@ -5,7 +5,6 @@ 'use strict'; var $ = require('jquery'), common = require('../common/common'); -var couponBean = require('./partials/couponList-bean'); /** * 全局变量 * departments 部门 @@ -61,15 +60,23 @@ var Bll = { getTime: function (time) { var t = new Date(time * 1000); return common.util.__dateFormat(t, "yyyy-MM-dd hh:mm:ss"); - }, - toast: function (content, fn) { + toast: function (content, url,data) { common.dialog.confirm("温馨提示", content, function () { common.util.__ajax({ - url: '/limitCode/auditLimitCode', - data: fn() + url:url, + data:data() + }, function () { + g.reload(); + }); + }); + }, + toastPass: function (content, url,data) { + common.dialog.confirm("温馨提示", content, function () { + common.util.__ajax({ + url:url, + data:data }, function () { - loadtab(); g.reload(); }); }); @@ -85,38 +92,6 @@ var Bll = { ] }) - - }, - __render: function (title, item) { - common.dialog({ - title: title, - width: "60%", - content: common.util.__template2($("#couponListAdd-template").html(), item), - button: [{ - value: "保存", - callback: function () { - console.log(couponBean); - common.util.__ajax({ - url:"/coupon/addOrUpdate", - data:couponBean - },function(res){ - console.log("res",res); - }) - } - }] - }); - - e.init(); - startTimeObj = $("#startTime").fdatepicker({ - format: 'yyyy-mm-dd hh:ii:ss', - pickTime: true - }).data("datepicker"); - endTimeObj = $("#endTime").fdatepicker({ - format: 'yyyy-mm-dd hh:ii:ss', - pickTime: true - }).data("datepicker"); - new common.dropDown({el: '#filter-couponType'}); - new common.dropDown({el: '#filter-department'}); }, getButtons: function (index, id, array) { var btns = []; @@ -124,7 +99,7 @@ var Bll = { '<a class="btn btn-warning btn-xs apply-back" data-index="' + index + '" >驳回</a>', '<a class="btn btn-primary btn-xs apply-success" data-index="' + index + '" >通过</a>', '<a data-index="' + index + '" class="btn btn-info btn-xs coupon-info">查看详情</a>', - '<a data-index="' + index + '"class="btn btn-info btn-xs apply-modify" >修改</a>', + '<a data-index="' + index + '"class="btn btn-info btn-xs apply-modify" href="/market/couponList/update/'+id +'">修改</a>', '<a class="btn btn-danger btn-xs apply-cancel" data-index="' + index + '" >作废</a>' ]; for (var i = 0; i < array.length; i++) { @@ -153,7 +128,7 @@ var g = new common.grid({ display: "基本信息", render: function (item) { var arr = []; arr.push("<p>名称:" + item.couponName + "</p>"); - arr.push("<p>类型:" + couponTypes[item.couponType] + "</p>"); + arr.push("<p>类型:" + couponTypes[item.couponType-1] + "</p>"); arr.push("<p>优惠结果:" + item.couponAmount + "</p>"); arr.push("<p>数量:" + item.couponNum + "</p>"); arr.push("<p>部门:" + departments[item.department - 1] + "</p>"); @@ -162,8 +137,8 @@ var g = new common.grid({ }, { display: "使用期限", render: function (item) { - var startTime = common.util.__dateFormat(new Date(item.startTime), "yyyy-MM-dd hh:mm:ss"); - var endTime = common.util.__dateFormat(new Date(item.endTime), "yyyy-MM-dd hh:mm:ss"); + var startTime = Bll.getTime(item.startTime); + var endTime = Bll.getTime(item.endTime); return startTime + "</br> 至 " + endTime; } }, @@ -207,34 +182,14 @@ g.init("/coupon/queryCouponList"); $("#filter-btn").click(function () { g.reload(1); }); - -var e = new common.edit2(".modal-body"); -var startTimeObj; -var endTimeObj; -/** - * 监控输入变化 - */ -$(document).on("change", ".observe", function () { - var $this = $(this); - var name = $this.data("field"); - couponBean = common.util.__buildobj(name, '.', couponBean, function (obj, name) { - obj[name] = $this.val(); - }); - //console.log("couponBean",couponBean); - -}); //审核通过 $(document).on('click', '.apply-success', function () { var item = g.rows[$(this).data("index")]; - var data = function () { - return { - id: item.id, - status: 1 - }; + var data ={ + couponId: item.id }; - Bll.toast("确定要通过该申请吗?", data); + Bll.toastPass("确定要通过该申请吗?", "/coupon/approve",data); }); - //驳回 $(document).on('click', '.apply-back', function () { var item = g.rows[$(this).data("index")]; @@ -244,14 +199,12 @@ $(document).on('click', '.apply-back', function () { return "请填写驳回原因"; } return { - id: item.id, - status: 2, - reason: reason + couponId: item.id, + rejectReason: reason }; }; - Bll.toast(common.util.__template2($("#template").html(), {name: "你确定要驳回该申请吗?"}), data); + Bll.toast(common.util.__template2($("#template").html(), {name: "你确定要驳回该申请吗?"}),"/coupon/reject", data); }); - //作废 $(document).on('click', '.apply-cancel', function () { var item = g.rows[$(this).data("index")]; @@ -261,19 +214,18 @@ $(document).on('click', '.apply-cancel', function () { return "请填写作废原因"; } return { - id: item.id, - status: 4, - reason: reason + couponId: item.id, + invalidReason:reason }; }; - Bll.toast(common.util.__template2($("#template").html(), {name: "你确定要作废此限购码吗?"}), data); + Bll.toast(common.util.__template2($("#template").html(), {name: "你确定要作废此限购码吗?"}),"/coupon/invalid", data); }); /** * 查看详情 */ $(document).on('click', '.coupon-info', function () { var item = g.rows[$(this).data("index")]; - console.log(item.customType); + console.log(item); var item1 = $.extend(true, {}, item); item1.createTime = Bll.getTime(item1.createTime); item1.startTime = Bll.getTime(item1.startTime); @@ -297,32 +249,5 @@ $(document).on('click', '.coupon-info', function () { } Bll.toastInfo(item1, '优惠券详情'); }); -/** - * 添加 - */ -$(document).on('click', "#add-btn", function () { - Bll.__render("添加优惠券", couponBean); -}); -/** - * 修改 - */ -$(document).on('click', ".apply-modify", function () { - var item = g.rows[$(this).data("index")]; - Bll.__render("修改优惠券", item); -}); - -$(document).on("change", "#useLimitType", function () { - -}); -$(document).on("change", "#useRange", function () { - if ($(this).val() == 0) { - - } -}); - -//输入限制 -$(document).on("keyup", ".number", function () { - $(this).val($(this).val().replace(/\D/g, '')); -}); diff --git a/client/js/market/couponListAdd.js b/client/js/market/couponListAdd.js index 8ca5124..194d969 100644 --- a/client/js/market/couponListAdd.js +++ b/client/js/market/couponListAdd.js @@ -6,14 +6,97 @@ var common = require('../common/common'); var couponBean = require('./partials/couponList-bean'); var e = new common.edit2("#basicForm"); -var type = $("#basicForm").attr("role"), - action = $("#basicForm").data("action"); +var type = $("#basicForm").attr("role"),//类型 新增或修改 + action = $("#basicForm").data("action");//路由 var startTimeObj; var endTimeObj; +/** + * 监听输入值的变化 + */ +$(document).on("change", ".observe", function () { + var $this = $(this); + var name = $this.data("field"); + couponBean = common.util.__buildobj(name, '.', couponBean, function (obj, name) { + obj[name] = $this.val(); + }); +}); +/** + * 全局对象 + */ var Bll = { - __render:function() { - $("#basicForm").html(common.util.__template2($("#couponListAdd-template").html(), couponBean)); + Brands: [], + Brands1: {}, + Brdata: [], + getBrands: function () { + var Brand = {}; + $.get("/ajax/yohosearch", function (res) { + if (!res.data || !res.data.brands) { + return; + } + for (var key in res.data.brands) { + var name = key; + if (/^[0-9]$/.test(name)) { + name = "0-9"; + } + if (name === "") { + name = "#"; + } + for (var key2 in res.data.brands[key]) { + var item = res.data.brands[key][key2]; + Brand[name] = Brand[name] || []; + Brand[name].push(item); + Bll.Brands1[item.id] = item; + } + } + for (var i in Brand) { + Brand[i].sort(function (a, b) { + var aName = a.brand_name.toLowerCase(), + bName = b.brand_name.toLowerCase(); + if (aName < bName) return -1; + if (aName > bName) return 1; + return 0; + }); + Bll.Brands.push({ + name: i, + items: Brand[i] + }); + + } + }); + }, + renderBrandPic: function (Brdata) { + var map2 = {}; + Brdata.forEach(function (item) { + map2[item.id] = item; + }); + Brdata = []; + for (var key in map2) { + Brdata.push(map2[key]); + } + var Brands2 = []; + Brdata.forEach(function (item, index) { + if (!item.brandIco) { + var a = Bll.Brands1[item.id]; + if (a.brandIco) { + a.brandIco = common.util.__joinImg("brandLogo", a.brand_ico); + } + Brands2.push(a); + } else { + item.brandIco = common.util.__template(item.brandIco, {width: 110, height: 150}); + Brands2.push(item); + } + + }); + return Brdata; + }, + getTime: function (time) { + var t = new Date(time * 1000); + return common.util.__dateFormat(t, "yyyy-MM-dd hh:mm:ss"); + + }, + __render: function (item) { + $("#basicForm").html(common.util.__template2($("#couponListAdd-template").html(), item)); e.init(); startTimeObj = $("#startTime").fdatepicker({ format: 'yyyy-mm-dd hh:ii:ss', @@ -23,84 +106,189 @@ var Bll = { format: 'yyyy-mm-dd hh:ii:ss', pickTime: true }).data("datepicker"); - //if(type == "edit") { - // $('input[name="skn_sku"]').prop('disabled', true); - // $(".noEdit").prop("disabled", true); - // $('input[name="userTypeLimit"]').prop('disabled', true); - //} new common.dropDown({el: '#filter-couponType'}); new common.dropDown({el: '#filter-department'}); + }, + checkSortNum: function () { + if ($('.sort-wrap').find('.row').size() > 1) { + $('.sort-wrap').find('.row').find('.add-sort-btn').hide().end().find('.del-sort-btn').show(); + $('.sort-wrap').find('.row:last').find('.add-sort-btn').show().end().find('.del-sort-btn').show(); + } else { + $('.sort-wrap').find('.row:first').find('.add-sort-btn').show().end().find('.del-sort-btn').hide(); + } } }; - -if(type != "add") { +/** + * 根据type判断界面 + */ +if (type == 'add') { + Bll.__render(couponBean); +} else { var id = location.href.substring(location.href.lastIndexOf("/") + 1); common.util.__ajax({ - url: "/limitCode/getLimitCode", - data: {id: id} + url: "/coupon/queryCouponList", + data: {couponId: id} }, function (res) { - editBean = res.data; - editBean.reqDepartment = editBean.reqDepartment.split("/"); - if(!editBean.reqDepartment.length) { - editBean.reqDepartment = [ - "零售部", - "营销策划" - ]; - } - editBean.selected = editBean.skus ? "SKU" : "SKN"; - editBean.updateType = type == "edit" ? "1":"2"; - editBean.skusInfo = []; - if(editBean.skus) { - var skuArr = editBean.skus.split(";"); - var skuNumArr = editBean.skuTimes.split(";"); - for(var i = 0; i < skuArr.length; i++) { - editBean.skusInfo.push({ - "sku": skuArr[i], - "skuTimes": skuNumArr[i] - }); - } - } - Bll.__render(); - },true); -} else { - Bll.__render(); + couponBean = res.data.list[0]; + couponBean.startTime = Bll.getTime(couponBean.startTime); + couponBean.endTime = Bll.getTime(couponBean.endTime); + Bll.__render(couponBean) + }, true); } - -$(document).on("change", ".observe", function () { - var $this = $(this); - var name = $this.data("field"); - couponBean = common.util.__buildobj(name, '.', couponBean, function (obj, name) { - obj[name] = $this.val(); +/** + * 优惠条件 + */ +$(document).on("change", "#useLimitType", function () { + Bll.__render(couponBean); +}); +/** + * 适用范围 + */ +$(document).on("change", "#useRange", function () { + couponBean.useRange = $(this).val(); + Bll.__render(couponBean); +}); +var tabTreeArr = []; +var tabTree; +//选择分类 +$(document).on('click',"#addSorts",function(){ + var data = {}; + common.dialog({ + title: "选择分类", + width: "60%", + content: common.util.__template2($('#editTemp').html(), data), + button: [{ + value: "保存", + callback: function () { + var ids = []; + if (tabTreeArr.length > 0) { + for (var i = 0; i < tabTreeArr.length; i++) { + for (var key in tabTreeArr[i].selected) { + ids.push(tabTreeArr[i].selected[key].id); + } + } + couponBean.sortLimit = ids.join(','); + } + }, + css: "btn btn-primary" + }, { + value: "取消" + }] + }); + tabTreeArr = []; + tabTree = new common.tabTree(".sortTree", { + sortLevel: 1 }); - //console.log(editBean); + tabTree.init(); + tabTreeArr.push(tabTree); + Bll.checkSortNum(); }); -$(document).on("change", "#useLimitType", function() { - +//添加一个分类 +$(document).on('click', '.add-sort-btn', function () { + var $sortGroup = $($('#sortWrap').html()); + $sortGroup.appendTo($('.sort-wrap')); + tabTree = new common.tabTree(".sortTree:last", { + sortLevel: 1 + }); + tabTreeArr.push(tabTree); + tabTree.init(); + Bll.checkSortNum(); }); - -$(document).on("change", "#useRange", function () { - if($(this).val() == 0) { - +//删除一个分类 +$(document).on('click', '.del-sort-btn', function () { + var sortIndex = $(this).parents('.row').index(); + $(this).parents('.row').remove(); + tabTreeArr.splice(sortIndex, 1); + Bll.checkSortNum(); +}); +/** + * 会员身份 + */ +var customType = []; +var len = couponBean.customType.length; +if (len > 0) { + customType = couponBean.customType.split(','); +} +$(document).on("click", "input[name='customType']", function () { + if ($(this).is(':checked')) { + customType.push($(this).val()); + } else { + for (var i = 0; i < a.length; i++) { + if ($(this).val() == a[i]) { + customType.splice(i, 1) + } + } } + couponBean.customType = customType.join(","); }); //输入限制 -$(document).on("keyup", ".number", function() { +$(document).on("keyup", ".number", function () { $(this).val($(this).val().replace(/\D/g, '')); }); - -$(document).on("click","#save_brand", function() { - // 限购码状态0:待审核 1:审核通过 2:驳回 3:过期 4:作废 - console.log(couponBean); - if(e.validate()) { - //console.log(JSON.stringify(editBean)); - //common.util.__ajax({ - // url: action, - // data: editBean - //}, function (res) { - // location.href = "/market/limitcode/index"; - //}); +/** + * 保存 + */ +$(document).on("click", "#save_brand", function () { + if (e.validate()) { + delete couponBean.useRange; + common.util.__ajax({ + url: action, + data: couponBean + }, function (res) { + location.href = "/market/couponList/index"; + }); } return false; -}); \ No newline at end of file +}); + + +/********************************************************品牌相关****************************************/ +//获取品牌 +Bll.getBrands(); +Bll.renderBrandPic(Bll.Brdata); +/** + * 添加品牌 + */ +$(document).on("click", "#addBrands", function () { + var e = new common.edit("#brandForm"); + common.dialog.confirm("选择品牌", common.util.__template2($("#template5").html(), { + Brands: Bll.Brands, + Brdata: Bll.Brdata.join(',') + }), function () { + $("#brandCheckBox").val().split('|').forEach(function (item) { + Bll.Brdata.push({ + "brandCategory": "1", + "id": item + }); + }); + couponBean.brandLimit = $("#brandCheckBox").val().split('|').join(","); + Bll.Brdata = Bll.renderBrandPic(Bll.Brdata); + }); + e.init(); +}); +/*点击品牌切换*/ +$(document).on('click', '.brand-index', function () { + var brandIndex = $(this).text(); + $('.brand-wrap').find('[name="' + brandIndex + '"]').show().siblings().hide(); +}); +$(document).on("focus", "#brandsearch", function () { + $('.brand-wrap').find('[name="brandsearch"]').show().siblings().hide(); +}); +$(document).on("keyup", "#brandsearch", function () { + var txt = $(this).val(); + var regex = new RegExp(txt); + var bs = []; + Bll.Brands.forEach(function (brands) { + brands.items.forEach(function (item) { + if (regex.test(item.brand_name)) { + bs.push('<a class="btn"><input type="checkbox" value="' + item.id + '" name="brandCheckBox"><label>' + item.brand_name + '</label></a>'); + } + }); + }); + $("#brandsearchwrap").html(bs.join('')); + var e = new common.edit("#brandForm"); + e.init(); + +}); diff --git a/client/js/market/partials/couponList-bean.js b/client/js/market/partials/couponList-bean.js index da92f4f..756f9d6 100644 --- a/client/js/market/partials/couponList-bean.js +++ b/client/js/market/partials/couponList-bean.js @@ -16,7 +16,8 @@ var couponBean = { couponAmount:"", brandLimit:"", sortLimit:"", - customType:"" + customType:"", + useRange:0 }; module.exports = couponBean; \ No newline at end of file diff --git a/server/interface/market.js b/server/interface/market.js index 5b58077..3ddf83a 100644 --- a/server/interface/market.js +++ b/server/interface/market.js @@ -50,7 +50,8 @@ exports.res = [ name: 'reqDepartment', type: 'String' }] - }, { + }, + { //营销码管理 -> 列表操作 route: '/market/coupon/auditPromotion', method: 'POST', @@ -66,7 +67,8 @@ exports.res = [ name: 'reason', type: 'String' }] - }, { + }, + { //营销码管理 -> 发放列表 route: '/market/coupon/sendPromotion', method: 'POST', @@ -76,7 +78,8 @@ exports.res = [ name: 'auditTime', type: 'String' }] - }, { + }, + { //营销码管理 -> tab卡数据 route: '/market/coupon/getCodeCount', method: 'POST', @@ -92,7 +95,8 @@ exports.res = [ name: 'batchNo', type: 'Number' }] - }, { + }, + { //营销码管理 -> 添加优惠码页面渲染 route: '/market/coupon/add', method: 'GET', @@ -111,7 +115,8 @@ exports.res = [ status: "0" } } - }, { + }, + { //营销码管理 -> 添加优惠码 route: '/market/coupon/addCode', method: 'POST', @@ -160,7 +165,8 @@ exports.res = [ name: 'staff', type: 'String' }] - }, { + }, + { //营销码管理 -> 编辑优惠码页面渲染 route: '/market/coupon/update/:id', method: 'GET', @@ -176,7 +182,8 @@ exports.res = [ name: "id", type: "String" }] - }, { + }, + { //营销码管理 -> 优惠码详情 route: '/market/coupon/info/:id', method: 'GET', @@ -191,7 +198,8 @@ exports.res = [ name: "id", type: "String" }] - }, { + }, + { //营销码管理 -> 验证优惠码 route: '/market/coupon/checkPromotionCode', method: 'POST', @@ -201,7 +209,8 @@ exports.res = [ name: 'code', type: 'String' }] - }, { + }, + { //营销码管理 -> 编辑优惠码 route: '/market/coupon/updateCode', method: 'POST', @@ -251,7 +260,7 @@ exports.res = [ type: 'String' }] }, - /*******************************************************************/ + /***************************************限购码管理****************************/ { //限购码管理 -> 页面渲染 route: '/market/limitcode/index', @@ -264,9 +273,10 @@ exports.res = [ filter: true, createUrl: '/market/limitcode/add', gridurl: '/limitCode/getLimitCodeList', - limitcode:true + limitcode: true } - }, { + }, + { //限购码管理 -> 限购码列表 route: '/limitCode/getLimitCodeList', method: 'POST', @@ -297,7 +307,8 @@ exports.res = [ name: 'skn', type: 'String' }] - }, { + }, + { //限购码管理 -> 添加限购码页面渲染 route: '/market/limitcode/add', method: 'GET', @@ -313,7 +324,8 @@ exports.res = [ } }, src: '/market/limitcode-edit' - }, { + }, + { //限购码管理 -> 添加限购码 route: '/limitCode/addLimitCode', method: 'POST', @@ -365,16 +377,18 @@ exports.res = [ name: "limitCodeType", type: "string" }] - },{ + }, + { //检查SKN的合法性并且获得其下的所有SKU route: '/limitCode/checkSknValidity', method: 'POST', url: '/limitCode/checkSknValidity', - params:[ + params: [ {name: "skn", type: "string"}, {name: "id", type: "string"} ] - }, { + }, + { //限购码管理 -> 查看限购码页面渲染 route: '/market/limitcode/info/:id', method: 'GET', @@ -386,7 +400,8 @@ exports.res = [ name: 'id', type: 'String' }] - }, { + }, + { //限购码管理 -> 修改限购码页面渲染 route: '/market/limitcode/update/:id', method: 'GET', @@ -396,20 +411,22 @@ exports.res = [ isJsonRaw: true, data: { action: "/limitCode/updateLimitCode", - type: "update", + type: "update" }, params: [{ name: 'id', type: 'String' }] - }, { - route:'/limitCode/getLimitCode', - method:'POST', - url:'/limitCode/getLimitCode', - params:[ - {name:'id', type:'string'} + }, + { + route: '/limitCode/getLimitCode', + method: 'POST', + url: '/limitCode/getLimitCode', + params: [ + {name: 'id', type: 'string'} ] - },{ + }, + { //限购码管理 -> 编辑限购码页面渲染 route: '/market/limitcode/edit/:id', method: 'GET', @@ -419,13 +436,14 @@ exports.res = [ //isJsonRaw: true, data: { action: "/limitCode/updateLimitCode", - type: "edit", + type: "edit" }, params: [{ name: 'id', type: 'String' }] - }, { + }, + { //限购码管理 -> 编辑限购码接口 route: '/limitCode/updateLimitCode', method: 'POST', @@ -483,7 +501,8 @@ exports.res = [ name: "skus", type: "string" }] - }, { + }, + { //限购码管理 -> 修改限购码接口 route: '/limitCode/auditLimitCode', method: 'POST', @@ -500,7 +519,8 @@ exports.res = [ name: 'reason', type: 'String' }] - }, { + }, + { //限购码管理 -> tab卡数据 route: '/limitCode/getLimitCodeCountByStatus', method: 'POST', @@ -530,7 +550,8 @@ exports.res = [ createUrl: '/market/vipamount/add', gridurl: '/market/vipamount/list' } - }, { + }, + { //vip累计金额翻倍 -> 列表数据 route: '/market/vipamount/list', method: 'POST', @@ -561,16 +582,18 @@ exports.res = [ } } - }, { + }, + { //vip累计金额翻倍 -> 添加页面渲染 route: '/market/vipamount/add', method: 'GET', view: 'pages/market/vipamount-edit', src: '/market/vipamount-edit', data: { - action: '/market/vipamount/save', + action: '/market/vipamount/save' } - }, { + }, + { //vip累计金额翻倍 -> 添加编辑活动 route: '/market/vipamount/save', method: 'POST', @@ -599,7 +622,7 @@ exports.res = [ type: 'Number' }] }, - /***********************************************************/ + /**********************************发券管理*************************/ { //发券管理列表页渲染 route: "/market/couponSend/index", @@ -714,7 +737,7 @@ exports.res = [ {name: "id", type: "number"} ] }, - /****************************************优惠券管理********************/ +/****************************************优惠券管理********************/ { //优惠券管理页面渲染 route: "/market/couponList/index", @@ -746,19 +769,96 @@ exports.res = [ view: "pages/market/couponListAdd", src: "/market/couponListAdd", data: { + title: "新增优惠券", type: "add", - actions: "" + action: "/coupon/add" } }, { - //优惠券列表编辑页面渲染 - route: "/market/couponList/add", + //优惠券新增 + route: "/coupon/add", method: "POST", - url: "pages/market/couponListAdd", - + url: "/coupon/addOrUpdate", + params: [ + {name: "id", type: "number"}, + {name: "couponType", type: "number"}, + {name: "couponName", type: "string"}, + {name: "couponNum", type: "number"}, + {name: "useNum", type: "number"}, + {name: "department", type: "number"}, + {name: "startTime", type: "string"}, + {name: "endTime", type: "string"}, + {name: "explains", type: "string"}, + {name: "useLimitType", type: "number"}, + {name: "useLimit", type: "number"}, + {name: "couponAmount", type: "number"}, + {name: "brandLimit", type: "string"}, + {name: "sortLimit", type: "string"}, + {name: "customType", type: "string"} + ] + }, + { + //优惠券列表编辑页面渲染 + route: "/market/couponList/update/:id", + method: "GET", + view: "pages/market/couponListAdd", + src: "/market/couponListAdd", data: { - type: "add", - actions: "" + title: "修改优惠券", + type: "update", + action: "/coupon/update" } + }, + { + //优惠券新增 + route: "/coupon/update", + method: "POST", + url: "/coupon/addOrUpdate", + params: [ + {name: "id", type: "number"}, + {name: "couponType", type: "number"}, + {name: "couponName", type: "string"}, + {name: "couponNum", type: "number"}, + {name: "useNum", type: "number"}, + {name: "department", type: "number"}, + {name: "startTime", type: "string"}, + {name: "endTime", type: "string"}, + {name: "explains", type: "string"}, + {name: "useLimitType", type: "number"}, + {name: "useLimit", type: "number"}, + {name: "couponAmount", type: "number"}, + {name: "brandLimit", type: "string"}, + {name: "sortLimit", type: "string"}, + {name: "customType", type: "string"} + ] + }, + { + //驳回 + route: "/coupon/reject", + method: "POST", + url: "/coupon/reject", + params: [ + {name: "couponId", type: "number"}, + {name: "rejectReason", type: "string"} + ] + }, + { + //通过 + route: "/coupon/approve", + method: "POST", + url: "/coupon/approve", + params: [ + {name: "couponId", type: "number"} + ] + }, + { + //作废 + route: "/coupon/invalid", + method: "POST", + url: "/coupon/invalid", + params: [ + {name: "couponId", type: "number"}, + {name: "invalidReason", type: "string"} + ] } ]; \ No newline at end of file diff --git a/server/views/pages/market/couponList.html b/server/views/pages/market/couponList.html index cf89b11..1bffe16 100644 --- a/server/views/pages/market/couponList.html +++ b/server/views/pages/market/couponList.html @@ -22,7 +22,7 @@ <div class="contentpanel"> <div class="panel panel-default" style="margin-bottom:10px;"> <div class="panel-heading"> - <a id="add-btn" class="btn btn-success "><i class="fa fa-plus"></i> 添加</a> + <a id="add-btn" href="{{createUrl}}" class="btn btn-success "><i class="fa fa-plus"></i> 添加</a> </div> <div class="panel-body"> <div class="row"> @@ -64,7 +64,7 @@ <script type="text/template" id="template"> <p>[[name]]</p> - <label class="col-sm-3 control-label">*请填写原因</label> + <label class="col-sm-3 control-label"><i class="red">*请填写原因</i></label> <input id="reason" type="text" class="form-control" name="agreement-code" style="width:280px;"> </script> @@ -215,201 +215,5 @@ </div> </script> -<script type="text/template" id="couponListAdd-template"> - <div class="panel panel-default"> - <div class="panel-body"> - <div class="row"> - <div class="form-group"> - <label class="col-sm-2 control-label">类型 <span class="red">*</span></label> - - <div class="col-sm-8"> - <select id="filter-couponType" tabindex="-1" class="select2-offscreen brandBtn-group observe" - value="[[couponType]]" data-field="couponType" required> - <option value="-1">优惠券类型</option> - <option value="1">A券</option> - <option value="2">B券</option> - <option value="3">公开券</option> - <option value="4">生日券</option> - <option value="5">免邮券</option> - </select> - </div> - </div> - </div> - </div> - <div class="panel-heading"> - <h4 class="panel-title">基本信息</h4> - </div> - <div class="panel-body"> - <div class="row"> - <div class="form-group"> - <label class="col-sm-2 control-label">名称 <span class="red">*</span></label> - - <div class="col-sm-8"> - <input type="text" placeholder="名称建议30字以内" prompt="名称" class="form-control observe" - data-field="couponName" required maxlength="30" value="[[couponName]]"> - </div> - </div> - - <div class="form-group"> - <label class="col-sm-2 control-label">数量<i class="red">*</i></label> - - <div class="col-sm-8"> - <input type="text" placeholder="数量" class="form-control observe number" data-field="couponNum" - required value="[[couponNum]]"> - </div> - </div> - - <div class="form-group"> - <label class="col-sm-2 control-label">使用次数<i class="red">*</i></label> - - <div class="col-sm-8"> - <input type="text" placeholder="使用次数" class="form-control observe number" data-field="useNum" - required value="[[useNum]]"> - </div> - </div> - - <div class="form-group"> - <label class="col-sm-2 control-label">申请部门</label> - - <div class="col-sm-8"> - <select id="filter-department" tabindex="-1" class="select2-offscreen brandBtn-group observe" - value="[[department]]" data-field="department" required> - <option value="-1">申请部门</option> - <option value="1">渠道二部</option> - <option value="2">渠道一部</option> - <option value="3">零售部</option> - <option value="4">品牌资源部</option> - <option value="5">店铺运营部</option> - <option value="6">类目运营部</option> - <option value="7">营销部</option> - <option value="8">市场部</option> - <option value="9">会员部</option> - <option value="10">客服部</option> - <option value="11">内容营销部</option> - </select> - </div> - </div> - - <div class="form-group"> - <label class="col-sm-2 control-label">使用期限<span class="red">*</span></label> - - <div class="col-sm-6"> - <div class="col-sm-6"> - <input type="text" class="form-control observe" data-field="startTime" id="startTime" - placeholder="开始时间" value="[[startTime]]" readonly required> - </div> - <div class="col-sm-6"> - <input type="text" class="form-control observe" data-field="endTime" id="endTime" - placeholder="结束时间" value="[[endTime]]" readonly required> - </div> - </div> - </div> - - <div class="form-group"> - <label class="col-sm-2 control-label">优惠券说明<i class="red">*</i></label> - - <div class="col-sm-8"> - <textarea class="form-control observe" prompt="优惠券说明" data-field="explains" maxlength="100" - placeholder="优惠券使用条件简介" required style="resize: none">[[explains]]</textarea> - </div> - </div> - </div> - </div> - <div class="panel-heading"> - <h4 class="panel-title">使用条件</h4> - </div> - <div class="panel-body"> - <div class="row"> - <div class="form-group"> - <label class="col-sm-2 control-label">优惠条件<i class="red">*</i></label>  - <select value="[[useLimitType]]" id="useLimitType" class="form-control input-form observe" - data-field="useLimitType"> - <option value="0">无限制</option> - <option value="1">件数</option> - <option value="2">金额</option> - </select>   - <label id="useLimitLabel" class="control-label">金额满</label> - <input value="[[useLimit]]" class="form-control input-form observe" data-field="useLimit"> - </div> - - <div class="form-group"> - <label class="col-sm-2 control-label">优惠结果<i class="red">*</i></label> - - <div class="col-sm-4"> - <label class="col-sm-2 control-label">面额</label> - - <div class="col-sm-8"> - <input type="text" class="form-control observe" data-field="couponAmount" - value="[[couponAmount]]"> - </div> - <label class="col-sm-2 control-label">元</label> - </div> - </div> - - <div class="form-group"> - <label class="col-sm-2 control-label">适用范围</label> - - <div class="col-sm-4"> - <div class="col-sm-10"> - <select value="[[useLimitType]]" id="useRange" class="form-control input-form"> - <option value="0">分类</option> - <option value="1" checked>品牌</option> - </select>   - <a class="btn btn-primary btn-xs" href="javascript:;">添加品牌</a> - </div> - </div> - </div> - </div> - </div> - - <div class="panel-heading"> - <h4 class="panel-title">领券条件</h4> - </div> - <div class="panel-body"> - <div class="row"> - <div class="form-group"> - <label class="col-sm-2 control-label">会员身份<i class="red">*</i></label> - - <div class="col-sm-10"> - <label class="checkbox-inline"> - <input type="checkbox" value="1" name="customType"> 新客户 (注册未购买) - </label> - <label class="checkbox-inline"> - <input type="checkbox" value="5" name="customType"> 普通会员 (不包含新客户) - </label> - <label class="checkbox-inline"> - <input type="checkbox" value="2" name="customType"> 银卡会员 - </label> - <label class="checkbox-inline"> - <input type="checkbox" value="3" name="customType"> 金卡会员 - </label> - <label class="checkbox-inline"> - <input type="checkbox" value="4" name="customType"> 白金会员 - </label> - </div> - - <input type="hidden" value="[[customType]]" id="customType" for="checkbox" required - placeholder="会员身份"> - </div> - </div> - </div> - <div class="panel-heading"> - <h4 class="panel-title">优惠互斥</h4> - </div> - <div class="panel-body"> - <div class="row"> - <div class="form-group"> - <label class="col-sm-2 control-label">申请人</label> - - <div class="col-sm-8"> - <label class="form-label control-label" id="creatorName">{{auth.name}}</label> - </div> - </div> - <input id="auth_id1" type="hidden" value="{{auth.uid}}"> - <input id="auth_name1" type="hidden" value="{{auth.name}}"> - </div> - </div> - </div> -</script> diff --git a/server/views/pages/market/couponListAdd.html b/server/views/pages/market/couponListAdd.html index 3184b52..a07e0e1 100644 --- a/server/views/pages/market/couponListAdd.html +++ b/server/views/pages/market/couponListAdd.html @@ -12,7 +12,7 @@ <div> <div style="width: 30%;float: left;"> - <h4>新增优惠券</h4> + <h4>{{title}}</h4> </div> </div> </div> @@ -28,52 +28,91 @@ </div> </div> </div> +<script type="text/template" id="template5"> + <div class="row" id="brandForm"> + <div class="form-group"> + [[each Brands as brand index]] + <a class="btn brand-index" href="#[[brand.name]]">[[brand.name]]</a> + [[/each]] + <input type="text" class="form-control" placeholder="搜索" id="brandsearch"/> + </div> + <div class="form-group brand-wrap" style="height: 400px;overflow: auto;"> + [[each Brands as brand index]] + <div class="form-group" name="[[brand.name]]"> + [[each brand.items as item __index ]] + <a class="btn"> + <input type="checkbox" value="[[item.id]]" name="brandCheckBox"> + <label>[[item.brand_name]]</label> + </a> + [[/each]] + </div> + [[/each]] + <div class="form-group" id="brandsearchwrap" name="brandsearch"> + </div> + </div> + <input type="hidden" id="brandCheckBox" for="checkbox" value="[[Brdata]]"/> + </div> +</script> <script type="text/template" id="couponListAdd-template"> <div class="panel panel-default"> - <div class="form-group"> - <label class="col-sm-2 control-label">类型 <span class="red">*</span></label> - <div class="col-sm-8"> - <select id="filter-couponType" tabindex="-1" class="select2-offscreen brandBtn-group observe" value="[[couponType]]" data-field="couponType" required> - <option value="-1">优惠券类型</option> - <option value="1">A券</option> - <option value="2">B券</option> - <option value="3">公开券</option> - <option value="4">生日券</option> - <option value="5">免邮券</option> - </select> + <div class="panel-body"> + <div class="row"> + <div class="form-group"> + <label class="col-sm-2 control-label">类型 <span class="red">*</span></label> + + <div class="col-sm-8"> + <select id="filter-couponType" tabindex="-1" class="select2-offscreen brandBtn-group observe" + value="[[couponType]]" data-field="couponType" required> + <option value="-1">优惠券类型</option> + <option value="1">A券</option> + <option value="2">B券</option> + <option value="3">公开券</option> + <option value="4">生日券</option> + <option value="5">免邮券</option> + </select> + </div> + </div> </div> </div> <div class="panel-heading"> <h4 class="panel-title">基本信息</h4> - </div><!-- panel-heading --> + </div> <div class="panel-body"> <div class="row"> <div class="form-group"> <label class="col-sm-2 control-label">名称 <span class="red">*</span></label> + <div class="col-sm-8"> - <input type="text" placeholder="名称建议30字以内" prompt="名称" class="form-control observe" data-field="couponName" required maxlength="30" value="[[couponName]]"> + <input type="text" placeholder="名称建议30字以内" prompt="名称" class="form-control observe" + data-field="couponName" required maxlength="30" value="[[couponName]]"> </div> </div> <div class="form-group"> <label class="col-sm-2 control-label">数量<i class="red">*</i></label> + <div class="col-sm-8"> - <input type="text" placeholder="数量" class="form-control observe number" data-field="couponNum" required value="[[couponNum]]"> + <input type="text" placeholder="数量" class="form-control observe number" data-field="couponNum" + required value="[[couponNum]]"> </div> </div> <div class="form-group"> <label class="col-sm-2 control-label">使用次数<i class="red">*</i></label> + <div class="col-sm-8"> - <input type="text" placeholder="使用次数" class="form-control observe number" data-field="useNum" required value="[[useNum]]"> + <input type="text" placeholder="使用次数" class="form-control observe number" data-field="useNum" + required value="[[useNum]]"> </div> </div> <div class="form-group"> - <label class="col-sm-2 control-label">申请部门</label> + <label class="col-sm-2 control-label">申请部门<i class="red">*</i></label> + <div class="col-sm-8"> - <select id="filter-department" tabindex="-1" class="select2-offscreen brandBtn-group observe" value="[[department]]" data-field="department" required> + <select id="filter-department" tabindex="-1" class="select2-offscreen brandBtn-group observe" + value="[[department]]" data-field="department" required> <option value="-1">申请部门</option> <option value="1">渠道二部</option> <option value="2">渠道一部</option> @@ -92,20 +131,25 @@ <div class="form-group"> <label class="col-sm-2 control-label">使用期限<span class="red">*</span></label> + <div class="col-sm-6"> <div class="col-sm-6"> - <input type="text" class="form-control observe" data-field="startTime" id="startTime" placeholder="开始时间" value="[[startTime]]" readonly required> + <input type="text" class="form-control observe" data-field="startTime" id="startTime" + placeholder="开始时间" value="[[startTime]]" readonly required> </div> <div class="col-sm-6"> - <input type="text" class="form-control observe" data-field="endTime" id="endTime" placeholder="结束时间" value="[[endTime]]" readonly required> + <input type="text" class="form-control observe" data-field="endTime" id="endTime" + placeholder="结束时间" value="[[endTime]]" readonly required> </div> </div> </div> <div class="form-group"> <label class="col-sm-2 control-label">优惠券说明<i class="red">*</i></label> + <div class="col-sm-8"> - <textarea class="form-control observe" prompt="优惠券说明" data-field="explains" maxlength="100" placeholder="优惠券使用条件简介" required>[[explains]]</textarea> + <textarea class="form-control observe" prompt="优惠券说明" data-field="explains" maxlength="100" + placeholder="优惠券使用条件简介" required style="resize: none">[[explains]]</textarea> </div> </div> </div> @@ -114,38 +158,57 @@ <div class="panel-heading"> <h4 class="panel-title">使用条件</h4> </div> + <div class="panel-body"> + <div class="row"> + <div class="form-group"> + <label class="col-sm-2 control-label">优惠条件<i class="red">*</i></label>  + <select value="[[useLimitType]]" id="useLimitType" class="form-control input-form observe" + data-field="useLimitType"> + <option value="0">无限制</option> + <option value="1">件数</option> + <option value="2">金额</option> + </select>   + [[if useLimitType=='2']] + <label class="control-label">金额满</label> + <input value="[[useLimit]]" class="form-control input-form observe" data-field="useLimit"> + [[/if]] + [[if useLimitType=='1']] + <label class="control-label">件数满</label> + <input value="[[useLimit]]" class="form-control input-form observe" data-field="useLimit"> + [[/if]] + </div> - <div class="form-group"> - <label class="col-sm-2 control-label">优惠条件<i class="red">*</i></label>  - <select value="[[basicForm]]" id="useLimitType" class="form-control input-form observe" data-field="useLimitType"> - <option value="0">无限制</option> - <option value="1">件数</option> - <option value="2">金额</option> - </select>   - <label id="useLimitLabel" class="control-label">金额满</label> - <input value="[[useLimit]]" class="form-control input-form observe" data-field="useLimit"> - </div> + <div class="form-group"> + <label class="col-sm-2 control-label">优惠结果<i class="red">*</i></label> - <div class="form-group"> - <label class="col-sm-2 control-label">优惠结果<i class="red">*</i></label> - <div class="col-sm-4"> - <label class="col-sm-2 control-label">面额</label> - <div class="col-sm-8"> - <input type="text" class="form-control observe" data-field="couponAmount" value="[[couponAmount]]"> + <div class="col-sm-4"> + <label class="col-sm-2 control-label">面额</label> + + <div class="col-sm-8"> + <input type="text" class="form-control observe" data-field="couponAmount" + value="[[couponAmount]]"> + </div> + <label class="col-sm-2 control-label">元</label> + </div> </div> - <label class="col-sm-2 control-label">元</label> - </div> - </div> - <div class="form-group"> - <label class="col-sm-2 control-label">适用范围</label> - <div class="col-sm-4"> - <div class="col-sm-10"> - <select value="[[useLimitType]]" id="useRange" class="form-control input-form"> - <option value="0">分类</option> - <option value="1" checked>品牌</option> - </select>   - <a class="btn btn-primary btn-xs" href="javascript:;">添加品牌</a> + <div class="form-group"> + <label class="col-sm-2 control-label">适用范围</label> + + <div class="col-sm-4"> + <div class="col-sm-10"> + <select id="useRange" class="form-control input-form" value="[[useRange]]"> + <option value="0">分类</option> + <option value="1" checked>品牌</option> + </select>   + [[if useRange==0]] + <a class="btn btn-primary btn-xs" href="javascript:;" id="addSorts">添加分类</a> + [[/if]] + [[if useRange==1]] + <a class="btn btn-primary btn-xs" href="javascript:;" id="addBrands">添加品牌</a> + [[/if]] + </div> + </div> </div> </div> </div> @@ -153,50 +216,95 @@ <div class="panel-heading"> <h4 class="panel-title">领券条件</h4> </div> + <div class="panel-body"> + <div class="row"> + <div class="form-group"> + <label class="col-sm-2 control-label">会员身份<i class="red">*</i></label> - <div class="form-group"> - <label class="col-sm-2 control-label">会员身份<i class="red">*</i></label> - <div class="col-sm-10"> - <label class="checkbox-inline"> - <input type="checkbox" value="1" name="customType" > 新客户 (注册未购买) - </label> - <label class="checkbox-inline"> - <input type="checkbox" value="5" name="customType"> 普通会员 (不包含新客户) - </label> - <label class="checkbox-inline"> - <input type="checkbox" value="2" name="customType"> 银卡会员 - </label> - <label class="checkbox-inline"> - <input type="checkbox" value="3" name="customType"> 金卡会员 - </label> - <label class="checkbox-inline"> - <input type="checkbox" value="4" name="customType"> 白金会员 - </label> - </div> + <div class="col-sm-10"> + <label class="checkbox-inline"> + <input type="checkbox" value="1" name="customType"> 新客户 (注册未购买) + </label> + <label class="checkbox-inline"> + <input type="checkbox" value="5" name="customType"> 普通会员 (不包含新客户) + </label> + <label class="checkbox-inline"> + <input type="checkbox" value="2" name="customType"> 银卡会员 + </label> + <label class="checkbox-inline"> + <input type="checkbox" value="3" name="customType"> 金卡会员 + </label> + <label class="checkbox-inline"> + <input type="checkbox" value="4" name="customType"> 白金会员 + </label> + </div> - <input type="hidden" value="[[customType]]" id="customType" for="checkbox" required placeholder="会员身份"> + <input type="hidden" value="[[customType]]" id="customType" for="checkbox" required + placeholder="会员身份"> + </div> + </div> </div> - <div class="panel-heading"> <h4 class="panel-title">优惠互斥</h4> </div> + <div class="panel-body"> + <div class="row"> + <div class="form-group"> + <label class="col-sm-2 control-label">申请人</label> - <div class="form-group"> - <label class="col-sm-2 control-label">申请人</label> - <div class="col-sm-8"> - <label class="form-label control-label" id="creatorName">{{auth.name}}</label> + <div class="col-sm-8"> + <label class="form-label control-label" id="creatorName">{{auth.name}}</label> + </div> + </div> + <input id="auth_id1" type="hidden" value="{{auth.uid}}"> + <input id="auth_name1" type="hidden" value="{{auth.name}}"> </div> </div> - <input id="auth_id" type="hidden" value="{{auth.uid}}"> - <input id="auth_name" type="hidden" value="{{auth.name}}"> <div class="panel-footer"> <div class="row"> <div class="col-sm-8 col-sm-offset-2"> - <a href="javascript:;" onclick="history.go(-1);" class="btn btn-default">取消</a> + <a href="javascript:;" onclick="history.go(-1);" class="btn btn-default">取消</a> <button id="save_brand" type="button" data-loading-text="保存中..." class="btn btn-primary">保存</button> </div> </div> </div> </div> </script> +<script type="text/template" id="editTemp"> + <div class="panel"> + <div class="panel-body nopadding"> + <form id="basicForm1" role="form" action="[[action]]" class="form-horizontal form-bordered"> + <div class="form-group" style="margin-bottom: 40px"> + <label class="col-sm-2 control-label">分类关联:</label> + <div class="col-sm-8 sort-wrap"> + <div class="row"> + <div class="col-sm-10"> + <div class="sortTree"></div> + </div> + <div class="col-sm-2 height40"> + <a class="btn btn-danger btn-xs del-sort-btn" href="javascript:;">-</a> + <a class="btn btn-info btn-xs add-sort-btn" href="javascript:;">+</a> + </div> + </div> + </div> + </div> + <input id="categoryId" type="hidden" value="[[categoryId]]"> + <input id="parentId" type="hidden" value="[[parentId]]"> + <input id="orderBy" type="hidden" value="[[orderBy]]"> + </form> + </div> + </div> +</script> +<script type="text/template" id="sortWrap"> + <div class="row"> + <div class="col-sm-10"> + <div class="sortTree"></div> + </div> + <div class="col-sm-2 height40"> + <a class="btn btn-danger btn-xs del-sort-btn" href="javascript:;">-</a> + <a class="btn btn-info btn-xs add-sort-btn" href="javascript:;">+</a> + </div> + </div> +</script> +