/**
|
* 初始化商品管理详情对话框
|
*/
|
var language =$("#language").val()
|
var TIntegralGoodsInfoDlg = {
|
tIntegralGoodsInfoData : {},
|
editor: null,
|
validateFields: {
|
name: {
|
validators: {
|
notEmpty: {
|
message: '商品名称不能为空'
|
}
|
}
|
},
|
integral: {
|
validators: {
|
notEmpty: {
|
message: '兑换积分不能为空'
|
},
|
regexp: {
|
regexp: /^[0-9]\d*$/,
|
message: '兑换积分格式不正确'
|
}
|
}
|
}
|
}
|
};
|
|
/**
|
* 验证数据是否为空
|
*/
|
TIntegralGoodsInfoDlg.validate = function () {
|
$('#integralGoodsInfoForm').data("bootstrapValidator").resetForm();
|
$('#integralGoodsInfoForm').bootstrapValidator('validate');
|
return $("#integralGoodsInfoForm").data('bootstrapValidator').isValid();
|
};
|
|
/**
|
* 清除数据
|
*/
|
TIntegralGoodsInfoDlg.clearData = function() {
|
this.tIntegralGoodsInfoData = {};
|
}
|
|
/**
|
* 设置对话框中的数据
|
*
|
* @param key 数据的名称
|
* @param val 数据的具体值
|
*/
|
TIntegralGoodsInfoDlg.set = function(key, val) {
|
this.tIntegralGoodsInfoData[key] = (typeof val == "undefined") ? $("#" + key).val() : val;
|
return this;
|
}
|
|
/**
|
* 设置对话框中的数据
|
*
|
* @param key 数据的名称
|
* @param val 数据的具体值
|
*/
|
TIntegralGoodsInfoDlg.get = function(key) {
|
return $("#" + key).val();
|
}
|
|
/**
|
* 关闭此对话框
|
*/
|
TIntegralGoodsInfoDlg.close = function() {
|
parent.layer.close(window.parent.TIntegralGoods.layerIndex);
|
}
|
|
/**
|
* 收集数据
|
*/
|
TIntegralGoodsInfoDlg.collectData = function() {
|
this.tIntegralGoodsInfoData['instructions'] = TIntegralGoodsInfoDlg.editor.getContent();
|
this
|
.set('id')
|
.set('insertTime')
|
.set('name')
|
.set('imgUrl')
|
.set('integral')
|
.set('state')
|
.set('insertUserId')
|
.set('insertUserRole');
|
}
|
|
/**
|
* 提交添加
|
*/
|
TIntegralGoodsInfoDlg.addSubmit = function() {
|
|
this.clearData();
|
this.collectData();
|
if(!this.validate()){
|
return ;
|
}
|
var imgUrl = $("#imgUrl").val();
|
if ("" == imgUrl){
|
Feng.info("请上传商品图片");
|
return;
|
}
|
//提交信息
|
var ajax = new $ax(Feng.ctxPath + "/tIntegralGoods/add", function(data){
|
Feng.success("添加成功!");
|
window.parent.TIntegralGoods.table.refresh();
|
TIntegralGoodsInfoDlg.close();
|
},function(data){
|
Feng.error("添加失败!" + data.responseJSON.message + "!");
|
});
|
ajax.set(this.tIntegralGoodsInfoData);
|
ajax.start();
|
}
|
|
/**
|
* 提交修改
|
*/
|
TIntegralGoodsInfoDlg.editSubmit = function() {
|
|
this.clearData();
|
this.collectData();
|
if(!this.validate()){
|
return ;
|
}
|
var imgUrl = $("#imgUrl").val();
|
if ("" == imgUrl){
|
Feng.info("请上传商品图片");
|
return;
|
}
|
//提交信息
|
var ajax = new $ax(Feng.ctxPath + "/tIntegralGoods/update", function(data){
|
Feng.success("修改成功!");
|
window.parent.TIntegralGoods.table.refresh();
|
TIntegralGoodsInfoDlg.close();
|
},function(data){
|
Feng.error("修改失败!" + data.responseJSON.message + "!");
|
});
|
ajax.set(this.tIntegralGoodsInfoData);
|
ajax.start();
|
}
|
|
$(function() {
|
Feng.initValidator("integralGoodsInfoForm", TIntegralGoodsInfoDlg.validateFields);
|
// 初始化图片上传
|
var imgUrl = new $WebUpload("imgUrl");
|
imgUrl.setUploadBarId("progressBar");
|
imgUrl.init();
|
// 初始化编辑器
|
TIntegralGoodsInfoDlg.editor = UE.getEditor('editor');
|
});
|