/**
|
* 顺风车设置管理初始化
|
*/
|
var AppParamRide = {
|
id: "AppParamRideTable", //表格id
|
seItem: null, //选中的条目
|
table: null,
|
layerIndex: -1
|
};
|
|
/**
|
* 初始化表格的列
|
*/
|
AppParamRide.initColumn = function () {
|
return [
|
{field: 'selectItem', radio: true},
|
{title: '', field: 'id', visible: true, align: 'center', valign: 'middle'},
|
{title: '1价格设置,2平台抽成,3乘客退单,4司机退单', field: 'type', visible: true, align: 'center', valign: 'middle'},
|
{title: '数量类型(1到8)', field: 'numType', visible: true, align: 'center', valign: 'middle'},
|
{title: '距离类型(1-100,100-200,200-500,500-800,800以上)', field: 'distanceType', visible: true, align: 'center', valign: 'middle'},
|
{title: '内容 ', field: 'context', visible: true, align: 'center', valign: 'middle'},
|
{title: '描述', field: 'remark', visible: true, align: 'center', valign: 'middle'},
|
{title: '', field: 'openCityId', visible: true, align: 'center', valign: 'middle'}
|
];
|
};
|
|
/**
|
* 检查是否选中
|
*/
|
AppParamRide.check = function () {
|
var selected = $('#' + this.id).bootstrapTable('getSelections');
|
if(selected.length == 0){
|
Feng.info("请先选中表格中的某一记录!");
|
return false;
|
}else{
|
AppParamRide.seItem = selected[0];
|
return true;
|
}
|
};
|
|
/**
|
* 点击添加顺风车设置
|
*/
|
AppParamRide.openAddAppParamRide = function () {
|
var index = layer.open({
|
type: 2,
|
title: '添加顺风车设置',
|
area: ['800px', '420px'], //宽高
|
fix: false, //不固定
|
maxmin: true,
|
content: Feng.ctxPath + '/appParamRide/appParamRide_add'
|
});
|
this.layerIndex = index;
|
};
|
|
/**
|
* 打开查看顺风车设置详情
|
*/
|
AppParamRide.openAppParamRideDetail = function () {
|
if (this.check()) {
|
var index = layer.open({
|
type: 2,
|
title: '顺风车设置详情',
|
area: ['800px', '420px'], //宽高
|
fix: false, //不固定
|
maxmin: true,
|
content: Feng.ctxPath + '/appParamRide/appParamRide_update/' + AppParamRide.seItem.id
|
});
|
this.layerIndex = index;
|
}
|
};
|
|
/**
|
* 删除顺风车设置
|
*/
|
AppParamRide.delete = function () {
|
if (this.check()) {
|
var ajax = new $ax(Feng.ctxPath + "/appParamRide/delete", function (data) {
|
Feng.success("删除成功!");
|
AppParamRide.table.refresh();
|
}, function (data) {
|
Feng.error("删除失败!" + data.responseJSON.message + "!");
|
});
|
ajax.set("appParamRideId",this.seItem.id);
|
ajax.start();
|
}
|
};
|
|
/**
|
* 每一个输入项验证
|
* @param type
|
* @returns {boolean}
|
*/
|
AppParamRide.validate = function (type) {
|
var ok=true;
|
var okN=true;
|
var reg_=/(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/;
|
if(type==1){//价格设置
|
$(".price").each(function () {
|
if($(this).val()==null || $(this).val()==''){
|
okN=false;
|
}
|
if(!reg_.test($(this).val())){
|
ok=false;
|
}
|
})
|
}else if(type==2){//平台抽成
|
$(".commission").each(function () {
|
if($(this).val()==null || $(this).val()==''){
|
okN=false;
|
}
|
if(!reg_.test($(this).val())){
|
ok=false;
|
}
|
})
|
}else if(type==3){//乘客退单
|
if($("#paramTD1").val()==null || $("#paramTD1").val()==''){
|
okN=false;
|
}
|
if(!reg_.test($("#paramTD1").val())){
|
ok=false;
|
}
|
}else if(type==4){//司机退单
|
if($("#paramTD2").val()==null || $("#paramTD2").val()==''){
|
okN=false;
|
}
|
if(!reg_.test($("#paramTD2").val())){
|
ok=false;
|
}
|
}
|
if(!okN){
|
Feng.info("各项不能为空");
|
return false;
|
}
|
if(!ok){
|
Feng.info("数值格式不正确");
|
}
|
return ok;
|
};
|
/**
|
* 清除数据
|
*/
|
AppParamRide.clearData = function() {
|
this.setInfoInfoData = {};
|
}
|
|
/**
|
* 收集数据
|
*/
|
AppParamRide.collectData = function(type) {
|
var content="";
|
if(type==1){//顺风车价格设置
|
content='{"person1":"'+$('#person11').val()+'","person2":"'+$('#person12').val()+'","person3":"'+$('#person13').val()+'","person4":"'+$('#person14').val()
|
+'","person5":"'+$('#person15').val()+'","person6":"'+$('#person16').val()+'","person7":"'+$('#person17').val()+'","person8":"'+$('#person18').val()+'"}'+"-";
|
content+='{"person1":"'+$('#person21').val()+'","person2":"'+$('#person22').val()+'","person3":"'+$('#person23').val()+'","person4":"'+$('#person24').val()
|
+'","person5":"'+$('#person25').val()+'","person6":"'+$('#person26').val()+'","person7":"'+$('#person27').val()+'","person8":"'+$('#person28').val()+'"}'+"-";
|
content+='{"person1":"'+$('#person31').val()+'","person2":"'+$('#person32').val()+'","person3":"'+$('#person33').val()+'","person4":"'+$('#person34').val()
|
+'","person5":"'+$('#person35').val()+'","person6":"'+$('#person36').val()+'","person7":"'+$('#person37').val()+'","person8":"'+$('#person38').val()+'"}'+"-";
|
content+='{"person1":"'+$('#person41').val()+'","person2":"'+$('#person42').val()+'","person3":"'+$('#person43').val()+'","person4":"'+$('#person44').val()
|
+'","person5":"'+$('#person45').val()+'","person6":"'+$('#person46').val()+'","person7":"'+$('#person47').val()+'","person8":"'+$('#person48').val()+'"}'+"-";
|
content+='{"person1":"'+$('#person51').val()+'","person2":"'+$('#person52').val()+'","person3":"'+$('#person53').val()+'","person4":"'+$('#person54').val()
|
+'","person5":"'+$('#person55').val()+'","person6":"'+$('#person56').val()+'","person7":"'+$('#person57').val()+'","person8":"'+$('#person58').val()+'"}';
|
|
}else if(type==2) {//平台抽成
|
content='{"commission1":"'+$('#commission1').val()+'","commission2":"'+$('#commission2').val()+'","commission3":"'+$('#commission3').val()+'","commission4":"'+$('#commission4').val()
|
+'","commission5":"'+$('#commission5').val()+'","commission6":"'+$('#commission6').val()+'","commission7":"'+$('#commission7').val()+'","commission8":"'+$('#commission8').val()+'"}';
|
}else if(type==3){//乘客退单
|
content=$("#paramTD1").val();
|
}else if(type==4){//司机退单
|
content=$("#paramTD2").val();
|
}
|
this.setInfoInfoData['context'] = content;
|
this.setInfoInfoData['type'] = type;
|
}
|
/**
|
* 提交添加
|
*/
|
AppParamRide.editSubmit = function(type) {
|
|
this.clearData();
|
this.collectData(type);
|
if (!this.validate(type)) {
|
return;
|
}
|
|
//提交信息
|
var ajax = new $ax(Feng.ctxPath + "/appParamRide/update", function(data){
|
Feng.success("修改成功!");
|
},function(data){
|
Feng.error("修改失败!" + data.responseJSON.message + "!");
|
});
|
ajax.set(this.setInfoInfoData);
|
ajax.start();
|
}
|
/**
|
* 点击获取数据
|
* @param typeName
|
* @param type
|
*/
|
AppParamRide.titleClick=function(typeName,type){
|
//重置
|
//this.resetSearch();
|
for(var i=1;i<=4;i++){
|
$("#titleDivU"+i+"").removeClass("titleItemCk");
|
$("#titleDivU"+i+"Form").hide();
|
}
|
$("#"+typeName).addClass("titleItemCk");
|
$("#"+typeName+"Form").show();
|
$.ajax({
|
type: "post",
|
url: Feng.ctxPath + "/appParamRide/getContentByType",
|
async: false,
|
data: {"type": type},
|
success: function (data) {
|
if(type==1){//价格设置
|
var content="";
|
var values=["0-99(公里)","100-199(公里)","200-499(公里)","500-799(公里)","800(公里)以上"];
|
for(var i = 0 ;i<data.length;i++){
|
var context= eval('('+data[i].context+')');
|
var contentTr="<tr>";
|
contentTr+="<td>"+values[i]+"</td>"
|
for(var j= 1;j<9;j++){
|
contentTr+="<td style=\"text-align: center\"><input value='"+context["person"+j]+"' id='person"+(i+1)+j+"' class=\"price\" style='width: 120px'></td>"
|
}
|
contentTr+="</tr>";
|
content+=contentTr;
|
}
|
$(".gridtable tr:gt(0)").empty();
|
$("#thContent").after(content);
|
}else if(type==2){//平台抽成
|
var context= eval('('+data[0].context+')');
|
for(var j= 1;j<9;j++){
|
$("#commission"+j+"").val(context["commission"+j]);
|
}
|
}else if(type==3){//乘客退单
|
$("#paramTD1").val(data[0].context);
|
}else if(type==4){//司机退单
|
$("#paramTD2").val(data[0].context);
|
}
|
}
|
});
|
}
|
/**
|
* 查询顺风车设置列表
|
*/
|
AppParamRide.search = function () {
|
var queryData = {};
|
queryData['condition'] = $("#condition").val();
|
AppParamRide.table.refresh({query: queryData});
|
};
|
|
$(function () {
|
AppParamRide.titleClick('titleDivU1',1);
|
});
|