|
|
var $ = require('jquery'),
|
|
|
common = require('../../../../common/common');
|
|
|
var promotionInfoRefresh=require('./promotionInfoRefresh');
|
|
|
console.log("multiPromotions in");
|
|
|
var multiPromotions={
|
|
|
tabLoader:null,
|
|
|
columnName:null,
|
|
|
batchIds:[],
|
|
|
pageIds :[],
|
|
|
buildCheckboxHtml:function(_class,_data_index,_checked){
|
|
|
var _checkBox="<input type='checkbox'";
|
|
|
var _end="/>";
|
|
|
if(_class){
|
|
|
_checkBox+=" class='"+_class+"'";
|
|
|
}
|
|
|
if(_data_index>=0){
|
|
|
_checkBox+=" data-index='"+_data_index+"'";
|
|
|
}
|
|
|
if(_checked){
|
|
|
|
|
|
console.log("_checkBox",_checkBox);
|
|
|
_checkBox+=" checked='"+_checked+"'";
|
|
|
}
|
|
|
_checkBox+=_end;
|
|
|
return _checkBox;
|
|
|
},
|
|
|
getParam:function(_config){
|
|
|
var g=this;
|
|
|
/*
|
|
|
var _buildCheckboxHtml = function (_class,_data_index,_checked) {
|
|
|
return this.buildCheckboxHtml(_class,_data_index,_checked);
|
|
|
};*/
|
|
|
var param={
|
|
|
el: '#basicTable_promotion',
|
|
|
size: 20,
|
|
|
parms: function(){ return _config.parmsData},
|
|
|
columns: [
|
|
|
{
|
|
|
display: '',
|
|
|
type: 'checkbox',
|
|
|
render: function (item) {
|
|
|
var htmlContent = "";
|
|
|
var _class="wqt_checkbox";
|
|
|
if(g.batchIds.length === 0 ){
|
|
|
|
|
|
htmlContent = g.buildCheckboxHtml(_class,item.__index);
|
|
|
}else{
|
|
|
$.each(g.batchIds,function(n,value) {
|
|
|
if(item.id == value){
|
|
|
htmlContent = g.buildCheckboxHtml(_class,item.__index,"checked");
|
|
|
return false
|
|
|
}else{
|
|
|
htmlContent = "<input type='checkbox' class='wqt_checkbox' data-index='"+item.__index+"'>";
|
|
|
htmlContent = g.buildCheckboxHtml(_class,item.__index);
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
return htmlContent;
|
|
|
}
|
|
|
},{
|
|
|
display: "ID",
|
|
|
name: "id",
|
|
|
render: function (item) {
|
|
|
g.pageIds.push(item.id);
|
|
|
return item.id;
|
|
|
}
|
|
|
}, {
|
|
|
display: "促销名称",
|
|
|
name: "title"
|
|
|
}, {
|
|
|
display: '优先级',
|
|
|
name: "priority"
|
|
|
}, {
|
|
|
display: '开始时间',
|
|
|
name: "startTime",
|
|
|
render: function(item) {
|
|
|
var date = new Date(item.startTime * 1000);
|
|
|
return date.getFullYear() + '-' + (date.getMonth() + 1) + '-' + date.getDate() + ' ' + date.getHours() + ':' + date.getMinutes() + ':' + date.getSeconds();
|
|
|
}
|
|
|
}, {
|
|
|
display: '结束时间',
|
|
|
name: "endTime",
|
|
|
render: function(item) {
|
|
|
var date = new Date(item.endTime * 1000);
|
|
|
return date.getFullYear() + '-' + (date.getMonth() + 1) + '-' + date.getDate() + ' ' + date.getHours() + ':' + date.getMinutes() + ':' + date.getSeconds();
|
|
|
}
|
|
|
}, {
|
|
|
display: '是否启用',
|
|
|
name: "status",
|
|
|
render: function(item) {
|
|
|
if(item.status==1){
|
|
|
var name ="已启用" ;
|
|
|
}else {
|
|
|
var name ="未启用" ;
|
|
|
}
|
|
|
return name;
|
|
|
}
|
|
|
}],
|
|
|
selectedCallback:function(item){
|
|
|
if($.inArray(item.id, g.batchIds) == -1 ){
|
|
|
g.batchIds.push(item.id);
|
|
|
}
|
|
|
console.log("batchIds",g.batchIds);
|
|
|
},
|
|
|
unselectedCallback:function(item){
|
|
|
var _index = $.inArray(item.id, g.batchIds);
|
|
|
if(_index != -1 ){
|
|
|
g.batchIds.splice(_index,1);
|
|
|
}
|
|
|
console.log("batchIds",g.batchIds);
|
|
|
},
|
|
|
complete:function(){
|
|
|
//渲染表头是否勾选
|
|
|
$.each(g.pageIds, function (i, pageItem) {
|
|
|
if($.inArray(pageItem, g.batchIds) == -1 ) {
|
|
|
$(".wqt_all").prop("checked", false);
|
|
|
return false;
|
|
|
}
|
|
|
$(".wqt_all").prop("checked", true);
|
|
|
});
|
|
|
g.pageIds = [];
|
|
|
}
|
|
|
};
|
|
|
return param;
|
|
|
},
|
|
|
bindGrid: function(param){
|
|
|
return new common.grid(param);
|
|
|
},
|
|
|
promotionId:null,
|
|
|
grid: null,
|
|
|
actionUrl:"/promotion/setMulti",
|
|
|
init: function(_config){
|
|
|
this.batchIds=_config.multi || [];
|
|
|
var parmsData={
|
|
|
id: _config.promotionId
|
|
|
};
|
|
|
var g=this,
|
|
|
_param=this.getParam({parmsData : parmsData});
|
|
|
this.promotionId=_config.promotionId;
|
|
|
if(!g.tabLoader){
|
|
|
g.tabLoader=_config.tabLoader;
|
|
|
}
|
|
|
if(!g.columnName){
|
|
|
g.columnName=_config.columnName;
|
|
|
}
|
|
|
if(!this.grid || this.grid===null){
|
|
|
this.grid=g.bindGrid(_param);
|
|
|
}
|
|
|
|
|
|
this.grid.init("/promotion/getMultiPromotionPage");
|
|
|
this.bindEvent();
|
|
|
},
|
|
|
reload:function(){
|
|
|
var g=this,
|
|
|
_grid=this.grid;
|
|
|
_grid.reload(1);
|
|
|
},
|
|
|
bindEvent: function() {
|
|
|
var _g = this;
|
|
|
$('#save_multi').off();
|
|
|
$('#save_multi').on('click',function(){return _g.save()});
|
|
|
},
|
|
|
save:function(){
|
|
|
var _g=this;
|
|
|
var multiParam="";
|
|
|
if(_g.batchIds && _g.batchIds.length>0){
|
|
|
multiParam +="[";
|
|
|
multiParam +=_g.batchIds.join(",");
|
|
|
multiParam +="]";
|
|
|
}else{
|
|
|
common.util.__tip("没有选择任何促销", "warning");
|
|
|
return;
|
|
|
}
|
|
|
var reqData={
|
|
|
promotionId:_g.promotionId,
|
|
|
multiParam: multiParam
|
|
|
};
|
|
|
var _options={
|
|
|
url: _g.actionUrl,
|
|
|
data:reqData
|
|
|
};
|
|
|
common.util.__ajax2(_options,function (res) {
|
|
|
if (res.code == "200") {
|
|
|
common.util.__tip("提交成功", "success");
|
|
|
//location.href = "/promotionInfo/edit/"+_g.promotionId||"";
|
|
|
promotionInfoRefresh.refresh({
|
|
|
tabLoader:_g.tabLoader,
|
|
|
columnName:_g.columnName,
|
|
|
promotionId:_g.promotionId
|
|
|
});
|
|
|
} else {
|
|
|
common.util.__tip(res.message, "warning");
|
|
|
}
|
|
|
return false;
|
|
|
},
|
|
|
function (res) {
|
|
|
common.util.__tip(res.message, "warning");
|
|
|
return false;
|
|
|
});
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
module.exports = multiPromotions; |
|
|
\ No newline at end of file |
...
|
...
|
|