/**
|
* 初始化车辆品牌管理详情对话框
|
*/
|
var MerchantCouponInfoDlg = {
|
merchantCouponInfoData : {},
|
validateFields: {
|
name: {
|
validators: {
|
notEmpty: {
|
message: '商家券名称不能为空'
|
}
|
}
|
},
|
}
|
};
|
|
/**
|
* 验证数据是否为空
|
*/
|
MerchantCouponInfoDlg.validate = function () {
|
$('#merchantCouponInfoForm').data("bootstrapValidator").resetForm();
|
$('#merchantCouponInfoForm').bootstrapValidator('validate');
|
return $("#merchantCouponInfoForm").data('bootstrapValidator').isValid();
|
};
|
|
/**
|
* 清除数据
|
*/
|
MerchantCouponInfoDlg.clearData = function() {
|
this.merchantCouponInfoData = {};
|
}
|
|
/**
|
* 设置对话框中的数据
|
*
|
* @param key 数据的名称
|
* @param val 数据的具体值
|
*/
|
MerchantCouponInfoDlg.set = function(key, val) {
|
this.merchantCouponInfoData[key] = (typeof val == "undefined") ? $("#" + key).val() : val;
|
return this;
|
}
|
|
/**
|
* 设置对话框中的数据
|
*
|
* @param key 数据的名称
|
* @param val 数据的具体值
|
*/
|
MerchantCouponInfoDlg.get = function(key) {
|
return $("#" + key).val();
|
}
|
|
/**
|
* 关闭此对话框
|
*/
|
MerchantCouponInfoDlg.close = function() {
|
parent.layer.close(window.parent.MerchantCoupon.layerIndex);
|
}
|
|
/**
|
* 收集数据
|
*/
|
MerchantCouponInfoDlg.collectData = function() {
|
this
|
.set('id')
|
.set('name')
|
.set('merchantId')
|
.set('type')
|
.set('discount')
|
.set('content')
|
.set('state')
|
.set('createTime')
|
.set('fullAmount');
|
}
|
|
/**
|
* 提交添加
|
*/
|
MerchantCouponInfoDlg.addSubmit = function() {
|
|
this.clearData();
|
this.collectData();
|
if(!this.validate()){
|
return ;
|
}
|
var merchantId = $("#merchantId").valueOf();
|
if ("" == merchantId){
|
Feng.info("请选择商家");
|
return;
|
}
|
//提交信息
|
var ajax = new $ax(Feng.ctxPath + "/merchantCoupon/add", function(data){
|
Feng.success("添加成功!");
|
window.parent.MerchantCoupon.table.refresh();
|
MerchantCouponInfoDlg.close();
|
},function(data){
|
Feng.error("添加失败!" + data.responseJSON.message + "!");
|
});
|
ajax.set(this.merchantCouponInfoData);
|
ajax.start();
|
}
|
|
/**
|
* 提交修改
|
*/
|
MerchantCouponInfoDlg.editSubmit = function() {
|
|
this.clearData();
|
this.collectData();
|
if(!this.validate()){
|
return ;
|
}
|
var merchantId = $("#merchantId").valueOf();
|
if ("" == merchantId){
|
Feng.info("请选择商家");
|
return;
|
}
|
|
//提交信息
|
var ajax = new $ax(Feng.ctxPath + "/merchantCoupon/update", function(data){
|
Feng.success("修改成功!");
|
window.parent.MerchantCoupon.table.refresh();
|
MerchantCouponInfoDlg.close();
|
},function(data){
|
Feng.error("修改失败!" + data.responseJSON.message + "!");
|
});
|
ajax.set(this.merchantCouponInfoData);
|
ajax.start();
|
}
|
|
$(function() {
|
Feng.initValidator("merchantCouponInfoForm", MerchantCouponInfoDlg.validateFields);
|
|
$("#merchantId").val($("#merchantId_").val())
|
|
});
|