/**
|
* 管理初始化
|
*/
|
var UserActivity = {
|
id: "UserActivityTable", //表格id
|
seItem: null, //选中的条目
|
table: null,
|
layerIndex: -1
|
};
|
|
var language =$("#language").val()
|
/**
|
* 初始化表格的列
|
*/
|
UserActivity.initColumn = function () {
|
return [
|
{field: 'selectItem', radio: true},
|
{title: '序号', field: 'id', visible: true, align: 'center', valign: 'middle'},
|
{title: language==1?'添加时间':(language==2?'Add Time':'Tambahkan waktu'), field: 'insertTime', visible: true, align: 'center', valign: 'middle',formatter:function (data) {
|
return currentTime(data);
|
}},
|
{title: language==1?'活动名称':(language==2?'Activity name':'Nama aktivitas'), field: 'name', visible: true, align: 'center', valign: 'middle'},
|
{title: language==1?'开始时间':(language==2?'Start time':'Waktu awal'), field: 'startTime', visible: true, align: 'center', valign: 'middle',formatter:function (data) {
|
return currentTime(data);
|
}},
|
{title: language==1?'结束时间':(language==2?'End time':'Waktu akhir'), field: 'endTime', visible: true, align: 'center', valign: 'middle',formatter:function (data) {
|
return currentTime(data);
|
}},
|
{title:language==1?'领取人次':(language==2?'Number of pickups':'Jumlah penjemputan') , field: 'number', visible: true, align: 'center', valign: 'middle'},
|
{title:language == 1 ? '备注' : ( language == 2 ? 'remark' : 'Catatan'), field: 'remark', visible: true, align: 'center', valign: 'middle'},
|
{title:language==1?'状态':(language==2?'State':'Status'), field: 'status', visible: true, align: 'center', valign: 'middle',
|
formatter: function (value, row) {
|
if(language==1){
|
if(value==1){
|
return "待审核";
|
}else if(value==2){
|
return "已驳回";
|
}else if(value==3){
|
if(new Date()<new Date(row.startTime)){
|
return "未开始";
|
}else if(new Date()>new Date(row.endTime)){
|
return "已结束";
|
}else{
|
return "进行中";
|
}
|
}else if(value==4){
|
return "已暂停";
|
}
|
}else if(language==2){
|
if(value==1){
|
return "Pending review";
|
}else if(value==2){
|
return "Has been rejected";
|
}else if(value==3){
|
if(new Date()<new Date(row.startTime)){
|
return "Not started";
|
}else if(new Date()>new Date(row.endTime)){
|
return "Has ended";
|
}else{
|
return "On going";
|
}
|
}else if(value==4){
|
return "Has been paused";
|
}
|
}else {
|
if(value==1){
|
return "Tinjauan tertunda";
|
}else if(value==2){
|
return "Telah ditolak";
|
}else if(value==3){
|
if(new Date()<new Date(row.startTime)){
|
return "Belum mulai";
|
}else if(new Date()>new Date(row.endTime)){
|
return "Telah berakhir";
|
}else{
|
return "Sedang berlangsung";
|
}
|
}else if(value==4){
|
return "Telah dijeda";
|
}
|
}
|
|
}
|
}
|
];
|
};
|
function currentTime(timestamp){
|
var time = timestamp + '';
|
if(time.length != 13){
|
timestamp = timestamp * 1000;
|
}
|
var date = new Date(timestamp);;
|
var Y = date.getFullYear() + '-';
|
var M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
|
var D = (date.getDate() < 10 ? '0' + (date.getDate()) : date.getDate()) + ' ';
|
|
var h = (date.getHours() < 10 ? '0' + (date.getHours()) : date.getHours()) + ':';
|
var m = (date.getMinutes() < 10 ? '0' + (date.getMinutes()) : date.getMinutes()) + ':';
|
var s = (date.getSeconds() < 10 ? '0' + (date.getSeconds()) : date.getSeconds());
|
var strDate = Y + M + D + h + m + s;
|
return strDate
|
}
|
/**
|
* 检查是否选中
|
*/
|
UserActivity.check = function (type) {
|
var selected = $('#' + this.id).bootstrapTable('getSelections');
|
if(selected.length == 0){
|
Feng.info("请先选中表格中的某一记录!");
|
return false;
|
}else{
|
|
//验证类型null删除,1=审核,2=编辑,3=启动/暂停
|
if(type==null){
|
UserActivity.seItem = selected[0];
|
return true;
|
}else if(type==3 && selected[0].status!=3 && selected[0].status!=4){
|
Feng.info("当前状态不能暂停/启动!");
|
|
return false;
|
}else if(type==3 && selected[0].status==3 && (selected[0].startTime>new Date() || new Date()>selected[0].endTime)){
|
Feng.info("当前状态不能暂停/启动!");
|
return false;
|
}else if(type==1 && selected[0].status!=1){
|
Feng.info("当前状态不能审核!");
|
|
return false;
|
}else if(type==2 && selected[0].status!=2){
|
Feng.info("当前状态不能编辑!");
|
|
return false;
|
}
|
UserActivity.seItem = selected[0];
|
return true;
|
}
|
};
|
|
/**
|
* 点击添加
|
*/
|
UserActivity.openAddUserActivity = function () {
|
var index = layer.open({
|
type: 2,
|
title: language==1?'添加':(language==2?'Add':'Tambahkan'),
|
area: ['100%', '100%'], //宽高
|
fix: false, //不固定
|
maxmin: true,
|
content: Feng.ctxPath + '/userActivity/userActivity_add'
|
});
|
this.layerIndex = index;
|
};
|
|
/**
|
* 打开查看详情
|
*/
|
UserActivity.openUserActivityDetail = function () {
|
if (this.check()) {
|
var index = layer.open({
|
type: 2,
|
title: language==1?'详情':(language==2?'details':'details'),
|
area: ['100%', '100%'], //宽高
|
fix: false, //不固定
|
maxmin: true,
|
content: Feng.ctxPath + '/userActivity/userActivity_detail/' + UserActivity.seItem.id
|
});
|
this.layerIndex = index;
|
}
|
};
|
/**
|
* 打开编辑
|
*/
|
UserActivity.openUpdateUserActivity = function () {
|
if (this.check(2)) {
|
var companyId = UserActivity.seItem.companyId
|
var id = $("#id").val()
|
if(companyId!=id){
|
if(language==1){
|
Feng.info("不可编辑!")
|
}else if(language==2){
|
Feng.info("not editable!")
|
}else {
|
Feng.info("tidak dapat diedit!")
|
}
|
|
}
|
var index = layer.open({
|
type: 2,
|
title: language==1?'编辑':(language==2?'Edit':'Edit'),
|
area: ['100%', '100%'], //宽高
|
fix: false, //不固定
|
maxmin: true,
|
content: Feng.ctxPath + '/userActivity/userActivity_update/' + UserActivity.seItem.id
|
});
|
this.layerIndex = index;
|
}
|
};
|
/**
|
* 删除
|
*/
|
UserActivity.delete = function () {
|
if (this.check()) {
|
var ajax = new $ax(Feng.ctxPath + "/userActivity/delete", function (data) {
|
Feng.success("删除成功!");
|
UserActivity.table.refresh();
|
}, function (data) {
|
Feng.error("删除失败!" + data.responseJSON.message + "!");
|
});
|
ajax.set("userActivityId",this.seItem.id);
|
ajax.start();
|
}
|
};
|
/**
|
* 启动/暂停
|
*/
|
UserActivity.updateStatus = function () {
|
if (this.check(3)) {
|
var ajax = new $ax(Feng.ctxPath + "/userActivity/updateStatus", function (data) {
|
Feng.success("启动/暂停成功!");
|
|
UserActivity.table.refresh();
|
}, function (data) {
|
Feng.success("启动/暂停失败!");
|
|
});
|
ajax.set("id",this.seItem.id);
|
ajax.set("status",this.seItem.status==3?4:3);
|
ajax.start();
|
}
|
};
|
/**
|
* 打开立即处理页面
|
*/
|
UserActivity.immediately = function () {
|
if (this.check(1)) {
|
var index = layer.open({
|
type: 2,
|
title: language==1?'审核':(language==2?'Audit':'Audit'),
|
area: ['800px', '420px'], //宽高
|
fix: false, //不固定
|
maxmin: true,
|
content: Feng.ctxPath + '/userActivity/userActivity_immediately/' + this.seItem.id
|
});
|
this.layerIndex = index;
|
}
|
};
|
/**
|
* 领取记录
|
*/
|
UserActivity.receiveRecord= function () {
|
if (this.check()) {
|
var index = layer.open({
|
type: 2,
|
title: language==1?'领取记录':(language==2?'Collect records':'Mengumpulkan catatan'),
|
area: ['100%', '100%'], //宽高
|
fix: false, //不固定
|
maxmin: true,
|
content: Feng.ctxPath + '/userActivity/receiveRecord?activityId='+ UserActivity.seItem.id
|
});
|
this.layerIndex = index;
|
}
|
};
|
/**
|
* 查询列表
|
*/
|
UserActivity.search = function () {
|
var queryData = {};
|
queryData['createTime'] = $("#createTime").val();
|
queryData['name'] = $("#name").val();
|
queryData['status'] = $("#status").val();
|
UserActivity.table.refresh({query: queryData});
|
};
|
UserActivity.resetSearch = function () {
|
$("#createTime").val("");
|
$("#name").val("");
|
$("#status").val("");
|
UserActivity.search();
|
};
|
$(function () {
|
var defaultColunms = UserActivity.initColumn();
|
var table = new BSTable(UserActivity.id, "/userActivity/list", defaultColunms);
|
table.setPaginationType("server");
|
UserActivity.table = table.init();
|
});
|