44323
2023-11-05 75bac456c3d66f6b173b1213776158c3bc5f8b96
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
/**
 * 管理初始化
 */
var TQuestion = {
    id: "TQuestionTable",    //表格id
    seItem: null,        //选中的条目
    table: null,
    layerIndex: -1
};
 
var roleType = $("#roleType").val()
/**
 * 初始化表格的列
 */
TQuestion.initColumn = function () {
    return [
        {field: 'selectItem', checkbox: true},
        {title: '序号', field: 'id', visible: true, align: 'center', valign: 'middle'},
        {title: '省', field: 'province', visible: roleType==1?true:false, align: 'center', valign: 'middle'},
        {title: '市', field: 'city', visible: roleType==1?true:false, align: 'center', valign: 'middle'},
        {title: '姓名', field: 'name', visible: true, align: 'center', valign: 'middle'},
        {title: '联系电话', field: 'phone', visible: true, align: 'center', valign: 'middle'},
        {title: '生日', field: 'birthday', visible: true, align: 'center', valign: 'middle'},
        {title: '性别', field: 'gender', visible: true, align: 'center', valign: 'middle',
            formatter:function (data) {
                return {1:"男",2:"女"}[data]
            }
        },
        {title: '销售人员', field: 'salesmanUserName', visible: true, align: 'center', valign: 'middle'},
        {title: '是否为年度会员', field: 'isVip', visible: true, align: 'center', valign: 'middle',
            formatter:function (data) {
                return {1:"是",0:"否"}[data]
            }
        },
        {title: '状态', field: 'state', visible: true, align: 'center', valign: 'middle',
            formatter:function (data) {
                return {1:"正常",2:"冻结",3:"已注销"}[data]
            }}
    ];
};
TQuestion.close = function() {
    parent.layer.close(window.parent.TQuestion.layerIndex);
}
/**
 * 检查是否选中
 */
TQuestion.check = function () {
    var selected = $('#' + this.id).bootstrapTable('getSelections');
 
    if(selected.length == 0){
        Feng.info("请先选中表格中的某一记录!");
        return false;
    }else{
        TQuestion.seItem = selected[0];
        return true;
    }
};
TQuestion.dataCount = 0;
TQuestion.phone = "";
TQuestion.phoneId = "";
 
/**
 * 点击添加
 */
TQuestion.openAdd = function () {
    var index = layer.open({
        type: 2,
        title: '添加分类',
        area: ['100%', '100%'], //宽高
        fix: false, //不固定
        maxmin: true,
        content: Feng.ctxPath + '/appUser/add'
    });
    this.layerIndex = index;
};
 
 
/**
 * 点击编辑
 */
TQuestion.openChange = function () {
    var selected = $('#' + this.id).bootstrapTable('getSelections');
    if(selected.length >1 ){
        Feng.info("只能选择一个用户进行编辑!");
    }else {
        if (this.check()){
            var selected = $('#' + this.id).bootstrapTable('getSelections');
            var index = layer.open({
                type: 2,
                title: '编辑分类',
                area: ['100%', '100%'], //宽高
                fix: false, //不固定
                maxmin: true,
                content: Feng.ctxPath + '/appUser/update/' + TQuestion.seItem.id+"/"+1
            });
            this.layerIndex = index;
        }
    }
};
 
/**
 * 查看详情
 */
TQuestion.openInfo = function () {
    var selected = $('#' + this.id).bootstrapTable('getSelections');
    if(selected.length >1 ){
        Feng.info("只能选择一个用户进行查看!");
    }else {
        if (this.check()){
            var selected = $('#' + this.id).bootstrapTable('getSelections');
            var index = layer.open({
                type: 2,
                title: '编辑分类',
                area: ['100%', '100%'], //宽高
                fix: false, //不固定
                maxmin: true,
                content: Feng.ctxPath + '/appUser/update/' + TQuestion.seItem.id+"/"+2
            });
            this.layerIndex = index;
        }
    }
};
/**
 * 查看学员详情
 */
