/**
|
* 初始化车辆品牌管理详情对话框
|
*/
|
var TCarColorInfoDlg = {
|
tCarBrandInfoData : {},
|
validateFields: {
|
name: {
|
validators: {
|
notEmpty: {
|
message: '颜色名称不能为空'
|
}
|
}
|
},
|
}
|
};
|
|
/**
|
* 验证数据是否为空
|
*/
|
TCarColorInfoDlg.validate = function () {
|
$('#carBrandInfoForm').data("bootstrapValidator").resetForm();
|
$('#carBrandInfoForm').bootstrapValidator('validate');
|
return $("#carBrandInfoForm").data('bootstrapValidator').isValid();
|
};
|
|
/**
|
* 清除数据
|
*/
|
TCarColorInfoDlg.clearData = function() {
|
this.tCarBrandInfoData = {};
|
}
|
|
/**
|
* 设置对话框中的数据
|
*
|
* @param key 数据的名称
|
* @param val 数据的具体值
|
*/
|
TCarColorInfoDlg.set = function(key, val) {
|
this.tCarBrandInfoData[key] = (typeof val == "undefined") ? $("#" + key).val() : val;
|
return this;
|
}
|
|
/**
|
* 设置对话框中的数据
|
*
|
* @param key 数据的名称
|
* @param val 数据的具体值
|
*/
|
TCarColorInfoDlg.get = function(key) {
|
return $("#" + key).val();
|
}
|
|
/**
|
* 关闭此对话框
|
*/
|
TCarColorInfoDlg.close = function() {
|
parent.layer.close(window.parent.TCarColor.layerIndex);
|
}
|
|
/**
|
* 收集数据
|
*/
|
TCarColorInfoDlg.collectData = function() {
|
this
|
.set('id')
|
.set('name')
|
}
|
|
/**
|
* 提交添加
|
*/
|
TCarColorInfoDlg.addSubmit = function() {
|
|
this.clearData();
|
this.collectData();
|
if(!this.validate()){
|
return ;
|
}
|
//提交信息
|
var ajax = new $ax(Feng.ctxPath + "/tCarColor/add", function(data){
|
if(data.status == 200){
|
Feng.success("添加成功!");
|
window.parent.TCarColor.table.refresh();
|
TCarColorInfoDlg.close();
|
}else{
|
swal("添加失败", data.msg + "!", "warning");
|
}
|
},function(data){
|
Feng.error("添加失败!" + data.responseJSON.message + "!");
|
});
|
ajax.set(this.tCarBrandInfoData);
|
ajax.start();
|
}
|
|
/**
|
* 提交修改
|
*/
|
TCarColorInfoDlg.editSubmit = function() {
|
|
this.clearData();
|
this.collectData();
|
if(!this.validate()){
|
return ;
|
}
|
//提交信息
|
var ajax = new $ax(Feng.ctxPath + "/tCarColor/update", function(data){
|
if(data.status == 200){
|
Feng.success("修改成功!");
|
window.parent.TCarColor.table.refresh();
|
TCarColorInfoDlg.close();
|
}else{
|
swal("修改失败", data.msg + "!", "warning");
|
}
|
},function(data){
|
Feng.error("修改失败!" + data.responseJSON.message + "!");
|
});
|
ajax.set(this.tCarBrandInfoData);
|
ajax.start();
|
}
|
|
$(function() {
|
Feng.initValidator("carBrandInfoForm", TCarColorInfoDlg.validateFields);
|
// 初始化图片上传
|
var imgUrl = new $WebUpload("imgUrl");
|
imgUrl.setUploadBarId("progressBar");
|
imgUrl.init();
|
});
|