puzhibing
2024-02-05 640ff18d2d7f4be02ddb7f8f75e899f05545eb98
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
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
/**
 * 初始化车辆管理详情对话框
 */
var language=1;
var TSiteInfo = {
    layerIndex: -1,
    validateFields: {
    },
    goodsPicArray:[],
};
 
/**
 * 验证数据是否为空
 */
TSiteInfo.validate = function () {
    $('#carInfoForm').data("bootstrapValidator").resetForm();
    $('#carInfoForm').bootstrapValidator('validate');
    return $("#carInfoForm").data('bootstrapValidator').isValid();
};
 
/**
 * 清除数据
 */
TSiteInfo.clearData = function() {
    this.tCarInfoData = {};
}
 
/**
 * 设置对话框中的数据
 *
 * @param key 数据的名称
 * @param val 数据的具体值
 */
TSiteInfo.set = function(key, val) {
    this.tCarInfoData[key] = (typeof val == "undefined") ? $("#" + key).val() : val;
    return this;
}
 
/**
 * 设置对话框中的数据
 *
 * @param key 数据的名称
 * @param val 数据的具体值
 */
TSiteInfo.get = function(key) {
    return $("#" + key).val();
}
 
// 场地管理首页 选择对应的省市
TSiteInfo.oneChange = function (e) {
    var oneId=$(e).val();
    var startTime = document.getElementById('start-time');
    var endTime = document.getElementById('end-time');
    var selectedValue = e.value;
    var citySelect = document.getElementById("cCode");
    var accountSelect = document.getElementById("account");
    var storeSelect = document.getElementById("store");
    var ajax = new $ax(Feng.ctxPath + "/tSite/getCity", function(data){
        if(data!=null){
            var content='<option value="">选择市</option>';
            $.each(data, function(k,v) {
                content += "<option value='"+v.city+"'>"+v.city+"</option>";
            });
            $("#cCode").empty().append(content);
        }
    });
    if (selectedValue === ""){
        citySelect.innerHTML = '<option value="">请先选择省</option>';
        startTime.disabled = true;
        endTime.disabled = true;
    }
    accountSelect.innerHTML = '<option value="">请先选择省/市</option>';
    storeSelect.innerHTML = '<option value="">请先选择省/市</option>';
    ajax.set("province",oneId);
    ajax.start();
};
TSiteInfo.oneChangeNext = function (e) {
    var selectedText = $('#cCode option:selected').text();
    var startTime = document.getElementById('start-time');
    var endTime = document.getElementById('end-time');
 
    var citySelect = document.getElementById("account");
    var storeSelect = document.getElementById("store");
    var ajax = new $ax(Feng.ctxPath + "/tSite/accountChangeNext", function(data){
        if(data!=null){
            var content='<option value="">选择账号</option>';
            $.each(data, function(k,v) {
                content += "<option style='width: 300px' value='"+v.id+"'>"+v.name+"</option>";
            });
            $("#account").empty().append(content);
        }
    });
    if (selectedText === ""){
        storeSelect.innerHTML = '<option style="width: 300px" value="">请先选择省/市</option>';
        citySelect.innerHTML = '<option style="width: 300px" value="">请先选择省/市</option>';
        startTime.disabled = true;
        endTime.disabled = true;
    }
 
    ajax.set("oneId",selectedText);
    ajax.start();
 
    var ajax1 = new $ax(Feng.ctxPath + "/tSite/storeChangeNext", function(data){
        if(data!=null && data.length !== 0){
            var content='<option value="">选择门店</option>';
            $.each(data, function(k,v) {
                content += "<option style='width: 300px' value='"+v.id+"'>"+v.name+"</option>";
            });
            $("#store").empty().append(content);
        }else {
            storeSelect.innerHTML = '<option value="">当前所选市没有门店</option>';
        }
    });
    ajax1.set("oneId",selectedText);
    ajax1.start();
};
TSiteInfo.getTime = function (e) {
 
    var selectedText = $('#store option:selected').text();
    $.ajax({
        url: Feng.ctxPath + "/tSite/getTime/" + selectedText,
        type: "GET",
        contentType: "application/json", // 设置请求头的 Content-Type
        success: function (response) {
            var sTime = document.getElementById("start-time"); //获取输入的开始时间
            var eTime  = document.getElementById("end-time"); // 获取输入的结束时间
            var rStime = response.startTime; //门店的经营开始时间
            var rEtime = response.endTime; //门店的经营结束时间
 
            var sh = rStime.split(':')[0];// 门店经营开始时间:小时
            var sm = rStime.split(':')[1];// 门店经营开始时间:分钟
            console.log("门店经营开始时间")
            console.log(sh)
            console.log(sm)
            rEtime = response.endTime;
            var eh = rEtime.split(':')[0];// 门店经营结束时间:小时
            var em = rEtime.split(':')[1];// 门店经营结束时间:分钟
            console.log("门店经营结束时间")
            console.log(eh)
            console.log(em)
            sTime.addEventListener('change',function () {
                var start = sTime.value;
                var startHour = start.split(':')[0];  // 输入的可预约开始时间:小时
                var startMinute = start.split(':')[1];// 输入的可预约开始时间:分钟
 
                if (Number(sh)>Number(startHour)){
                    Feng.error("预约的开始时间不应小于营业开始时间!")
                }else if(Number(sh) === Number(startHour) ){
                    if (Number(sm)>Number(startMinute)){
                        Feng.error("预约的开始时间不应大于营业开始时间!")
                    }
                }else if (Number(eh)<Number(startHour)){
                    Feng.error("预约的开始时间不应大于营业结束时间!")
                }else if(Number(eh)===Number(startHour)){
                    Feng.error("预约的开始时间不应大于等于营业结束时间!")
                }
            });
            eTime.addEventListener('change',function () {
                var end = eTime.value;
                var endHour = end.split(':')[0];  // 输入的可预约结束时间:小时
                var endMinute = end.split(':')[1];// 输入的可预约结束时间:分钟
                if (Number(eh)<Number(endHour)){
                    Feng.error("预约的结束时间不应大于营业结束时间!")
                }else if(Number(eh) === Number(endHour) ){
                    if (Number(em)<Number(endMinute)){
                        Feng.error("预约的开始时间不应大于开始营业时间!")
                    }
                }else if(Number(sh)>Number(endHour)){
                    Feng.error("预约的结束时间不应小于营业开始时间!")
                }
            })
 
        },
        error: function (xhr, status, error) {
            Feng.error("您的网络异常!");
        }
    });
};
function UploadFileFn(){
    $('#upFile').click();
}
TSiteInfo.addSubmit = function(){
    var data = {
        id:null,
        province:"",
        city:"",
        cityManagerId:"",
        storeId:"",
        siteTypeId:null,
        appointmentStartTime:"",
        appointmentEndTime:"",
        cashPrice:null,
        playPaiCoin:null,
        insuranceEndTime:"",
        name:"",
        insuranceImg:"",
        managementPlan:"",
        operatorId:"",
        typeName:"",
        nextName:"",
        ishalf:"",
        cashPriceOne:"",
        playPaiCoinOne:"",
        halfName:"",
        introduce:"",
        imgs:"",
        ids:""
    };
    data.province            = $("#pCode").val()
    data.id            = $("#id").val()
    data.city                = $("#cCode").val()
    data.cityManagerId       = $("#account").val()
    data.storeId             = $("#store").val()
    data.siteTypeId          = $("#siteTypeId").val()
    data.appointmentStartTime= $("#start-time").val()
    data.appointmentEndTime  = $("#end-time").val()
    data.cashPrice           = $("#cashPrice").val()
    data.playPaiCoin         = $("#playPaiCoin").val()
    data.insuranceEndTime    = $("#insuranceEndTime").val()
    data.name                = $("#name").val()
    data.insuranceImg        = $("#img").val()
    data.managementPlan      = $('#courseVideo').val()
    data.typeName      = $('#siteTypeOne').val()
    var sh =data.appointmentStartTime.split(':')[0];
    var sm =data.appointmentStartTime.split(':')[1];
    var eh =data.appointmentEndTime.split(':')[0];
    var em =data.appointmentEndTime.split(':')[1];
 
    if (data.typeName === "智慧场地"){
        console.log("===========这是智慧球场")
 
        console.log("====="+data.appointmentStartTime)
 
        var value = data.appointmentStartTime;
        var lastTwoDigits = value.slice(-2);
 
        if (lastTwoDigits === "00" || lastTwoDigits === "15" || lastTwoDigits === "30" || lastTwoDigits === "45") {
            console.log("Last two digits are 00, 15, 30, or 45");
        } else {
            Feng.error("智慧场地的可预约时间段是15分钟的倍数")
            return;
 
        }
 
 
        var value1 = data.appointmentEndTime;
        var lastTwoDigits1 = value1.slice(-2);
 
        if (lastTwoDigits1 === "00" || lastTwoDigits1 === "15" || lastTwoDigits1 === "30" || lastTwoDigits1 === "45") {
            console.log("Last two digits are 00, 15, 30, or 45");
        } else {
            Feng.error("智慧场地的可预约时间段是15分钟的倍数")
            return;
 
        }
 
 
    }else {
        console.log("===========这是普通球场")
 
        console.log("====="+data.appointmentStartTime)
        var value = data.appointmentStartTime;
        var lastTwoDigits = value.slice(-2);
 
        if (lastTwoDigits === "00" || lastTwoDigits === "30" ) {
            console.log("Last two digits are 00, 15, 30, or 45");
        } else {
            Feng.info("普通场地可预约时间段需是30分钟的倍数")
            return;
        }
 
 
        var value1 = data.appointmentEndTime;
        var lastTwoDigits1 = value1.slice(-2);
 
        if (lastTwoDigits1 === "00"|| lastTwoDigits1 === "30" ) {
            console.log("Last two digits are 00, 15, 30, or 45");
        } else {
            Feng.info("普通场地可预约时间段需是30分钟的倍数")
            return;
 
        }
 
 
 
    }
 
 
    var SelectValue="";
    var getSelectValueMenbers = $("input[name='pt']:checked").each(function(j) {
        if (j >= 0) {
            SelectValue += $(this).val()
        }
    });
    if(SelectValue==''){
        let yys = $("#yys").val()
        if(yys==""){
            Feng.info("请选择运营商")
            return;
        }
        SelectValue= yys
    }
    data.operatorId= SelectValue;
 
 
 
    let num24 = $('input[name="name1"]');
    var nextName="";
    for (let i = 0; i < num24.length; i++) {
        if($(num24[i]).val()==''){
            Feng.info("请填写场地名称")
            return;
        }
        if(i==num24.length-1){
            nextName += $(num24[i]).val()
        }else {
            nextName += $(num24[i]).val()+","
        }
    }
    data.nextName= nextName;
 
 
    var ishalf= $("input[name='ishalf']:checked").val();
    data.ishalf= ishalf;
    var halfName="";
    if(ishalf==1){
        let cashPriceOne = $("#cashPriceOne").val()
        if(cashPriceOne=='' ){
            Feng.info("请填写现金价格")
            return;
        }
        data.cashPriceOne= cashPriceOne;
 
        let playPaiCoinOne = $("#playPaiCoinOne").val()
        if(playPaiCoinOne=='' ){
            Feng.info("请填写玩湃币价格")
            return;
        }
 
        data.playPaiCoinOne= playPaiCoinOne;
        let num2 = $('input[name="name2"]');
        for (let i = 0; i < num2.length; i++) {
            if($(num2[i]).val()==''){
                Feng.info("请填写半场名称")
                return;
            }
            if(i==num2.length-1){
                halfName += $(num2[i]).val()
            }else {
                halfName += $(num2[i]).val()+","
            }
        }
    }
 
    var objectType =$("#objectType").val()
    data.halfName= halfName;
    data.ids= $("#ids").val();
    if (objectType==1){
        introduce  = TSiteInfo.editor.getContent();
    }
 
    console.log(introduce)
    if(introduce==""){
        Feng.info("请输入公告内容")
        return;
    }
    data.introduce= introduce;
 
 
    var goodImgs = TSiteInfo.goodsPicArray;
 
    if(goodImgs.length==0){
        Feng.info("请上传实景图")
        return;
    }
    var imgOne ="";
    console.log(goodImgs)
    console.log(goodImgs.length)
    for (let i = 0; i <goodImgs.length; i++) {
        console.log(goodImgs[i].response,11)
        if(i==goodImgs.length-1){
            imgOne += (goodImgs[i].response)
        }else {
            imgOne+=(goodImgs[i].response+",")
        }
 
    }
    console.log(imgOne)
    data.imgs = imgOne
 
 
 
 
    if($("#store").val()=='' ){
        Feng.info("请选择门店")
        return;
    }
    if($("#siteTypeId").val()=='' ){
        Feng.info("请选择场地类型")
        return;
    }
    if($("#name").val()==''){
        Feng.info("请输入场地名称")
        return;
    }
    if($("#start-time").val()=='' ){
        Feng.info("请输入可预约时间段 开始时间")
        return;
    }
    if($("#end-time").val()==''){
        Feng.info("请输入可预约时间段 结束时间")
        return;
    }
    if($("#cashPrice").val()==''){
        Feng.info("请输入现金价格")
        return;
    }
    if($("#playPaiCoin").val()==''){
        Feng.info("请输入玩湃币价格")
        return;
    }
    if($("#insuranceEndTime").val()==''){
        Feng.info("请输入场地责任险有效期")
        return;
    }
 
    // if($("#img").val()==''){
    //     Feng.info("请上传场地责任有效期图片")
    //     return;
    // }
    if($('#courseVideo').val()==''){
        Feng.info("请上传消防及应急管理方案")
        return;
    }
    var sTime = document.getElementById("start-time"); //获取输入的开始时间
    var eTime  = document.getElementById("end-time"); // 获取输入的结束时间
    var rStime = ""; //门店的经营开始时间
    var rEtime = ""; //门店的经营结束时间
    var selectedText = $('#store option:selected').text();
    $.ajax({
        url: Feng.ctxPath + "/tSite/getTime/" + selectedText,
        type: "GET",
        contentType: "application/json", // 设置请求头的 Content-Type
        success: function (response) {
            rStime = response.startTime;
            sh = rStime.split(':')[0];// 门店经营开始时间:小时
            sm = rStime.split(':')[1];// 门店经营开始时间:分钟
 
            rEtime = response.endTime;
            eh = rEtime.split(':')[0];// 门店经营结束时间:小时
            em = rEtime.split(':')[1];// 门店经营结束时间:分钟
 
            var start = sTime.value;
            var startHour = start.split(':')[0];  // 输入的可预约开始时间:小时
            var startMinute = start.split(':')[1];// 输入的可预约开始时间:分钟
            if (Number(sh)>Number(startHour)){
                Feng.error("预约的开始时间不应小于营业开始时间!")
                return false;
            }else if(Number(sh) === Number(startHour) ){
                if (Number(sm)>Number(startMinute)){
                    Feng.error("预约的开始时间不应大于营业开始时间!")
                    return false;
                }
            }else if (Number(eh)<Number(startHour)){
                Feng.error("预约的开始时间不应大于营业结束时间!")
                return false;
            }else if(Number(eh)===Number(startHour)){
                Feng.error("预约的开始时间不应大于等于营业结束时间!")
                return false;
            }
            var end = eTime.value;
            var endHour = end.split(':')[0];  // 输入的可预约结束时间:小时
            var endMinute = end.split(':')[1];// 输入的可预约结束时间:分钟
            if (Number(eh)<Number(endHour)){
                Feng.error("预约的结束时间不应大于营业结束时间!")
                return ;
            }else if(Number(eh) === Number(endHour) ){
                if (Number(em)<Number(endMinute)){
                    Feng.error("预约的开始时间不应大于开始营业时间!")
                    return ;
                }
            }else if(Number(sh)>Number(endHour)){
                Feng.error("预约的结束时间不应小于营业开始时间!")
                return ;
            }
            if (Number(endHour)===Number(sh)){
                if(Number(endMinute) < Number(sm)){
                    Feng.error("预约结束时间不应小于营业开始时间");
                    return;
                }
            }
            if (Number(startHour)===Number(endHour) && Number(startMinute)===Number(endMinute)){
                Feng.error("至少预约半个小时");
                return;
            }
            $.ajax({
                url: Feng.ctxPath + "/tSite/updateSite" ,
                type: "POST",
                data: JSON.stringify(data),
                contentType: "application/json",
                success: function (response) {
                    window.parent.TSite.table.refresh();
                    TSiteInfo.close();
                    Feng.success("修改成功");
                },
                error: function (xhr, status, error) {
                    Feng.error("修改失败!" + error);
                }
            });
        },
        error: function (xhr, status, error) {
            var errorMessage = xhr.responseText ? xhr.responseText : "上架失败!";
            Feng.error("您的网络异常!");
            return false;
        }
    });
 
};
 