TQuestion.studentInfo = function (e) {
    var index = layer.open({
        type: 2,
        title: '详情',
        area: ['100%', '100%'],  //宽高
        fix: false, //不固定
        maxmin: true,
        content: Feng.ctxPath + '/tStudent/tStudent_info/' + e
    });
    this.layerIndex = index;
};
/**
 * 添加学员
 */
TQuestion.openAddStudent = function (e) {
    var selected = $('#' + this.id).bootstrapTable('getSelections');
    if(selected.length >1 ){
        Feng.info("只能选择一个用户进行添加学员!");
    }else {
        if (this.check()) {
            var index = layer.open({
                type: 2,
                title: '详情',
                area: ['100%', '100%'],  //宽高
                fix: false, //不固定
                maxmin: true,
                content: Feng.ctxPath + '/appUser/addStudent/' + TQuestion.seItem.id
            });
            this.layerIndex = index;
        }
    }
};
/**
 * 上架
 */
 
TQuestion.onShelf = function () {
if (this.check()){
    var selected = $('#' + this.id).bootstrapTable('getSelections');
    const data1 = {
        ids:[],
        state:null
    };
    selected.forEach(function(obj) {
        var id = obj.id;
        data1.ids.push(id);
    });
    data1.state = 1;
    $.ajax({
        url: Feng.ctxPath + "/appUser/changeState",
        type: "POST",
        contentType: "application/json", // 设置请求头的 Content-Type
        data: JSON.stringify(data1), // 将数据转换为 JSON 字符串
        success: function(response) {
            Feng.success("解冻成功!");
            TQuestion.search();
 
        },
        error: function(xhr, status, error) {
            var errorMessage = xhr.responseText ? xhr.responseText : "修改失败!";
            Feng.error("您的网络异常!");
        }
    });
 
}
};
 
 
/**
 * 下架
 */
TQuestion.offShelf = function () {
    if (this.check()){
        var selected = $('#' + this.id).bootstrapTable('getSelections');
        const data1 = {
            ids:[],
            state:null
        };
        selected.forEach(function(obj) {
            var id = obj.id;
            data1.ids.push(id);
        });
        data1.state = 2;
        console.log("看看")
        console.log(data1)
        $.ajax({
            url: Feng.ctxPath + "/appUser/changeState",
            type: "POST",
            contentType: "application/json", // 设置请求头的 Content-Type
            data: JSON.stringify(data1), // 将数据转换为 JSON 字符串
            success: function(response) {
                Feng.success("冻结成功!");
                TQuestion.search();
            },
            error: function(xhr, status, error) {
                var errorMessage = xhr.responseText ? xhr.responseText : "修改失败!";
                Feng.error("您的网络异常!");
            }
        });
    }
};
 
/**
 * 查看视频详情
 */
TQuestion.getInfo = function () {
    var selected = $('#' + this.id).bootstrapTable('getSelections');
    if(selected.length >1 ){
        Feng.info("只能选择一条进行查看!");
    }else {
        if (this.check()){
            var selected = $('#' + this.id).bootstrapTable('getSelections');
 
            var index = layer.open({
                type: 2,
                title: '详情',
                area: ['100%', '100%'], //宽高
                fix: false, //不固定
                maxmin: true,
                content: Feng.ctxPath + '/benefits/getBenefitsVideos/' + TQuestion.seItem.id
            });
            this.layerIndex = index;
        }
    }
};
 
/**
 * 删除
 */
TQuestion.delete = function () {
    if (this.check()){
        var selected = $('#' + this.id).bootstrapTable('getSelections');
        const data1 = {
            ids:[],
            state:null
        };
        selected.forEach(function(obj) {
            var id = obj.id;
            data1.ids.push(id);
        });
        data1.state = 3;
        $.ajax({
            url: Feng.ctxPath + "/benefits/changeState",
            type: "POST",
            contentType: "application/json", // 设置请求头的 Content-Type
            data: JSON.stringify(data1), // 将数据转换为 JSON 字符串
            success: function(response) {
                Feng.success("删除成功!");
                TQuestion.search();
            },
            error: function(xhr, status, error) {
                var errorMessage = xhr.responseText ? xhr.responseText : "删除失败!";
                Feng.error(errorMessage);
            }
        });
    }
};
 
 
 
