/**
* 初始化调度管理详情对话框
*/
var language =$("#language").val()
var TDispatchInfoDlg = {
tDispatchInfoData : {},
validateFields: {
name: {
validators: {
notEmpty: {
message: '调度名称不能为空'
}
}
},
/*oneId: {
validators: {
notEmpty: {
message: '请选择所属分公司'
}
}
},
twoId: {
validators: {
notEmpty: {
message: '请选择所属加盟商'
}
}
},
franchiseeId: {
validators: {
notEmpty: {
message: '请选择所属加盟商'
}
}
},*/
phone: {
validators: {
notEmpty: {
message: '联系电话不能为空'
},
}
},
account: {
validators: {
notEmpty: {
message: language==1?'登录账号不能为空':(language==2?"The login account number cannot be empty":"Nomor akun login tidak bisa kosong")
},
regexp: {
regexp: /^1\d{10}$/,
message: '登录账号格式不正确'
}
}
},
password: {
validators: {
notEmpty: {
message: language==1?'密码不能为空':(language==2?"The password cannot be empty.":"Kata sandi tidak bisa kosong.")
},
identical: {
field: 'rePassword',
message: language==1?'两次密码不一致':(language==2?"The password entered twice are inconsistent.":"Kata sandi yang dimasukkan dua kali tidak konsisten.")
},
}
},
rePassword: {
validators: {
notEmpty: {
message: language==1?'密码不能为空':(language==2?"The password cannot be empty.":"Kata sandi tidak bisa kosong.")
},
identical: {
field: 'password',
message: language==1?'两次密码不一致':(language==2?"The password entered twice are inconsistent.":"Kata sandi yang dimasukkan dua kali tidak konsisten.")
},
}
}
}
};
/**
* 验证数据是否为空
*/
TDispatchInfoDlg.validate = function () {
$('#dispatchInfoForm').data("bootstrapValidator").resetForm();
$('#dispatchInfoForm').bootstrapValidator('validate');
return $("#dispatchInfoForm").data('bootstrapValidator').isValid();
};
/**
* 清除数据
*/
TDispatchInfoDlg.clearData = function() {
this.tDispatchInfoData = {};
}
/**
* 设置对话框中的数据
*
* @param key 数据的名称
* @param val 数据的具体值
*/
TDispatchInfoDlg.set = function(key, val) {
this.tDispatchInfoData[key] = (typeof val == "undefined") ? $("#" + key).val() : val;
return this;
}
/**
* 设置对话框中的数据
*
* @param key 数据的名称
* @param val 数据的具体值
*/
TDispatchInfoDlg.get = function(key) {
return $("#" + key).val();
}
/**
* 关闭此对话框
*/
TDispatchInfoDlg.close = function() {
parent.layer.close(window.parent.TDispatch.layerIndex);
}
/**
* 收集数据
*/
TDispatchInfoDlg.collectData = function() {
this
.set('id')
.set('insertTime')
.set('name')
.set('companyId')
.set('franchiseeId')
.set('phone')
.set('account')
.set('password')
.set('insertUserId')
.set('insertUserRole')
.set('state');
}
/**
* 提交添加
*/
TDispatchInfoDlg.addSubmit = function() {
this.clearData();
this.collectData();
if(!this.validate()){
return ;
}
var roleType = $("#roleType").val(); //1=平台 2=分公司 3=加盟商
//提交信息
var ajax = new $ax(Feng.ctxPath + "/tDispatch/add", function(data){
if (data.code == 500){
Feng.error(data.message);
return ;
} else {
Feng.success("添加成功!");
window.parent.TDispatch.table.refresh();
TDispatchInfoDlg.close();
}
},function(data){
Feng.error("添加失败!" + data.responseJSON.message + "!");
});
ajax.set(this.tDispatchInfoData);
if (1 == roleType){
var companyId = $("#oneId").val();
if ("" != companyId && null != companyId && undefined != companyId){
ajax.set("companyId",companyId);
}
var franchiseeId = $("#twoId").val();
if ("" != franchiseeId && null != franchiseeId && undefined != franchiseeId){
ajax.set("franchiseeId",franchiseeId);
}
}else if (2 == roleType) {
var franchiseeId = $("#franchiseeId").val();
if ("" != franchiseeId && null != franchiseeId && undefined != franchiseeId){
ajax.set("franchiseeId",franchiseeId);
}
}
ajax.start();
}
/**
* 提交修改
*/
TDispatchInfoDlg.editSubmit = function() {
this.clearData();
this.collectData();
if(!this.validate()){
return ;
}
var roleType = $("#roleType").val(); //1=平台 2=分公司 3=加盟商
//提交信息
var ajax = new $ax(Feng.ctxPath + "/tDispatch/update", function(data){
if (data.code == 500){
Feng.error(data.message);
return ;
} else {
Feng.success("修改成功!");
window.parent.TDispatch.table.refresh();
TDispatchInfoDlg.close();
}
},function(data){
Feng.error("修改失败!" + data.responseJSON.message + "!");
});
ajax.set(this.tDispatchInfoData);
if (1 == roleType){
var companyId = $("#oneId").val();
if ("" != companyId && null != companyId && undefined != companyId){
ajax.set("companyId",companyId);
}
var franchiseeId = $("#twoId").val();
if ("" != franchiseeId && null != franchiseeId && undefined != franchiseeId){
ajax.set("franchiseeId",franchiseeId);
}
}else if (2 == roleType) {
var franchiseeId = $("#franchiseeId").val();
if ("" != franchiseeId && null != franchiseeId && undefined != franchiseeId){
ajax.set("franchiseeId",franchiseeId);
}
}
ajax.start();
}
$(function() {
Feng.initValidator("dispatchInfoForm", TDispatchInfoDlg.validateFields);
});
/**
* 公司改变执行
*/
TDispatchInfoDlg.companyChange = function (e) {
var oneId=$(e).val();
var ajax = new $ax(Feng.ctxPath + "/tDispatch/companyChange", function(data){
if(data!=null){
if(language==1){
var content='';
}else if(language==2){
var content='';
}else {
var content='';
}
$.each(data, function(k,v) {
content += "";
});
$("#twoId").empty().append(content);
}
});
ajax.set("oneId",oneId);
ajax.start();
}