/**
|
* 初始化详情对话框
|
*/
|
var TCouponInfoDlg = {
|
tCouponInfoData : {},
|
validateFields: {
|
couponName: {
|
validators: {
|
notEmpty: {
|
message: '优惠券名称不能为空'
|
}
|
}
|
},
|
couponType: {
|
validators: {
|
notEmpty: {
|
message: '请选择优惠券类型'
|
}
|
}
|
},
|
couponServiceType: {
|
validators: {
|
notEmpty: {
|
message: '请选择服务类类型'
|
}
|
}
|
},
|
couponCount: {
|
validators: {
|
notEmpty: {
|
message: '优惠券数量不能为空'
|
}
|
}
|
},
|
couponConditionalAmount: {
|
validators: {
|
notEmpty: {
|
message: '条件金额不能为空'
|
}
|
}
|
},
|
couponPreferentialAmount: {
|
validators: {
|
notEmpty: {
|
message: '优惠金额不能为空'
|
}
|
}
|
},
|
couponValidity: {
|
validators: {
|
notEmpty: {
|
message: '有效期不能为空'
|
}
|
}
|
},
|
remainingQuantity: {
|
validators: {
|
notEmpty: {
|
message: '优惠券总量不能为空'
|
}
|
}
|
},
|
}
|
};
|
|
/**
|
* 验证数据是否为空
|
*/
|
TCouponInfoDlg.validate = function () {
|
$('#couponInfoForm').data("bootstrapValidator").resetForm();
|
$('#couponInfoForm').bootstrapValidator('validate');
|
return $("#couponInfoForm").data('bootstrapValidator').isValid();
|
};
|
|
/**
|
* 清除数据
|
*/
|
TCouponInfoDlg.clearData = function() {
|
this.tCouponInfoData = {};
|
}
|
|
/**
|
* 设置对话框中的数据
|
*
|
* @param key 数据的名称
|
* @param val 数据的具体值
|
*/
|
TCouponInfoDlg.set = function(key, val) {
|
this.tCouponInfoData[key] = (typeof val == "undefined") ? $("#" + key).val() : val;
|
return this;
|
}
|
|
/**
|
* 设置对话框中的数据
|
*
|
* @param key 数据的名称
|
* @param val 数据的具体值
|
*/
|
TCouponInfoDlg.get = function(key) {
|
return $("#" + key).val();
|
}
|
|
/**
|
* 关闭此对话框
|
*/
|
TCouponInfoDlg.close = function() {
|
parent.layer.close(window.parent.TCoupon.layerIndex);
|
}
|
|
/**
|
* 收集数据
|
*/
|
TCouponInfoDlg.collectData = function() {
|
this
|
.set('id')
|
.set('createTime')
|
.set('couponType')
|
.set('couponServiceType')
|
.set('couponCount')
|
.set('couponConditionalAmount')
|
.set('couponPreferentialAmount')
|
.set('couponValidity')
|
.set('couponSendQuantity')
|
.set('remainingQuantity')
|
.set('couponName');
|
}
|
|
/**
|
* 提交添加
|
*/
|
TCouponInfoDlg.addSubmit = function() {
|
|
this.clearData();
|
this.collectData();
|
|
if(!this.validate()){
|
return ;
|
}
|
|
//提交信息
|
var ajax = new $ax(Feng.ctxPath + "/tCoupon/add", function(data){
|
Feng.success("添加成功!");
|
window.parent.TCoupon.table.refresh();
|
TCouponInfoDlg.close();
|
},function(data){
|
Feng.error("添加失败!" + data.responseJSON.message + "!");
|
});
|
ajax.set(this.tCouponInfoData);
|
ajax.start();
|
}
|
|
/**
|
* 提交修改
|
*/
|
TCouponInfoDlg.editSubmit = function() {
|
|
this.clearData();
|
this.collectData();
|
|
//提交信息
|
var ajax = new $ax(Feng.ctxPath + "/tCoupon/update", function(data){
|
Feng.success("修改成功!");
|
window.parent.TCoupon.table.refresh();
|
TCouponInfoDlg.close();
|
},function(data){
|
Feng.error("修改失败!" + data.responseJSON.message + "!");
|
});
|
ajax.set(this.tCouponInfoData);
|
ajax.start();
|
}
|
|
$(function() {
|
Feng.initValidator("couponInfoForm", TCouponInfoDlg.validateFields);
|
});
|