TQuestion.oneChange = function (e) {
    var oneId=$(e).val();
    console.log(oneId)
    console.log("!!!!!!!!!!!!!")
    var ajax = new $ax(Feng.ctxPath + "/tCompetition/onChange", function(data){
        if(data!=null){
            var content='<option value="">选择市</option>';
            $.each(data, function(k,v) {
                content += "<option value='"+v.code+"'>"+v.name+"</option>";
            });
            $("#cCode").empty().append(content);
        }
    });
    ajax.set("oneId",oneId);
    ajax.start();
};
TQuestion.addSubmit = function(){
    var data = {
        id:null,
        province:"",
        provinceCode:"",
        city:"",
        cityCode:"",
        phone:"",
        name:"",
        birthday:"",
        gender:null,
        salesmanUserId:null
 
    };
    data.province                = $('#pCode option:selected').text();
    data.provinceCode            = $("#pCode").val()
    data.city                    = $('#cCode option:selected').text();
    data.cityCode                = $("#cCode").val()
    data.phone                   = $("#phone").val()
    data.name             = $("#learnerName").val()
    data.birthday                = $("#birthday").val()
    data.gender                  = $("#gender").val()
    data.salesmanUserId                  = $("#salesmanUserName").val()
 
    if($("#pCode").val()==''){
        Feng.info("请选择省")
        return;
    }
    if($("#cCode").val()==''){
        Feng.info("请选择市")
        return;
    }
    if($("#phone").val()=='' ){
        Feng.info("请输入联系方式")
        return;
    }
    if($("#learnerName").val()=='' ){
        Feng.info("请输入学员姓名")
        return;
    }
    if($("#birthday").val()=='' ){
        Feng.info("请选择生日")
        return;
    }
    if($("#gender").val()=='' ){
        Feng.info("请选择性别")
        return;
    }
    if($("#salesmanUserName").val()=='' ){
        Feng.info("请选择销售人员")
        return;
    }
 
    $.ajax({
        url: Feng.ctxPath + "/appUser/addAppUser" ,
        type: "POST",
        data: JSON.stringify(data),
        contentType: "application/json",
        success: function (response) {
            if (response=="5001"){
                Feng.error("当前手机号 已被注册")
            }else{
                window.parent.TQuestion.table.refresh();
                TQuestion.close();
                Feng.success("添加成功");
            }
 
        },
        error: function (xhr, status, error) {
            Feng.error("添加失败!" + error);
        }
    });
 
};
TQuestion.addStudentSubmit = function(){
    var data = {
        appUserId:null,
        phone:"",
        name:"",
        birthday:"",
        sex:null,
        idCard:"",
        lateralSurface:"",
        weight:null,
        height:null,
        state:1,
 
    };
    data.phone                   = $("#phone").val()
    data.name             = $("#name").val()
    data.birthday                = $("#birthday").val()
    data.sex                  = $("#gender").val()
    data.idCard                  = $("#idCard").val()
    data.appUserId                  = $("#userId").val()
    data.lateralSurface                  = $("#img").val()
    data.weight                  = $("#weight").val()
    data.height                  = $("#height").val()
 
 
 
 
    if($("#learnerName").val()=='' ){
        Feng.info("请输入学员姓名")
        return;
    }
    if($("#birthday").val()=='' ){
        Feng.info("请选择生日")
        return;
    }
    if($("#gender").val()=='' ){
        Feng.info("请选择性别")
        return;
    }
    if($("#height").val()==''){
        Feng.info("请输入身高")
        return;
    }
    if($("#weight").val()==''){
        Feng.info("请输入体重")
        return;
    }
    if($("#phone").val()=='' ){
        Feng.info("请输入联系方式")
        return;
    }
    if($("#idCard").val()=='' ){
        Feng.info("请输入身份证号")
        return;
    }
    if($("#img").val()=='' ){
        Feng.info("请上传体测表")
        return;
    }
 
    $.ajax({
        url: Feng.ctxPath + "/appUser/addAppUserStudent" ,
        type: "POST",
        data: JSON.stringify(data),
        contentType: "application/json",
        success: function (response) {
                window.parent.TQuestion.table.refresh();
                TQuestion.close();
                Feng.success("添加成功");
        },
        error: function (xhr, status, error) {
            Feng.error("添加失败!" + error);
        }
    });
 
};
TQuestion.updateSubmit = function(){
    var data = {
        id:null,
        province:"",
        provinceCode:"",
        city:"",
        cityCode:"",
        phone:"",
        name:"",
        birthday:"",
        gender:null,
        salesmanUserId:null
 
    };
    data.id                      = $("#id").val()
    data.province                = $('#pCode option:selected').text();
    data.provinceCode            = $("#pCode").val()
    data.city                    = $('#cCode option:selected').text();
    data.cityCode                = $("#cCode").val()
    data.phone                   = $("#phone").val()
    data.name                    = $("#learnerName").val()
    data.birthday                = $("#birthday").val()
    data.gender                  = $("#gender").val()
    data.salesmanUserId                  = $("#salesmanUserName").val()
 
    if($("#pCode").val()==''){
        Feng.info("请选择省")
        return;
    }
    if($("#cCode").val()==''){
        Feng.info("请选择市")
        return;
    }
    if($("#phone").val()=='' ){
        Feng.info("请输入联系方式")
        return;
    }
    if($("#learnerName").val()=='' ){
        Feng.info("请输入学员姓名")
        return;
    }
    if($("#birthday").val()=='' ){
        Feng.info("请选择生日")
        return;
    }
    if($("#gender").val()=='' ){
        Feng.info("请选择性别")
        return;
    }
    if($("#salesmanUserName").val()=='' ){
        Feng.info("请选择销售人员")
        return;
    }
 
    $.ajax({
        url: Feng.ctxPath + "/appUser/addAppUser" ,
        type: "POST",
        data: JSON.stringify(data),
        contentType: "application/json",
        success: function (response) {
            if (response=="5001"){
                Feng.error("当前手机号 已被注册")
            }else{
                window.parent.TQuestion.table.refresh();
                TQuestion.close();
                Feng.success("添加成功");
            }
 
        },
        error: function (xhr, status, error) {
            Feng.error("添加失败!" + error);
        }
    });
 
};
 
