Pu Zhibing
2025-07-23 2ab5f166d0fad4b1a860fde3bab1adb46d062c3f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
/**
 * 顺风车设置管理初始化
 */
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);
});