Authored by liuyue

限售商品

... ... @@ -5,37 +5,66 @@
var $ = require('jquery'),
common=require('../common/common');
common = require('../common/common');
var baseNum = 1;
var ENUM={
status:{0:'待审核',1:'审核通过',2:'驳回',3:'过期',4:'作废'},//全部
tips:{"salenum":0,"notsalenum":0,"hotnum":0,"nothotnum":0,"all":0}
var ENUM = {
status: {
0: '待审核',
1: '审核通过',
2: '驳回',
3: '过期',
4: '作废'
}, //全部
tips: {
"salenum": 0,
"notsalenum": 0,
"hotnum": 0,
"nothotnum": 0,
"all": 0
}
}
var t = new common.tab({
el:"#basicTab",
click:function(){
el: "#basicTab",
click: function() {
tableGird.reload();
},
columns:[
{name:"salenum", key: "saleFlag", value: "1", display:"已发售({salenum})"},
{name:"notsalenum", key: "saleFlag", value: "0", display:"未发售({notsalenum})"},
{name:"hotnum", key: "hotFlag", value: "1", display:"热门({hotnum})"},
{name:"nothotnum", key: "hotFlag", value: "0", display:"非热门({nothotnum})"},
{name:"all",display:"全部({all})"}
]
columns: [{
name: "salenum",
key: "saleFlag",
value: "1",
display: "已发售({salenum})"
}, {
name: "notsalenum",
key: "saleFlag",
value: "0",
display: "未发售({notsalenum})"
}, {
name: "hotnum",
key: "hotFlag",
value: "1",
display: "热门({hotnum})"
}, {
name: "nothotnum",
key: "hotFlag",
value: "0",
display: "非热门({nothotnum})"
}, {
name: "all",
display: "全部({all})"
}]
}).init(ENUM.tips);
var tableGird = new common.grid({
el:"#limit-table-box",
parms:function(){
el: "#limit-table-box",
parms: function() {
var obj = {
productName:common.util.__input("product-name"),
productSkn:common.util.__input("skn"),
productName: common.util.__input("product-name"),
productSkn: common.util.__input("skn"),
hotFlag: $('input[name="hotFlag"]:checked').val(),
saleFlag: $('input[name="saleFlag"]:checked').val(),
showFlag: $('input[name="showFlag"]:checked').val()
... ... @@ -43,129 +72,127 @@ var tableGird = new common.grid({
if (t.key) {
obj[t.key] = t.value;
}
return obj;
},
columns:[
{
display: "名称",
name: "productName"
}, {
display: "热门排序",
name: "hotSort",
render: function (item) {
if (item.hotFlag) {
return ('<input class="order-input width50" data-id="' + item.id + '" data-type="orderBy" type="text" value="'+ item.orderBy +'"/>');
} else {
return '-';
}
columns: [{
display: "名称",
name: "productName"
}, {
display: "热门排序",
name: "hotSort",
render: function(item) {
if (item.hotFlag) {
return ('<input class="order-input width50" data-id="' + item.id + '" data-type="orderBy" type="text" value="' + item.orderBy + '"/>');
} else {
return '-';
}
}, {
display: "未发售排序",
name:"notSaleSort",
render: function (item) {
if (item.saleFlag == 1) {
return '-';
} else {
return ('<input class="order-input width50" data-id="' + item.id + '" data-type="notSaleOrderBy" type="text" value="'+ item.notSaleOrderBy +'"/>');
}
}
}, {
display: "未发售排序",
name: "notSaleSort",
render: function(item) {
if (item.saleFlag == 1) {
return '-';
} else {
return ('<input class="order-input width50" data-id="' + item.id + '" data-type="notSaleOrderBy" type="text" value="' + item.notSaleOrderBy + '"/>');
}
}, {
display: "封面图",
render: function(item){
}
}, {
display: "封面图",
render: function(item) {
return ('<img class="cover-img" src="'+item.attachUrl+'" />');
return ('<img class="cover-img" src="' + item.attachUrl + '" />');
}
}, {
display: "SKN",
name: "productSkn"
}, {
display: "发售日期",
name: "saleTime",
render: function(item) {
var date = new Date(item.saleTime * 1000),
showDate = date.getFullYear() + '-' + (date.getMonth() + 1);
if (item.dayFlag == 1) {
showDate += '-' + date.getDate();
}
}, {
display:"SKN",
name:"productSkn"
}, {
display:"发售日期",
name:"saleTime",
render: function(item) {
var date = new Date(item.saleTime * 1000),
showDate = date.getFullYear() + '-' + (date.getMonth() + 1);
if (item.dayFlag == 1) {
showDate += '-' + date.getDate();
}
return showDate;
return showDate;
}
}, {
display: "是否发售",
name: "saleFlag",
render: function(item) {
if (item.saleFlag == 1) {
return '是';
} else {
return '否';
}
}, {
display:"是否发售",
name:"saleFlag",
render:function(item){
if (item.saleFlag == 1) {
return '是';
} else {
return '否';
}
}
}, {
display: "是否热门",
name: "hotFlag",
render: function(items) {
if (items.hotFlag) {
return '是';
} else {
return '否';
}
}, {
display:"是否热门",
name:"hotFlag",
render:function(items){
if (items.hotFlag) {
return '是';
} else {
return '否';
}
}
}, {
display: "是否开启",
name: "showFlag",
render: function(items) {
if (items.showFlag) {
return '是';
} else {
return '否';
}
}, {
display:"是否开启",
name:"showFlag",
render:function(items){
if (items.showFlag) {
return '是';
} else {
return '否';
}
}
}, {
display: "操作",
render: function(items) {
var HtmArr = [];
if (items.showFlag) {
HtmArr.push('<a href="javascript:;" data-id="' + items.id + '" class="btn btn-info btn-xs close-btn">关闭</a>');
} else {
HtmArr.push('<a href="javascript:;" data-id="' + items.id + '" class="btn btn-info btn-xs open-btn">开启</a>');
}
}, {
display:"操作",
render:function(items){
var HtmArr=[];
if (items.showFlag) {
HtmArr.push('<a href="javascript:;" data-id="' + items.id + '" class="btn btn-info btn-xs close-btn">关闭</a>');
} else {
HtmArr.push('<a href="javascript:;" data-id="' + items.id + '" class="btn btn-info btn-xs open-btn">开启</a>');
}
if (items.hotFlag) {
HtmArr.push('<a href="javascript:;" data-id="' + items.id + '" class="btn btn-warning btn-xs hot-cancel">取消热门</a>');
} else {
HtmArr.push('<a href="javascript:;" data-id="' + items.id + '" class="btn btn-warning btn-xs hot-btn">设为热门</a>');
}
HtmArr.push('<a href="/limit/edit/' + items.id + '" data-id="' + items.id + '" class="btn btn-info btn-xs">编辑</a>');
HtmArr.push('<a href="javascript:;" data-id="' + items.id + '" class="btn btn-danger btn-xs delete-btn">删除</a>');
return HtmArr.join('');
if (items.hotFlag) {
HtmArr.push('<a href="javascript:;" data-id="' + items.id + '" class="btn btn-warning btn-xs hot-cancel">取消热门</a>');
} else {
HtmArr.push('<a href="javascript:;" data-id="' + items.id + '" class="btn btn-warning btn-xs hot-btn">设为热门</a>');
}
HtmArr.push('<a href="/limit/edit/' + items.id + '" data-id="' + items.id + '" class="btn btn-info btn-xs">编辑</a>');
HtmArr.push('<a href="javascript:;" data-id="' + items.id + '" class="btn btn-danger btn-xs delete-btn">删除</a>');
return HtmArr.join('');
}
]
}]
});
tableGird.init('/limit/product/page');
var loadtab=function(){
t.active=undefined;
setTimeout(function(){
var loadtab = function() {
t.active = undefined;
setTimeout(function() {
common.util.__ajax({
url:'/limit/ajax/getCodeCount',
data:tableGird.options.parms()
url: '/limit/ajax/getCodeCount',
data: tableGird.options.parms()
},function(res){
for(var key in res.data){
ENUM.tips[key]=res.data[key];
}, function(res) {
for (var key in res.data) {
ENUM.tips[key] = res.data[key];
}
t.init(ENUM.tips);
},true);
},400);
}, true);
}, 400);
}
loadtab();
$("#filter-btn").click(function(){
$("#filter-btn").click(function() {
loadtab();
tableGird.reload();
});
... ... @@ -176,12 +203,12 @@ $('#limit-table-box').on('click', '.open-btn', function() {
var param = {
id: $(this).data('id'),
showFlag: '1'
}
}
common.util.__ajax({
url:'/limit/audit',
data:param
url: '/limit/audit',
data: param
},function(res){
}, function(res) {
tableGird.reload();
});
});
... ... @@ -191,12 +218,12 @@ $('#limit-table-box').on('click', '.close-btn', function() {
var param = {
id: $(this).data('id'),
showFlag: '0'
}
}
common.util.__ajax({
url:'/limit/audit',
data:param
url: '/limit/audit',
data: param
},function(res){
}, function(res) {
tableGird.reload();
});
});
... ... @@ -206,12 +233,12 @@ $('#limit-table-box').on('click', '.hot-btn', function() {
var param = {
id: $(this).data('id'),
hotFlag: 1
}
}
common.util.__ajax({
url:'/limit/audit',
data:param
url: '/limit/audit',
data: param
},function(res){
}, function(res) {
tableGird.reload();
});
});
... ... @@ -221,12 +248,12 @@ $('#limit-table-box').on('click', '.hot-cancel', function() {
var param = {
id: $(this).data('id'),
hotFlag: 0
}
}
common.util.__ajax({
url:'/limit/audit',
data:param
url: '/limit/audit',
data: param
},function(res){
}, function(res) {
tableGird.reload();
});
});
... ... @@ -234,21 +261,21 @@ $('#limit-table-box').on('click', '.hot-cancel', function() {
//删除商品
$('#limit-table-box').on('click', '.delete-btn', function() {
var param = {
id: $(this).data('id')
}
/*common.util.__ajax({
url:'/limit/delete',
data:param
id: $(this).data('id')
}
/*common.util.__ajax({
url:'/limit/delete',
data:param
},function(res){
tableGird.reload();
});*/
},function(res){
tableGird.reload();
});*/
common.dialog.confirm("温馨提示","你确定要删除吗?",function(){
common.dialog.confirm("温馨提示", "你确定要删除吗?", function() {
common.util.__ajax({
url:'/limit/delete',
url: '/limit/delete',
data: param
}, function(){
}, function() {
tableGird.reload();
});
});
... ... @@ -262,14 +289,20 @@ $('#limit-table-box').on('change', '.order-input', function() {
id: goodsId
};
param[type] = $(this).val();
if ($(this).val() < 0) {
common.util.__tip('排序不能为负', 'warning');
return;
} else {
param[type] = $(this).val();
}
common.util.__ajax({
url:'/limit/audit',
url: '/limit/audit',
data: param
},function(res){
}, function(res) {
console.log(res);
});
});
}).on('keyup', '.order-input', function() {
$(this).val() = $(this).val().replace(/\D/gi, '')
});
\ No newline at end of file
... ...
... ... @@ -44,7 +44,7 @@
<div class="row">
{{# skn}}
<div class="panel-col2">
<input id="skn" class="form-control panel-input height40" type="text" placeholder="请输入SKN">
<input id="skn" class="form-control panel-input height40" type="text" placeholder="请输入SKN" onkeyup="this.value=this.value.replace(/\D/gi,'')">
</div>
{{/ skn}}
... ...