/**
 * 查询列表
 */
TQuestion.search = function (e) {
    var queryData = {};
    queryData['province']           = $("#pCode").val();
    queryData['city']               = $("#cCode").val();
    queryData['name']               = $("#name").val();
    queryData['phone']              = $("#phone").val();
    queryData['isVip']              = $("#isVip").val();
    queryData['salesmanUserName']   = $("#salesmanUserName").val();
    TQuestion.table.refresh({query: queryData});
};
 
 
/**
 * 重置搜索
 */
TQuestion.resetSearch = function () {
    $("#pCode").val('');
    $("#cCode").val('');
    $("#name").val('');
    $("#phone").val('');
    $("#isVip").val('');
    $("#salesmanUserName").val('');
    TQuestion.search(null);
};
 
function UploadFileFn(){
    $('#upFile').click();
}
$(function () {
    var defaultColunms = TQuestion.initColumn();
    var table = new BSTable(TQuestion.id, "/appUser/listAll", defaultColunms);
    table.setPaginationType("client");
    TQuestion.table = table.init();
    var carPhoto = new $WebUpload("img");
    carPhoto.setUploadBarId("progressBar");
    carPhoto.init();
 
    // //提交信息
    // var ajax = new $ax(Feng.ctxPath + "/operatorUser/mgtShopAuth", function (data) {
    //     Feng.success("添加成功!");
    //     window.parent.Course.table.refresh();
    //     CourseInfo.close();
    // }, function (data) {
    //     Feng.error("添加失败!" + data.responseJSON.message + "!");
    // });
    // ajax.start();
 
});