liujie
2023-08-02 b64d67ef01e81a857046f19dd556b4e4f0695e1c
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
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
/**
 * 初始化车辆管理详情对话框
 */
var language=1;
var TCarInfoDlg = {
    tCarInfoData : {},
    validateFields: {
    }
};
 
/**
 * 验证数据是否为空
 */
TCarInfoDlg.validate = function () {
    $('#carInfoForm').data("bootstrapValidator").resetForm();
    $('#carInfoForm').bootstrapValidator('validate');
    return $("#carInfoForm").data('bootstrapValidator').isValid();
};
 
/**
 * 清除数据
 */
TCarInfoDlg.clearData = function() {
    this.tCarInfoData = {};
}
 
/**
 * 设置对话框中的数据
 *
 * @param key 数据的名称
 * @param val 数据的具体值
 */
TCarInfoDlg.set = function(key, val) {
    this.tCarInfoData[key] = (typeof val == "undefined") ? $("#" + key).val() : val;
    return this;
}
 
/**
 * 设置对话框中的数据
 *
 * @param key 数据的名称
 * @param val 数据的具体值
 */
TCarInfoDlg.get = function(key) {
    return $("#" + key).val();
}
 
/**
 * 关闭此对话框
 */
TCarInfoDlg.close = function() {
    parent.layer.close(window.parent.TCompetition.layerIndex);
}
 
/**
 * 收集数据
 */
TCarInfoDlg.collectData = function() {
    this
    .set('id')
    .set('isPlatCar')
    .set('companyId')
    .set('franchiseeId')
    .set('carColor')
    .set('carModelId')
    .set('carBrandId')
    .set('carLicensePlate')
    .set('carPhoto')
    .set('drivingLicenseNumber')
    .set('drivingLicensePhoto')
    .set('annualInspectionTime')
    .set('commercialInsuranceTime')
    .set('createTime')
    .set('state')
    .set('addType')
    .set('addObjectId')
    .set('plateColor')
    .set('vehicleType')
    .set('ownerName')
    .set('engineId')
    .set('VIN')
    .set('certifyDateA')
    .set('fuelType')
    .set('engineDisplace')
    .set('certificate')
    .set('transAgency')
    .set('transArea')
    .set('transDateStart')
    .set('transDateStop')
    .set('certifyDateB')
    .set('fixState')
    .set('nextFixDate')
    .set('checkState')
    .set('feePrintId')
    .set('GPSBrand')
    .set('GPSModel')
    .set('GPSIMEI')
    .set('GPSInstallDate')
    .set('registerDate')
    .set('commercialType');
}
 
/**
 * 提交添加
 */
TCarInfoDlg.addSubmit = function() {
 
    this.clearData();
    this.collectData();
    if(!this.validate()){
        return ;
    }
 
    let pCode = $("#pCode").val()
    let cCode = $("#cCode").val()
    let name = $("#name").val()
    let phone = $("#phone").val()
 
    if(pCode==''){
        Feng.info("请选择省")
        return;
    }
    if(cCode==''){
        Feng.info("请选择市")
        return;
    }
    if(name==''){
        Feng.info("管理员姓名不能为空")
        return;
    }
    if(phone==''){
        Feng.info("管理员手机号不能为空")
        return;
    }
 
    //提交信息
    var ajax = new $ax(Feng.ctxPath + "/tCity/add", function(data){
        if(data=="5001"){
            Feng.error("改账号已经存在");
        }else
        if(data.code == 200){
            if(language==1){
                Feng.success("添加成功!");
            }else if(language==2){
                Feng.success("Successfully added!");
            }else {
                Feng.success("Sangat berhasil ditambah!");
            }
            window.parent.TCompetition.table.refresh();
            TCarInfoDlg.close();
        }else{
            Feng.error(data.msg);
        }
 
    },function(data){
        Feng.error("添加失败!" + data.responseJSON.message + "!");
    });
    ajax.set(this.tCarInfoData);
    ajax.set("provinceCode",pCode);
    ajax.set("cityCode",cCode);
    ajax.set("name",name);
    ajax.set("phone",phone);
    ajax.start();
}
 
/**
 * 提交修改
 */
