/**
|
* 初始化调度管理详情对话框
|
*/
|
var TDispatchInfoDlg = {
|
tDispatchInfoData : {},
|
validateFields: {
|
name: {
|
validators: {
|
notEmpty: {
|
message: '调度名称不能为空'
|
}
|
}
|
},
|
/*oneId: {
|
validators: {
|
notEmpty: {
|
message: '请选择所属分公司'
|
}
|
}
|
},
|
twoId: {
|
validators: {
|
notEmpty: {
|
message: '请选择所属加盟商'
|
}
|
}
|
},
|
franchiseeId: {
|
validators: {
|
notEmpty: {
|
message: '请选择所属加盟商'
|
}
|
}
|
},*/
|
phone: {
|
validators: {
|
notEmpty: {
|
message: '联系电话不能为空'
|
},
|
regexp: {
|
regexp: /^1\d{10}$/,
|
message: '联系电话格式不正确'
|
}
|
}
|
},
|
account: {
|
validators: {
|
notEmpty: {
|
message: '登录账号不能为空'
|
},
|
regexp: {
|
regexp: /^1\d{10}$/,
|
message: '登录账号格式不正确'
|
}
|
}
|
},
|
password: {
|
validators: {
|
notEmpty: {
|
message: '密码不能为空'
|
},
|
identical: {
|
field: 'rePassword',
|
message: '两次密码不一致'
|
},
|
}
|
},
|
rePassword: {
|
validators: {
|
notEmpty: {
|
message: '密码不能为空'
|
},
|
identical: {
|
field: 'password',
|
message: '两次密码不一致'
|
},
|
}
|
}
|
}
|
};
|
|
/**
|
* 验证数据是否为空
|
*/
|
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){
|
var content='<option value="">选择所属加盟商</option>';
|
$.each(data, function(k,v) {
|
content += "<option value='"+v.id+"'>"+v.name+"</option>";
|
});
|
$("#twoId").empty().append(content);
|
}
|
});
|
ajax.set("oneId",oneId);
|
ajax.start();
|
}
|