Authored by weiqingting

优惠码

... ... @@ -3,7 +3,16 @@ var edit=require('../common/edit');
exports.init = function() {
var e=new edit("#basicForm");
//brandTonality
e.on("validate",function(){
var num=$("#brandTonality").val();
if(!!num){
if(!(/^\d[0-100]$/g.test(num))){
return "调性指数(范围:1-100)";
}
}
return true;
});
e.init();
$("#save_brand").click(function(){
e.submit($("#basicForm").attr("action"),function(option){
... ...
... ... @@ -44,7 +44,7 @@ exports.init = function() {
},
columns: [
{display: "LOGO", name: "brandIco",render:function(item){
return '<img src="'+item.brandIco+'"/>'
return '<img src="'+item.brandIco+'" width="100" height="60"/>'
}},
{display: '品牌名称', name: "brandName"},
{display: '英文名称', name: "brandNameEn"},
... ... @@ -76,15 +76,10 @@ exports.init = function() {
$("#filter-btn").click(function(){
location.hash = '';
g.reload({
page: 1
});
});
/*$(window).on('hashchange', function() {
g.reload();
});
*/
function operateAjax(options, callback) {
$.ajax({
type: 'POST',
... ...
... ... @@ -5,87 +5,16 @@ var grid=require('./grid'),
edit = require('./edit'),
dropDown = require('./dropDown'),
dialog=require('./dialog');
tab=require('./tab'),
util=require('./util');
var common={
grid:grid,
dialog:dialog,
tab:tab,
dropDown:dropDown,
edit:edit,
util:{
__ajax:function(options,callback){
if(typeof options.data=="string"){
common.util.__tip(options.data,"danger");
}else{
$.ajax({
type: 'POST',
url: options.url,
dataType: 'json',
data:options.data||{},
success: function(res) {
res=res.data;
if (("" + res.code) === "200") {
common.util.__tip(res.message,"success",callback.bind(this,res));
} else {
common.util.__tip(res.message,"danger");
}
}
});
}
},
__tip:function(message,callback){
//danger
var options={};
if (arguments.length > 1) {
options.title=arguments[0];
if (typeof (arguments[1]) === "string") {
options.class_name="growl-"+arguments[1];
}else{
options.class_name="growl-success";
}
var lastargs = Array.prototype.slice.call(arguments, arguments.length-1);
lastargs=lastargs[0];
if(typeof lastargs==="function"){
options.after_open=setTimeout(function() {
lastargs&&lastargs();
},100)
}
} else {
console.log("__tip error");
return false;
};
options.sticky=false;
options.time=1000;
$.gritter.add(options);
},
__template: function () {
var args = arguments, result;
if (args.length > 0) {
if (typeof args[0]==="string") {
result = args[0];
if (args.length == 2 && typeof args[1]=="object") {
for (var key in args[1]) {
if (args[1][key] != undefined) {
var reg = new RegExp("({" + key + "})", "g");
result = result.replace(reg, args[1][key]);
}
}
} else {
for (var i = 1; i < args.length; i++) {
if (args[i] != undefined) {
var reg = new RegExp("({[" + (i - 1) + "]})", "g");
result = result.replace(reg, args[i]);
}
}
}
}
}
return result;
},
__input:function(id){
return !!~$.trim($('#'+id).val())?$('#'+id).val():""
}
}
util:util
}
module.exports=common;
\ No newline at end of file
... ...
... ... @@ -191,11 +191,12 @@ edit.prototype={
$("input:text",that.el)
.add("input[type=number]",that.el)
.add("input[type=file]",that.el)
.add("input:hidden",that.el)
.add("textarea",that.el)
.each(function() {
var id = $(this).attr("id");
var value = $(this).val();
var value =$.trim($(this).val());
var name=$(this).attr("placeholder")&&!(/^\d+$/.test($(this).attr("placeholder")))?$(this).attr("placeholder").replace(/请填写/g,''):$(this).parents(".form-group").find("label").text().replace(/\*/g,'');
var rule = [];
... ... @@ -260,7 +261,7 @@ edit.prototype={
.add("textarea",that.el)
.each(function(){
var name=$(this).attr("id");
var value=$(this).val();
var value=$.trim($(this).val());
data[name]=value;
});
$("input[type=file]",that.el).each(function(){
... ...
... ... @@ -51,44 +51,7 @@ grid.prototype={
g.clear();
g.renderHead();
g.renderBody();
g.renderTab();
},
renderTab: function() {
var g = this,
p = this.options,
$tab = $('<ul class="nav nav-pills"></ul>');
if (!p.tabUrl) return;
$('#table-tabs').empty().append($tab);
setTimeout(function() {
$.ajax({
type: 'POST',
dataType: 'json',
url: '/getCodeCount',
data: g.__getparams()
}).then(function(res) {
var data = res.data.data,
_s = g.__getparams().status;
$tab.empty();
$.each(data, function(key, value) {
$tab.append($('<li data-status="' + key + '"><a href="javascript:;">' + p.tabConvert(key) + '(' + value + ')</a></li>'));
});
if ($('#table-tabs').find('[data-status="' + _s + '"]').size() < 1) {
$('#table-tabs').find('[data-status="all"]').addClass('active').siblings().removeClass('active');
} else {
$('#table-tabs').find('[data-status="' + _s + '"]').addClass('active').siblings().removeClass('active');
}
});
}, 500);
$('#table-tabs').on('click', 'li', function() {
$(this).addClass('active').siblings().removeClass('active');
p.status = parseInt($(this).data('status'));
p.page = 1;
g.renderBody();
});
// g.renderTab();
},
renderBody:function(){
var g = this, p = this.options;
... ... @@ -138,12 +101,6 @@ grid.prototype={
param.page = urlParam.page;
}
if (param.status !== p.status) {
param.status = p.status;
} else {
param.status = urlParam.status;
}
param.size = p.size;
var urlHash = '';
... ... @@ -291,7 +248,7 @@ grid.prototype={
reload:function(param){
var g = this, p = this.options;
p.page=1;
g.renderTab();
// g.renderTab();
g.__bodyload();
},
... ...
var $=require('jquery'),
util=require('./util');
var tab=function(options) {
var defaults={
innerHtml:'<ul class="nav nav-pills"></ul>'
};
this.options=$.extend({}, defaults, options);
$(options.el).html(this.options.innerHtml);
this.tab=$("ul",options.el);
this.active=undefined;//undefined==void(0)
return this;
}
tab.prototype={
constructor:tab,
init:function(data){
var g = this, p = this.options;
$(this.tab).html("");
this.render(data);
this.bind(p.click);
return this;
},
bind:function(callback){
var g = this, p = this.options;
$(p.el).on("click","li",function(){
$(this).addClass('active').siblings().removeClass('active');
g.active=$(this).find("a").attr("columnname");
callback&&callback();
});
},
render:function(data){
var g = this, p = this.options;
var lis=[];
$(p.columns).each(function (i, column) {
var li = $("<li></li>");
var a=$("<a href='javascript:void(0);'></a>");
if (column.name) a.attr({ columnname: column.name });
var h_t = column.display || "";
a.html(h_t);
li.append(a);
g.tab.append(li);
});
g.tab.html(util.__template(g.tab.html(),data||{}));
}
}
module.exports=tab;
\ No newline at end of file
... ...
var $=require('jquery');
var util={
__ajax:function(options,callback,notip){
if(typeof options.data=="string"){
util.__tip(options.data,"danger");
}else{
$.ajax({
type: 'POST',
url: options.url,
dataType: 'json',
data:options.data||{},
success: function(res) {
res=res.data;
if (("" + res.code) === "200") {
notip?callback.bind(this,res)():util.__tip(res.message,"success",callback.bind(this,res));
} else {
util.__tip(res.message,"danger");
}
}
});
}
},
__tip:function(message,callback){
//danger
var options={};
if (arguments.length > 1) {
options.title=arguments[0];
if (typeof (arguments[1]) === "string") {
options.class_name="growl-"+arguments[1];
}else{
options.class_name="growl-success";
}
var lastargs = Array.prototype.slice.call(arguments, arguments.length-1);
lastargs=lastargs[0];
if(typeof lastargs==="function"){
options.after_open=setTimeout(function() {
lastargs&&lastargs();
},100)
}
} else {
console.log("__tip error");
return false;
};
options.sticky=false;
options.time=1000;
$.gritter.add(options);
},
__template: function () {
var args = arguments, result;
if (args.length > 0) {
if (typeof args[0]==="string") {
result = args[0];
if (args.length == 2 && typeof args[1]=="object") {
for (var key in args[1]) {
if (args[1][key] != undefined) {
var regkey=((+key)==(+key))?"["+key+"]":key;
var reg = new RegExp("({" + regkey + "})", "g");
result = result.replace(reg, args[1][key]);
}
}
} else {
for (var i = 1; i < args.length; i++) {
if (args[i] != undefined) {
var reg = new RegExp("({[" + (i - 1) + "]})", "g");
result = result.replace(reg, args[i]);
}
}
}
}
}
return result;
},
__input:function(id){
return !!~$.trim($('#'+id).val())?$('#'+id).val():""
}
}
module.exports=util;
\ No newline at end of file
... ...
... ... @@ -114,7 +114,7 @@ exports.init = function() {
return result;
}
}
result=badcode.join(",")+"重复";
result=""+badcode.join(",")+"重复";
}, function() {
result="检查优惠码,网络发生异常";
});
... ...
... ... @@ -13,18 +13,33 @@ exports.init = function() {
//下拉框
new common.dropDown({el: '#filter-dep'});
var t = new common.tab({
el:"#basicTab",
click:function(){
g.reload();
},
columns:[
{name:"0",display:"待审核({0})"},
{name:"1",display:"审核通过({1})"},
{name:"2",display:"驳回({2})"},
{name:"3",display:"过期({3})"},
{name:"4",display:"作废({4})"},
{name:"all",display:"全部({all})"}
]}).init({"0":0,"1":0,"2":0,"3":0,"4":0,"all":0});
//grid
var g = new common.grid({
el: '#basicTable',
// tabUrl: $('#tabUrl').val(),
// tabConvert: statusConvert,
// size: 10,
parms:function(){
return {
batchNo: common.util.__input("filter-id"),
name: common.util.__input("filter-name"),
reqDepartment:common.util.__input("filter-dep")
reqDepartment:common.util.__input("filter-dep"),
status:t.active
};
},
columns:[
... ... @@ -64,15 +79,35 @@ exports.init = function() {
}}
]
})
g.init($("#gridurl").val());
//tab
var loadtab=function(){
setTimeout(function(){
common.util.__ajax({
url:'/coupon/ajax/getCodeCount',
data:g.options.parms()
},function(res){
t.init(res.data);
},true);
},400);
}
g.init($("#gridurl").val());
loadtab();
$("#filter-btn").click(function(){
g.reload();
loadtab();
});
$("#all-btn").click(function(){
$("#filter-id").add("#filter-name").val('');
$('#filter-dep').val("-1").trigger("change");
g.reload();
loadtab();
});
var Bll={
... ...
... ... @@ -32,34 +32,13 @@ exports.res = [
url: '/erpproduct/brands/index',
isJsonRaw: true,
params: [
{
name: 'brandId',
type: 'Number'
},
{
name: 'status',
type: 'Number'
},
{
name: 'brandLevel',
type: 'string'
},
{
name: 'startTime',
type: 'string'
},
{
name: 'endTime',
type: 'string'
},
{
name: 'page',
type: 'string'
},
{
name: 'size',
type: 'Number'
}
{name: 'brandId',type: 'Number'},
{name: 'status', type: 'Number'},
{name: 'brandLevel',type: 'string'},
{name: 'startTime',type: 'string'},
{name: 'endTime',type: 'string'},
{name: 'page',type: 'Number'},
{name: 'size',type: 'Number'}
]
}, {
//品牌管理 -> 编辑/关闭/开启品牌ajax
... ... @@ -68,78 +47,24 @@ exports.res = [
url: '/erpproduct/brands/editBrand',
isJsonRaw: true,
params: [
{
name: 'id',
type: 'Number'
},
{
name: 'status',
type: 'Number'
},
{
name: 'brandName',
type: 'string'
},
{
name: 'brandNameEn',
type: 'string'
},
{
name: 'brandDomain',
type: 'string'
},
{
name: 'brandIco',
type: 'string'
},
{
name: 'brandLevel',
type: 'string'
},
{
name: 'promotionLevel',
type: 'Number'
},
{
name: 'mainCategory',
type: 'Number'
},
{
name: 'brandHeadstream',
type: 'Number'
},
{
name: 'brandTypes',
type: 'Number'
},
{
name: 'brandUrl',
type: 'string'
},
{
name: 'brandIntro',
type: 'string'
},
{
name: 'brandOutline',
type: 'string'
},
{
name: 'brandFounder',
type: 'string'
},
{
name: 'brandStyle',
type: 'string'
},
{
name: 'brandNature',
type: 'Number'
},
{
name: 'brandTonality',
type: 'string'
}
{name: 'id',type: 'Number'},
{name: 'status',type: 'Number'},
{name: 'brandName',type: 'string'},
{name: 'brandNameEn',type: 'string'},
{name: 'brandDomain',type: 'string'},
{name: 'brandIco',type: 'string'},
{name: 'brandLevel',type: 'string'},
{name: 'promotionLevel',type: 'Number'},
{name: 'mainCategory',type: 'Number'},
{name: 'brandHeadstream',type: 'Number'},
{name: 'brandTypes',type: 'Number'},
{name: 'brandUrl',type: 'string'},
{name: 'brandIntro',type: 'string'},
{name: 'brandOutline',type: 'string'},
{name: 'brandFounder',type: 'string'},
{name: 'brandStyle',type: 'string'},
{name: 'brandNature',type: 'Number'},
{name: 'brandTonality',type: 'string'}
]
}, {
route: '/erpproduct/brands/edit/:brandId',
... ... @@ -164,79 +89,31 @@ exports.res = [
src:'/brand/edit',
noApi:true,
data:{
action:'/erpproduct/brand/add',
action:'/erpproduct/ajax/brands/add',
data:{}
}
}, {
route: '/erpproduct/brand/add',
route: '/erpproduct/ajax/brands/add',
method: 'POST',
url: '/erpproduct/brands/addBrand',
isJsonRaw: true,
params:[
{
name: 'brandName',
type: 'string'
},
{
name: 'brandNameEn',
type: 'string'
},
{
name: 'brandDomain',
type: 'string'
},
{
name: 'brandIco',
type: 'string'
},
{
name: 'brandLevel',
type: 'string'
},
{
name: 'promotionLevel',
type: 'Number'
},
{
name: 'mainCategory',
type: 'Number'
},
{
name: 'brandHeadstream',
type: 'Number'
},
{
name: 'brandTypes',
type: 'Number'
},
{
name: 'brandUrl',
type: 'string'
},
{
name: 'brandIntro',
type: 'string'
},
{
name: 'brandOutline',
type: 'string'
},
{
name: 'brandFounder',
type: 'string'
},
{
name: 'brandStyle',
type: 'string'
},
{
name: 'brandNature',
type: 'Number'
},
{
name: 'brandTonality',
type: 'string'
}
{name: 'brandName',type: 'string'},
{name: 'brandNameEn',type: 'string'},
{name: 'brandDomain',type: 'string'},
{name: 'brandIco',type: 'string'},
{name: 'brandLevel',type: 'string'},
{name: 'promotionLevel',type: 'Number'},
{name: 'mainCategory',type: 'Number'},
{name: 'brandHeadstream',type: 'Number'},
{name: 'brandTypes',type: 'Number'},
{name: 'brandUrl',type: 'string'},
{name: 'brandIntro',type: 'string'},
{name: 'brandOutline',type: 'string'},
{name: 'brandFounder',type: 'string'},
{name: 'brandStyle',type: 'string'},
{name: 'brandNature',type: 'Number'},
{name: 'brandTonality',type: 'string'}
]
}
]
\ No newline at end of file
... ...
... ... @@ -12,7 +12,7 @@ exports.res = [
data: {
pageTitle: '优惠码列表',
createUrl: '/coupon/add',
gridurl:'/coupon/getPromotion',
gridurl:'/coupon/ajax/getPromotion',
// tabUrl: '/getCodeCount',
// sendUrl: '/sendPromotion',
// auditUrl: '/auditPromotion'
... ... @@ -30,7 +30,7 @@ exports.res = [
}]
},
{
route: '/coupon/getPromotion',
route: '/coupon/ajax/getPromotion',
method: 'POST',
url: '/promotioncode/getPromotionCodeList',
isJsonRaw: true,
... ... @@ -81,7 +81,7 @@ exports.res = [
]
},
{
route: '/getCodeCount',
route: '/coupon/ajax/getCodeCount',
method: 'POST',
url: '/promotioncode/getPromotionCodeCountByStatus',
isJsonRaw: true,
... ...
... ... @@ -35,7 +35,7 @@
<div class="form-group">
<label class="col-sm-2 control-label">品牌logo <span class="red">*</span></label>
<div class="col-sm-8">
<input type="file" id="brandIco" name="brandIco" value="{{brandIco}}" />
<input type="file" id="brandIco" name="brandIco" value="{{brandIco}}" required placeholder="品牌logo" />
</div>
</div>
<div class="form-group">
... ... @@ -102,7 +102,7 @@
<label class="radio-inline">
<input type="radio" name="brandHeadstream" value="8" />美国 </label>
</div>
<input type="hidden" id="brandHeadstream" value="{{brandHeadstream}}" for="radio">
<input type="hidden" id="brandHeadstream" value="{{brandHeadstream}}" required for="radio">
</div>
<div class="form-group">
... ...
... ... @@ -51,14 +51,9 @@
</div>
</div>
<div class="panel panel-primary-head">
<div id="basicTable_wrapper" class="dataTables_wrapper no-footer">
<div id="table-tabs" class="list-tabs">
</div>
<div class="dataTables_length" id="basicTable">
</div>
<nav>
<ul id="pagination" class="pagination pagination-lg" data-page="{{pagination}}"></ul>
</nav>
<div class="dataTab_wrapper" id="basicTab">
</div>
<div class="basicTable_wrapper" id="basicTable">
</div>
</div>
</div>
... ...
... ... @@ -30,7 +30,7 @@
<form id="new-class-form" class="form-horizontal form-bordered" method="post" action="/product/sort/addProductSort">
<div class="form-group">
<label class="col-md-1 control-label">
物理类目<i>*</i>
物理类目<span class="red">*</span>
</label>
<div class="col-md-5">
... ... @@ -40,7 +40,7 @@
<div class="form-group">
<label class="col-md-1 control-label">
品类缩写<i>*</i>
品类缩写<span class="red">*</span>
</label>
<div class="col-md-5">
... ... @@ -85,7 +85,9 @@
</div>-->
<div class="form-group">
<label class="col-md-1 control-label">排序</label>
<label class="col-md-1 control-label">排序
<span class="red">*</span>
</label>
<div class="col-md-5">
<input id="orderBy" class="form-control" required value="{{data.orderBy}}" type="text" placeholder="">
... ...
... ... @@ -67,7 +67,8 @@
</div>
</div>
<div class="panel panel-primary-head">
<div class="dataTables_wrapper no-footer" id="basicTable">
<div class="dataTables_wrapper" id="basicTable">
</div>
</div>
</div>
... ...