TCarInfoDlg.editSubmit = function() {
 
    this.clearData();
    this.collectData();
    if(!this.validate()){
        return ;
    }
    let pCode = $("#pCode").val()
    let cCode = $("#cCode").val()
    let name = $("#name").val()
    let phone = $("#phone").val()
 
    if(pCode==''){
        Feng.info("请选择省")
        return;
    }
    if(cCode==''){
        Feng.info("请选择市")
        return;
    }
    if(name==''){
        Feng.info("管理员姓名不能为空")
        return;
    }
    if(phone==''){
        Feng.info("管理员手机号不能为空")
        return;
    }
    //提交信息
    var ajax = new $ax(Feng.ctxPath + "/tCity/update", function(data){
        if(data=="5001"){
            Feng.error("改账号已经存在");
        }else
        if(data.code == 200){
            if(language==1){
                Feng.success("修改成功!");
            }else if(language==2){
                Feng.success("Modify successfully!");
            }else {
                Feng.success("Mengubah dengan sukses!");
            }
            window.parent.TCompetition.table.refresh();
            TCarInfoDlg.close();
        }else{
            Feng.error(data.msg);
        }
    },function(data){
        Feng.error("修改失败!" + data.responseJSON.message + "!");
    });
    ajax.set("provinceCode",pCode);
    ajax.set("cityCode",cCode);
    ajax.set("name",name);
    ajax.set("phone",phone);
    ajax.set("id",$("#id").val());
    ajax.start();
}
 
$(function() {
    Feng.initValidator("carInfoForm", TCarInfoDlg.validateFields);
    // 初始化图片上传
    var carPhoto = new $WebUpload("carPhoto");
    carPhoto.setUploadBarId("progressBar");
    carPhoto.init();
    var drivingLicensePhoto = new $WebUpload("drivingLicensePhoto");
    drivingLicensePhoto.setUploadBarId("progressBar");
    drivingLicensePhoto.init();
});
 
/**
 * 选择分公司后执行
 */
TCarInfoDlg.oneChange = function (e) {
    var oneId=$(e).val();
    var ajax = new $ax(Feng.ctxPath + "/tCity/onChange", function(data){
        if(data!=null){
            if(language==1){
                var content='<option value="">选择市</option>';
            }else if(language==2){
                var content='<option value="">Choose your franchisee</option>';
            }else {
                var content='<option value="">Pilih franchisee Anda</option>';
            }
            $.each(data, function(k,v) {
                content += "<option value='"+v.code+"'>"+v.name+"</option>";
            });
            $("#cCode").empty().append(content);
        }
    });
    ajax.set("oneId",oneId);
    ajax.start();
}
 
/**
 * 类型改变执行
 * @param e
 */
TCarInfoDlg.companyTypeClick = function (e) {
    if (1 == e){
        $(".companyDiv").hide();
    } else if (2 == e){
        $(".companyDiv").show();
    }
}
 
/**
 * 车辆品牌改变时执行
 */
TCarInfoDlg.brandChange = function (e) {
    var carBrandId=$(e).val();
    var ajax = new $ax(Feng.ctxPath + "/tCar/brandChange", function(data){
        if(data!=null){
            if(language==1){
                var content='<option value="">选择车辆类型</option>';
            }else if(language==2){
                var content='<option value="">Please select the vehicle type</option>';
            }else {
                var content='<option value="">Pilih Jenis Kendaraan</option>';
            }
 
            $.each(data, function(k,v) {
                content += "<option value='"+v.id+"'>"+v.name+"</option>";
            });
            $("#carModelId").empty().append(content);
        }
    });
    ajax.set("carBrandId",carBrandId);
    ajax.start();
}
 
/**
 * 专车服务被点击
 */
TCarInfoDlg.zcServerClick = function () {
    var serverBox1 = $('#serverBox1').prop('checked');
    if (serverBox1){
        $("#zcModelDiv").show();
    } else {
        $("#zcModelDiv").hide();
    }
}
 
/**
 * 跨城服务被点击
 */
TCarInfoDlg.kcServerClick = function () {
    var serverBox3 = $('#serverBox3').prop('checked');
    if (serverBox3){
        $("#kcModelDiv").show();
    } else {
        $("#kcModelDiv").hide();
    }
}