/**
|
* 初始化快车价格设置详情对话框
|
*/
|
var TSystemPriceInfoDlg = {
|
tSystemPriceInfoData : {},
|
};
|
|
|
|
function checkedLable(e) {
|
$(e).attr('class', 'lab checked');
|
let tag = $(e).attr('tag');
|
$('.' + tag).show();
|
$(e).siblings().each(function (i, el) {
|
$(el).attr('class', 'lab');
|
let tag1 = $(el).attr('tag');
|
$('.' + tag1).hide();
|
})
|
}
|
|
function chooseCarpool(e, t){
|
if(t == 1){
|
$(e).attr('class', 'people');
|
$(e).siblings().each(function (i, el) {
|
$(el).removeAttr('class');
|
})
|
}
|
if(t == 2){
|
$(e).attr('class', 'carpool');
|
$(e).siblings().each(function (i, el) {
|
$(el).removeAttr('class');
|
})
|
}
|
let people = $('.shareSeatPriceSetting .people').attr('tag');
|
let carpool = $('.shareSeatPriceSetting .carpool').attr('tag');
|
if(people == 1){
|
if(carpool == 'spell'){
|
$('.p1').show();
|
$('.p1').siblings().each(function (i, el) {
|
$(el).hide();
|
})
|
}
|
if(carpool == 'notSpelled'){
|
$('.wp1').show();
|
$('.wp1').siblings().each(function (i, el) {
|
$(el).hide();
|
})
|
}
|
}
|
if(people == 2){
|
if(carpool == 'spell'){
|
$('.p2').show();
|
$('.p2').siblings().each(function (i, el) {
|
$(el).hide();
|
})
|
}
|
if(carpool == 'notSpelled'){
|
$('.wp2').show();
|
$('.wp2').siblings().each(function (i, el) {
|
$(el).hide();
|
})
|
}
|
}
|
if(people == 3){
|
if(carpool == 'spell'){
|
$('.p3').show();
|
$('.p3').siblings().each(function (i, el) {
|
$(el).hide();
|
})
|
}
|
if(carpool == 'notSpelled'){
|
$('.wp3').show();
|
$('.wp3').siblings().each(function (i, el) {
|
$(el).hide();
|
})
|
}
|
}
|
}
|
|
|
/**
|
* 验证数据是否为空
|
*/
|
TSystemPriceInfoDlg.validate = function () {
|
$('#specialPriceInfoForm').data("bootstrapValidator").resetForm();
|
$('#specialPriceInfoForm').bootstrapValidator('validate');
|
return $("#specialPriceInfoForm").data('bootstrapValidator').isValid();
|
};
|
|
/**
|
* 清除数据
|
*/
|
TSystemPriceInfoDlg.clearData = function() {
|
this.tSystemPriceInfoData = {};
|
}
|
|
/**
|
* 设置对话框中的数据
|
*
|
* @param key 数据的名称
|
* @param val 数据的具体值
|
*/
|
TSystemPriceInfoDlg.set = function(key, val) {
|
this.tSystemPriceInfoData[key] = (typeof val == "undefined") ? $("#" + key).val() : val;
|
return this;
|
}
|
|
/**
|
* 设置对话框中的数据
|
*
|
* @param key 数据的名称
|
* @param val 数据的具体值
|
*/
|
TSystemPriceInfoDlg.get = function(key) {
|
return $("#" + key).val();
|
}
|
|
/**
|
* 关闭此对话框
|
*/
|
TSystemPriceInfoDlg.close = function() {
|
parent.layer.close(window.parent.TSystemPrice.layerIndex);
|
}
|
|
/**
|
* 收集数据
|
*/
|
TSystemPriceInfoDlg.collectData = function() {
|
this
|
.set('id')
|
.set('type')
|
.set('companyId')
|
.set('serverCarModelId')
|
.set('fareTypeNote')
|
.set('content');
|
}
|
|
/**
|
* 提交添加
|
*/
|
TSystemPriceInfoDlg.addSubmit = function() {
|
let serverCarModelId = $('#serverCarModelId').val();
|
if(null == serverCarModelId){
|
Feng.error("请选择车型");
|
return
|
}
|
|
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
|
}
|
|
let fareTypeNote1 = $('#fareTypeNote1').val();
|
let isOpen = $('#isOpen').is(":checked");
|
if (isOpen){
|
isOpen = 1;
|
} else {
|
isOpen = 2;
|
}
|
|
let fareTypeNote2 = $('#fareTypeNote2').val();
|
let isOpenExclusive = $('#isOpenExclusive').is(":checked");
|
if (isOpenExclusive){
|
isOpenExclusive = 1;
|
} else {
|
isOpenExclusive = 2;
|
}
|
|
let fareTypeNote3 = $('#fareTypeNote3').val();
|
let isOpenPrice = $('#isOpenPrice').is(":checked");
|
if (isOpenPrice){
|
isOpenPrice = 1;
|
} else {
|
isOpenPrice = 2;
|
}
|
|
|
//提交信息
|
var ajax = new $ax(Feng.ctxPath + "/tSystemPrice/add", function(data){
|
if (500 == data.code){
|
Feng.error(data.message);
|
return;
|
}else{
|
Feng.success("添加成功!");
|
window.parent.TSystemPrice.table.refresh();
|
TSystemPriceInfoDlg.close();
|
}
|
},function(data){
|
Feng.error("添加失败!" + data.responseJSON.message + "!");
|
});
|
ajax.setData({
|
serverCarModelId: serverCarModelId,
|
content: waitFee,
|
fareTypeNote1: fareTypeNote1,
|
fareTypeNote2: fareTypeNote2,
|
fareTypeNote3: fareTypeNote3,
|
contentPutOne: p1,
|
contentNotOne: wp1,
|
contentPutTwo: p2,
|
contentNotTwo: wp2,
|
contentPutThree: p3,
|
contentNotThree: wp3,
|
contentExclusive: contentExclusive,
|
contentPrice: contentPrice,
|
isOpen: isOpen,
|
isOpenExclusive: isOpenExclusive,
|
isOpenPrice: isOpenPrice
|
})
|
ajax.start();
|
}
|
|
/**
|
* 提交修改
|
*/
|
TSystemPriceInfoDlg.editSubmit = function() {
|
let serverCarModelId = $('#serverCarModelId').val();
|
if(null == serverCarModelId){
|
Feng.error("请选择车型");
|
return
|
}
|
|
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
|
}
|
|
let fareTypeNote1 = $('#fareTypeNote1').val();
|
let isOpen = $('#isOpen').is(":checked");
|
if (isOpen){
|
isOpen = 1;
|
} else {
|
isOpen = 2;
|
}
|
|
let fareTypeNote2 = $('#fareTypeNote2').val();
|
let isOpenExclusive = $('#isOpenExclusive').is(":checked");
|
if (isOpenExclusive){
|
isOpenExclusive = 1;
|
} else {
|
isOpenExclusive = 2;
|
}
|
|
let fareTypeNote3 = $('#fareTypeNote3').val();
|
let isOpenPrice = $('#isOpenPrice').is(":checked");
|
if (isOpenPrice){
|
isOpenPrice = 1;
|
} else {
|
isOpenPrice = 2;
|
};
|
//提交信息
|
var ajax = new $ax(Feng.ctxPath + "/tSystemPrice/update", function(data){
|
if (500 == data.code){
|
Feng.error(data.message);
|
return;
|
}else {
|
Feng.success("修改成功!");
|
window.parent.TSystemPrice.table.refresh();
|
TSystemPriceInfoDlg.close();
|
}
|
},function(data){
|
Feng.error("修改失败!" + data.responseJSON.message + "!");
|
});
|
ajax.setData({
|
id: $('#id').val(),
|
serverCarModelId: serverCarModelId,
|
content: waitFee,
|
fareTypeNote1: fareTypeNote1,
|
fareTypeNote2: fareTypeNote2,
|
fareTypeNote3: fareTypeNote3,
|
contentPutOne: p1,
|
contentNotOne: wp1,
|
contentPutTwo: p2,
|
contentNotTwo: wp2,
|
contentPutThree: p3,
|
contentNotThree: wp3,
|
contentExclusive: contentExclusive,
|
contentPrice: contentPrice,
|
isOpen: isOpen,
|
isOpenExclusive: isOpenExclusive,
|
isOpenPrice: isOpenPrice
|
})
|
ajax.start();
|
}
|
|
$(function() {
|
var elem1 = document.querySelector(".js-switch1");
|
var init = new Switchery(elem1);
|
var elem2 = document.querySelector(".js-switch2");
|
var init1 = new Switchery(elem2);
|
var elem3 = document.querySelector(".js-switch3");
|
var init1 = new Switchery(elem3);
|
Feng.initValidator("specialPriceInfoForm", TSystemPriceInfoDlg.validateFields);
|
});
|