TSiteInfo.oneChangeYys = function(e){
    var oneId=$(e).val();
    var SelectValue="";
    var getSelectValueMenbers = $("input[name='pt']:checked").each(function(j) {
        if (j >= 0) {
            SelectValue += $(this).val()
        }
    });
    if(SelectValue=='0' ){
        oneId=0
    }
    var ajax = new $ax(Feng.ctxPath + "/tSite/getChangeOne", function(data){
        if(data!=null){
            var content='<option value="">选择门店</option>';
            $.each(data, function(k,v) {
                content += "<option value='"+v.id+"'>"+v.name+"</option>";
            });
            $("#store").empty().append(content);
        }
    });
    ajax.set("oneId",oneId);
    ajax.start();
};
/**
 * 关闭此对话框
 */
TSiteInfo.close = function() {
    parent.layer.close(window.parent.TSite.layerIndex);
}
function UploadFileFn(){
    $('#upFile').click();
}
$(function () {
    TSiteInfo.editor = UE.getEditor('editor');
    // 限制分钟选项为 0 和 30
    // var timeInputs = document.querySelectorAll('input[type="time"]');
    // timeInputs.forEach(function(input) {
    //     input.addEventListener('change', function() {
    //         var selectedTime = input.value;
    //         var hour = selectedTime.split(':')[0];
    //         var minute = selectedTime.split(':')[1];
    //         if (minute < 30 &&minute>0) {
    //             minute = '30';
    //         } else if (minute >30) {
    //             hour++;
    //             minute = '00';
    //             if (hour<10){
    //                 hour = '0'+hour;
    //             }
    //         }
    //         input.value = hour + ':' + minute;
    //
    //     });
    // });
    Feng.initValidator("carInfoForm", TSiteInfo.validateFields);
    var carPhoto = new $WebUpload("img");
    carPhoto.setUploadBarId("progressBar");
    carPhoto.init();
 
    var carPhoto1 = new $WebUpload("url");
    carPhoto1.setUploadBarId("progressBar");
    carPhoto1.init();
    TSiteInfo.getTime()
 
 
});