Pu Zhibing
2025-08-04 4af0a2ddc8940cd38d0e602409cace1a7c50ea13
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
255
256
257
258
259
260
261
262
/**
 * 初始化城市管理详情对话框
 */
var TOpenCityInfoDlg = {
    tOpenCityInfoData : {},
    editor: null,
    validateFields: {
        areaCode: {
            validators: {
                notEmpty: {
                    message: '请选择省'
                }
            }
        }
    }
};
 
/**
 * 验证数据是否为空
 */
TOpenCityInfoDlg.validate = function () {
    $('#openCityForm').data("bootstrapValidator").resetForm();
    $('#openCityForm').bootstrapValidator('validate');
    return $("#openCityForm").data('bootstrapValidator').isValid();
};
 
 
/**
 * 清除数据
 */
TOpenCityInfoDlg.clearData = function() {
    this.tOpenCityInfoData = {};
}
 
/**
 * 设置对话框中的数据
 *
 * @param key 数据的名称
 * @param val 数据的具体值
 */
TOpenCityInfoDlg.set = function(key, val) {
    this.tOpenCityInfoData[key] = (typeof val == "undefined") ? $("#" + key).val() : val;
    return this;
}
 
/**
 * 设置对话框中的数据
 *
 * @param key 数据的名称
 * @param val 数据的具体值
 */
TOpenCityInfoDlg.get = function(key) {
    return $("#" + key).val();
}
 
/**
 * 关闭此对话框
 */
TOpenCityInfoDlg.close = function() {
    parent.layer.close(window.parent.TOpenCity.layerIndex);
}
 
/**
 * 收集数据
 */
TOpenCityInfoDlg.collectData = function() {
    this
            .set('id')
            .set('areaCode')
            .set('cityCode')
            .set('provinceCode')
}
 
 
TOpenCityInfoDlg.openAddTextPrice = function () {
    var index = layer.open({
        type: 2,
        title: '添加出租车价格',
        area: ['100%', '100%'], //宽高
        fix: false, //不固定
        maxmin: true,
        content: Feng.ctxPath + '/tSystemPrice/taxi?price=' + $('#zc_price').val()
    });
    this.layerIndex = index;
};
 
 
TOpenCityInfoDlg.openAddTZCPrice = function (id){
    var index = layer.open({
        type: 2,
        title: '添加专车价格',
        area: ['100%', '100%'], //宽高
        fix: false, //不固定
        maxmin: true,
        content: Feng.ctxPath + '/tSystemPrice/tSystemPrice_add?id=' + id + "&price=" + $('#' + id).val()
    });
    this.layerIndex = index;
}
 
 
 
 
/**
 * 提交添加
 */
TOpenCityInfoDlg.addSubmit = function() {
    
    this.clearData();
    this.collectData();
    if(!this.validate()){
        return ;
    }
    var zcArr=[];
    $("#coun tr").each(function () {
        var value = $(this).find("input[name='price']").val();
        if('' != value && null != value){
            zcArr.push(JSON.parse(atob(value)))
        }
    });
    if(zcArr.length == 0){
        Feng.error("请配置专车价格")
        return;
    }
    
    console.log(zcArr);
    var zczArr = $('#zc_price').val();
    if(null == zczArr || zczArr == ''){
        Feng.error("请配置出租车价格")
        return;
    }
    if(null != this.tOpenCityInfoData.areaCode && '' != this.tOpenCityInfoData.areaCode){
        this.tOpenCityInfoData.areaName = $('#areaCode').find('option:selected').text();
    }
    if(null != this.tOpenCityInfoData.cityCode && '' != this.tOpenCityInfoData.cityCode){
        this.tOpenCityInfoData.cityName = $('#cityCode').find('option:selected').text();
    }
    if(null != this.tOpenCityInfoData.provinceCode && '' != this.tOpenCityInfoData.provinceCode){
        this.tOpenCityInfoData.provinceName = $('#provinceCode').find('option:selected').text();
    }
    
    //提交信息
    var ajax = new $ax(Feng.ctxPath + "/tSystemPrice/add", function(data){
        Feng.success("添加成功!");
        window.parent.TOpenCity.table.refresh();
        TOpenCityInfoDlg.close();
    },function(data){
        Feng.error("添加失败!" + data.responseJSON.message + "!");
    });
    ajax.set(this.tOpenCityInfoData);
    ajax.set("zcPrice",JSON.stringify(zcArr));
    ajax.set("czcPrice", atob(zczArr));
    ajax.start();
}
 
