/**
|
* 车辆管理管理初始化
|
*/
|
var TCompetition = {
|
id: "TCompetitionTable", //表格id
|
seItem: null, //选中的条目
|
table: null,
|
layerIndex: -1
|
};
|
var language =1
|
/**
|
* 初始化表格的列
|
*/
|
TCompetition.initColumn = function () {
|
return [
|
{field: 'selectItem', checkbox: true},
|
{title: '序号', field: 'id', visible: true, align: 'center', valign: 'middle'},
|
{title: '所在省市', field: 'provinceAndCity', visible: true, align: 'center', valign: 'middle',},
|
{title: '开始时间', field: 'startTime', visible: true, align: 'center', valign: 'middle',},
|
{title: '结束时间', field: 'endTime', visible: true, align: 'center', valign: 'middle',},
|
{title: '赠送课时数', field: 'giveClass', visible: true, align: 'center', valign: 'middle',},
|
{title: '参与次数', field: 'number', visible: true, align: 'center', valign: 'middle',},
|
{title: '状态', field: 'activityState', visible: true, align: 'center', valign: 'middle',
|
formatter:function (data) {
|
return {1:"已开始",2:"未开始",3:"已结束"}[data]
|
}
|
},
|
{title: '活动状态', field: 'state', visible: true, align: 'center', valign: 'middle',
|
formatter:function (data) {
|
return {1:"已上架",2:"已下架"}[data]
|
}
|
},
|
];
|
};
|
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
|
}
|
|
function currentTime1(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 ;
|
return strDate
|
}
|
/**
|
* 检查是否选中
|
*/
|
TCompetition.check = function () {
|
var selected = $('#' + this.id).bootstrapTable('getSelections');
|
if(selected.length == 0){
|
Feng.info("请先选中表格中的某一记录!");
|
return false;
|
}else{
|
TCompetition.seItem = selected[0];
|
return true;
|
}
|
};
|
|
TCompetition.addSubmit = function(){
|
var data = {
|
id:null,
|
province:"",
|
provinceCode:"",
|
city:"",
|
cityCode:"",
|
startTime:"",
|
endTime:"",
|
giveClass:"",
|
state:1
|
};
|
data.province = $('#pCode option:selected').text();
|
data.provinceCode = $("#pCode").val()
|
data.city = $('#cCode option:selected').text();
|
data.cityCode = $("#cCode").val()
|
data.startTime = $("#startTime").val()
|
data.endTime = $("#endTime").val()
|
data.giveClass = $("#giveClass").val()
|
|
|
if($("#pCode").val()==''){
|
Feng.info("请选择省")
|
return;
|
}
|
if($("#cCode").val()==''){
|
Feng.info("请选择市")
|
return;
|
}
|
if($("#startTime").val()=='' ){
|
Feng.info("请选择开始时间")
|
return;
|
}
|
if($("#endTime").val()=='' ){
|
Feng.info("请选择结束时间")
|
return;
|
}
|
if($("#giveClass").val()=='' ){
|
Feng.info("请输入赠送课时数")
|
return;
|
}
|
var date = new Date(data.endTime);
|
var date1 = new Date(data.startTime);
|
if (date<date1){
|
Feng.error("开始时间必须小于等于结束时间!")
|
return;
|
}
|
|
$.ajax({
|
url: Feng.ctxPath + "/introduce/addIntroduce" ,
|
type: "POST",
|
data: JSON.stringify(data),
|
contentType: "application/json",
|
success: function (response) {
|
if (response=="5001"){
|
Feng.error("当前手机号 已被注册")
|
}else{
|
window.parent.TCompetition.table.refresh();
|
TQuestion.close();
|
Feng.success("添加成功");
|
}
|
},
|
error: function (xhr, status, error) {
|
Feng.error("添加失败!" + error);
|
}
|
});
|
};
|
TCompetition.onShelf = function () {
|
if (this.check()){
|
var selected = $('#' + this.id).bootstrapTable('getSelections');
|
const data1 = {
|
ids:[],
|
state:null
|
};
|
selected.forEach(function(obj) {
|
var id = obj.id;
|
data1.ids.push(id);
|
});
|
data1.state = 1;
|
|
$.ajax({
|
url: Feng.ctxPath + "/introduce/changeState",
|
type: "POST",
|
contentType: "application/json", // 设置请求头的 Content-Type
|
data: JSON.stringify(data1), // 将数据转换为 JSON 字符串
|
success: function(response) {
|
Feng.success("上架成功!");
|
TCompetition.search();
|
},
|
error: function(xhr, status, error) {
|
var errorMessage = xhr.responseText ? xhr.responseText : "上架失败!";
|
}
|
});
|
}
|
};
|
/**
|
* 下架
|
*/
|
TCompetition.offShelf = function () {
|
if (this.check()){
|
var selected = $('#' + this.id).bootstrapTable('getSelections');
|
const data1 = {
|
ids:[],
|
state:null
|
};
|
selected.forEach(function(obj) {
|
var id = obj.id;
|
data1.ids.push(id);
|
});
|
data1.state = 2;
|
$.ajax({
|
url: Feng.ctxPath + "/introduce/changeState",
|
type: "POST",
|
contentType: "application/json", // 设置请求头的 Content-Type
|
data: JSON.stringify(data1), // 将数据转换为 JSON 字符串
|
success: function(response) {
|
Feng.success("下架成功!");
|
TCompetition.search();
|
},
|
error: function(xhr, status, error) {
|
var errorMessage = xhr.responseText ? xhr.responseText : "下架失败!";
|
}
|
});
|
}
|
};
|
/**
|
* 关闭此对话框
|
*/
|
TCompetition.close = function() {
|
parent.layer.close(window.parent.TCompetition.layerIndex);
|
}
|
/**
|
* 点击添加车辆管理
|
*/
|
TCompetition.openAddTCompetition = function () {
|
var index = layer.open({
|
type: 2,
|
title: '添加',
|
area: ['100%', '100%'], //宽高
|
fix: false, //不固定
|
maxmin: true,
|
content: Feng.ctxPath + '/introduce/add'
|
});
|
this.layerIndex = index;
|
};
|
|
TCompetition.info = function () {
|
var selected = $('#' + this.id).bootstrapTable('getSelections');
|
if(selected.length >1 ){
|
Feng.info("只能选择一条进行查看!");
|
}else {
|
if (this.check()) {
|
|
var index = layer.open({
|
type: 2,
|
title: '详情',
|
area: ['100%', '100%'], //宽高
|
fix: false, //不固定
|
maxmin: true,
|
content: Feng.ctxPath + '/introduce/update/' + TCompetition.seItem.id
|
});
|
this.layerIndex = index;
|
}
|
}
|
};
|
// 跳转参与用户页面
|
TCompetition.user = function () {
|
var selected = $('#' + this.id).bootstrapTable('getSelections');
|
if(selected.length >1 ){
|
Feng.info("只能选择一条进行查看!");
|
}else {
|
if (this.check()) {
|
var index = layer.open({
|
type: 2,
|
title: '详情',
|
area: ['100%', '100%'], //宽高
|
fix: false, //不固定
|
maxmin: true,
|
content: Feng.ctxPath + '/introduce/user/' + TCompetition.seItem.id
|
});
|
this.layerIndex = index;
|
}
|
}
|
};
|
|
|
|
|
|
|
/**
|
* 查询车辆管理列表
|
*/
|
TCompetition.search = function () {
|
var queryData = {};
|
queryData['province'] = $("#pCode").val();
|
queryData['city'] = $("#cCode").val();
|
queryData['activityState'] = $("#activityState").val();
|
queryData['time'] = $("#createTime").val();
|
queryData['state'] = $("#state").val();
|
TCompetition.table.refresh({query: queryData});
|
};
|
TCompetition.oneChange = function (e) {
|
var oneId=$(e).val();
|
var ajax = new $ax(Feng.ctxPath + "/tCompetition/onChange", function(data){
|
if(data!=null){
|
var content='<option value="">选择市</option>';
|
$.each(data, function(k,v) {
|
content += "<option value='"+v.code+"'>"+v.name+"</option>";
|
});
|
$("#cCode").empty().append(content);
|
}
|
});
|
ajax.set("oneId",oneId);
|
ajax.start();
|
};
|
TCompetition.resetSearch = function () {
|
$("#pCode").val("");
|
$("#cCode").val("");
|
$("#createTime").val("");
|
$("#state").val("");
|
$("#activityState").val("");
|
TCompetition.search();
|
};
|
|
$(function () {
|
var defaultColunms = TCompetition.initColumn();
|
var table = new BSTable(TCompetition.id, "/introduce/listAll", defaultColunms);
|
table.setPaginationType("client");
|
TCompetition.table = table.init();
|
});
|