/**
|
* 初始化车队管理详情对话框
|
*/
|
var TDriverTeamInfoDlg = {
|
tDriverTeamInfoData : {},
|
validateFields: {
|
teamName: {
|
validators: {
|
notEmpty: {
|
message: '车队名称不能为空!'
|
}
|
}
|
}
|
}
|
};
|
|
/**
|
* 清除数据
|
*/
|
TDriverTeamInfoDlg.clearData = function() {
|
this.tDriverTeamInfoData = {};
|
}
|
|
/**
|
* 验证数据是否为空
|
*/
|
TDriverTeamInfoDlg.validate = function () {
|
$('#tDriverTeamForm').data("bootstrapValidator").resetForm();
|
$('#tDriverTeamForm').bootstrapValidator('validate');
|
return $("#tDriverTeamForm").data('bootstrapValidator').isValid();
|
};
|
|
/**
|
* 设置对话框中的数据
|
*
|
* @param key 数据的名称
|
* @param val 数据的具体值
|
*/
|
TDriverTeamInfoDlg.set = function(key, val) {
|
this.tDriverTeamInfoData[key] = (typeof val == "undefined") ? $("#" + key).val() : val;
|
return this;
|
}
|
|
/**
|
* 设置对话框中的数据
|
*
|
* @param key 数据的名称
|
* @param val 数据的具体值
|
*/
|
TDriverTeamInfoDlg.get = function(key) {
|
return $("#" + key).val();
|
}
|
|
/**
|
* 关闭此对话框
|
*/
|
TDriverTeamInfoDlg.close = function() {
|
parent.layer.close(window.parent.TDriverTeam.layerIndex);
|
}
|
|
/**
|
* 收集数据
|
*/
|
TDriverTeamInfoDlg.collectData = function() {
|
this
|
.set('id')
|
.set('teamName')
|
.set('remark');
|
}
|
|
/**
|
* 提交添加
|
*/
|
TDriverTeamInfoDlg.addSubmit = function() {
|
|
this.clearData();
|
this.collectData();
|
|
if(!this.validate()){
|
return ;
|
}
|
|
//提交信息
|
var ajax = new $ax(Feng.ctxPath + "/tDriverTeam/add", function(data){
|
if("400"==data.code){
|
Feng.error("添加失败!当前车队已经存在!");
|
return;
|
}
|
Feng.success("添加成功!");
|
window.parent.TDriverTeam.table.refresh();
|
TDriverTeamInfoDlg.close();
|
},function(data){
|
console.log(data);
|
Feng.error("添加失败!" + data.responseJSON.message + "!");
|
});
|
ajax.set(this.tDriverTeamInfoData);
|
ajax.start();
|
}
|
|
/**
|
* 提交修改
|
*/
|
TDriverTeamInfoDlg.editSubmit = function() {
|
|
this.clearData();
|
this.collectData();
|
|
//提交信息
|
var ajax = new $ax(Feng.ctxPath + "/tDriverTeam/update", function(data){
|
if("400"==data.code){
|
Feng.error("修改失败!当前车队已经存在!");
|
return;
|
}
|
Feng.success("修改成功!");
|
window.parent.TDriverTeam.table.refresh();
|
TDriverTeamInfoDlg.close();
|
},function(data){
|
Feng.error("修改失败!" + data.responseJSON.message + "!");
|
});
|
ajax.set(this.tDriverTeamInfoData);
|
ajax.start();
|
}
|
|
$(function() {
|
Feng.initValidator("tDriverTeamForm", TDriverTeamInfoDlg.validateFields);
|
});
|