/**
|
* 初始化加盟商管理详情对话框
|
*/
|
var FranchiseeInfoDlg = {
|
franchiseeInfoData : {},
|
editor: null,
|
validateFields: {
|
superiorId: {
|
validators: {
|
notEmpty: {
|
message: '请选择所属分公司'
|
}
|
}
|
},
|
name: {
|
validators: {
|
notEmpty: {
|
message: '分公司名称不能为空'
|
}
|
}
|
},
|
account: {
|
validators: {
|
notEmpty: {
|
message: '登录账号不能为空'
|
}
|
}
|
},
|
password: {
|
validators: {
|
notEmpty: {
|
message: '登录密码不能为空'
|
},
|
|
}
|
},
|
|
}
|
};
|
|
/**
|
* 验证数据是否为空
|
*/
|
FranchiseeInfoDlg.validate = function () {
|
$('#franchiseeInfoForm').data("bootstrapValidator").resetForm();
|
$('#franchiseeInfoForm').bootstrapValidator('validate');
|
return $("#franchiseeInfoForm").data('bootstrapValidator').isValid();
|
};
|
|
/**
|
* 清除数据
|
*/
|
FranchiseeInfoDlg.clearData = function() {
|
this.franchiseeInfoData = {};
|
}
|
|
/**
|
* 设置对话框中的数据
|
*
|
* @param key 数据的名称
|
* @param val 数据的具体值
|
*/
|
FranchiseeInfoDlg.set = function(key, val) {
|
this.franchiseeInfoData[key] = (typeof val == "undefined") ? $("#" + key).val() : val;
|
return this;
|
}
|
|
/**
|
* 设置对话框中的数据
|
*
|
* @param key 数据的名称
|
* @param val 数据的具体值
|
*/
|
FranchiseeInfoDlg.get = function(key) {
|
return $("#" + key).val();
|
}
|
|
/**
|
* 关闭此对话框
|
*/
|
FranchiseeInfoDlg.close = function() {
|
parent.layer.close(window.parent.Franchisee.layerIndex);
|
}
|
|
/**
|
* 收集数据
|
*/
|
FranchiseeInfoDlg.collectData = function() {
|
if ("" != $("#licenseTime").val()){
|
this.set('licenseTime')
|
}
|
if ("" != $("#licenseStartTime").val()){
|
this.set('licenseStartTime')
|
}
|
if ("" != $("#licenseEndTime").val()){
|
this.set('licenseEndTime')
|
}
|
if ("" != $("#setupTime").val()){
|
this.set('setupTime')
|
}
|
this
|
.set('id')
|
.set('isSpe')
|
.set('isTaxi')
|
.set('isCross')
|
.set('isCrossLogistics')
|
.set('isSameLogistics')
|
.set('isCharter')
|
.set('isSpeFixedOrProportional')
|
.set('isTaxiFixedOrProportional')
|
.set('isCrossLogisticsFixedOrProportional')
|
.set('isSameLogisticsFixedOrProportional')
|
.set('speMoney')
|
.set('taxiMoney')
|
.set('crossLogisticsMoney')
|
.set('sameLogisticsMoney')
|
|
.set('name')
|
.set('type')
|
.set('superiorId')
|
.set('principalName')
|
.set('principalPhone')
|
.set('adminName')
|
.set('adminPhone')
|
.set('urgentPhoen')
|
.set('identifier')
|
.set('addressCode')
|
.set('businessScope')
|
.set('contactAddress')
|
.set('documentAddress')
|
.set('economicType')
|
.set('regCapital')
|
.set('legalName')
|
.set('legalId')
|
.set('legalPhone')
|
.set('legalPhotoUrl')
|
.set('licensingAgency')
|
.set('licenseNumber')
|
.set('carNum')
|
.set('driverNum')
|
.set('mac')
|
.set('state')
|
.set('flag')
|
.set('upload')
|
.set('detailAddress')
|
.set('code')
|
.set('scopeCode')
|
.set('idCardPositive')
|
.set('idCardReverse')
|
.set('fixedDeduction')
|
.set('percentageDeduction')
|
.set('driverRestriction')
|
.set('serviceScope');
|
}
|
|
/**
|
* 提交添加
|
*/
|
FranchiseeInfoDlg.addFranchisee = function() {
|
|
this.clearData();
|
this.collectData();
|
if(!this.validate()){
|
return ;
|
}
|
var serverBox =[];
|
$('input[name="checkbox"]:checked').each(function(){
|
serverBox.push($(this).val());
|
});
|
if (serverBox.length == 0){
|
Feng.info("请选择经营业务!");
|
return;
|
}
|
var checkbox2 = $('#checkbox2').prop('checked');
|
|
let fixedDeduction = $('#fixedDeduction').val();
|
regexp(fixedDeduction, "固定费用")
|
|
let percentageDeduction = $('#percentageDeduction').val();
|
regexp(percentageDeduction, "线上下单扣除")
|
|
let driverRestriction = $('#driverRestriction').val();
|
regexp(driverRestriction, "司机接单限制")
|
|
|
var b = false;
|
var waitFee = '{';
|
$('.waitFee input[type="text"]').each(function(){
|
var value = $(this).val();
|
if('' == value){
|
b = true;
|
Feng.info("请填写完整配置");
|
return
|
}
|
waitFee = waitFee + '"'+$(this)[0].name+'":"'+value+'",';
|
});
|
waitFee = waitFee.substring(0,waitFee.length-1);
|
waitFee += '}';
|
console.log(waitFee);
|
|
var p1 = '{';
|
$('.p1 input[type="text"]').each(function(){
|
var value = $(this).val();
|
if('' == value){
|
b = true;
|
Feng.info("请填写完整配置");
|
return
|
}
|
p1 = p1 + '"'+$(this)[0].name+'":"'+value+'",';
|
});
|
p1 = p1.substring(0,p1.length-1);
|
p1 += '}';
|
console.log(p1);
|
if(b){
|
return
|
}
|
|
var p2 = '{';
|
$('.p2 input[type="text"]').each(function(){
|
var value = $(this).val();
|
if('' == value){
|
b = true;
|
Feng.info("请填写完整配置");
|
return
|
}
|
p2 = p2 + '"'+$(this)[0].name+'":"'+value+'",';
|
});
|
p2 = p2.substring(0,p2.length-1);
|
p2 += '}';
|
console.log(p2);
|
if(b){
|
return
|
}
|
|
var p3 = '{';
|
$('.p3 input[type="text"]').each(function(){
|
var value = $(this).val();
|
if('' == value){
|
b = true;
|
Feng.info("请填写完整配置");
|
return
|
}
|
p3 = p3 + '"'+$(this)[0].name+'":"'+value+'",';
|
});
|
p3 = p3.substring(0,p3.length-1);
|
p3 += '}';
|
console.log(p3);
|
if(b){
|
return
|
}
|
|
var wp1 = '{';
|
$('.wp1 input[type="text"]').each(function(){
|
var value = $(this).val();
|
if('' == value){
|
b = true;
|
Feng.info("请填写完整配置");
|
return
|
}
|
wp1 = wp1 + '"'+$(this)[0].name+'":"'+value+'",';
|
});
|
wp1 = wp1.substring(0,wp1.length-1);
|
wp1 += '}';
|
console.log(wp1);
|
if(b){
|
return
|
}
|
|
var wp2 = '{';
|
$('.wp2 input[type="text"]').each(function(){
|
var value = $(this).val();
|
if('' == value){
|
b = true;
|
Feng.info("请填写完整配置");
|
return
|
}
|
wp2 = wp2 + '"'+$(this)[0].name+'":"'+value+'",';
|
});
|
wp2 = wp2.substring(0,wp2.length-1);
|
wp2 += '}';
|
console.log(wp2);
|
if(b){
|
return
|
}
|
|
var wp3 = '{';
|
$('.wp3 input[type="text"]').each(function(){
|
var value = $(this).val();
|
if('' == value){
|
b = true;
|
Feng.info("请填写完整配置");
|
return
|
}
|
wp3 = wp3 + '"'+$(this)[0].name+'":"'+value+'",';
|
});
|
wp3 = wp3.substring(0,wp3.length-1);
|
wp3 += '}';
|
console.log(wp3);
|
if(b){
|
return
|
}
|
|
var contentExclusive = '{';
|
//拼接数据
|
$(".exclusivePriceSettings input[type='text']").each(function(){
|
var value = $(this).val();
|
if('' == value){
|
b = true;
|
Feng.info("请填写完整配置");
|
return
|
}
|
contentExclusive = contentExclusive + '"'+$(this)[0].name+'":"'+value+'",';
|
});
|
contentExclusive = contentExclusive.substring(0,contentExclusive.length-1);
|
contentExclusive += '}';
|
console.log(contentExclusive);
|
if(b){
|
return
|
}
|
|
var contentPrice = '{';
|
//拼接数据
|
$(".onePriceSetting input[type='text']").each(function(){
|
var value = $(this).val();
|
if('' == value){
|
b = true;
|
Feng.info("请填写完整配置");
|
return
|
}
|
contentPrice = contentPrice + '"'+$(this)[0].name+'":"'+value+'",';
|
});
|
contentPrice = contentPrice.substring(0,contentPrice.length-1);
|
contentPrice += '}';
|
console.log(contentPrice);
|
if(b){
|
return
|
}
|
|
var content = '{';
|
//拼接数据
|
$(".content input[type='text']").each(function(){
|
var value = $(this).val();
|
if('' == value){
|
b = true;
|
Feng.info("请填写完整配置");
|
return
|
}
|
content = content + '"'+$(this)[0].name+'":"'+value+'",';
|
});
|
content = content.substring(0,content.length-1);
|
content += '}';
|
console.log(content);
|
if(b){
|
return
|
}
|
//提交信息
|
var ajax = new $ax(Feng.ctxPath + "/tCompany/addFranchisee", function(data){
|
if ("error" == data){
|
Feng.error("登录账户已存在,请重新输入");
|
return;
|
}
|
Feng.success("添加成功!");
|
window.parent.Franchisee.table.refresh();
|
FranchiseeInfoDlg.close();
|
},function(data){
|
Feng.error("添加失败!" + data.responseJSON.message + "!");
|
});
|
ajax.set(FranchiseeInfoDlg.franchiseeInfoData);
|
ajax.set("isTaxi",1);
|
ajax.set("account",$("#account").val());
|
ajax.set("password",$("#password").val());
|
ajax.set("content",content);
|
ajax.start();
|
}
|
|
/**
|
* 提交修改
|
*/
|
FranchiseeInfoDlg.updateFranchisee = function() {
|
|
this.clearData();
|
this.collectData();
|
if(!this.validate()){
|
return ;
|
}
|
var serverBox =[];
|
$('input[name="checkbox"]:checked').each(function(){
|
serverBox.push($(this).val());
|
});
|
if (serverBox.length == 0){
|
Feng.info("请选择经营业务!");
|
return;
|
}
|
var checkbox2 = $('#checkbox2').prop('checked');
|
if (checkbox2) {
|
var cz = $("input[name='cz']:checked").val();
|
if (1 == cz){
|
var czPercent = $("#czPercent").val();
|
if ("" == czPercent){
|
Feng.info("出租车比例抽成不能为空!");
|
return;
|
}else if (!regDouble.test(czPercent)) {
|
Feng.info("出租车比例抽成格式不正确!");
|
return;
|
}
|
}else if (2 == cz){
|
var czMoney = $("#czMoney").val();
|
if ("" == czMoney){
|
Feng.info("出租车固定金额抽成不能为空!");
|
return;
|
}else if (!regDouble.test(czMoney)) {
|
Feng.info("出租车固定金额抽成格式不正确!");
|
return;
|
}
|
}
|
}
|
|
let fixedDeduction = $('#fixedDeduction').val();
|
regexp(fixedDeduction, "固定费用")
|
|
let percentageDeduction = $('#percentageDeduction').val();
|
regexp(percentageDeduction, "线上下单扣除")
|
|
let driverRestriction = $('#driverRestriction').val();
|
regexp(driverRestriction, "司机接单限制")
|
|
|
var b = false;
|
var waitFee = '{';
|
$('.waitFee input[type="text"]').each(function(){
|
var value = $(this).val();
|
if('' == value){
|
b = true;
|
Feng.info("请填写完整配置");
|
return
|
}
|
waitFee = waitFee + '"'+$(this)[0].name+'":"'+value+'",';
|
});
|
waitFee = waitFee.substring(0,waitFee.length-1);
|
waitFee += '}';
|
console.log(waitFee);
|
|
var p1 = '{';
|
$('.p1 input[type="text"]').each(function(){
|
var value = $(this).val();
|
if('' == value){
|
b = true;
|
Feng.info("请填写完整配置");
|
return
|
}
|
p1 = p1 + '"'+$(this)[0].name+'":"'+value+'",';
|
});
|
p1 = p1.substring(0,p1.length-1);
|
p1 += '}';
|
console.log(p1);
|
if(b){
|
return
|
}
|
|
var p2 = '{';
|
$('.p2 input[type="text"]').each(function(){
|
var value = $(this).val();
|
if('' == value){
|
b = true;
|
Feng.info("请填写完整配置");
|
return
|
}
|
p2 = p2 + '"'+$(this)[0].name+'":"'+value+'",';
|
});
|
p2 = p2.substring(0,p2.length-1);
|
p2 += '}';
|
console.log(p2);
|
if(b){
|
return
|
}
|
|
var p3 = '{';
|
$('.p3 input[type="text"]').each(function(){
|
var value = $(this).val();
|
if('' == value){
|
b = true;
|
Feng.info("请填写完整配置");
|
return
|
}
|
p3 = p3 + '"'+$(this)[0].name+'":"'+value+'",';
|
});
|
p3 = p3.substring(0,p3.length-1);
|
p3 += '}';
|
console.log(p3);
|
if(b){
|
return
|
}
|
|
var wp1 = '{';
|
$('.wp1 input[type="text"]').each(function(){
|
var value = $(this).val();
|
if('' == value){
|
b = true;
|
Feng.info("请填写完整配置");
|
return
|
}
|
wp1 = wp1 + '"'+$(this)[0].name+'":"'+value+'",';
|
});
|
wp1 = wp1.substring(0,wp1.length-1);
|
wp1 += '}';
|
console.log(wp1);
|
if(b){
|
return
|
}
|
|
var wp2 = '{';
|
$('.wp2 input[type="text"]').each(function(){
|
var value = $(this).val();
|
if('' == value){
|
b = true;
|
Feng.info("请填写完整配置");
|
return
|
}
|
wp2 = wp2 + '"'+$(this)[0].name+'":"'+value+'",';
|
});
|
wp2 = wp2.substring(0,wp2.length-1);
|
wp2 += '}';
|
console.log(wp2);
|
if(b){
|
return
|
}
|
|
var wp3 = '{';
|
$('.wp3 input[type="text"]').each(function(){
|
var value = $(this).val();
|
if('' == value){
|
b = true;
|
Feng.info("请填写完整配置");
|
return
|
}
|
wp3 = wp3 + '"'+$(this)[0].name+'":"'+value+'",';
|
});
|
wp3 = wp3.substring(0,wp3.length-1);
|
wp3 += '}';
|
console.log(wp3);
|
if(b){
|
return
|
}
|
|
var contentExclusive = '{';
|
//拼接数据
|
$(".exclusivePriceSettings input[type='text']").each(function(){
|
var value = $(this).val();
|
if('' == value){
|
b = true;
|
Feng.info("请填写完整配置");
|
return
|
}
|
contentExclusive = contentExclusive + '"'+$(this)[0].name+'":"'+value+'",';
|
});
|
contentExclusive = contentExclusive.substring(0,contentExclusive.length-1);
|
contentExclusive += '}';
|
console.log(contentExclusive);
|
if(b){
|
return
|
}
|
|
var contentPrice = '{';
|
//拼接数据
|
$(".onePriceSetting input[type='text']").each(function(){
|
var value = $(this).val();
|
if('' == value){
|
b = true;
|
Feng.info("请填写完整配置");
|
return
|
}
|
contentPrice = contentPrice + '"'+$(this)[0].name+'":"'+value+'",';
|
});
|
contentPrice = contentPrice.substring(0,contentPrice.length-1);
|
contentPrice += '}';
|
console.log(contentPrice);
|
if(b){
|
return
|
}
|
var content = '{';
|
//拼接数据
|
$(".content input[type='text']").each(function(){
|
var value = $(this).val();
|
if('' == value){
|
b = true;
|
Feng.info("请填写完整配置");
|
return
|
}
|
content = content + '"'+$(this)[0].name+'":"'+value+'",';
|
});
|
content = content.substring(0,content.length-1);
|
content += '}';
|
console.log(content);
|
if(b){
|
return
|
}
|
|
//提交信息
|
var ajax = new $ax(Feng.ctxPath + "/tCompany/updateFranchisee", function(data){
|
if ("error" == data){
|
Feng.error("登录账户已存在,请重新输入");
|
return;
|
}
|
Feng.success("修改成功!");
|
window.parent.Franchisee.table.refresh();
|
FranchiseeInfoDlg.close();
|
},function(data){
|
Feng.error("修改失败!" + data.responseJSON.message + "!");
|
});
|
ajax.set(FranchiseeInfoDlg.franchiseeInfoData);
|
if (checkbox2){
|
var cz = $("input[name='cz']:checked").val()
|
ajax.set("isTaxiFixedOrProportional",cz);
|
if (1 == cz){
|
ajax.set("taxiMoney",$("#czPercent").val());
|
}else if (2 == cz) {
|
ajax.set("taxiMoney",$("#czMoney").val());
|
}
|
ajax.set("isTaxi",1);
|
}else{
|
ajax.set("isTaxi",2);
|
}
|
ajax.set("account",$("#account").val());
|
ajax.set("password",$("#password").val());
|
ajax.set("userId",$("#userId").val());
|
ajax.set("content",content);
|
ajax.start();
|
}
|
|
$(function() {
|
Feng.initValidator("franchiseeInfoForm", FranchiseeInfoDlg.validateFields);
|
});
|
|
function regexp(value, msg){
|
var reg=/^(\d+.?)?\d{0,2}$/;//由 1-9开头 的正则表达式 整数 两位小数
|
//先判断是否为整数 在判断 是否在 1-总页 整数范围之内
|
if(reg.test(value)){
|
if(value == 0){
|
Feng.error(msg+"请输入大于0的整数或保留两位小数");
|
return;
|
}
|
}else{
|
Feng.error(msg+"请输入整数或保留两位小数");
|
return;
|
}
|
}
|
|
//专车
|
FranchiseeInfoDlg.checkbox1 = function () {
|
var checkbox1 = $('#checkbox1').prop('checked');
|
if (checkbox1){
|
$("#zcDiv").show();
|
} else {
|
$("#zcDiv").hide();
|
}
|
}
|
//出租车
|
FranchiseeInfoDlg.checkbox2 = function () {
|
var checkbox2 = $('#checkbox2').prop('checked');
|
if (checkbox2){
|
$("#czDiv").show();
|
} else {
|
$("#czDiv").hide();
|
}
|
}
|
//跨城出行
|
FranchiseeInfoDlg.checkbox3 = function () {
|
var checkbox3 = $('#checkbox3').prop('checked');
|
if (checkbox3){
|
$("#kcDiv").show();
|
} else {
|
$("#kcDiv").hide();
|
}
|
}
|
//同城小件物流
|
FranchiseeInfoDlg.checkbox4 = function () {
|
var checkbox4 = $('#checkbox4').prop('checked');
|
if (checkbox4){
|
$("#tcxDiv").show();
|
} else {
|
$("#tcxDiv").hide();
|
}
|
}
|
//跨城小件物流
|
FranchiseeInfoDlg.checkbox5 = function () {
|
var checkbox5 = $('#checkbox5').prop('checked');
|
if (checkbox5){
|
$("#kcxDiv").show();
|
} else {
|
$("#kcxDiv").hide();
|
}
|
}
|
//包车
|
FranchiseeInfoDlg.checkbox6 = function () {
|
var checkbox6 = $('#checkbox6').prop('checked');
|
if (checkbox6){
|
$("#bcDiv").show();
|
} else {
|
$("#bcDiv").hide();
|
}
|
}
|