田源
2024-04-07 2ac55ce0edf4870a29691b56bfad59f4830a11a2
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
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
/**
 * 主数据引擎
 * @author weidy
 * @date 2022-2-23
 */
layui.define(['layer','element','form','table','dynamicCondition' ,'tree','transfer','mdm/MdmEngineForm'],function(exports){
        var webUtil = $webUtil;
    var Class = function(){
        this.MODELNAME = "mdm/MdmEngine";
        this.moduleKey = "MdmEngine";
        this.backPath =  configData.compatibility? path:configData.mdmService;
        this.url = {
            classifyController: 'codeClassifyController/',
            classifyTree:'referTree',
            controller:'mdmEngineController/',
            tableUI:'getUIInfoByClassifyOid',
            formUI:'getFormDefineByTemplateOid',
            tableData:'gridTableDataByClassifyOid',
            getDataByOid:'getDataByOid',
            export:'exportCode',
            downloadImportExcel:'downloadImportExcel',
            downloadImportExcelHistory:'downloadImportExcelHistory',
            batchImportCode:'batchImportCode',
            importHistoryData:'batchImportHistoryData',
            processTemplateController:'codeClsProcessTempController/',
            listProcessTemplate:'listProcessTemplate'
        };
        this.getContent = function (){
            var that = this;
            return '<div id="UIContent_' + that.id + '" style="overflow: auto;padding:0 5px"></div>';
        };
        this.showContent=function(){
            var html = "";
            var that = this;
            html = [
                '<div class="layui-layout easyui-layout UIContentLayout" id="easyuiLayout_',that.id,'" data-options="fit:true" style="display:block;overflow-y: hidden">',
                    '<div data-options="region:\'west\',split:true,tools:\'#refresh_',that.id,'\'" title="主题库分类" style="width:270px;padding: 5px;">',
                        '<div class="layui-vci-tree" style="overflow: auto">',
                            '<ul layui-filter="tree_',that.id,'"><ul>',
                        '</div>',
                        '</div>',
                            '<div data-options="region:\'center\',split:true" style="border:0;" id="border_',that.id,'">',
                                '<div id="easyuiLayoutCenter_',that.id,'" class="easyui-layout" data-options="fit:true">',
                                    '<div class="layui-layout" data-options="region:\'center\',minHeight:50" title="分类数据" style="padding-left:5px;padding-right:5px;">',
                                        '<div class="layui-center">',
                                            that.getToolbarHtml(),
                                            '<table id="table_', that.id , '" lay-filter="table_',that.id , '" style="overflow-x:auto;"></table>',
                                        '</div>',
                                    '</div>',
                                    '<div class="layui-south" data-options="region:\'south\',split:true,collapsed:true" title="附件列表" style="padding:5px;height: 260px;">',
                                        '<div layui-filter="toolbar_south_',that.id,'" class="layui-btn-container layui-buttons">',
                                         '</div>',
                                        '<table id="table_attach_', that.id , '" lay-filter="table_attach_',that.id , '" style="overflow-x:auto;"></table>',
                                    '</div>',
                                '</div>',
                            '</div>',
                        '</div>',
                    '</div>',
                '</div>',
                '<div id="refresh_',that.id,'" style="position: absolute;top:0"><a href="javascript:void(0);" id="refresh_tree_',that.id,'"><i class="layui-icon layui-icon-refresh"></i>刷新</a></div>'
            ].join("");
            $("#UIContent_" + that.id).html(html);
        };
        this.getWestToolbarHtml = function(){
            var that = this;
            var html = [
                '<div layui-filter="toolbar_west_',that.id,'" class="layui-btn-container layui-buttons">',
                '<button class="layui-btn layui-btn-sm" layui-filter="toolbar_west_',that.id,'_refreshTree"><i class="layui-icon layui-icon-refresh"></i>刷新</button>'
            ];
            html.push('</div>');
            return html.join("");
        };
        this.createWestSearchHtml = function () {
            var that = this;
            webUtil.bindDefultButtonLisenter(that,"west_" + that.id);
        };
        this.getToolbarHtml =function(){
            var that = this;
            var html = [
                '<div layui-filter="toolbar_',that.id,'" class="layui-btn-container layui-buttons">',
                '</div>'];
            return html.join('');
        };
        this.createSearchHtml = function (queryColumns) {
            var that = this;
            var queryD = {};
            layui.each(queryColumns,function (i,item){
                var type =  item.fieldType || item.type || "text";
                if(type == 'text'){
                    queryD[(item.queryField||item.field)]=item.title
                }
            })
            //要移除以前的
            var toolbarDiv =$("[layui-filter='toolbar_" + that.id + "']");
            var search =  toolbarDiv.find("select[name='fast_search_select']");
            if(search && search.length>0){
                var div = $(search[0]).parent();
                div.next().remove();
                div.remove();
            }
            webUtil.createSearchHtml(queryD ,toolbarDiv, "table_" + that.id);
 
        };
        this.buttonIconMap = {
            CODEADD:'layui-icon-add-1',
            CODEBATCHADD:'layui-icon-list',
            CODEEDIT:'layui-icon-edit',
            CODEDELETE:'layui-icon-delete',
            CODEIMPORTHISTORY:'layui-icon-up',
            CODEEXPORT:'layui-icon-export',
            CODESTARTPROCESS:'layui-icon-read',
            CODEQUERY:'layui-icon-search',
            UPLOADFILE:'layui-icon-upload-circle',
            DOWNLOADFILE:'layui-icon-download-circle',
            revisefile:'layui-icon-edit',
            DELETEFILE:'layui-icon-delete',
            refreshTable:'layui-icon-refresh',
            refreshAttachTable:'layui-icon-refresh'
        };
        this.config={}
        this.init = function(){
            var that = this;
            webUtil.copyConfig(that,that.moduleKey);
            this.config[that.id] = {
                executeJsMap:{},
                sourceData:that.sourceData
            };
            that.MdmEngineForm = layui['mdm/MdmEngineForm'];
            setTimeout(function () {
                that.showContent();
                var easyuiLayout = $('#easyuiLayout_' + that.id)
                easyuiLayout.css({height: $('#portal_body').height() - 43, width: $('#portal_body').width() - 15})
                $('#easyuiLayoutCenter_'+that.id).layout();
                easyuiLayout.layout();
 
                that.initTree();
                that.createWestSearchHtml();
                $('#refresh_tree_' + that.id).click(function (){
                    var id=$(this).attr('id').replace('refresh_tree_','')
                    that.refresh(id);
                });
                that.initAttachTable(that.id)
 
            },1);
        };
        this.initTree = function () {
            var that = this;
            var tree = layui.tree;
            var scrollHeight =  window.innerHeight;
            var treeUL = $('[layui-filter="tree_' + that.id + '"]');
            var treeHeight = scrollHeight - 160;
            treeUL.parent().height(treeHeight);
            var rootParams = {};
            if(that.config[that.id].sourceData){
                for(var key in that.config[that.id].sourceData){
                    rootParams["conditionMap['" + key + "']"] = that.config[that.id].sourceData[key];
                }
            }
            tree.init("tree_" + that.id, treeUL, {
                url: that.url.classifyController + that.url.classifyTree,
                backPath: that.backPath,
                extraParams: {
                    isMuti: false,
                    isQueryAllColumn: true
                },
                rootParams:rootParams,
                showSearch:true,
                click: function (item, elem, options) {
                    that.config[options.rootParams["conditionMap['functionId']"]].currentItemOid = item.oid;
                    that.config[options.rootParams["conditionMap['functionId']"]].currentItemAttributes = item.attributes;
                    that.showTableByClassifyOid(item.oid,options.rootParams["conditionMap['functionId']"]);
                },
                done:function (filter,children,elem) {
                    var options=tree.getConfig(filter).options
                    that.config[options.rootParams["conditionMap['functionId']"]].rootItemName= children[0].attributes.name;
                    that.config[options.rootParams["conditionMap['functionId']"]].rootItemAttributes= children[0].attributes;
                }
            });
        };
        this.showTableByClassifyOid = function (codeClassifyOid,functionId){
            var that = this;
            that.config[functionId].componentVO = null;
            webUtil.get(that.url.controller + that.url.tableUI,{codeClassifyOid:codeClassifyOid,functionId:functionId},function (result){
                if(!result.success){
                    $webUtil.showAutoMsg(result.msg);
                    that.config[functionId].componentVO = null;
                    var  table = layui.table;
                    if(that.config[functionId].currentTableId){
                        table.destory(that.config[functionId].currentTableId);
                    }
                    $("[layui-filter='toolbar_" + functionId + "']").html('');
                }else{
                    //显示表格和快速查询
                    that.showTableByDefine(result.obj,functionId);
                    that.config[functionId].componentVO = result.obj;
                }
            });
        };
 
        this.showTableByDefine = function (componentVO,configId){
            var that = this;
            var  table = layui.table;
            if(that.config[configId].currentTableId){
                table.destory(that.config[configId].currentTableId);
            }
            that.initButtonByComponent(componentVO,configId);
 
            //处理列表
            var cols = [];
            var filter = 'table_' + configId;
            var eventMap = {};
            for (var i = 0; i < componentVO.tableDefineVO.cols.length; i++) {
                if (i == 0) {
                    componentVO.tableDefineVO.cols[i].unshift({
                        field: table.config.indexName,
                        type: 'numbers',
                        title: '序号',
                        rowspan: componentVO.tableDefineVO.cols.length,
                        width: 40
                    }, {
                        field: table.config.checkName,
                        type: 'checkbox',
                        rowspan: componentVO.tableDefineVO.cols.length,
                        width: 30
                    })
                }
                //每个字段都需要扫描一下是否有事件
                for (var j = 0; j < componentVO.tableDefineVO.cols[i].length; j++) {
                    var record =  componentVO.tableDefineVO.cols[i][j];
                    if(record.optionJsMap){
                        for(var key in record.optionJsMap){
                            eventMap[key] =  record.optionJsMap[key];
                        }
                    }
                    if(record.field == 'id' && $webUtil.isNull(record.templet)){
                        //企业编码的默认添加超链接
                        record.templet = '<div><a name="code" href="javascript:;" dataIndex="{{d.LAY_INDEX}}" lay-event="VIEWDETAIL" data-oid="{{d.oid}}" data-template="{{d.codetemplateoid}}" style="text-decoration:underline;color:blue;" >{{d.id}}</a></div>';
                    }else {
                        if (record.templet && typeof (record.templet) == 'string' && $webUtil.isNotNull(record.templet) && record.templet.indexOf("function(d)")>-1) {
                            record.templet = eval("(" + record.templet + ")");
                        }
                    }
                }
 
                cols.push(componentVO.tableDefineVO.cols[i]);
            }
 
            //找分页的数量
            var centerHeight = $("#border_" + configId).height()-100;
            var limit = (centerHeight-centerHeight%28)/28;
 
            var tableParams={
                templateOid:componentVO.templateVO.oid,
                codeClassifyOid: that.config[configId].currentItemOid,
                queryTemplate:that.config[configId].sourceData['queryTemplate']
            }
            that.config[configId].currentTableLoad = false;
            that.config[configId].componentVO = componentVO;
            table.render({
                elem: '#' + filter,
                id: filter,
                url:that.url.controller + that.url.tableData,
                backPath: that.backPath,
                page: {
                    limit: limit,
                    page: 1
                },
                limits: limit,
                where: tableParams,
                selectMode: table.selectMode.muti,
                cols: cols,
                done: function (res, cur, total) {
                    table.on('tool(' + filter + ')', function (obj) {
                        var data = obj.data;//当前选择行的数据
                        var layEvent = obj.event;//点的是什么按钮
 
                        if (layEvent == 'VIEWDETAIL') {
                            that.MdmEngineForm.VIEWDETAIL(data.oid,data.codetemplateoid,that.config[configId].currentItemOid);
                        } else {
                            if (layEvent in eventMap) {
                                that.callEvent(eventMap[layEvent], data);
                            }
                        }
                    });
                    that.config[configId].currentTableId = filter;
                },
                rowClick: function (tablefifter, record, options) {
                    table.reload("table_attach_" + configId, {
                        extraParams: {
                            ownbizOid: record.oid,
                            ownbizBtm: record.btmname
                        }
                    })
                }
            });
            if (componentVO.tableDefineVO.queryColumns && componentVO.tableDefineVO.queryColumns.length > 0) {
                that.createSearchHtml(componentVO.tableDefineVO.queryColumns)
            }
        };
        this.initButtonByComponent = function (componentVO,configId){
            var that = this;
            var toolbar = $("[layui-filter='toolbar_" + configId + "']");
            var toolbarSouth=$("[layui-filter='toolbar_south_" + configId + "']");
            toolbarSouth.empty();
            var buttons= toolbar.find('button');
            if(buttons){
                layui.each(buttons,function (_index,_item){
                    _item.remove();
                });
            }
            var buttonInfos = componentVO.buttons;
            if(!buttonInfos){
                buttonInfos = [];
            }
            buttonInfos.push({
                uniqueFlag: 'refreshTable',
                alias: '刷新'
            });
            var buttonHtml = [];
            that.config[configId].executeJsMap = {};
            layui.each(buttonInfos,function (_index,_item) {
                var filter = _item.uniqueFlag;
                if ($webUtil.endWith(filter, "VIEW")){
                    return;
                }
                if ($webUtil.endWith(filter, "CODEQUERY")
                    || $webUtil.endWith(filter, "refreshTable") || $webUtil.endWith(filter, "CODEIMPORTHISTORY")
                    || $webUtil.endWith(filter, "CODEEXPORT") || componentVO.leaf) {
                    if($webUtil.isNotNull(_item.iconCls)){
                        that.buttonIconMap[_item.uniqueFlag] = _item.iconCls;
                    }
                    if($webUtil.endWith(filter, "FILE") || $webUtil.endWith(filter, "file")){
                        toolbarSouth.append($webUtil.getButtonHtmlFromBtnObject(_item, configId, that.buttonIconMap));
                    }else {
                        buttonHtml.push($webUtil.getButtonHtmlFromBtnObject(_item, configId, that.buttonIconMap));
                    }
 
                }
            });
            $(buttonHtml.join('')).prependTo(toolbar)
            toolbarSouth.append($webUtil.getButtonHtmlFromBtnObject({
                uniqueFlag: 'refreshAttachTable',
                alias: '刷新'
            }, configId, that.buttonIconMap));
            webUtil.bindDefultButtonLisenter(that, configId);
            webUtil.bindDefultButtonLisenter(that, 'south_'+configId);
        };
        this.initAttachTable=function (configId){
            var that = this;
            var table=layui.table;
            var cols=[table.getIndexColumn(), table.getCheckColumn(),{
                field: 'name',
                title: '名称',
                width: 260,
                templet: function (d) {
                    return '<a class="layui-btn layui-btn-intable"  lay-event="VIEWFILE">'+d.name+'</a>';
                }
            },{
                field: 'fileSize',
                title: '文件大小',
                width: 100
            },{
                field: 'creator',
                title: '创建者',
                width: 100
            },{
                field: 'createTime',
                title: '创建时间',
                width: 200
            }]
            table.render({
                elem: '#table_attach_' + configId,
                id: 'table_attach_'+configId,
                url:'vciFileQueryController/gridFiles',
                backPath: that.backPath,
                page: {
                    limit: 10,
                    page: 1
                },
                extraParams: {
                    ownbizOid:'1',
                    ownbizBtm: '1',
                    fileDocClassify:'!=processAuditSuggest'
                },
                selectMode: table.selectMode.muti,
                cols: [cols],
                done: function (res, cur, total) {
                    table.on('tool(table_attach_' + configId + ')', function (obj) {
                        var data = obj.data;//当前选择行的数据
                        var layEvent = obj.event;//点的是什么按钮
 
                        if (layEvent == 'VIEWFILE') {
                            that.VIEWFILE(data,configId);
                        }
                    });
                }
            });
        }
        this.refresh = function (configId) {
            var that=this;
            var tree = layui.tree;
            tree.reload("tree_" + configId,{rootNodeLoaded:false});
        };
        this.refreshTable = function (type,button){
            var that = this;
            var configId=$(button).attr('layui-filter').split('_')[1]
            layui.table.reload('table_' + configId);
        };
        this.refreshAttachTable = function (type,button){
            var that = this;
            var configId=$(button).attr('layui-filter').split('_')[1]
            layui.table.reload('table_attach_' + configId);
        };
        this.checkComponentVO = function (configId){
            var that = this;
            if(!that.config[configId].componentVO || that.config[configId].componentVO == null){
                $webUtil.showErrorMsg("请先选择主题库分类,并且保证分类有关联的模板");
                return false;
            }
            return true;
        };
        this.CODEQUERY = function (type,button) {
            var that = this;
            var configId=$(button).attr('layui-filter').split('_')[1]
            if(!that.checkComponentVO(configId)){
                return false;
            }
            if(!that.config[configId].serinorQueryInstance && that.config[configId].componentVO.tableDefineVO.seniorQueryColumns) {
                var dynamicCondition = layui.dynamicCondition;
                $('[layui-filter="toolbar_' + configId + '"]').append('<div  id="toolbar' + configId + '" class="layui-inline"></div>');
                that.config[configId].serinorQueryInstance = dynamicCondition.create({
                    fields: that.config[configId].componentVO.tableDefineVO.seniorQueryColumns//查询字段
                    , tableId: "table_" + configId//需要查询的表格
                    , type: "complex"  //type:"simple"/"complex"  查询的方法  暂时写死为 complex
                    , queryCallBack: function (requestData) {//查询之后的callback
 
                    }
                });
            }
            that.config[configId].serinorQueryInstance.open();
        };
        this.callEvent = function (jsPath,data){
            var that = this;
            if(jsPath && data){
                if($webUtil.startWith(jsPath.toLowerCase(),"usejs:")||$webUtil.startWith(jsPath.toLowerCase(),"js:")){
                    //是执行js
                    if($webUtil.startWith(jsPath.toLowerCase(),"usejs:")){
                        jsPath = jsPath.substr(6);
                    }else {
                        jsPath = jsPath.substr(3);
                    }
                    layui.use(jsPath,function (){
                        layui[jsPath].doEvent(data,that);
                    });
                }else if($webUtil.startWith(jsPath.toLowerCase(),"https://") || $webUtil.startWith(jsPath.toLowerCase(),"http://")){
                    var tabId = (data.oid || jsPath) + "_link";
                    portal.showTabByMenu(data.oid || jsPath,{
                        id:data.oid || jsPath,
                        text:'查看链接',
                        url:jsPath
                    });
                }else if(that[jsPath]){
                    that[jsPath](data);
                }else{
                    //直接是js的暂时还不支持
                }
            }
        };
        this.CODEADD = function (type,button){
            var that = this;
            var configId=$(button).attr('layui-filter').split('_')[1]
            that.codeAddOrEdit(button,configId,true);
        };
        this.codeAddOrEdit = function (button,configId,add,oid,up){
            var that = this;
            if(!that.checkComponentVO(configId)){
                return false;
            }
            that.MdmEngineForm.getFormDefine(that.config[configId].componentVO.templateVO.oid,that.config[configId].currentItemOid,function (componentVO){
                var formDefineVO= componentVO.formDefineVO;
                if(formDefineVO) {
                    var filter = (oid||configId) + "_add_form";
                    var form = layui.form;
                    var colCount = that.MdmEngineForm.getFormCol(formDefineVO);
                    var items = that.MdmEngineForm.getFormItemsByVO(formDefineVO, false,colCount,add);
                    var html = [
                        '<div class="easyui-layout UIContentLayout"  id="easyuiLayout_', filter, '" data-options="fit:true" style="display:block;overflow-y: hidden;">',
                            '<div data-options="region:\'center\'" style="padding: 5px;">',
                                '<form id="form_' + filter + '" lay-filter="' + filter + '" class="layui-form " style="margin-top:5px" ></form>',
                            '</div>',
                            '<div data-options="region:\'south\',split:true" style="height:270px;padding-left: 5px;padding-right: 5px;" id="border_', filter, '">',
                                '<div class="layui-layout-border layui-tab" lay-filter="tab_',filter ,'" style="display:block;margin:5px;">',
                                        '<ul class="layui-tab-title tabTitle tab_center_', filter, '" lay-allowClose="false">',
                                            '<li lay-id="codeorder" class="',(add?'layui-this':''),'" style="',(add?'':'display:none;'),'">码值申请</li>',
                                            '<li lay-id="resemble">相似项查询</li>',
                                        '</ul>',
                                        '<ul class="layui-tab-content tabContent">',
                                            '<li lay-id="codeorder" class="layui-tab-item ',(add?'layui-show':''),'" style="',(add?'':'display:none;'),'">',
                                                '<form class="layui-form" lay-filter="form_codevlaue_', filter, '" style="height:100%;"></form>',
                                            '</li>',
                                            '<li class="layui-tab-item"  lay-id="resemble">',
                                                '<table id="resemble_', filter , '" lay-filter="resemble_',filter , '" style="overflow-x:auto;"></table>',
                                            '</li>',
                                        '</ul>',
                                '</div>',
                            '</div>',
                        '</div>'
                    ]
                    var hasResemble =  (componentVO.resembleTableVO && componentVO.resembleTableVO.cols && componentVO.resembleTableVO.cols.length > 0);
                    var dialogIndex = webUtil.dialog({
                        title: (add ? "编码申请" : (up?"数据更改":'修改编码信息')),
                        btn: !hasResemble?['保存', '取消']:['保存', '取消', '相似项查询'],
                        fullScreen: true,
                        content: html.join(''),
                        resizing: function (layero) {
                            form.doResize(filter);
                        },
                        success: function (layero) {
                            var easyuiLayout = $('#easyuiLayout_' + filter)
                            easyuiLayout.css({height: easyuiLayout.parents('.layui-layer-content').height()-10, width: easyuiLayout.parents('.layui-layer-content').width()-10})
                            easyuiLayout.parent().parent().css({padding: '5px'})
                            easyuiLayout.layout();
                            that.MdmEngineForm.initResembleTable(componentVO,filter);
                            form.addItems(filter, items,
                                function () {
                                    //只传递了数据的主键,所以我们需要从后台获取一下
                                    if (!add) {
                                        form.load(filter, {
                                            backPath: that.backPath,
                                            url: that.url.controller + that.url.getDataByOid,
                                            method: 'get',
                                            params: {
                                                oid: oid,
                                                templateOid: that.config[configId].componentVO.templateVO.oid
                                            }
                                        });
                                    }
 
                                    if(add){
                                        webUtil.get(that.url.controller + 'getCodeRuleByClassifyOid', {codeClassifyOid: that.config[configId].currentItemOid}, function (result) {
                                            if (!result.success) {
                                                $webUtil.showErrorMsg(result.msg);
                                            } else {
                                                that.config[configId].codeRuleOid=result.obj.oid;
                                                var codeValueItems=that.MdmEngineForm.getCodeValueItems(result.obj.secVOList,'form_codevlaue_'+filter);
                                                if(codeValueItems.length==0 && !hasResemble){
                                                    easyuiLayout.layout('remove','south');
                                                    return;
                                                }
                                                if(codeValueItems.length == 0 && hasResemble){
                                                    //隐藏当前的选项卡
                                                    layui.element.tabDelete("tab_" + filter, "codeorder");
                                                    return;
                                                }
                                                var height=Math.ceil(codeValueItems.length/colCount)*53+70;
                                                if(hasResemble && height<270){
                                                    height =270;
                                                }
                                                var top=easyuiLayout.height()-height-5;
                                                $('#border_'+ filter).height(height-5).parent().css({top:top+'px'}).prev().find('.layout-body').height(top-12);
                                                form.addItems('form_codevlaue_'+filter, codeValueItems,function (){}, {}, {defaultColumnOneRow: colCount, labelWidth: 160});
                                            }
                                        });
                                    }else{
                                        if(!hasResemble){
                                            easyuiLayout.layout('remove','south');
                                            return;
                                        }else{
                                            //隐藏码值申请选项卡
                                            layui.element.tabDelete("tab_" + filter, "codeorder");
                                            return;
                                        }
                                    }
 
                                }, {}, {defaultColumnOneRow: colCount, labelWidth: 160});
 
                        },
                        yes: function (layero) {
                            if (form.validata(filter) && form.validata("form_codevlaue_" + filter)) {
                                var values = form.getDefaultValues(filter, true);
                                if(up){
                                    values.defaultValues['copyfromversion'] = values.defaultValues.oid;
                                    values.defaultValues.oid = '';
                                }
                                var codevalues = form.getValues("form_codevlaue_" + filter, true);
                                var secDTOList=[];
                                layui.each(codevalues,function (i,item){
                                    secDTOList.push({secOid:i,secValue:item})
                                })
                                var datas = {
                                    codeClassifyOid:that.config[configId].currentItemOid,
                                    templateOid:that.config[configId].componentVO.templateVO.oid,
                                    codeRuleOid:that.config[configId].codeRuleOid,
                                    data: values.otherValue,
                                    secDTOList:secDTOList
                                }
                                $.extend(datas, values.defaultValues);
                                webUtil.manualAjax((add||up)?'post':'put', that.url.controller+(add?'addSaveCode':(up?'upSaveCode':'editSaveCode')), JSON.stringify(datas), function (result) {
                                    if (result.success) {
                                        webUtil.showMsgFromResult(result, (add?"添加成功":(up?'数据更改成功':"修改成功")));
                                        layer.close(dialogIndex);
                                        that.refreshTable(null,button)
                                    } else {
                                        webUtil.showErrorMsg(result.msg);
                                    }
                                }, function (xhr, err) {
                                    webUtil.showErrorMsg("请求服务出现了错误,可能服务器未开启");
                                }, that.backPath);
                            }
                        },
                        btn3:function (layero){
                            if(form.validata(filter)){
                                var values = form.getDefaultValues(filter, true);
                                if(up){
                                    values.defaultValues['copyfromversion'] = values.defaultValues.oid;
                                    values.defaultValues.oid = '';
                                }
                                var datas = {
                                    codeClassifyOid:that.config[configId].currentItemOid,
                                    templateOid:that.config[configId].componentVO.templateVO.oid,
                                    codeRuleOid:that.config[configId].codeRuleOid,
                                    data: values.otherValue
                                }
                                $.extend(datas, values.defaultValues);
                                webUtil.manualAjax('post', that.url.controller+'resembleQuery', JSON.stringify(datas), function (result) {
                                    if (result.success) {
                                        layui.table.reload("resemble_" + filter, {
                                            data: result.data
                                        });
                                        layui.element.tabChange("tab_" + filter, 'resemble');
                                    } else {
                                        webUtil.showErrorMsg(result.msg);
                                    }
                                }, function (xhr, err) {
                                    webUtil.showErrorMsg("请求服务出现了错误,可能服务器未开启");
                                }, that.backPath);
                            }
                            return false;
                        },
                        btn2: function (layero) {
                            layer.close(dialogIndex);
                        }
                    });
                }
            });
        };
        this.CODEEDIT=function (type,button){
            var that = this;
            var configId=$(button).attr('layui-filter').split('_')[1]
            var oid = webUtil.getOidFromGrid('table_' + configId,true,true);
            if(!oid){
                return;
            }
            var lcStatus = webUtil.getOidFromGrid('table_' + configId,true,true,'lcstatus');
            if (lcStatus != 'Editing') {
                webUtil.showErrorMsg('编码状态不是“编辑中”,不可编辑');
                return false;
            }
            that.codeAddOrEdit(button,configId,false,oid,null);
        }
        this.CODEDELETE=function (type,button){
            var that = this;
            var configId=$(button).attr('layui-filter').split('_')[1]
            if(!that.checkComponentVO(configId)){
                return false;
            }
            var oid = webUtil.getOidFromGrid('table_' + configId,true,false);
            if(!oid){
                return false;
            }
            webUtil.showConfirmMsg("是否删除选中数据?",function () {
                var submitData = {
                    oidList:oid.split(","),
                    codeClassifyOid:that.config[configId].currentItemOid
                }
                webUtil.manualAjax("delete",that.url.controller + 'deleteCode',JSON.stringify(submitData),function(result){
                    if(result.success){
                        webUtil.showMsgFromResult(result,"删除成功");
                        that.refreshTable(null,button);
                    }else{
                        webUtil.showErrorMsg(result.msg);
                    }
                },function(xhr,err){
                    webUtil.showErrorMsg("请求服务出现了错误,可能服务器未开启");
                },that.backPath);
            });
        }
 
        this.CODEEXPORT = function (type,button){
            //导出
            var that = this;
            var configId=$(button).attr('layui-filter').split('_')[1]
            var form=layui.form;
            var filter = "codeexport_" + configId;
            var content =['<div style="display:block;">',
                    '<form id="form_' + filter + '" lay-filter="' + filter + '" class="layui-form" style="margin-top:5px" ></form>',
                    '<div id="transfer_'+filter+'" style="margin: 0 15px;display: inline-block"></div>',
                    '<div id="tool_'+filter+'" style="display: inline-block">',
                        '<button disabled class="layui-btn layui-btn-sm layui-btn-disabled toolbar_', filter, '_UPSELECT" style="display:block"><i class="layui-icon layui-icon-up"></i>上移</button>',
                        '<button disabled class="layui-btn layui-btn-sm layui-btn-disabled toolbar_', filter, '_DOWNSELECT" style="margin:10px 0 0 0"><i class="layui-icon layui-icon-down"></i>下移</button>',
                    '</div>',
                '</div>'];
            var dialogndex = $webUtil.dialog({
                title: '数据导出属性选择窗口',
                btn: ['确定', '取消'],
                content: content.join(''),
                area: ['800px', '670px'],
                success: function (layero) {
                    form.addItems(filter, [{
                            field: 'type',
                            title: '导出方式',
                            textWidth: 275,
                            textStyle: 'margin-bottom: 5px;',
                            type: 'radio',
                            comboxKey: 'type',
                            data: [{key: 'check', value: '选择&nbsp;&nbsp;&nbsp;&nbsp;'}, {key: 'all', value: '全部&nbsp;&nbsp;&nbsp;&nbsp;'}, {key: 'page', value: '页码'}]
                        }],
                        function () {
                            form.on('radio(type)', function (data) {
                                var parentDiv = data.othis.parents('.layui-form-item');
                                if (this.value != 'page') {
                                    parentDiv.find('.layui-form-mid').remove();
                                } else {
                                    if (parentDiv.find('.layui-form-mid').length == 0) {
                                        var inputDiv = $('<div class="layui-form-mid" style="padding: 0 !important"><input type="text" name="exportPage" autofocus lay-verify="exportPage" class="layui-input" style="width: 100px;display: inline-block"> (输入页码或者页面范围,如:1-10)</div>');
                                        inputDiv.appendTo(parentDiv);
                                    }
                                }
                            });
                        }, {}, {});
                    var datas=[];
                    for (var i = 0; i < that.config[configId].componentVO.templateVO.attributes.length; i++) {
                        if(that.config[configId].componentVO.templateVO.attributes[i].formdisplayflag=='true' || that.config[configId].componentVO.templateVO.attributes[i].tabledisplayflag=='true'){
                            datas.push(that.config[configId].componentVO.templateVO.attributes[i])
                        }
                    }
                    layui.transfer.render({
                        elem: '#transfer_'+filter
                        ,data: datas
                        ,width:310
                        ,height:500
                        ,id:'transfer_'+filter//索引
                        ,parseData: function(res){
                            return {
                                "value": res.id //数据值
                                ,"title": res.name//数据标题
                            }
                        }
                        ,title: ['未选属性', '已选属性']
                        ,showSearch: true
                        ,done:function (d,laybox) {
                            laybox.eq(1).on('click', 'input[lay-filter="layTransferCheckbox"]+', function () {
                                var checkbox = laybox.eq(1).find('input[name="layTransferLeftCheck"]:checked');
                                if (checkbox.length > 0) {
                                    $('.toolbar_' + filter + '_UPSELECT').removeAttr('disabled').removeClass('layui-btn-disabled')
                                    $('.toolbar_' + filter + '_DOWNSELECT').removeAttr('disabled').removeClass('layui-btn-disabled')
                                } else {
                                    $('.toolbar_' + filter + '_UPSELECT').attr('disabled', 'disabled').addClass('layui-btn-disabled')
                                    $('.toolbar_' + filter + '_DOWNSELECT').attr('disabled', 'disabled').addClass('layui-btn-disabled')
                                }
                            })
                            $('.toolbar_' + filter + '_UPSELECT').click(function () {
                                var checkbox = laybox.eq(1).find('input[name="layTransferLeftCheck"]:checked');
                                if (checkbox.length > 1) {
                                    $webUtil.showErrorMsg("请选择一条需要移动的数据");
                                    return;
                                }
                                var index=checkbox.eq(0).parent().index()
                                index!=0 && layui.transfer.moveData('transfer_' + filter,1,index,index-1);
                            })
                            $('.toolbar_' + filter + '_DOWNSELECT').click(function () {
                                var data = layui.transfer.getData('transfer_' + filter);
                                var checkbox = laybox.eq(1).find('input[name="layTransferLeftCheck"]:checked');
                                if (checkbox.length > 1) {
                                    $webUtil.showErrorMsg("请选择一条需要移动的数据");
                                    return;
                                }
                                var index=checkbox.eq(0).parent().index()
                                index!=data.length-1 && layui.transfer.moveData('transfer_' + filter,1,index,index+1);
                            })
                        }
                    })
 
 
                },
                yes: function (layero) {
                    var data={
                        codeClassifyOid:that.config[configId].currentItemOid
                    }
                    var getData = layui.transfer.getData('transfer_'+filter);
                    $.each(getData,function (i,item){
                        data['attrIdIndexMap["' + i + '"]']=item.value
                    })
 
                    var requestData={};
                    var queryValue = $('[layui-filter="toolbar_' + configId + '"] input[name="fast_search_select_value"]').val();
                    var queryKey = $('[layui-filter="toolbar_' + configId + '"] select[name="fast_search_select"]').val();
                    if($webUtil.isNotNull(queryKey)){
                        requestData['conditionMap["' + queryKey + '"]'] = ($webUtil.isNull(queryValue)?"":("*" + queryValue + "*"));
                        var lastQueryKeyInput = $('[layui-filter="toolbar_' + configId + '"] input[name="fast_search_select_value"]').next();
                        var lastQueryKey =lastQueryKeyInput.val();
                        if($webUtil.isNotNull(lastQueryKey) && lastQueryKey != queryKey){
                            requestData['conditionMap["' + lastQueryKey + '"]'] = "";
                        }
                    }
                    if(that.config[configId].serinorQueryInstance && that.config[configId].serinorQueryInstance.requestData){
                        $.extend(requestData,that.config[configId].serinorQueryInstance.requestData);
                    }
                    $.each(requestData,function (i,item){
                        data[i]=item
                    })
 
                    var type = form.getValues(filter, true).type;
                    if(type=='check'){
                        var selectData = layui.table.checkStatus("table_" +configId).data;
                        if(selectData.length == 0){
                            $webUtil.showErrorMsg("请选择要导出的数据");
                            return false;
                        }
                        var oids=[];
                        layui.each(selectData,function (i,item){
                            oids.push(item.oid);
                        });
                        data['conditionMap["oid"]']=oids.join(',')
                    }else if (type=='page'){
                        data.limit=$("div.layui-table-view[lay-id='table_" +configId+"'] .layui-laypage-limits select").val();
                        var exportPage=$('input[name="exportPage"]').val();
                        if(webUtil.isNull(exportPage)){
                            $webUtil.showErrorMsg("请选择要导出的页码");
                            return false;
                        }
                        if(exportPage.indexOf('-')!=-1){
                            if(!/^[1-9]\d*$/.test(exportPage.split('-')[0]) || !/^[1-9]\d*$/.test(exportPage.split('-')[1])){
                                $webUtil.showErrorMsg("请输入正确的页面范围");
                                return false;
                            }
                            data.page=exportPage.split('-')[0];
                            data.endPage=exportPage.split('-')[1];
                        }else {
                            if(!/^[1-9]\d*$/.test(exportPage)){
                                $webUtil.showErrorMsg("请输入正确的页码");
                                return false;
                            }
                            data.page=exportPage;
                            data.endPage=exportPage;
                        }
 
                    }else{
                        data.limit=-1;
                    }
                    $webUtil.fileDownloadPost(that.backPath + that.url.controller + that.url.export, data,function (){ layer.close(dialogndex);});
                },
                btn2: function (layero) {
                    layer.close(dialogndex);
                }
            })
 
        };
 
        this.CODEBATCHADD = function (type,button) {
            // 先把模板下载下来
            var that = this;
            var configId=$(button).attr('layui-filter').split('_')[1]
            var filter = "batchAdd" + configId;
            var form = layui.form;
            var content = ['<form id="', filter, '" lay-filter="', filter, '" class="layui-form" style="margin:15px 30px 15px 0;" >' +
            '</form>',
                '<button type="button" className="layui-btn" id="upload_button_' , filter ,
                '" style="margin:5px 50px;display: block;float:left;"><i className="layui-icon layui-icon-upload"></i>浏览文件</button>'
            ].join('');
            var addSaveIndex = $webUtil.dialog({
                title: '批量申请编码',
                btn: ['下载导入模板', '关闭'],
                content: content,
                area: ['800px', '600px'],
                success: function (layero) {
                    //添加编码规则的字段
                    webUtil.get(that.url.controller + 'getCodeRuleByClassifyOid', {codeClassifyOid: that.config[configId].currentItemOid}, function (result) {
                        if (!result.success) {
                            $webUtil.showErrorMsg(result.msg);
                        } else {
                            var items = [{
                                type:'line',
                                field:'tips',
                                text:'导入提示'
                            },{
                                field: 'keyAttrTips',
                                text:'1.标题带五角星的表示关键属性,带星号表示必输项',
                                type: 'label',
                                labelWidth:475,
                                labelStyle:'margin-left:50px',
                                useAllWidth:true
                            },{
                                field: 'requiredTips',
                                text:'2.请一定先选择/输入编码规则的码段值后再选择excel文件',
                                type: 'label',
                                labelWidth:475,
                                labelStyle:'margin-left:50px',
                                useAllWidth:true
                            },{
                                field: 'totalTooltips',
                                text:'3.每次仅能最多导入10000条数据,如果出错会返回错误的数据和原因,但是正确的数据会保存',
                                type: 'label',
                                labelWidth:475,
                                labelStyle:'margin-left:50px',
                                useAllWidth:true
                            }, {
                                field: 'classifyTips',
                                text: '4.如果属性为参照,在参照配置中设置多个属性时,优先使用name属性的值,否则填写第一个属性的值。',
                                type: 'label',
                                labelWidth: 600,
                                labelStyle: 'margin-left:50px',
                                useAllWidth: true
                            },{
                                type:'line',
                                field:'codeValues',
                                text:'编码规则的码段信息,请先选择后再导入'
                            }];
                            var codeValueItems=that.MdmEngineForm.getCodeValueItems(result.obj.secVOList);
                            //我们把提示的信息也加进去
                            if(codeValueItems){
                                layui.each(codeValueItems,function (_index,_item){
                                    items.push(_item);
                                });
                            }
                            items.push({
                                type:'line',
                                field:'excelFile',
                                text:'excel文件,选择文件后会自动上传'
                            })
                            form.addItems(filter, items,function (){}, {}, {defaultColumnOneRow: that.MdmEngineForm.getFormCol({items:[], labelWidth: 160}), labelWidth: 160});
                            var upload = layui.upload;
                            //执行实例
                            var uploadInst = upload.render({
                                elem: '#upload_button_' + filter //绑定元素
                                ,accept:'file'
                                ,acceptMime:'file/*'
                                ,exts:'xls|xlsx'
                                ,url: that.backPath+ that.url.controller + that.url.batchImportCode//上传接口
                                ,auto:true
                                ,before:function(obj){
                                    if(!form.validata(filter)){
                                        return false;
                                    }
                                    var values = form.getValues(filter, true);
                                    var secDTOList=[];
                                    layui.each(values,function (i,item){
                                        secDTOList.push({secOid:i,secValue:item})
                                    })
                                    values['secDTOList'] = JSON.stringify(secDTOList);
                                    values['codeClassifyOid'] = that.config[configId].currentItemOid;
                                    obj.setData(values);
                                    return true;
                                }
                                ,done: function(result){//不需要输入内容,因此没有before
                                    if(result.success){
                                        layer.close(addSaveIndex);
                                        $webUtil.showMsgFromResult(result,"批量申请成功!");
                                        that.refreshTable(null,button);
                                    }else{
                                        //需要去下载错误信息
                                        $webUtil.fileDownload(that.backPath + that.url.controller + "downloadErrorFile?uuid=" + result.obj,null,'导入错误,请查看下载的【错误信息】文件');
                                    }
                                }
                                ,error: function(){
                                    //请求异常回调
                                    $webUtil.showErrorMsg("上传异常,服务端出错了");
                                }
                            });
                        }
                    });
                },
                yes: function (layero) {
                    $webUtil.fileDownload(that.backPath + that.url.controller + that.url.downloadImportExcel + "?codeClassifyOid=" + that.config[configId].currentItemOid);
                },
                btn2: function (layero) {
                    layer.close(addSaveIndex);
                }
            });
        };
        this.CODEIMPORTHISTORY = function (type,button){
            // 先把模板下载下来
            var that = this;
            var configId=$(button).attr('layui-filter').split('_')[1]
            var filter = "history" + configId;
            var form = layui.form;
            var content = ['<form id="', filter, '" lay-filter="', filter, '" class="layui-form" style="margin:15px 30px 15px 0;" >' +
            '</form>',
                '<button type="button" className="layui-btn" id="upload_button_' , filter ,
                '" style="margin:5px 50px;display: block;float:left;"><i className="layui-icon layui-icon-upload"></i>浏览文件</button>'
            ].join('');
            var addSaveIndex = $webUtil.dialog({
                title: '历史数据导入',
                btn: ['下载导入模板', '关闭'],
                content: content,
                area: ['800px', '600px'],
                success: function (layero) {
                    //历史数据不导规则
                    var items = [{
                        type: 'line',
                        field: 'tips',
                        text: '导入提示'
                    }, {
                        field: 'keyAttrTips',
                        text: '1.标题带五角星的表示关键属性,带星号表示必输项',
                        type: 'label',
                        labelWidth: 600,
                        labelStyle: 'margin-left:50px',
                        useAllWidth: true
                    }, {
                        field: 'requiredTips',
                        text: '2.企业编码,集团码和状态都需要导入',
                        type: 'label',
                        labelWidth: 600,
                        labelStyle: 'margin-left:50px',
                        useAllWidth: true
                    },{
                        field: 'requiredTips',
                        text:'3.每次仅能最多导入10000条数据,如果出错会返回错误的数据和原因,但是正确的数据会保存',
                        type: 'label',
                        labelWidth:600,
                        labelStyle:'margin-left:50px',
                        useAllWidth:true
                    }, {
                        field: 'classifyTips',
                        text: '4.分类的路径需要用#分隔。仅填写当前选的分类树上的下级分类的路径,如果当前分类已经是叶子节点,则不填写',
                        type: 'label',
                        labelWidth: 600,
                        labelStyle: 'margin-left:50px',
                        useAllWidth: true
                    },{
                        field: 'classifyAttr',
                        title: '分类的路径使用的属性',
                        textWidth: 350,
                        labelWidth: 200,
                        textStyle: 'margin-bottom: 15px;',
                        type: 'radio',
                        comboxKey: 'classifyAttr',
                        data: [{key: 'id', value: '分类编号'}, {key: 'name', value: '分类名称'}]
                    }, {
                        type: 'line',
                        field: 'excelFile',
                        text: 'excel文件,选择文件后会自动上传'
                    }];
                    form.addItems(filter, items, function () {
                    }, {}, {defaultColumnOneRow: that.MdmEngineForm.getFormCol({items: [], labelWidth: 160}), labelWidth: 160});
                    var upload = layui.upload;
                    //执行实例
                    var uploadInst = upload.render({
                        elem: '#upload_button_' + filter //绑定元素
                        , accept: 'file'
                        , acceptMime: 'file/*'
                        , exts: 'xls|xlsx'
                        , url: that.backPath + that.url.controller + that.url.importHistoryData//上传接口
                        , auto: true
                        , before: function (obj) {
                            if (!form.validata(filter)) {
                                return false;
                            }
                            var values = form.getValues(filter, true);
                            values['codeClassifyOid'] = that.config[configId].currentItemOid;
 
                            obj.setData(values);
                            return true;
                        }
                        , done: function (result) {//不需要输入内容,因此没有before
                            if (result.success) {
                                layer.close(addSaveIndex);
                                $webUtil.showMsgFromResult(result, "导入历史数据成功!");
                                that.refreshTable(null,button);
                            }else{
                                //需要去下载错误信息
                                $webUtil.fileDownload(that.backPath + that.url.controller + "downloadErrorFile?uuid=" + result.obj,null,'导入错误,请查看下载的【错误信息】文件');
                            }
                        }
                        , error: function () {
                            //请求异常回调
                            $webUtil.showErrorMsg("上传异常,服务端出错了");
                        }
                    });
                },
                yes: function (layero) {
                    $webUtil.fileDownload(that.backPath + that.url.controller + that.url.downloadImportExcelHistory + "?codeClassifyOid=" + that.config[configId].currentItemOid);
                },
                btn2: function (layero) {
                    layer.close(addSaveIndex);
                }
            });
        };
        this.CODESTARTPROCESS = function (type,button){
            var configId=$(button).attr('layui-filter').split('_')[1]
            var options = {
                processUse:'code_cls_flow_use_order',
                processUseText:'申请',
                allowStatus:'Editing',
                allowStatusText:'已编辑',
                startStatus:'Auditing',
                resetStatus:'Editing',
                batchTitle:'批量提交编码数据到流程审批',
                title:'提交编码数据到流程审批'
            }
            var that = this;
            that.checkStatusAndSubmitProcess(options,'Released',configId,button);
        };
        this.CODEDISABLE = function (type,button){
            var configId=$(button).attr('layui-filter').split('_')[1]
            var options = {
                processUse:'code_cls_flow_use_freeze',
                processUseText:'停用',
                allowStatus:'Released',
                allowStatusText:'已发布',
                resetStatus:'Released',
                batchTitle:'批量停用(冻结)的编码数据',
                title:'停用(冻结)编码数据',
                confirmMsg:'是否要停用这些数据',
            }
            var that = this;
            that.checkStatusAndSubmitProcess(options,'Disabled',configId,button);
        };
        this.CODERECYCLE = function (type,button){
            var configId=$(button).attr('layui-filter').split('_')[1]
            var options = {
                processUse:'code_cls_flow_use_delete',
                processUseText:'回收',
                allowStatus:'Released,Disabled',
                allowStatusText:'已发布,已停用',
                batchTitle:'批量回收的编码数据',
                title:'回收编码数据',
                confirmMsg:'是否要回收这些数据',
            }
            var that = this;
            that.checkStatusAndSubmitProcess(options,'TakeBack',configId,button);
        };
        this.CODEENABLE = function (type,button){
            var configId=$(button).attr('layui-filter').split('_')[1]
            var options = {
                processUse:'code_cls_flow_use_unfreeze',
                processUseText:'启用',
                allowStatus:'Disabled',
                allowStatusText:'已停用',
                resetStatus:'Disabled',
                batchTitle:'批量启用(解冻)的编码数据',
                title:'启用(解冻)编码数据',
                confirmMsg:'是否要启用(解冻)这些数据',
            }
            var that = this;
            that.checkStatusAndSubmitProcess(options,'Released',configId,button);
        };
        this.CODEUPREVISION = function (type,button){
            //升版
            var that = this;
            var configId=$(button).attr('layui-filter').split('_')[1]
            var oid = webUtil.getOidFromGrid('table_' + configId,true,true);
            if(!oid){
                return;
            }
            var lcstatus = webUtil.getOidFromGrid('table_' + configId,false,false,'lcstatus');
            if(lcstatus != 'Released'){
                $webUtil.showErrorMsg('只有状态为已发布的数据才能进行数据更改');
                return false;
            }
            that.codeAddOrEdit(button,configId,false,oid,true);
        };
        this.checkStatusAndSubmitProcess = function (options,targetLcstatus,configId,button){
            var that = this;
            if(!that.checkComponentVO(configId)){
                return false;
            }
            var oids = $webUtil.getOidFromGrid("table_" + configId,true,false);
            if(!oids){
                return false;
            }
            var selectData = layui.table.checkStatus("table_" + configId).data;
            if(selectData.length > 1000){
                $webUtil.showErrorMsg("每次提交到流程的数量请不要超过1000条");
                return false;
            }
            //审批的数据的状态必须相同
            var lcstatus = selectData[0].lcstatus;
            var same = true;
            layui.each(selectData,function (_index,_item){
                if(_item.lcstatus != lcstatus){
                    same =false;
                    return true;
                }
            });
            if(!same){
                $webUtil.showErrorMsg("您选择的数据的状态不相同");
                return false;
            }
            var sameStatus = false;
            layui.each(selectData,function (_index,_item){
                if(_item.lcstatus== targetLcstatus){
                    sameStatus =true;
                    return true;
                }
            });
            if(sameStatus){
                $webUtil.showErrorMsg("选择的数据中状态无需再执行当前操作");
                return false;
            }
            if(options.processUseText=='申请' && webUtil.isNotNull(selectData[0].copyfromversion)){
                options.processUseText='修改'
                options.processUse='code_cls_flow_use_modify'
            }
            //去后台获取模板
            $webUtil.get(that.url.processTemplateController + that.url.listProcessTemplate,{codeTemplateOid:that.config[configId].componentVO.templateVO.oid,processUse:options.processUse},function (result){
                if(!result.success || !result.data || result.data.length == 0){
                     that.changeStatus(targetLcstatus,oids,selectData[0].btmname,configId);
                    return false;
                }else{
                    var canUseTemplate = [];
                    layui.each(result.data,function (_index,_item){
                        canUseTemplate.push(_item.id);
                    });
                    //$webUtil.showConfirmMsg(options.confirmMsg || "是否将这些数据提交审批?",function (r){
                        //if(r){
                            layui.use(["process/vciWebStartProcess"], function () {
                                var startProcess = layui['process/vciWebStartProcess'];
                                startProcess.init();
                                startProcess.showStartWindow(that.config[configId].componentVO.templateVO.btmTypeId, selectData, {
                                    title: ((selectData.length>1?options.batchTitle:options.title) || '流程审批'),
                                    checkAllowAttributeValues:options.allowStatus,
                                    allowAttributesMsg:'只有状态是【' + options.allowStatusText + '】的数据才可以发起流程',
                                    startStatus: options.startStatus,
                                    resetStatus: (options.allowStatus.indexOf(",")>-1?lcstatus:options.resetStatus),
                                    isMutiProcess:false,
                                    canUseTemplate:canUseTemplate.join(","),
                                    variablesInfo:{
                                        codeClassifyOid:that.config[configId].currentItemOid,
                                        processUse:options.processUse
                                    },
                                    processName:webUtil.getSystemVar(webUtil.sessionInfoKey.userName)+'-'+options.processUseText+'['+that.config[configId].rootItemName+'-'+selectData[0].name+']',
                                    detailUrl:"USEJS:mdm/MdmEngineInProcess#",
                                }, function (result) {
                                    that.refreshTable(null,button);
                                });
                            });
                        //}
                    //});
                }
            },function (error,xhr){
                $webUtil.showErrorMsg("获取可用的流程模板出错,可能是服务没有启动,可以一会再试")
            },that.backPath);
        }
        this.VIEWFILE=function (rowData,configId){
            //文件预览
            layui.use('BaseFileDownloadAction', function () {
                var vciWebFilePreview = layui['BaseFileDownloadAction'];
                vciWebFilePreview.PREVIEW(rowData.oid,{fileOid:rowData.oid},function (){
                    $webUtil.showErrorMsg("文件预览失败,请联系管理员")
                })
            })
        }
        this.UPLOADFILE=function (type,button){
            var that=this;
            var configId=$(button).attr('layui-filter').split('_')[1]
            layui.use('BaseFileUploadAction', function () {
                var BaseAction = layui['BaseFileUploadAction'];
                var viewid = 'uploadfile_' + configId;
                var callback = function () {
                    that.refreshAttachTable(null,button)
                }
                var sourceData = layui.table.checkStatus("table_" + configId).data;
                if(sourceData.length!=1){
                    $webUtil.showErrorMsg("请选择一条分类数据")
                    return;
                }
                var dataStore = layui.table.checkStatus("table_attach_" + configId).data;
                BaseAction['doAction']({
                    paramVOS: {
                        title: "上传附件列表",
                        type: "fileobject"
                    },
                    id: viewid,
                    dataStore: dataStore,
                    sourceData: sourceData[0],
                    callback: callback
                });
            })
        }
        this.DOWNLOADFILE=function (type,button){
            var that=this;
            var configId=$(button).attr('layui-filter').split('_')[1]
            layui.use('BaseFileDownloadAction', function () {
                var BaseAction = layui['BaseFileDownloadAction'];
                var viewid = 'downloadfile_' + configId;
                var callback = function () {
                    that.refreshAttachTable(null,button)
                }
                var sourceData = layui.table.checkStatus("table_" + configId).data;
                var dataStore = layui.table.checkStatus("table_attach_" + configId).data;
                BaseAction['doAction']({
                    paramVOS: {
                        title: "下载附件列表",
                        type: "fileobject"
                    },
                    id: viewid,
                    dataStore: dataStore,
                    sourceData: sourceData[0],
                    callback: callback
                });
            })
 
        }
        this.revisefile=function (type,button){
            var that=this;
            var configId=$(button).attr('layui-filter').split('_')[1]
            layui.use('BaseFileUploadAction', function () {
                var BaseAction = layui['BaseFileUploadAction'];
                var viewid = 'uploadfile_' + configId;
                var callback = function () {
                    that.refreshAttachTable(null,button)
                }
                var sourceData = layui.table.checkStatus("table_" + configId).data;
                if(sourceData.length!=1){
                    $webUtil.showErrorMsg("请选择一条分类数据")
                    return;
                }
                var dataStore = layui.table.checkStatus("table_attach_" + configId).data;
                if(dataStore.length!=1){
                    $webUtil.showErrorMsg("请选择一条需要修改的数据")
                    return;
                }
                BaseAction['doAction']({
                    paramVOS: {
                        title: "修改附件列表",
                        type: "fileobject",
                        updatefileflag:'true'
                    },
                    id: viewid,
                    dataStore: dataStore,
                    sourceData: sourceData[0],
                    callback: callback
                });
            })
        }
        this.DELETEFILE=function (type,button){
            var that=this;
            var configId=$(button).attr('layui-filter').split('_')[1]
            layui.use('BaseDeleteAction', function () {
                var BaseAction = layui['BaseDeleteAction'];
                var viewid = 'uploadfile_' +configId;
                var callback = function () {
                    that.refreshAttachTable(null,button)
                }
                var sourceData = layui.table.checkStatus("table_" + configId).data;
                var dataStore = layui.table.checkStatus("table_attach_" + configId).data;
                BaseAction['doAction']({
                    paramVOS: {
                        owner: "true",
                        title: "删除附件列表",
                        type: "fileobject",
                        multi:true
                    },
                    id: viewid,
                    dataStore: dataStore,
                    sourceData: sourceData[0],
                    callback: callback
                });
            })
        };
        this.changeStatus = function (lcstatus,oids,btmname,configId){
            var that = this;
            $webUtil.showConfirmMsg("当前分类没有添加流程模板,是否不用流程审批直接执行",function (r) {
                if (r) {
                    $webUtil.post(that.url.controller + "/changeStatus", {
                        oid: oids,
                        btmname: btmname,
                        lcStatus: lcstatus
                    }, function (result) {
                        if (result.success) {
                            $webUtil.showMsgFromResult(result, "执行成功");
                            layui.table.reload('table_' + configId);
                        } else {
                            $webUtil.showErrorMsg(result.msg);
                        }
                    }, function (error, xhr) {
                        $webUtil.showErrorMsg("链接有误,可以一会再试");
                    }, that.backPath);
                }
            });
        }
    };
    var cs = new Class();
    exports(cs.MODELNAME,cs);
});