/**
 * 提交修改
 */
TOpenCityInfoDlg.editSubmit = function() {
    this.clearData();
    this.collectData();
    if(!this.validate()){
        return ;
    }
    var zcArr=[];
    $("#coun tr").each(function () {
        var value = $(this).find("input[name='price']").val();
        if('' != value && null != value){
            zcArr.push(JSON.parse(atob(value)))
        }
    });
    if(zcArr.length == 0){
        Feng.error("请配置专车价格")
        return;
    }
    
    console.log(zcArr);
    var zczArr = $('#zc_price').val();
    if(null == zczArr || zczArr == ''){
        Feng.error("请配置出租车价格")
        return;
    }
    if(null != this.tOpenCityInfoData.areaCode && '' != this.tOpenCityInfoData.areaCode){
        this.tOpenCityInfoData.areaName = $('#areaCode').find('option:selected').text();
    }
    if(null != this.tOpenCityInfoData.cityCode && '' != this.tOpenCityInfoData.cityCode){
        this.tOpenCityInfoData.cityName = $('#cityCode').find('option:selected').text();
    }
    if(null != this.tOpenCityInfoData.provinceCode && '' != this.tOpenCityInfoData.provinceCode){
        this.tOpenCityInfoData.provinceName = $('#provinceCode').find('option:selected').text();
    }
    
    //提交信息
    var ajax = new $ax(Feng.ctxPath + "/tSystemPrice/update", function(data){
        Feng.success("修改成功!");
        window.parent.TOpenCity.table.refresh();
        TOpenCityInfoDlg.close();
    },function(data){
        Feng.error("添加失败!" + data.responseJSON.message + "!");
    });
    ajax.set(this.tOpenCityInfoData);
    ajax.set("zcPrice",JSON.stringify(zcArr));
    ajax.set("czcPrice", atob(zczArr));
    ajax.start();
}
 
$(function() {
    Feng.initValidator("openCityForm", TOpenCityInfoDlg.validateFields);
});
 
/**
 * 省改变时执行
 */
TOpenCityInfoDlg.provinceChange = function () {
    var provinceId = $("#areaCode").val();
    var ajax = new $ax(Feng.ctxPath + "/tOpenCity/change", function(data){
        if(data!=null){
            var content='<option value="">选择市</option>';
            $.each(data, function(k,v) {
                content += "<option value='"+v.id+"'>"+v.name+"</option>";
            });
            $("#cityCode").empty().append(content);
            $("#provinceCode").empty().append('<option value="">选择区</option>');
        }
    });
    ajax.set("id",provinceId);
    ajax.start();
}
/**
 * 市改变时执行
 */
TOpenCityInfoDlg.cityChange = function () {
    var cityId = $("#cityCode").val();
    var ajax = new $ax(Feng.ctxPath + "/tOpenCity/change", function(data){
        if(data!=null){
            var content='<option value="">选择区</option>';
            $.each(data, function(k,v) {
                content += "<option value='"+v.id+"'>"+v.name+"</option>";
            });
            $("#provinceCode").empty().append(content);
        }
    });
    ajax.set("id",cityId);
    ajax.start();
}
 
 
//获取当前时间,格式YYYY-MM-DD
function getNowFormatDate() {
    var date = new Date();
    var seperator1 = "-";
    var year = date.getFullYear();
    var month = date.getMonth() + 1;
    var strDate = date.getDate();
    if (month >= 1 && month <= 9) {
        month = "0" + month;
    }
    if (strDate >= 0 && strDate <= 9) {
        strDate = "0" + strDate;
    }
    var currentdate = year + seperator1 + month + seperator1 + strDate;
    return currentdate;
}