/**
|
* 初始化车辆类型管理详情对话框
|
*/
|
var TCarModelInfoDlg = {
|
tCarModelInfoData : {},
|
validateFields: {
|
name: {
|
validators: {
|
notEmpty: {
|
message: '类型名称不能为空'
|
}
|
}
|
},
|
seat: {
|
validators: {
|
notEmpty: {
|
message: '座位数不能为空'
|
},
|
regexp: {
|
regexp: /^[1-9]\d*$/,
|
message: '座位数不正确'
|
}
|
}
|
},
|
brandId: {
|
validators: {
|
notEmpty: {
|
message: '请选择所属车辆品牌'
|
}
|
}
|
},
|
}
|
};
|
|
/**
|
* 验证数据是否为空
|
*/
|
TCarModelInfoDlg.validate = function () {
|
$('#carModelInfoForm').data("bootstrapValidator").resetForm();
|
$('#carModelInfoForm').bootstrapValidator('validate');
|
return $("#carModelInfoForm").data('bootstrapValidator').isValid();
|
};
|
|
/**
|
* 清除数据
|
*/
|
TCarModelInfoDlg.clearData = function() {
|
this.tCarModelInfoData = {};
|
}
|
|
/**
|
* 设置对话框中的数据
|
*
|
* @param key 数据的名称
|
* @param val 数据的具体值
|
*/
|
TCarModelInfoDlg.set = function(key, val) {
|
this.tCarModelInfoData[key] = (typeof val == "undefined") ? $("#" + key).val() : val;
|
return this;
|
}
|
|
/**
|
* 设置对话框中的数据
|
*
|
* @param key 数据的名称
|
* @param val 数据的具体值
|
*/
|
TCarModelInfoDlg.get = function(key) {
|
return $("#" + key).val();
|
}
|
|
/**
|
* 关闭此对话框
|
*/
|
TCarModelInfoDlg.close = function() {
|
parent.layer.close(window.parent.TCarModel.layerIndex);
|
}
|
|
/**
|
* 收集数据
|
*/
|
TCarModelInfoDlg.collectData = function() {
|
this
|
.set('id')
|
.set('name')
|
.set('remark')
|
.set('createTime')
|
.set('state')
|
.set('seat')
|
.set('brandId');
|
}
|
|
/**
|
* 提交添加
|
*/
|
TCarModelInfoDlg.addSubmit = function() {
|
|
this.clearData();
|
this.collectData();
|
if(!this.validate()){
|
return ;
|
}
|
//提交信息
|
var ajax = new $ax(Feng.ctxPath + "/tCarModel/add", function(data){
|
Feng.success("添加成功!");
|
window.parent.TCarModel.table.refresh();
|
TCarModelInfoDlg.close();
|
},function(data){
|
Feng.error("添加失败!" + data.responseJSON.message + "!");
|
});
|
ajax.set(this.tCarModelInfoData);
|
ajax.start();
|
}
|
|
/**
|
* 提交修改
|
*/
|
TCarModelInfoDlg.editSubmit = function() {
|
|
this.clearData();
|
this.collectData();
|
if(!this.validate()){
|
return ;
|
}
|
//提交信息
|
var ajax = new $ax(Feng.ctxPath + "/tCarModel/update", function(data){
|
Feng.success("修改成功!");
|
window.parent.TCarModel.table.refresh();
|
TCarModelInfoDlg.close();
|
},function(data){
|
Feng.error("修改失败!" + data.responseJSON.message + "!");
|
});
|
ajax.set(this.tCarModelInfoData);
|
ajax.start();
|
}
|
|
$(function() {
|
Feng.initValidator("carModelInfoForm", TCarModelInfoDlg.validateFields);
|
});
|