/**
|
* 初始化详情对话框
|
*/
|
var TAgentInfoDlg = {
|
tAgentInfoData : {},
|
validateFields: {
|
principal: {
|
validators: {
|
notEmpty: {
|
message: '负责人姓名不能为空'
|
},
|
regexp: {
|
regexp: /^[\u4E00-\u9FA5A-Za-z\s]+$/,
|
message: '不能输入特殊字符和数字'
|
}
|
}
|
},
|
principalPhone: {
|
validators: {
|
notEmpty: {
|
message: '联系电话不能为空'
|
},
|
regexp: {
|
regexp: /^1[3-9]\d{9}$/,
|
message: '请输入合法手机号'
|
}
|
}
|
},
|
area: {
|
validators: {
|
notEmpty: {
|
message: '请选择代理区域'
|
}
|
}
|
},
|
account: {
|
validators: {
|
notEmpty: {
|
message: '登录账号不能为空'
|
}
|
}
|
},
|
password: {
|
validators: {
|
notEmpty: {
|
message: '登录密码不能为空'
|
},
|
identical: {
|
field: 'rePassword',
|
message: '两次密码不一致'
|
},
|
}
|
},
|
rePassword: {
|
validators: {
|
notEmpty: {
|
message: '密码不能为空'
|
},
|
identical: {
|
field: 'password',
|
message: '两次密码不一致'
|
},
|
}
|
}
|
}
|
};
|
|
/**
|
* 验证数据是否为空
|
*/
|
TAgentInfoDlg.validate = function () {
|
$('#tAgentInfoForm').data("bootstrapValidator").resetForm();
|
$('#tAgentInfoForm').bootstrapValidator('validate');
|
return $("#tAgentInfoForm").data('bootstrapValidator').isValid();
|
};
|
|
/**
|
* 清除数据
|
*/
|
TAgentInfoDlg.clearData = function() {
|
this.tAgentInfoData = {};
|
}
|
|
/**
|
* 设置对话框中的数据
|
*
|
* @param key 数据的名称
|
* @param val 数据的具体值
|
*/
|
TAgentInfoDlg.set = function(key, val) {
|
this.tAgentInfoData[key] = (typeof val == "undefined") ? $("#" + key).val() : val;
|
return this;
|
}
|
|
/**
|
* 设置对话框中的数据
|
*
|
* @param key 数据的名称
|
* @param val 数据的具体值
|
*/
|
TAgentInfoDlg.get = function(key) {
|
return $("#" + key).val();
|
}
|
|
/**
|
* 关闭此对话框
|
*/
|
TAgentInfoDlg.close = function() {
|
parent.layer.close(window.parent.TAgent.layerIndex);
|
}
|
|
/**
|
* 收集数据
|
*/
|
TAgentInfoDlg.collectData = function() {
|
this
|
.set('id')
|
.set('principal')
|
.set('principalPhone')
|
.set('email')
|
.set('provinceCode')
|
.set('provinceName')
|
.set('cityCode')
|
.set('cityName')
|
.set('status')
|
.set('area')
|
.set('areaId')
|
.set('account')
|
.set('password')
|
.set('createTime');
|
}
|
|
/**
|
* 提交添加
|
*/
|
TAgentInfoDlg.addSubmit = function() {
|
|
this.clearData();
|
this.collectData();
|
|
if(!this.validate()){
|
return ;
|
}
|
|
//提交信息
|
var ajax = new $ax(Feng.ctxPath + "/tAgent/add", function(data){
|
if(data.code == 500){
|
Feng.error("添加失败!" + data.message + "!");
|
return false;
|
}
|
Feng.success("添加成功!");
|
window.parent.TAgent.table.refresh();
|
TAgentInfoDlg.close();
|
},function(data){
|
Feng.error("添加失败!" + data.message + "!");
|
});
|
ajax.set(this.tAgentInfoData);
|
ajax.start();
|
}
|
|
/**
|
* 提交修改
|
*/
|
TAgentInfoDlg.editSubmit = function() {
|
|
this.clearData();
|
this.collectData();
|
|
if(!this.validate()){
|
return ;
|
}
|
|
//提交信息
|
var ajax = new $ax(Feng.ctxPath + "/tAgent/update", function(data){
|
Feng.success("修改成功!");
|
window.parent.TAgent.table.refresh();
|
TAgentInfoDlg.close();
|
},function(data){
|
Feng.error("修改失败!" + data.responseJSON.message + "!");
|
});
|
ajax.set(this.tAgentInfoData);
|
ajax.start();
|
}
|
|
$(function() {
|
Feng.initValidator("tAgentInfoForm", TAgentInfoDlg.validateFields);
|
});
|