/**
|
* 调度管理管理初始化
|
*/
|
var TDispatch = {
|
id: "TDispatchTable", //表格id
|
seItem: null, //选中的条目
|
table: null,
|
layerIndex: -1
|
};
|
|
/**
|
* 初始化表格的列
|
*/
|
TDispatch.initColumn = function () {
|
return [
|
{field: 'selectItem', radio: true},
|
{title: '主键ID', field: 'id', visible: false, align: 'center', valign: 'middle'},
|
{title: '添加时间', field: 'insertTime', visible: true, align: 'center', valign: 'middle',width:'10%',
|
formatter: function (value, row) {
|
var btn = "";
|
if(row.insertTime != '' && row.insertTime != null) {
|
var time = row.insertTime.replace(" ",'<br>');
|
btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="' + row.insertTime + '" onfocus="TUser.tooltip()">' + time + '</p>']
|
}
|
return btn;
|
}
|
},
|
{title: '调度名称', field: 'name', visible: true, align: 'center', valign: 'middle',
|
formatter: function (value, row) {
|
var btn = "";
|
if(row.name != '' && row.name != null) {
|
btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="' + row.name + '" onfocus="TUser.tooltip()">' + row.name + '</p>']
|
}
|
return btn;
|
}
|
},
|
{title: '所属分公司ID', field: 'companyId', visible: false, align: 'center', valign: 'middle'},
|
{title: '所属分公司', field: 'companyName', visible: true, align: 'center', valign: 'middle',
|
formatter: function (value, row) {
|
var btn = "";
|
if(row.companyName != '' && row.companyName != null) {
|
btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="' + row.companyName + '" onfocus="TUser.tooltip()">' + row.companyName + '</p>']
|
}
|
return btn;
|
}
|
},
|
{title: '所属加盟商ID', field: 'franchiseeId', visible: false, align: 'center', valign: 'middle'},
|
{title: '所属加盟商', field: 'franchiseeName', visible: true, align: 'center', valign: 'middle',
|
formatter: function (value, row) {
|
var btn = "";
|
if(row.franchiseeName != '' && row.franchiseeName != null) {
|
btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="' + row.franchiseeName + '" onfocus="TUser.tooltip()">' + row.franchiseeName + '</p>']
|
}
|
return btn;
|
}
|
},
|
{title: '调度电话', field: 'phone', visible: true, align: 'center', valign: 'middle',
|
formatter: function (value, row) {
|
var btn = "";
|
if(row.phone != '' && row.phone != null) {
|
btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="' + row.phone + '" onfocus="TUser.tooltip()">' + row.phone + '</p>']
|
}
|
return btn;
|
}
|
},
|
{title: '账号', field: 'account', visible: true, align: 'center', valign: 'middle',
|
formatter: function (value, row) {
|
var btn = "";
|
if(row.account != '' && row.account != null) {
|
btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="' + row.account + '" onfocus="TUser.tooltip()">' + row.account + '</p>']
|
}
|
return btn;
|
}
|
},
|
{title: '状态', field: 'state', visible: true, align: 'center', valign: 'middle',
|
formatter: function (value, row) {
|
var btn = "";
|
if(row.state != '' && row.state != null) {
|
if (1 == row.state){
|
btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="正常" onfocus="TUser.tooltip()">正常</p>']
|
} else if (2 == row.state){
|
btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;color: red;" title="冻结" onfocus="TUser.tooltip()">冻结</p>']
|
}
|
}
|
return btn;
|
}
|
}
|
];
|
};
|
|
/**
|
* 检查是否选中
|
*/
|
TDispatch.check = function () {
|
var selected = $('#' + this.id).bootstrapTable('getSelections');
|
if(selected.length == 0){
|
Feng.info("请先选中表格中的某一记录!");
|
return false;
|
}else{
|
TDispatch.seItem = selected[0];
|
return true;
|
}
|
};
|
|
/**
|
* 点击添加调度管理
|
*/
|
TDispatch.openAddTDispatch = function () {
|
var index = layer.open({
|
type: 2,
|
title: '添加调度管理',
|
area: ['800px', '80%'], //宽高
|
fix: false, //不固定
|
maxmin: true,
|
content: Feng.ctxPath + '/tDispatch/tDispatch_add'
|
});
|
this.layerIndex = index;
|
};
|
|
/**
|
* 打开查看调度管理详情
|
*/
|
TDispatch.openTDispatchDetail = function () {
|
if (this.check()) {
|
var index = layer.open({
|
type: 2,
|
title: '调度管理详情',
|
area: ['800px', '80%'], //宽高
|
fix: false, //不固定
|
maxmin: true,
|
content: Feng.ctxPath + '/tDispatch/tDispatch_update/' + TDispatch.seItem.id
|
});
|
this.layerIndex = index;
|
}
|
};
|
|
/**
|
* 删除调度管理
|
*/
|
TDispatch.opt = function (type) {
|
if (this.check()) {
|
var name = TDispatch.seItem.name;
|
if (name == "" || name == null || name == undefined) {
|
name = "该调度账号";
|
} else {
|
name = "【" + name + "】";
|
}
|
var str = "";
|
var text = "请谨慎操作!";
|
var title = "请谨慎操作!";
|
if (1 == type){
|
str = "删除";
|
title = "您是否确认删除"+name+"?";
|
text = "请谨慎操作,删除后数据无法恢复!";
|
} else if (2 == type){
|
str = "冻结";
|
title = "您是否确认冻结"+name+"?";
|
} else if (3 == type){
|
str = "解冻";
|
title = "您是否确认解冻"+name+"?";
|
}
|
if(2 == type){
|
if (TDispatch.seItem.state != 1) {
|
swal("冻结失败", "【正常】状态下才能执行此操作", "warning");
|
return;
|
}
|
}
|
if (3 == type){
|
if (TDispatch.seItem.state != 2){
|
swal("解冻失败", "【冻结】状态下才能执行此操作", "warning");
|
return;
|
}
|
}
|
|
swal({
|
title: title,
|
text: text,
|
type: "warning",
|
showCancelButton: true,
|
confirmButtonColor: "#DD6B55",
|
confirmButtonText: str,
|
closeOnConfirm: true
|
}, function () {
|
var ajax = new $ax(Feng.ctxPath + "/tDispatch/opt", function (data) {
|
swal(str+"成功", "您已经"+str+"了" + name + "。", "success");
|
TDispatch.table.refresh();
|
}, function (data) {
|
swal(str+"失败", data.responseJSON.message + "!", "warning");
|
});
|
ajax.set("tDispatchId",TDispatch.seItem.id);
|
ajax.set("optType", type);
|
ajax.start();
|
});
|
}
|
};
|
|
/**
|
* 查询调度管理列表
|
*/
|
TDispatch.search = function () {
|
var queryData = {};
|
queryData['insertTime'] = $("#insertTime").val();
|
queryData['name'] = $("#name").val();
|
queryData['companyName'] = $("#companyName").val();
|
queryData['franchiseeName'] = $("#franchiseeName").val();
|
queryData['account'] = $("#account").val();
|
queryData['state'] = $("#state").val();
|
TDispatch.table.refresh({query: queryData});
|
};
|
|
TDispatch.resetSearch = function () {
|
$("#insertTime").val("");
|
$("#name").val("");
|
$("#companyName").val("");
|
$("#franchiseeName").val("");
|
$("#account").val("");
|
$("#state").val("");
|
TDispatch.search();
|
};
|
|
$(function () {
|
var defaultColunms = TDispatch.initColumn();
|
var table = new BSTable(TDispatch.id, "/tDispatch/list", defaultColunms);
|
table.setPaginationType("server");
|
TDispatch.table = table.init();
|
});
|