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