yujian
2020-06-17 6e4b63c399b88cd531674c1f6ac8b03e8c21deb0
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
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
// 一些常复用的块封装
 
// 事件 申明(全局才可获取调用)
var vm_header = null; // 顶部vue对象
var vm_table = null; // 表格vue对象
var vm_editTan = null; // 修改弹框vue对象
 
// admin后台的dom创建方法集成
var adminDom = {
    
    // 获取XML文件
    hostPath: "/flqAdmin/", // 项目根目录
    requestGet: function (XMLurlC)
    {
        // 加载XMLDoc
        var xhttp = null;
        if (window.XMLHttpRequest) { xhttp = new XMLHttpRequest(); }
        else { xhttp = new ActiveXObject("Microsoft.XMLHTTP"); }
        xhttp.open("GET", XMLurlC, false);
        xhttp.send();
        // 获得dom
        return xhttp.responseText;
    },
    
    // 顶部悬浮 筛选栏
    header: {
        // dom节点、vue对象创造
        creat: function (objC) 
        {
            if (typeof(objC.el)=="undefined") { objC.el = ""; } // 要在哪个标签里面书写dom
            if (typeof(objC.touchSearch)=="undefined") { objC.touchSearch = function () {}; } // 某种行为触发搜索后的回调
            
            // 请求对应的pageHeader.xml
            var dom_str = adminDom.requestGet(adminDom.hostPath+"js/pageHeader.xml");
            // 打印xml的节点
            $(objC.el).html(dom_str);
            
            // 顶部vue对象 实例化
            vm_header = new Vue({
                el: "#admin-header",
                // 数据
                data: {
                    // 返回按钮
                    back: { 
                        show: false, // 是否显示
                        value: "", // 按钮文字
                        touch: function () {}, // 事件触发
                    },
                    // 搜索下拉框
                    select: { 
                        show: false, // 是否显示
                        list: [], // 可选列表
                        result: "", // 选择结果
                        touch: function () {}, // 事件触发
                        // 值改变事件
                        action_change: function()
                        {
                            // 获取下拉框结果
                            var thisKey = $(".admin-header select[name='select']").val();
                            // 将结果给事件触发
                            vm_header.select.touch(thisKey);
                        },
                    },
                    // 输入框
                    input: {
                        show: true,
                        num: 1, // 输入框数量
                        type: "text", // 输入框类型
                        placeholder: "输入关键字", // 默认提示文字
                        result: ["","",""], // 输入结果,因为可能是多个输入框,所以是结果数组,先初始化3个
                        // 搜索按钮点击
                        action_click: function()
                        {
                            // 隐藏筛选弹框
                            if (document.getElementsByClassName("admin-header-screen").length > 0)
                            {
                                var classScreen = $(".admin-header-screen").attr("class").split(" ");
                                var displayIndex = classScreen.indexOf("displayNone");
                                if (displayIndex < 0) { 
                                    classScreen.push("displayNone"); 
                                    $(".admin-header-screen").attr("class", classScreen.join(" ")); 
                                }
                            }
                            // 进入搜索方法
                            if (vm_table != null)
                            {
                                // 将页码回到1
                                vm_table.opt.page = 1;
                                vm_table.opt.pageMax = 1;
                                // 表格内容数据初始化
                                vm_table.tbody.tr = new Array();
                                // 进行搜索
                                vm_table.search();
                            }
                            else { vm_header.search(); }
                        },
                    },
                    // 切换
                    change: {
                        show: false, // 是否显示
                        list: [], // 可选列表
                        result: "", // 最终结果
                        touch: function () {}, // 事件触发
                        // 值改变事件
                        action_click: function(itemC)
                        {
                            if (itemC.key != vm_header.change.result) 
                            {
                                // 选中的key赋值
                                vm_header.change.result = itemC.key;
                                // 将结果key值给事件触发
                                vm_header.change.touch(itemC.key);
                                // 进行表格数据刷新
                                if (vm_table != null)
                                {
                                    // 将页码回到1
                                    vm_table.opt.page = 1;
                                    vm_table.opt.pageMax = 1;
                                    // 表格内容数据初始化
                                    vm_table.tbody.tr = new Array();
                                    // 进行搜索
                                    vm_table.search();
                                }
                                else { vm_header.search(); }
                            }
                        },
                    },
                    // 筛选项
                    screen: { 
                        show: false, // 是否显示
                        list: [], // 可选列表
                        touch: function () {}, // 事件触发
                        // 展开 / 收起 点击
                        action_show: function () { $(".admin-header-screen").toggleClass("displayNone"); },
                        // 筛选子项点击
                        action_screenClick: function (item, item2, index2) 
                        {
                            // 将当前所点击的项状态改变
                            item2.check = !item2.check;
                            // 如果不允许多选且这个已经选了,那么将其他的取消
                            if (item.muchCheck==false && item2.check==true) 
                            {
                                for (var i = 0; i < item.child.length; i++)
                                {
                                    if (i!=index2) { item.child[i].check = false; }
                                }
                            }
                            // 获取当前结果
                            var thisScreen = vm_header.resultGet();
                            vm_header.screen.touch(thisScreen.screen);
                        },
                    },
                },
                // 额外方法
                methods: {
                    // 筛选栏 获取筛选结果
                    resultGet: function ()
                    {
                        // 返回值初始化
                        var back = {
                            select: { result: vm_header.select.result }, // 下拉列表
                            input: [], // 搜索输入
                            change: { result: vm_header.change.result }, // 右上切换
                            screen: [], // 展开的筛选项结果
                        };
                        
                        // 获取输入结果
                        for (var i = 0, mo = vm_header.input.result; i < mo.length; i++)
                        {
                            // 当前行的初始化
                            var su_obj = { result: mo[i] }; 
                            back.input.push(su_obj); 
                        }
                        
                        // 获取筛选项结果
                        for (var i = 0, mo = vm_header.screen.list; i < mo.length; i++)
                        {
                            // 当前行的初始化
                            var su_obj = { title: mo[i].title, result: [] }; 
                            // 根据child的check添加
                            for (var j = 0, mo2 = mo[i].child; j < mo2.length; j++)
                            {
                                if (mo2[j].check == true) { su_obj.result = su_obj.result.concat(mo2[j].key); }
                            }
                            if (su_obj.result.length <= 0) { su_obj.result.push(""); }
                            // 但是如果输入组件中有内容,那么以输入为准
                            if (mo[i].input && mo[i].input.num > 0) 
                            {
                                var hadString = false;
                                var su_objresult = [];
                                $("#adminHeaderOpt"+i+" input").each(function()
                                {
                                    var su_input = $(this).val();
                                    if (typeof(su_input)!="undefined" && su_input.length > 0) { hadString = true; }
                                    su_objresult.push(su_input);
                                });
                                if (hadString == true) { su_obj.result = su_objresult; }
                            }
                            back.screen.push(su_obj); 
                        }
                        
                        // 返回结果
                        return back;
                    },
                    // 相当于搜索的行为,这是用于触发回调
                    search: function ()
                    {
                        // 获取筛选结果
                        var result_header = {};
                        if (vm_header != null) { result_header = vm_header.resultGet(); }
                        // 获取表格设置
                        var result_table = {}; 
                        if (vm_table != null) { result_table = vm_table.resultGet(); }
                        // 组合两个结果
                        var back = result_header;
                        back["table"] = result_table.table;
                        // 获取成功后触发搜索回调
                        objC.touchSearch(back);
                    },
                }
            });
        },
        
        // 返回按钮设置
        back: function (objC)
        {
            if (typeof(objC.show)!="undefined") { vm_header.back.show = objC.show; }
            if (typeof(objC.value)!="undefined") { vm_header.back.value = objC.value; }
            if (typeof(objC.touch)!="undefined") { vm_header.back.touch = objC.touch; }
        },
        // 下拉框数据设置
        select: function (objC) 
        {
            /*
            格式提示:
            objC.list = [ 
                { key: "spID", value: "商品ID" } 
            ];
            */
            if (typeof(objC.show)!="undefined") { vm_header.select.show = objC.show; }
            if (typeof(objC.list)!="undefined") 
            {
                vm_header.select.list = objC.list;
                if (objC.list.length > 0) { vm_header.select.result = objC.list[0].key; }
            }
            if (typeof(objC.touch)!="undefined") { vm_header.select.touch = objC.touch; }
        },
        // 输入框
        input: function (objC) 
        {
            if (typeof(objC.show)!="undefined") { vm_header.input.show = objC.show; }
            if (typeof(objC.num)!="undefined") { vm_header.input.num = objC.num; }
            if (typeof(objC.type)!="undefined") { vm_header.input.type = objC.type; }
            if (typeof(objC.placeholder)!="undefined") { vm_header.input.placeholder = objC.placeholder; }
        },
        // 右上角内容切换
        change: function (objC)
        {
            /*
            格式提示:
            objC.list = [ 
                { key: "tong", value: "柱状表" },
                { key: "tong", value: "线性表" },
                { key: "tong", value: "全部" } 
            ];
            */
            if (typeof(objC.show)!="undefined") { vm_header.change.show = objC.show; }
            if (typeof(objC.list)!="undefined") 
            { 
                vm_header.change.list = objC.list; 
                // 初始化结果为第一个key
                if (objC.list.length > 0) { vm_header.change.result = objC.list[0].key; }
            }
            if (typeof(objC.touch)!="undefined") { vm_header.change.touch = objC.touch; }
        },
        // 开启筛选
        screen: function (objC)
        {
            /*
            格式提示:
            objC.list = [
                {
                     title: "价格", 
                     muchCheck: false, // 是否可以多选
                     child: [
                        { key: [30], value: "¥30", check: false, },
                         { key: [0, 50], value: "¥0~¥50", check: false, },
                         { key: [50, 300], value: "¥50~¥300", check: false, },
                     ],
                     input: { type: "number", num: 2 },
                }
            ];
            */
            if (typeof(objC.show)!="undefined") { vm_header.screen.show = objC.show; }
            if (typeof(objC.list)!="undefined") { vm_header.screen.list = objC.list; }
            if (typeof(objC.touch)!="undefined") { vm_header.screen.touch = objC.touch; }
        },
    },
    
    // 数据表格 创建dom
    table: {
        // dom节点、vue对象创造
        creat: function (objC) 
        {
            if (typeof(objC.el)=="undefined") { objC.el = ""; } // 要在哪个标签里面书写dom
            if (typeof(objC.touchSearch)=="undefined") { objC.touchSearch = function () {}; } // 某种行为触发搜索后的回调
            
            // 请求对应的pageHeader.xml
            var dom_str = adminDom.requestGet(adminDom.hostPath+"js/pageTable.xml");
            // 打印xml的节点
            $(objC.el).html(dom_str);
            
            // 表格vue对象 实例化
            vm_table = new Vue({
                el: objC.el,
                // 数据
                data: {
                    // 表格设置
                    opt: { 
                        showCheck: true, // 行选择列开启?
                        showSerial: true, // 行序数开启?
                        allCheck: false, // 是否全选
                        order: "", // 排序选择值
                        page: 1, // 当前页码
                        pageMax: 1, // 最大页码数量
                        pageSize: 20, // 每页数据
                    },
                    // 表格头排
                    thead: { 
                        show: true, // 是否显示
                        th: [], // th列表
                        // 全选按钮点击
                        action_allCheckClick: function ()
                        {
                            // 已经是全选状态
                            if (typeof(vm_table.opt.allCheck)!="undefined" && vm_table.opt.allCheck==true) 
                            {
                                // 将每一行不选中
                                for (var i = 0, mo = vm_table.tbody.tr; i < mo.length; i++) { mo[i]["check"] = false; }
                                // 全选取消
                                vm_table.opt.allCheck = false;
                            }
                            else
                            {
                                // 将每一行选中
                                for (var i = 0, mo = vm_table.tbody.tr; i < mo.length; i++) { mo[i]["check"] = true; }
                                // 全选触发
                                vm_table.opt.allCheck = true;
                            }
                        },
                        // 列表排序 点击
                        action_orderClick: function (orderKey) 
                        {
                            if (orderKey != vm_table.opt.order) { vm_table.opt.order = orderKey; }
                            else { vm_table.opt.order = ""; }
                            // 将页码回到1
                            vm_table.opt.page = 1;
                            // 表格内容数据初始化
                            vm_table.tbody.tr = new Array();
                            // 进行搜索
                            vm_table.search();
                        },
                    },
                    // 表格内容
                    tbody: { 
                        show: true, // 是否显示
                        multiChose:true,
                        tr: [], // tr列表
                        // 某一行选中 点击
                        action_trClick: function (itemC)
                        {
                            // 将所有状态清除
                            if(objC.multiChose!=undefined && objC.multiChose==false)
                            {
                                for (var i = 0, mo = vm_table.tbody.tr; i < mo.length; i++) 
                                { 
                                    mo[i]["check"]=false;
                                }
                            }
                            
                            // 将当前行的选中状态反向
                            if (typeof(itemC.check)=="undefined") { itemC["check"] = true; }
                            else { itemC["check"] = !itemC["check"]; }
                            // 是否形成全选
                            var allCheckTF = true;
                            for (var i = 0, mo = vm_table.tbody.tr; i < mo.length; i++) 
                            { 
                                if (typeof(mo[i]["check"])=="undefined" || mo[i]["check"]==false) 
                                { allCheckTF = false; break; }
                            }
                            if (allCheckTF == true) { vm_table.opt.allCheck = true; }
                            else { vm_table.opt.allCheck = false; }
                        },
                    },
                    // 表格工具
                    tools: { 
                        show: true, 
                        list: [ 
                            { "title": "新建", "name": "add", "icon": "fi fi-plus" }, 
                            { "title": "删除", "name": "del", "icon": "fi fi-trash" },
                            { "title": "修改", "name": "edit", "icon": "fi fi-edit-box" },
                        ],
                        touch: function () {}, // 事件触发
                        // tools工具栏 点击
                        action_toolsClick: function (itemC) 
                        {
                            // 返回值初始化
                            var back = {
                                toolName: itemC.name, // 工具按钮name
                                list: [], // 被选中行的列表,其中的每一个行也是一个数组
                            };
                            
                            // 循环表格中的行
                            for (var i = 0, mo = vm_table.tbody.tr; i < mo.length; i++) 
                            {
                                // 看看哪些选中了
                                if (typeof(mo[i].check)!="undefined" && mo[i].check == true) 
                                {
                                    // 当前行初始化为 数组
                                    var mo_zu = new Array();
                                    // 将每一个td的数据放入 该数组
                                    for (var j = 0, moTh = vm_table.thead.th, moTd = mo[i].td; j < moTh.length; j++) 
                                    { 
                                        var jiedian = {
                                            title: moTh[j].title,
                                            key: moTd[j].key,
                                            value: moTd[j].value,
                                        };
                                        mo_zu.push(jiedian);
                                    }
                                    // 加入最终返回值的 选中行列表
                                    back.list.push(mo_zu);
                                }
                            }
                            
                            // 触发回调
                            if (back.toolName != "add" && back.list.length <= 0) { doui.showToast({ content: "未选择" }); }
                            else { vm_table.tools.touch(back); }
                        },
                    },
                    // 翻页区域
                    pageTool: {
                        // 表格页码改变
                        action_pageChange: function (typeC) 
                        {
                            // 上一页
                            if (typeC == "shang") 
                            {
                                if (vm_table.opt.page > 1) { vm_table.opt.page--; }
                                else { return false; }
                            }
                            // 下一页
                            else if (typeC=="xia") 
                            { 
                                if (typeof(vm_table.opt.pageMax)!="number") { vm_table.opt.page++; }
                                else if (vm_table.opt.page < vm_table.opt.pageMax) { vm_table.opt.page++; }
                                else { return false; }
                            }
                            // 直接跳转
                            else if (typeC == "jump") 
                            {
                                if ($("#pageToolZhuandao").val() && $("#pageToolZhuandao").val().length > 0) 
                                { 
                                    var mo = parseInt($("#pageToolZhuandao").val());
                                    if (mo < 1 || mo > vm_table.opt.pageMax) { doui.showToast({ content: "页码不在范围内" }); return false; }
                                    else { vm_table.opt.page = mo; }
                                }
                            }
                            // 表格内容数据初始化
                            vm_table.tbody.tr = new Array();
                            // 进行搜索
                            vm_table.search();
                        },
                    },
                },
                // 初始化layui表单元素修饰
                updated: function() {
                    layui.use('form', function() {
                        var form = layui.form;
                        form.render();
                    });
                },
                // 通用方法
                methods: {
                    // 表格 获取设置结果
                    resultGet: function ()
                    {
                        // 返回值初始化
                        var back = {
                            table: {
                                order: "", // 列表排序
                                page: 1, // 当前页码
                                pageMax: 1, // 最大页码数
                                pageSize: 20, // 每页数据条数
                            },
                        };
                        back.table.order = vm_table.opt.order;
                        back.table.page = vm_table.opt.page;
                        back.table.pageMax = vm_table.opt.pageMax;
                        back.table.pageSize = vm_table.opt.pageSize;
                        // 结果回调
                        return back;
                    },
                    // 相当于搜索的行为,这是用于触发回调
                    search: function ()
                    {
                        // 获取筛选结果
                        var result_header = {};
                        if (vm_header != null) { result_header = vm_header.resultGet(); }
                        // 获取表格设置
                        var result_table = {}; 
                        if (vm_table != null) { result_table = vm_table.resultGet(); }
                        // 组合两个结果
                        var back = result_header;
                        back["table"] = result_table.table;
                        // 获取成功后触发搜索回调
                        objC.touchSearch(back);
                    }
                },
                
                
                    
            });
        },
        
        // 表格的相关设置
        opt: function (objC) 
        {
            if (typeof(objC.showCheck)!="undefined") { vm_table.opt.showCheck = objC.showCheck; } // 是否开启“选中”
            if (typeof(objC.showSerial)!="undefined") { vm_table.opt.showSerial = objC.showSerial; } // 是否开启“序号”
            if (typeof(objC.allCheck)!="undefined") { vm_table.opt.allCheck = objC.allCheck; } // 是否已经“全选”
            if (typeof(objC.order)!="undefined") { vm_table.opt.order = objC.order; } // 当前排序所选key有效值
            if (typeof(objC.page)!="undefined") { vm_table.opt.page = objC.page; } // 当前页码
            if (typeof(objC.pageMax)!="undefined") { vm_table.opt.pageMax = objC.pageMax; } // 最大页码数
            if (typeof(objC.pageSize)!="undefined") { vm_table.opt.pageSize = objC.pageSize; } // 每页数据条数
        },
        // thead
        thead: function (objC) 
        {
            /*
            格式提示:
            objC.th = [
                { 
                    title: "ID", // 肉眼看见的表格头排显示文字
                    width: "", // 该列宽度
                    orderUp: "", // 升序key传递值
                    orderDown: "", // 降序key传递值
                    // 是否可以触发修改
                    edit: {
                        type: "radio", // text-文本输入  radio-单选  checks-多选  select-下拉列表  date-时间  datetime-local-包含时分的时间  toggle-开关型  file-文件选择
                        placeholder: "",
                        list: [ 
                            { key: "0", value: "正常" },
                            { key: "1", value: "删除" },
                            { key: "2", value: "封禁" } 
                        ],
                    },
                }
            ];
            */
            if (typeof(objC.show)!="undefined") { vm_table.thead.show = objC.show; }
            if (typeof(objC.th)!="undefined") { vm_table.thead.th = objC.th; }
        },
        // tbody
        tbody: function (objC) 
        {
            /*
            格式提示:
            objC.tr = [
                {
                    check: false, // 当前行是否已选中
                    td: [  // td列
                        { title: "ID", key: "d13wc4r321fc4", value: "d13wc4r321fc4", class: "", style: "" },
                        { title: "图片", key: "http://www.baidu.com/hollo.jpg", value: "http://www.baidu.com/hollo.jpg", dataType: "img", class: "", style: "", },
                        { title: "链接", key: "http://www.alibaba.com", value: "http://www.alibaba.com", dataType: "link", class: "", style: "", },
                    ], 
                }
            ];
            */
            if (typeof(objC.show)!="undefined") { vm_table.tbody.show = objC.show; }
            if (typeof(objC.tr)!="undefined") { vm_table.tbody.tr = objC.tr; }
        },
        // 工具栏
        tools: function (objC)
        {
            if (typeof(objC.show)!="undefined") { vm_table.tools.show = objC.show; }
            if (typeof(objC.list)!="undefined") { vm_table.tools.list = objC.list; }
            if (typeof(objC.touch)!="undefined") { vm_table.tools.touch = objC.touch; }
        },
        // 行选择初始化
        initCheck: function ()
        {
            // 循环表格中的行  将每个行设置为未选中
            for (var i = 0, mo = vm_table.tbody.tr; i < mo.length; i++) { mo[i]["check"] = false; }
            // 非全选
            vm_table.opt.allCheck = false;
        },
    },
    
    // 数据修改弹框(遵守规则,一次只能操作一行)
    editTan: {
        // dom节点、vue对象创造
        creat: function (objC)
        {
            if (typeof(objC.el)=="undefined") { objC.el = "body"; } // 要在哪个标签里面书写dom
            if (typeof(objC.touch)=="undefined") { objC.touch = function () {}; } // 操作变更触发的回调方法
            if (typeof(objC.touchSubmit)=="undefined") { objC.touchSubmit = function () {}; } // 提交按钮点击触发的回调方法
            
            // 请求对应的pageHeader.xml
            var dom_str = adminDom.requestGet(adminDom.hostPath+"js/pageEditTan.xml");
            // 打印xml的节点
            $(objC.el).append(dom_str);
            
            // vue实例化
            vm_editTan = new Vue({
                el: "#admin-edit-tan",
                data: {
                    // 弹框设置
                    opt: { 
                        title: "新建", // 弹框标题
                    },
                    // 完全复制表格的thead数据
                    thead: { 
                        show: true, 
                        th: [],
                    },
                    // 初始存在的操作数据
                    thereData: {
                        show: false, // 修改框上 是否显示存在的数据
                        list: [], // 已经存在的数据列表
                    },
                },
                // 初始化layui表单元素修饰
                updated: function() {
                    layui.use('form', function() {
                        var form = layui.form;
                        form.render();
                        
                        //监听指定开关
                        form.on('switch(switchTest)', function(data) {
                            var value = 0;
                            if (this.checked) {
                                value = 1;
                            }
                            vm_editTan.thereData.list[this.title].key = value;
                        });
                    });
                },
                methods: {
                    // 关闭按钮 点击
                    closeClick: function () { adminDom.editTan.remove(); },
                    // 操作变化 触发
                    action_change: function (indexC, thereD) 
                    {
                        var back = {
                            index: indexC,
                            title: thereD.title,
                            key: thereD.key,
                            value: thereD.value,
                        };
                        objC.touch(back);
                    },
                    // 复选框选项 点击
                    checkClick: function (editListItem, tdItem) 
                    {
                        var index = tdItem.key.indexOf(editListItem.key);
                        // 如果是选过的    从key中除去该选项
                        if (index >= 0) { tdItem.key.splice(index, 1); }
                        // 没有则添加
                        else { tdItem.key.push(editListItem.key); }
                    },
                    
                    // 文件资源获取,{ key: (用来保存新选择的文件对象), value: (是已经拥有的老数据) }
                    fileInputChange: function (indexC)
                    {
                        // 获取当前组件选择的文件
                        var back = $("#adminEditTanFileInput"+indexC)[0].files[0];
                        // 保存到 key
                        vm_editTan.thereData.list[indexC].key = back;
                        // 是否改变标识
                        if (typeof(back)=="object") 
                        { 
                            vm_editTan.thereData.list[indexC].change = true;
                            // 获取文件本地路径
                            var reader = new FileReader();
                            reader.onload = function (e) { vm_editTan.thereData.list[indexC].filePath = e.target.result; };
                            reader.readAsDataURL(back);
                        }
                        else { vm_editTan.thereData.list[indexC].change = false; }
                        // 是否删除标识
                        if (typeof(vm_editTan.thereData.list[indexC].del)=="undefined") { vm_editTan.thereData.list[indexC]["del"] = false; }
                    },
                    // 确定提交点击
                    subClick: function () 
                    {
                        // 构造返回数据
                        var back = vm_editTan.thereData;
                        // 触发
                        objC.touchSubmit(back);
                    }
                },
            });
        
            // 获取表格thead
            if (vm_table != null) { vm_editTan.thead = JSON.parse( JSON.stringify(vm_table.thead) ); }
        },
        
        // 弹框设置
        opt: function (objC) 
        {
            if (typeof(objC.title)!="undefined") { vm_editTan.opt.title = objC.title; } // 弹框标题
        },
        // 定义初始操作数据
        thereData: function (objC) 
        {
            /*
            格式提示: 相当于表格中的一行数据
            objC.list = [
                { title: "ID", key: "d13wc4r321fc4", value: "d13wc4r321fc4", class: "", style: "" },
                { title: "图片", key: "http://www.baidu.com/hollo.jpg", value: "http://www.baidu.com/hollo.jpg", dataType: "img", class: "", style: "", },
                { title: "链接", key: "http://www.alibaba.com", value: "http://www.alibaba.com", dataType: "link", class: "", style: "", },
            ],
            */
            if (typeof(objC.show)!="undefined") { vm_editTan.thereData.show = objC.show; }
            if (typeof(objC.list)!="undefined") 
            { 
                // 重新定义传递进来的list
                var listNew = JSON.parse( JSON.stringify(objC.list) );
                // 对列表的一些项做初始化
                for (var i = 0, mo = vm_editTan.thead.th; i < mo.length; i++) 
                {
                    // 如果是file型,初始化del为false
                    if (mo[i].edit && mo[i].edit.type == "file") 
                    { 
                        listNew[i]["change"] = false; 
                        listNew[i]["del"] = false;
                        listNew[i]["filePath"] = "";
                    }
                }
                // 赋值
                vm_editTan.thereData.list = listNew; 
            }
            
            // 如果不想显示已经存在的数据,那么自我新建模版
            if (vm_editTan.thereData.show == false)
            {
                var mo_zu = new Array();
                for (var i = 0, mo = vm_editTan.thead.th; i < mo.length; i++) 
                {
                    var jiedian = { title: mo[i].title, key: "", value: "" };
                    // 如果是多选项,将key设置为数组
                    if (mo[i].edit && mo[i].edit.type == "check") { jiedian.key = []; }
                    // 如果是file型,初始化del为false
                    else if (mo[i].edit && mo[i].edit.type == "file") 
                    { 
                        jiedian["change"] = false; 
                        jiedian["del"] = false;
                        jiedian["filePath"] = "";
                    }
                    mo_zu.push(jiedian);
                }
                vm_editTan.thereData.list = mo_zu;
            }
        },
        // 删除dom
        remove: function () { $("#admin-edit-tan").remove(); },
    },
    
};