田源
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
/**
 * Created by weidy on 2020/2/25. from dengbk
 *
 * 物料基本信息
 */
 
layui.define(['layer','element','form','table','upload','platform/basedoc/BdMaterialClassifyExtendAttr'],function(exports){
    var Class = function(){
        this.MODULE_NAME = "platform/basedoc/BdMaterial";
        this.moduleKey = "BdMaterial";
        this.id='BdMaterial';
        this.sourceData={};
        this.columns = [];
        this.detailcolumns = [];
        this.backPath = configData.compatibility?path:configData.frameworkPath;//默认流程和项目的路径是一样的
        this.accountPath = configData.compatibility?path:configData.invmPath;
        this.controlSecret = true;//是否控制密级
        this.url={
            classifyTree:'materialClassifyController/referTree',
            referClassifyTree: 'materialClassifyController/referTree',
            controller:'materialController/',
            dataGrid:'gridMaterial',//列表数据和查询
            add:'addMaterial',
            edit:'editMaterial',
            del:'delMaterial',
            upRevision:'upRevisionMaterial',
            referOldRevision:'referOldRevision',
            release:'releaseForMaterial',
            getObjectByOid:'getObjectByOid',
            accountGrid:'materialAccountController/gridMaterAccountByMaterialOid',
            referUnit:'unitOfMeasurementController/referGridData',
            listCheckRule:'bdMaterialCheckController/gridBdMaterialCheck',
            addSave:'bdMaterialCheckController/addSave',
            editSave:'bdMaterialCheckController/editSave',
            deleteData:'bdMaterialCheckController/deleteData',
            download:'bdMaterialCheckController/downloadImportTemplate', // 导入定检规则下载文件
            importData:'bdMaterialCheckController/importData', // 导入定检规则下载文件
            exportData:'bdMaterialCheckController/exportData' //导出定检规则
        };
        this.buttonIconMap = {
            SEARCH:'layui-icon-refresh-2',
            SENIORSEARCH:'layui-icon-query',
            ADD:'layui-icon-add-1',
            EDIT:'layui-icon-edit',
            DELETE:'layui-icon-delete'
        };
        this.checkRuleTypeMap = {
            CHECK_HOUR:'check_hour',
            CHECK_COUNT:'check_count',
            CHECK_STORE_TIME:'check_store_time',
            CHECK_REACH_COUNT:'check_reach_cunt',
            CHECK_REACH_TIME:'check_reach_time',
            CHECK_DAY:'check_day',
            CHECK_MONTH:'check_month',
            CHECK_YEAR:'check_year',
            NONE:'check_none'
        };
        this.getContent=function(){
            //返回这个组件的基础html
            var that = this;
            var html = [
                '<div class="layui-layout-border" id="border_',that.id,'" style="overflow-x:hidden;">',
                    '<div class="layui-vci-deptTree" style="width:220px;float: left;background-color:#ffffff;">',
                        that.getClassifyToolbarHtml(),
                        '<label class="layui-icon layui-icon-tree" style="color:red;">物料/工具基本分类</label>',
                        '<ul layui-filter="tree_',that.id,'"></ul>',
                    '</div>',
                    '<div class="layui-center" style="margin-left:225px;">',
                         that.getToolbarHtml(),
                        '<table id="table_', that.id , '" lay-filter="',that.id , '" style="overflow-x:auto;"></table>',//主列表
                        '<div id="toolbar_column_',that.id ,'" style="display:none;"></div>',
                    '</div>',
                    '<div class="layui-south" style="margin-left:225px;">',
                        '<div class="layui-tab">',
                            '<ul class="layui-tab-title">',
                                '<li  class="layui-this">定检规则</li>',
                                ($webUtil.isNotNull(that.accountPath)?'<li>包含台账清单</li>':''),
                            '</ul>',
                            '<div class="layui-tab-content">',
                                '<div class="layui-tab-item layui-show">',
                                    that.getCheckToolbarHtml(),
                                    '<table id="table_check_', that.id , '" lay-filter="check_',that.id , '" style="overflow-x:auto;"></table>',
                                    '<div id="toolbar_column_check_',that.id ,'" style="display:none;"></div>',
                                '</div>',
                                ($webUtil.isNotNull(that.accountPath)?('<div class="layui-tab-item"><table id="detail_' + that.id + '" lay-filter="detail_' + that.id + '" style="width:100%"></table><div id="toolbar_column_detail_' + that.id  + '" style="display:none;"></div></div>'):''),
                            '</div>',
                        '</div>',
                    '</div>'];
            html.push('</div>');
            return html.join("");
        };
        this.getToolbarHtml =function(){
            var that = this;
            var html = [
                '<div layui-filter="toolbar_',that.id, '" class="layui-btn-container ">',//主列表的按钮 IMPORTTEMPLATE
                    '<button class="layui-btn layui-btn-sm" layui-filter="toolbar_',that.id,'_ADD"><i class="layui-icon layui-icon-add-1"></i>创建</button>',
                    '<button class="layui-btn layui-btn-sm" layui-filter="toolbar_',that.id,'_EDIT"><i class="layui-icon layui-icon-set"></i>修改</button>',
                    '<button class="layui-btn layui-btn-sm" layui-filter="toolbar_',that.id,'_RELEASE"><i class="layui-icon layui-icon-ok-circle"></i>发布</button>',
                    '<button class="layui-btn layui-btn-sm" layui-filter="toolbar_',that.id,'_UPREVISION"><i class="layui-icon layui-icon-templeate-1"></i>升版</button>',
                    '<button class="layui-btn layui-btn-sm" layui-filter="toolbar_',that.id,'_DEL"><i class="layui-icon layui-icon-delete"></i>删除</button>',
                    '<button class="layui-btn layui-btn-sm" layui-filter="toolbar_',that.id,'_IMPORT"><i class="layui-icon layui-icon-upload"></i>导入物料</button>',
                    '<button class="layui-btn layui-btn-sm" layui-filter="toolbar_',that.id,'_EXPORT"><i class="layui-icon layui-icon-export"></i>导出物料</button>',
                    '<button class="layui-btn layui-btn-sm" layui-filter="toolbar_',that.id,'_IMPORTRULE"><i class="layui-icon layui-icon-upload"></i>导入定检规则</button>',
                    '<button class="layui-btn layui-btn-sm" layui-filter="toolbar_',that.id,'_EXPORTRULE"><i class="layui-icon layui-icon-export"></i>导出定检规则</button>',
                    '<button class="layui-btn layui-btn-sm" layui-filter="toolbar_',that.id,'_refresh"><i class="layui-icon layui-icon-refresh"></i>刷新</button>',
                    '<div class="layui-input-inline" style="position: relative; padding-right: 5px;">',
                        '<div id="selectWrapForIE" style="display:none"></div>',
                        '<label class="layui-form-label" style="width: 100px;font-size:14px;padding: 5px;">显示所有版本:</label>',
                        '<div class="layui-unselect layui-form-switch" lay-skin="_switch" style="margin-top:0px" id="switch_',that.id,'"><em>否</em><i></i></div>',
                    '</div>',
 
                '</div>'
            ].join("");
            return html;
        };
        this.getCheckToolbarHtml = function () {
            var that = this;
            var html = [  '<div layui-filter="toolbar_check_',that.id, '" class="layui-btn-container layui-buttons">',
                '<button class="layui-btn layui-btn-sm" layui-filter="toolbar_check_',that.id,'_ADDRULE"><i class="layui-icon layui-icon-add-1"></i>创建定检规则</button>',
                '<button class="layui-btn layui-btn-sm" layui-filter="toolbar_check_',that.id,'_EDITRULE"><i class="layui-icon layui-icon-set"></i>修改定检规则</button>',
                '<button class="layui-btn layui-btn-sm" layui-filter="toolbar_check_',that.id,'_DELRULE"><i class="layui-icon layui-icon-delete"></i>删除定检规则</button>',
 
                '<button class="layui-btn layui-btn-sm" layui-filter="toolbar_check_',that.id,'_refreshRule"><i class="layui-icon layui-icon-refresh"></i>刷新</button>',
                '</div>'
            ].join("");
            return html;
        };
        this.getClassifyToolbarHtml = function(){
            var that = this;
            var html = [
                '<div layui-filter="toolbar_classify_',that.id, '" class="layui-btn-container layui-buttons">',
                '<button class="layui-btn layui-btn-sm" layui-filter="toolbar_classify_',that.id,'_refreshClassify"><i class="layui-icon layui-icon-refresh"></i>刷新</button>',
                '</div>'
            ].join("");
            return html;
        };
        this.init=function(){//基础的html被添加后,再执行初始化
            var that = this;
            $webUtil.copyConfig(that,that.moduleKey);
            $webUtil.bindDefultButtonLisenter(that, that.id);
            $webUtil.bindDefultButtonLisenter(that, "classify_" + that.id);
            $webUtil.bindDefultButtonLisenter(that, "check_" + that.id);
            var table = layui.table;
            that.materialExtendAttr = layui['platform/basedoc/BdMaterialClassifyExtendAttr'];
            //初始化
            that.classifyTreeInit(function () {
                that.initMainTable(
                    function () {
                        $webUtil.createSearchHtml({
                            id: '编号',
                            code:'图号',
                            name:'名称',
                            specification:'规格',
                            brand:'品牌',
                            material:'材质',
                            applyProduct:'适用产品',
                            supplier:'常用制造/供应商',
                            "useDept.name":'使用部门名称',
                            revisionValue:'版本号'
                        }, $('[layui-filter="toolbar_' + that.id + '"]'), that.id);
                        // that.initCheckTable();
                        if($webUtil.isNotNull(that.accountPath)) {
                            that.detailTableInit();
                        }
                    }
                );
            });
            $("#switch_" + that.id).unbind('click').click(function (e) {
                var thisObject = $(this);
                if(thisObject.hasClass("layui-form-onswitch")){
                    //说明现在点的是,需要修改为否
                    thisObject.removeClass("layui-form-onswitch");
                    thisObject.find("em").html("否");
                    table.reload("table_"+that.id,{
                        where:{
                            "conditionMap['${queryAllRevision}']":false
                        }
                    });
                }else{
                    thisObject.addClass("layui-form-onswitch");
                    thisObject.find("em").html("是");
                    table.reload("table_"+that.id,{
                        where:{
                            "conditionMap['${queryAllRevision}']":true
                        }
                    });
                }
                layui.stope(e);
            });
        };
        this.classifyTreeInit = function(callback){
            //初始化分类树
            var that = this;
            var tree = layui.tree;
            that.fristTreeLoad = false;
            tree.init("tree_" + that.id, $('[layui-filter="tree_' + that.id + '"]'), {
                url: that.url.classifyTree,
                backPath: that.backPath,
                extraParams: {
                    isMuti: false,
                    isQueryAllColumn: true
                },
                treeFilter: that.id,
                treeName: 'materialClassify',
                click: function (item, elem, options) {
                    that.currentItemOid = item.oid;
                    that.currentItemAttributes = item.attributes;
                    that.showMaterialByClassify(item.attributes);
                },
                done:function (filter,children) {
                    if(!that.fristTreeLoad &&callback){
                        callback();
                    }
                    that.fristTreeLoad = true;
                }
            });
        };
        this.showMaterialByClassify = function (classifyAttributes) {
            var that =this;
            var table = layui.table;
            that.materialExtendAttr.initExtendAttr(classifyAttributes.id,function(){
                table.reload("table_"+that.id,{
                    where:{
                        materialClassify:classifyAttributes.oid
                    }
                });
            });
        };
        this.initMainTable = function (callback) {
            var that = this;
            that.checkColumns();
            var table = layui.table;
            that.fristMainLoad = false;
            //主列表中列。
            var tableWidth = $("#border_" + that.id).width()-225;
            table.render({
                elem: '#table_' + that.id,
                id: 'table_' + that.id,
                url: that.backPath + that.url.controller + that.url.dataGrid,
                page: {
                    limit: 20,
                    page: 1
                },
                height:400,
                cols: [that.columns],
                width:tableWidth,
                done:function(res,cur,total){
                    if(!that.fristMainLoad ){
                        if(callback) {
                            callback();
                        }
                        table.on('tool(' + that.id + ')',function(obj){
                            var data = obj.data;//当前选择行的数据
                            var layEvent = obj.event;//点的是什么按钮
                            if(layEvent == 'viewInfo'){
                                that.showMaterialByOid(data.oid);
                            }
                        });
                    }
                    that.fristMainLoad = true;
                },
                rowClick:function(thisTableFilter,record){
                    that.initCheckTable(record.oid);
                    that.addRuleOid = record.oid
                    if($webUtil.isNotNull(that.accountPath)) {
                        table.reload("detail_" + that.id, {
                            extraParams: {
                                pkMaterial: record.oid
                            }
                        });
                    }
                    table.reload("check_" + that.id, {
                        extraParams: {
                            pkMaterial: record.oid
                        }
                    });
                }
            });
            document.getElementById("toolbar_column_" + that.id).innerHTML = '<a class="layui-btn layui-btn-intable" lay-event="viewInfo">查看</a>';
        };
        this.initCheckTable = function (oid) {
            //初始化定检规则的表格
            var that = this;
            that.checkCheckRuleColumns();
            var table = layui.table;
            //主列表中列。
            var tableWidth = $("#border_" + that.id).width()-225;
            var requestData = {};
            if(oid != undefined) {
                requestData["conditionMap['pkMaterial']"] = oid;
            };
            table.render({
                elem: '#table_check_' + that.id,
                id: 'table_check_' + that.id,
                url: that.backPath  + that.url.listCheckRule,
                page: {
                    limit: 20,
                    page: 1
                },
                where: requestData,
                cols: [that.checkRuleColumns],
                width:tableWidth,
                done:function(res,cur,total){
                    // if(!that.fristMainLoadCheck ){
                    //     if(callback) {
                    //         callback();
                    //     }
                        table.on('tool(check_' + that.id + ')',function(obj){
                            console.log(obj)
                            var data = obj.data;//当前选择行的数据
                            var layEvent = obj.event;//点的是什么按钮
                            if(layEvent == 'viewInfo'){
                                that.showRuleByOid(data);
                            }
                        });
                    // }
                    // that.fristMainLoadCheck = true;
                }
            });
            document.getElementById("toolbar_column_check_" + that.id).innerHTML = '<a class="layui-btn layui-btn-intable" lay-event="viewInfo">查看</a>';;
        };
        this.detailTableInit = function(){
            //初始化明细的列表
            var that = this,table = layui.table;
            that.detailCheckColumns();
            var tableWidth = $("#border_" + that.id).width()-225;
            table.render({
                elem: '#detail_' + that.id,
                id: 'detail_' + that.id,
                height:230,
                width:tableWidth,
                url:that.accountPath + that.url.accountGrid,
                extraParams:{
                    pkMaterial: ''
                },
                page: {
                    limit: 5,
                    page: 1
                },
                cols: [that.detailcolumns]
            });
        };
        this.checkLength = function(str){
            var reg = str.replace(/[\u4e00-\u9fa5]/g,'');
            if((str.length-reg.length)*2+reg.length<=127){
                return str
            }else{
                return str.substring(0,127)
            }
        };
 
        this.advancedQuery = function(){
            var that = this;
            var dynamicCondition = layui.dynamicCondition;
            $('[layui-filter="toolbar_' + that.id + '"]').append('<div  id="toolbar'+ that.id+'" class="layui-inline"></div>');
            var dataFields = that.columns;
            that.serinorQueryInstance = dynamicCondition.create({
                fields : dataFields//查询字段
                ,tableId:"table_"+that.id//需要查询的表格
                ,type:"complex"  //type:"simple"/"complex"  查询的方法  暂时写死为 complex
                ,conditionTextId:"#toolbar"+that.id//高级查询 按钮所在的div
                ,popupShowQueryBtn: true//显示高级查询按钮
                ,queryCallBack:function(requestData){//查询之后的callback
                    //console.log(JSON.stringify(requestData))
                }
            });
        };
        this.ADD = function(){
            var that = this;
            if(!that.currentItemOid){
                $webUtil.showErrorMsg("请先选择分类节点后再操作");
                return false;
            }
            that.addOrEdit(true);
        };
        this.EDIT = function(oid){
            var that = this;
            if(!oid) {
                oid = $webUtil.getOidFromGrid("table_" + that.id, true, true);
            }
            if(!oid){
                return false;
            }
            var lcStatus = $webUtil.getOidFromGrid("table_" + that.id,false,false,'lcStatus');
            if('Editing' != lcStatus){
                $webUtil.showErrorMsg("只有状态为【编辑中】时才能修改");
                return  false;
            }
            that.addOrEdit(false);
        };
        this.addOrEdit = function (add) {
            var that = this;
            var filter = "addOrEdit_" + that.id;
            if(!add){
                var oid = $webUtil.getOidFromGrid("table_" + that.id,true,true);
                if(!oid){
                    return false;
                }
            }
            var form = layui.form;
            var addSaveIndex = layer.open({
                type:1,
                title: add?'新增物料/工具基本信息':'修改物料/工具基本信息',
                btn: ['保存', '取消'],
                skin: 'layui-layer-lan',
                content: '<form id="form_' + filter + '" lay-filter="' + filter + '" class="layui-form" style="margin-top:5px" ></form>',
                fullScreen:true,
                resizing: function (layero) {
                    form.doResize(filter);
                },
                success: function (layero) {
                    form.addItems(filter,that.getFormItems(false),
                        function () {
                            if(add){
                                //添加的时候,如果选择树节点,则设置为物料基本分类
                                if($webUtil.isNotNull(that.currentItemOid)){
                                    form.setValues({
                                        materialClassify:that.currentItemOid,
                                        materialClassifyText:(that.currentItemAttributes.id + " " + that.currentItemAttributes.name),
                                        materialClassifyId:that.currentItemAttributes.id
                                    },filter);
                                }else{
                                    form.setValues({},filter);
                                }
                            }else{
                                var selectRowData = layui.table.checkStatus("table_" + that.id).data[0];
                                that.materialExtendAttr.loadMaterialForForm(filter,selectRowData.oid,that.currentItemAttributes.id);
                            }
                            //监控事件
                            form.on("select(" + filter + ")",function(data){
                                //我们需要在这里处理扩展属性
                                //获取新的分类的值,获取对应的业务类型的字段内容
                                //然后设置新的内容
                            });
                        }
                        , {}
                        , {
                            defaultColumnOneRow: 3
                        });
                },
                yes:function(layero){
                    if(form.validata(filter)){
                        var formValues = form.getValues(filter,true);
                        delete formValues['extendAttrData'];
                        for(var key in formValues){
                            if($webUtil.startWith(key,"extendAttrData[")){
                                delete formValues[key];
                            }
                        }
                        //处理扩展属性
                        for(var key in formValues){
                            if($webUtil.startWith(key,"ext_")){
                                var fieldName = key.replace("ext_","");
                                formValues['extendAttrData[' + fieldName + ']'] = formValues[key];
                            }
                        }
                        $webUtil.ajax(add?'post':'put',that.url.controller + (add?that.url.add:that.url.edit),formValues,function (result) {
                            if(result.success){
                                $webUtil.showMsgFromResult(result,add?"新增物料/工具基本信息成功":"修改物料/工具基本信息成功");
                                that.refresh();
                                layer.close(addSaveIndex);
                            }else{
                                $webUtil.showErrorMsg(result.msg);
                            }
                        },function (xhr,error) {
                            $webUtil.showErrorMsg("访问服务器出现了错误,可能服务器没有开启,或者连接失败");
                        },that.backPath);
                    }
                },
                btn2:function(layero){
                    that.refresh();
                    layer.close()
                }
            });
        };
        this.ADDRULE = function () {
            var that = this;
            //添加规则
            var  oid = $webUtil.getOidFromGrid("table_" + that.id, true, true);
            if(!oid){
                return false;
            }
            var lcStatus = $webUtil.getOidFromGrid("table_" + that.id,false,false,'lcStatus');
            if('Editing' != lcStatus){
                $webUtil.showErrorMsg("只有基本信息的状态为【编辑中】时才能添加定检规则");
                return  false;
            }
            that.addOrEditRule(true);
        };
        this.EDITRULE = function (oid) {
            var that = this;
            var  materialOid = $webUtil.getOidFromGrid("table_" + that.id, true, true);
            if(!materialOid){
                return false;
            }
            var lcStatus = $webUtil.getOidFromGrid("table_" + that.id,false,false,'lcStatus');
            if('Editing' != lcStatus){
                $webUtil.showErrorMsg("只有基本信息的状态为【编辑中】时才能添加定检规则");
                return  false;
            }
            if(!oid) {
                oid = $webUtil.getOidFromGrid("table_check_" + that.id, true, true);
            }
            if(!oid){
                return false;
            }
            that.addOrEditRule(false,oid);
        };
        this.DELRULE = function(){//删除
            var that = this;
            var oid = $webUtil.getOidFromGrid("table_check_" +that.id,true,true);
            if(!oid){
                return false;
            }
            var ts =  $webUtil.getOidFromGrid("table_check_" +that.id,false,false,"ts");
            $webUtil.showConfirmMsg("是否删除?如果物料/工具已经有台账内容,则不能删除",function () {
                $webUtil.deleteRequest(that.url.deleteData,{oid:oid,ts:ts},function (result) {
                    if(result.success){
                        $webUtil.showMsgFromResult(result,"删除成功");
                        that.refreshRule();
                    }else{
                        $webUtil.showErrorMsg(result.msg);
                    }
                },function (xhr,error) {
                    $webUtil.showErrorMsg("访问服务器出现了错误,可能服务器没有开启,或者连接失败");
                },that.backPath)
            });
        };
        this.IMPORT = function () {
            var that = this;
            var filter =that.id + "_uploadAccount";
            var uploadIndex = layer.open({
                type:1,
                title:'导入物料基本信息',
                skin:'layui-layer-lan',
                btn:['下载导入模板','取消'],
                content:'<div id="importAccount_' + that.id + '"><button type="button" class="layui-btn" id="upload_button_\' + filter + \'" style="margin:5px auto;display: block;float:left;"><i class="layui-icon layui-icon-upload"></i>浏览文件</button></div>',
                closeBtn:2,
                shade:true,
                area:['250px','180px'],
                shadeClose:true,
                resize:false,
                success:function(layero){
 
                },
                yes:function(){
                    var iframeId = MD5("downloadImportTemplate" +$webUtil.getSystemVar($webUtil.systemValueKey.currentDateTimeSSS)  +$webUtil.getSystemVar($webUtil.systemValueKey.userOid));
                    $webUtil.fileDownload(that.backPath + that.url.controller + that.url.downloadImportTemplate+ "?" + TOKEN_KEY + "=" + $webUtil.getToken() + "&downloadUUID=" + iframeId + "&materialClassifyId=" + that.currentItemAttributes.id);
                }
            });
        };
        this.IMPORTRULE = function () { //导入定检规则
            var that = this;
            var selectData  = layui.table.checkStatus("table_" + that.id).data[0];
            if(selectData == undefined){
                $webUtil.showErrorMsg('请选择一条数据!');
                return false;
            }
            var form = layui.form;
            var filter = that.id + "_uploadAccount";
            var uploadIndex = layer.open({
                type:1,
                title:'导入定检规则',
                skin:'layui-layer-lan',
                btn:['下载导入模板','取消'],
                content:'<div id="importAccount_' + filter + '"></div>',
                closeBtn:2,
                shade:true,
                area:['500px','300px'],
                shadeClose:true,
                resize:false,
                success:function(layero){
                    form.addItems(filter,[{
                        type:'label',
                        name:'uploadTwoDimensions',
                        labelWidth:140,
                    }],function(){
                        $("#importAccount_" + filter).append('<div style="display:block;width:190px;margin:10px auto 0">选择文件后自动上传</div>');
                        $("#importAccount_" + filter).append('<button type="button" class="layui-btn" id="upload_button_' + filter + '" style="display:block;width:190px;margin:100px auto 0"><i class="layui-icon layui-icon-upload"></i>选择文件后自动上传</button>');
                        var upload = layui.upload;
                        //执行实例
                        var uploadInst = upload.render({
                            elem: '#upload_button_' + filter //绑定元素
                            ,accept:'file'
                            ,acceptMime:'file/*'
                            ,exts:'xls|xlsx'
                            ,url: that.backPath+ that.url.importData//上传接口
                            ,auto:true
                            ,before:function(obj){            
                                obj.setData({pkMaterial:selectData.oid});
                                return true;
                            }
                            ,done: function(result){//不需要输入内容,因此没有before
                                if(result.success){
                                    layer.close(uploadIndex);
                                    $webUtil.showMsg("上传定检规则成功!");
                                    that.refresh();
                                    that.refreshRule();
                                }else{
                                    $webUtil.showErrorMsg(result.msg);
                                }
                            }
                            ,error: function(){
                                //请求异常回调
                                $webUtil.showErrorMsg("上传异常,服务端出错了");
                            }
                        });
                    },{},{
                        defaultColumnOneRow:1,
                        inDialog:true
                    });
                },
                yes:function(){
                    // var iframeId = MD5("downloadImportTemplate" +$webUtil.getSystemVar($webUtil.systemValueKey.currentDateTimeSSS)  +$webUtil.getSystemVar($webUtil.systemValueKey.userOid));
                    // $webUtil.fileDownload(that.backPath + that.url.download+ "?" + TOKEN_KEY + "=" + $webUtil.getToken() + "&downloadUUID=" + iframeId + "&materialClassifyId=" + that.currentItemAttributes.id);
                    var oid = "&" + "conditionMap['pkMaterial']=" + selectData.oid
                    var downIframe = $("<iframe>");
                    var iframeId = MD5("downloadImportTemplate" +$webUtil.getSystemVar($webUtil.systemValueKey.currentDateTimeSSS)  +$webUtil.getSystemVar($webUtil.systemValueKey.userOid));
                    iframeId.src = that.backPath + that.url.download;
                    portal.downloadFileUUID.push(iframeId);
                    downIframe.attr("style","display:none;");
                    downIframe.attr("id",iframeId);
                    $("body").append(downIframe);
                    downIframe.attr("src",that.backPath + that.url.download+ "?" + TOKEN_KEY + "=" + $webUtil.getToken() + "&downloadUUID=" + iframeId + "&materialClassifyId=" + that.currentItemAttributes.id+encodeURI(oid));
                    downIframe.load(function(){
                        if(downIframe.contents() && downIframe.contents().length>0) {
                            $webUtil.showErrorMsg(downIframe.contents().find("pre").html());
                        }
                        downIframe.remove();
                    });
                }
            });
        };
        this.EXPORTRULE = function () {  // 导出定检规则
            var that = this
            var selectData  = layui.table.checkStatus("table_" + that.id).data[0];
            if(selectData != undefined){
                var query = "";
                query += "&" + "conditionMap['pkMaterial']=" + selectData.oid
                // $webUtil.showConfirmMsg("您确定要下载文件吗?下载后请解压压缩包后再自行打开文件",function(){
                var downIframe = $("<iframe>");
                var iframeId = MD5(that.id + $webUtil.getSystemVar($webUtil.systemValueKey.userOid));
                iframeId.src = that.backPath + that.url.exportData;
                portal.downloadFileUUID.push(iframeId);
                downIframe.attr("style","display:none;");
                downIframe.attr("id",iframeId);
                $("body").append(downIframe);
                downIframe.attr("src",that.backPath + that.url.exportData+"?limit=-1"+ "&AuthorizationToken=" + $webUtil.getToken() + encodeURI(query));
                downIframe.load(function(){
                    if(downIframe.contents() && downIframe.contents().length>0) {
                        $webUtil.showErrorMsg(downIframe.contents().find("pre").html());
                    }
                    downIframe.remove();
                });
                // });
            } else {
                $webUtil.showErrorMsg('请选择一条数据!');
            }
        };
        this.addOrEditRule = function (add,oid) {
            var that = this;
            var filter = "addOrEditRule_" + that.id;
            if(!add){
                if(!oid) {
                    oid = $webUtil.getOidFromGrid("table_check_" + that.id, true, true);
                }
                if(!oid){
                    return false;
                }
            }
            var form = layui.form;
            var addSaveIndex = layer.open({
                type:1,
                title: add?'新增定检规则':'修改定检规则',
                btn: ['保存', '取消'],
                skin: 'layui-layer-lan',
                content: '<form id="form_' + filter + '" lay-filter="' + filter + '" class="layui-form" style="margin-top:5px" ></form>',
                fullScreen:true,
                resizing: function (layero) {
                    form.doResize(filter);
                },
                success: function (layero) {
                    form.addItems(filter,that.getFormCheckItems(false),
                        function () {
                            if(add) {
 
                            }else {
                                var selectRowData = layui.table.checkStatus("table_check_" + that.id).data[0];
                                form.setValues(selectRowData,filter);
                            }
                        }
                        , {}
                        , {
                            defaultColumnOneRow: 2
                        });
                },
                yes:function(layero){
                    if(form.validata(filter)){
                        var formValues = form.getValues(filter,true);
                        formValues.pkMaterial = that.addRuleOid;
                        $webUtil.ajax(add?'post':'put',(add?that.url.addSave:that.url.editSave),formValues,function (result) {
                            if(result.success){
                                $webUtil.showMsgFromResult(result,add?"新增定检规则成功":"修改定检规则成功");
                                that.refreshRule();
                                layer.close(addSaveIndex);
                            }else{
                                $webUtil.showErrorMsg(result.msg);
                            }
                        },function (xhr,error) {
                            $webUtil.showErrorMsg("访问服务器出现了错误,可能服务器没有开启,或者连接失败");
                        },that.backPath);
                    }
                },
                btn2:function(layero){
                    that.refreshRule();
                    layer.close()
                }
            });
        };
 
        this.showMaterialByOid =function (oid) { //物料基本信息查看
            var that = this;
            if(!oid){
                return false;
            }
            var filter = "view_" + that.id;
            var form = layui.form;
            var addSaveIndex = layer.open({
                type:1,
                title: '查看物料/工具基本信息',
                skin: 'layui-layer-lan',
                content: '<form id="form_' + filter + '" lay-filter="' + filter + '" class="layui-form" style="margin-top:5px" ></form>',
                fullScreen:true,
                resizing: function (layero) {
                    form.doResize(filter);
                },
                success: function (layero) {
                    form.addItems(filter,that.getFormItems(true),function () {
                            that.materialExtendAttr.loadMaterialForForm(filter,oid,that.currentItemAttributes.id);
                        }
                        , {}
                        , {
                            defaultColumnOneRow: 3
                        });
                }
            });
        };
        this.showRuleByOid =function (data) { //定检规则查看
            var that = this;
            var filter = "view_" + that.id;
            var form = layui.form;
            var addSaveIndex = layer.open({
                type:1,
                title: '定检规则',
                skin: 'layui-layer-lan',
                content: '<form id="form_' + filter + '" lay-filter="' + filter + '" class="layui-form" style="margin-top:5px" ></form>',
                fullScreen:true,
                resizing: function (layero) {
                    form.doResize(filter);
                },
                success: function (layero) {
                    form.addItems(filter,that.getFormCheckItems(true),function () {
                            form.setValues(data,filter)
                        }
                        , {}
                        , {
                            defaultColumnOneRow: 3
                        });
                }
            });
        };
        this.getFormItems = function(readOnly){
            var that = this;
            var items = [{
                name:'materialClassify',
                text:'物料/工具分类',
                type:'refer',
                showField: 'materialClassifyText',
                required:true,
                readOnly:readOnly,
                referConfig:{
                    type:'tree',
                    url: that.url.referClassifyTree,
                    backPath:that.backPath,
                    textField:'id,name',
                    valueField:'oid',
                    isMuti:false
                }
            },{
                name:'id',
                text:'物料/工具编号',
                readOnly:readOnly,
                required:true
            },{
                name:'code',
                readOnly:readOnly,
                text:'图号'
            },{
                name:'name',
                text:'名称',
                readOnly:readOnly,
                required:true
            },{
                name:'revisionValue',
                readOnly:readOnly,
                text:'版本'
            },{
                name:'useDept',
                text:'使用部门',
                readOnly:readOnly,
                type:'refer',
                showField: 'useDeptName',
                referConfig: {
                    type:layui.vciAlias.referRegister.departmentRefer
                }
            },{
                name:'specification',
                readOnly:readOnly,
                text:'规格'
            },{
                name:'materialModel',
                readOnly:readOnly,
                text:'物料型号'
            },{
                name:'brand',
                readOnly:readOnly,
                text:'品牌'
            },{
                name:'material',
                readOnly:readOnly,
                text:'材质'
            },{
                name:'applyProduct',
                readOnly:readOnly,
                text:'适用产品'
            },{
                name:'supplier',
                text:'常用制造/供应商',
                readOnly:readOnly
            },{
                readOnly:readOnly,
                name:'unitOfMeasurement',
                text:'计量单位(可手输)',
                type:'refer',
                showField: 'unitOfMeasurement',
                referConfig: {
                    type:'grid',
                    url: that.url.referUnit,
                    backPath: configData.frameworkPath,
                    textField:'id',
                    valueField:'id',
                    editable:true,
                    tableConfig: {
                        page: {
                            limit: 15,
                            page: 1
                        },
                        cols: [layui.table.getIndexColumn(), layui.table.getCheckColumn(), {
                            field: 'id',
                            title: '单位',
                            sort:true,
                            width: 150
                        }, {
                            field: 'name',
                            title: '说明',
                            sort:true,
                            width: 150
                        }],
                        queryColumns: [{
                            field: 'id',
                            title: '单位'
                        }, {
                            field: 'name',
                            title: '说明'
                        }]
                    }
                }
            },{
                name:'priceOfUnit',
                text:'单价',
                readOnly:readOnly,
                verify:'number'
            },layui.vciWebComboxStore.getSecretObject(that.controlSecret)];
            var extendAttrs = that.materialExtendAttr.getFormItemsByClassifyId(that.currentItemAttributes.id);
            if(extendAttrs && extendAttrs.length > 0){
                layui.each(extendAttrs,function (_index,_item) {
                    _item.name = "ext_" + _item.name;
                    if(readOnly){
                        _item.readOnly = readOnly;
                    }
                });
                items = items.concat(extendAttrs);
            }
            items.push({
                name:'materialLife',
                text:'寿命',
                readOnly:readOnly
            },{
                name:'description',
                type:'textarea',
                textWidth:870,
                readOnly:readOnly,
                text:'备注'
            });
            return items;
        };
        this.getFormCheckItems = function (readOnly) {
            var that = this;
            var table = layui.table;
            var items = [{
                name: 'name',
                text: '规则名称',
                required:true,
                readOnly:readOnly
            },{
                name:readOnly ? 'checkTypeText' : 'checkType',
                text:'定检类型',
                type:readOnly ? 'text' : 'combox',
                comboxKey:'lifeCountType',
                required:true,
                readOnly:readOnly
            },{
                name:'checkCycle',
                text:'定检周期数',
                verify:'number',
                required:true,
                readOnly:readOnly
            },{
                name:'alertCycle',
                text:'提前提醒数',
                verify:'number',
                required:true,
                readOnly:readOnly
            },{
                name:'checkContent',
                text:'定检内容',
                isNewRow:true,
                inputWidth:400,
                type:'textarea',
                readOnly:readOnly
            },{
                field:'exclusiveRuleName',
                text:'互斥定检规则',
                type:'refer',
                showField:'exclusiveRuleName',
                readOnly:readOnly,
                referConfig:{
                    type:'grid',
                    url: "bdMaterialCheckController/getByMaterialOid",
                    backPath:that.backPath,
                    textField:'name',
                    valueField:'oid',
                    extraParams:{
                        materialOid:that.addRuleOid
                    },
                    isMuti:false,
                    tableConfig:{
                        page:{
                            limit:15,
                            page:1
                        },
                        cols:[table.getIndexColumn(),table.getCheckColumn(),{
                            field:'name',
                            title:'定检名称',
                            width:430
                        },{
                            field:'exclusiveRuleName',
                            title:'互斥规则名称',
                        }],
                        queryColumns:[{
                            field:'name',
                            title:'定检名称'
                        }]
                    }
                }
            }];
            return items;
        };
        this.RELEASE = function(){
            var that = this;
            //发布版本
            var oid = $webUtil.getOidFromGrid("table_" +that.id,true,true);
            if(!oid){
                return false;
            }
            var ts =  $webUtil.getOidFromGrid("table_" +that.id,false,false,"ts");
            $webUtil.showConfirmMsg("是否发布当前版本,发布后老的版本将无法被使用",function () {
                $webUtil.put(that.url.controller + that.url.release,{oid:oid,ts:ts},function (result) {
                    if(result.success){
                        $webUtil.showMsgFromResult(result,"发布成功");
                        that.refresh();
                    }else{
                        $webUtil.showErrorMsg(result.msg);
                    }
                },function (xhr,error) {
                    $webUtil.showErrorMsg("访问服务器出现了错误,可能服务器没有开启,或者连接失败");
                },that.backPath);
            });
        };
        this.UPREVISION= function () {
            var that = this;
            //升版本,把之前的版本的信息,去除基本信息和版本的信息后,作为新版本的数据
            var filter = "uprevision_" + that.id;
            var form = layui.form;
            var oid = $webUtil.getOidFromGrid("table_" +that.id,true,true);
            if(!oid){
                return false;
            }
            var lcStatus = $webUtil.getOidFromGrid("table_" + that.id,false,false,'lcStatus');
            if('Released' != lcStatus){
                $webUtil.showErrorMsg("只有状态为【已发布】时才能升版");
                return  false;
            }
            var selectRowData = layui.table.checkStatus("table_" + that.id);
            var addSaveIndex = layer.open({
                type:1,
                title: '物料/工具基本信息修订(升版)',
                btn: ['保存', '取消'],
                skin: 'layui-layer-lan',
                content: '<form id="form_' + filter + '" lay-filter="' + filter + '" class="layui-form" style="margin-top:5px" ></form>',
                fullScreen:true,
                resizing: function (layero) {
                    form.doResize(filter);
                },
                success: function (layero) {
                    var formItems = that.getFormItems(false);
                    //需要在第一个元素里添加
                    formItems.unshift({
                        name:'copyFromVersion',
                        text:'修订来自(源)',
                        type: 'refer',
                        showField:'copyFromVersionName',
                        required:true,
                        textWidth:870,
                        useAllWidth:true,
                        referConfig:{
                            type:'grid',
                            url: that.url.controller + that.url.referOldRevision,
                            backPath:that.backPath,
                            textField:'id,name,revision',
                            valueField:'oid',
                            extraParams:{
                                nameOid:selectRowData.data[0].nameOid
                            },
                            isMuti:false,
                            tableConfig:{
                                page:{
                                    limit:15,
                                    page:1
                                },
                                cols:that.getOldRevisionColumns(),
                                method:'get'
                            }
                        }
                    });
                    form.addItems(filter,formItems,
                        function () {
                            var selectRowData = layui.table.checkStatus("table_" + that.id);
                            if(selectRowData !=null && selectRowData.data !=null && selectRowData.data.length > 0) {
                                var selectValues = selectRowData.data[0];
                                var newRevisionData = {};
                                for (var key in selectValues) {
                                    if(key !='revisionValue' && key !='versionValue') {
                                        newRevisionData[key] = selectValues[key];
                                    }
                                }
                                newRevisionData['copyFromVersion'] = selectValues.oid;
                                newRevisionData['copyFromVersionName'] = selectValues.id + " " + selectValues.name + "(" + selectValues.revisionValue + ")";
                                form.setValues(newRevisionData, filter);
                            }
 
                            //监控事件
                            form.on("select(" + filter + ")",function(data){
                                if(data.elem.name == 'copyFromVersion'){
                                    //说明变更了版本,需要重新加载数据
                                    $webUtil.get(that.url.controller + that.url.getObjectByOid ,{oid:data.value},function (result) {
                                        if(result.success){
                                            result.obj['copyFromVersion'] = data.value;
                                            result.obj['copyFromVersionName']=result.obj[0].oid + " " + result.obj[0].id + " " + result.obj[0].name + "(" + result.obj[0].revisionValue + ")";
                                            form.setValues(result.obj,filter);
                                        }else{
                                            $webUtil.showErrorForResult(result,"获取老版本的数据出现了错误");
                                        }
                                    },function (xhr,error) {
                                        $webUtil.showErrorMsg("连接服务器出现了错误,可能因为服务器未启动");
                                    },that.backPath);
                                }
                                //我们需要在这里处理扩展属性
                                //获取新的分类的值,获取对应的业务类型的字段内容
                                //然后设置新的内容
                            });
                        }
                        , {}
                        , {
                            defaultColumnOneRow: 3
                        });
                },
                yes:function(layero){
                    if(form.validata(filter)){
                        var formValues = form.getValues(filter);
                        formValues.materialClassifyId = formValues.materialClassify;
                        $webUtil.post(that.url.controller + that.url.upRevision,formValues,function (result) {
                            if(result.success){
                                $webUtil.showMsgFromResult(result,"修订(升版)物料/工具基本信息成功");
                                that.refresh();
                                layer.close(addSaveIndex);
                            }else{
                                $webUtil.showErrorMsg(result.msg);
                            }
                        },function (xhr,error) {
                            $webUtil.showErrorMsg("访问服务器出现了错误,可能服务器没有开启,或者连接失败");
                        },that.backPath);
                    }
                },
                btn2:function(layero){
                    that.refresh();
                    layer.close()
                }
            });
        };
        this.getOldRevisionColumns = function () {
            var that = this;
            var table = layui.table;
            return [table.getIndexColumn(),table.getCheckColumn(),{
                    field:'id',
                    title:'编号',
                    width:150
                },{
                    field:'name',
                    title:'名称',
                    width:200
                },{
                    field:'revisionValue',
                    title:'版本',
                    width:80
                },{
                    field:'code',
                    title:'图号',
                    width:120
                },{
                    field:'specification',
                    title:'规格',
                    width:120
                },{
                    field:'brand',
                    title:'品牌',
                    width:120
                },{
                    field:'lcStatusText',
                    title:'状态',
                    width:80
                }];
        };
        this.DEL = function(){//删除
            var that = this;
            var oid = $webUtil.getOidFromGrid("table_" +that.id,true,true);
            if(!oid){
                return false;
            }
            var ts =  $webUtil.getOidFromGrid("table_" +that.id,false,false,"ts");
            $webUtil.showConfirmMsg("是否删除?如果物料/工具已经有台账内容,则不能删除",function () {
                $webUtil.deleteRequest(that.url.controller + that.url.del,{oid:oid,ts:ts},function (result) {
                    if(result.success){
                        $webUtil.showMsgFromResult(result,"删除成功");
                        that.refresh();
                    }else{
                        $webUtil.showErrorMsg(result.msg);
                    }
                },function (xhr,error) {
                    $webUtil.showErrorMsg("访问服务器出现了错误,可能服务器没有开启,或者连接失败");
                },that.backPath)
            }); 
        };
 
        this.checkColumns = function(){
            var that = this;
            var table = layui.table;
            if(that.columns==null || that.columns.length==0){//如果其他地方想使用这个组件的时候,可以自定义列
                that.columns = [table.getIndexColumn(),table.getCheckColumn(),{
                    field:'id',
                    title:'物料/工具编号 名称 (版本)',
                    width:350,
                    templet:function(d){
                        return  d.id + ' ' + d.name + ' (' + d.revisionValue + ')' ;
                    }
                },{
                    field:'code',
                    title:'图号',
                    width:120
                },{
                    field:'specification',
                    title:'规格',
                    width:120
                },{
                    field:'brand',
                    title:'品牌',
                    width:120
                },{
                    field:'lcStatusText',
                    title:'状态',
                    width:80
                },{
                    title:'操作',
                    field:'options',
                    width:140,
                    fixed:'right',
                    toolbar: '#toolbar_column_' + that.id
                }];
            }
        };
        this.checkCheckRuleColumns = function () {
            var that = this;
            var table = layui.table;
            if(that.checkRuleColumns==null || that.checkRuleColumns.length==0){//如果其他地方想使用这个组件的时候,可以自定义列
                that.checkRuleColumns = [table.getIndexColumn(),table.getCheckColumn(),{
                    field:'name',
                    title:'规则名称',
                    width:150
                },{
                    field:'checkCycle',
                    title:'定检周期数',
                    width:90
                },{
                    field:'checkTypeText',
                    title:'定检类型',
                    width:200
                    // templet:function (d) {
                    //     if(d.checkCycle*1>0 && $webUtil.isNotNull(d.checkCycleType) && 'check_none' != d.checkCycleType){
                    //         if(that.checkRuleTypeMap.CHECK_REACH_COUNT == d.checkCycleType){
                    //             return "使用次数达到【" + d.checkCycle + "】定检";
                    //         }else if(that.checkRuleTypeMap.CHECK_REACH_TIME == d.checkCycleType){
                    //             return "使用时间达到【" + d.checkCycle + "】定检";
                    //         }else if(that.checkRuleTypeMap.CHECK_COUNT == d.checkCycleType){
                    //             return "使用次数每间隔【" + d.checkCycle + "】次定检";
                    //         }else if(that.checkRuleTypeMap.CHECK_STORE_TIME == d.checkCycleType){
                    //             return "存放时间每间隔【" + d.checkCycle + "】次定检";
                    //         }else{
                    //             return "每间隔【" + d.checkCycle + "】" + d.checkCycleType + "定检";
                    //         }
                    //     }
                    //     return '不定检';
                    // }
                },{
                    field:'alertCycle',
                    title:'提前提醒数',
                    width:90
                },{
                    field:'checkContent',
                    title:'定检内容',
                    width:300
                },{
                    field:'exclusiveRuleName',
                    title:'互斥规则名称',
                    width:150
                },{
                    title:'操作',
                    field:'options',
                    width:140,
                    fixed:'right',
                    toolbar: '#toolbar_column_check_' + that.id
                }];
            }
        };
        this.detailCheckColumns = function(){
            var that = this;
            var table = layui.table;
            if(that.detailcolumns==null || that.detailcolumns.length==0){//如果其他地方想使用这个组件的时候,可以自定义列
                that.detailcolumns = [table.getIndexColumn(),table.getCheckColumn(),{
                    field:'id',
                    title:'台账编号 名称(版本)',
                    width:350,
                    fixed:'left',
                    templet:function(d) {
                        return d.id + ' ' + d.name + ' (' + d.revisionValue + ')';
                    }
                },{
                    field:'code',
                    title:'图号',
                    width:120
                },{
                    field:'specification',
                    title:'规格',
                    width:120
                },{
                    field:'quantity',
                    title:'总数量/在库/可领',
                    width:160,
                    templet:function(d){
                        return d.quantity + "/" + d.quantityInStore + "/" + d.canBorrowQuantity + " (" + d.unitOfMeasurement  + ")";
                    }
                },{
                    field:'pkWarehouseName',
                    title:'所属库房',
                    width:120
                },{
                    field:'invStatusText',
                    title:'库存状态',
                    width:90
                },{
                    field:'brand',
                    title:'品牌',
                    width:80
                },{
                    field:'material',
                    title:'材质',
                    width:80
                },{
                    field:'applyProduct',
                    title:'适用产品',
                    width:120
                },{
                    field:'supplier',
                    title:'制造/供应商',
                    width:120
                },{
                    field:'description',
                    title:'备注',
                    width:120
                }];
            }
        };
        this.refreshClassify = function () {
            var that = this;
            layui.tree.reload("tree_" + that.id);
        };
        this.refresh = function(){
            var that = this;
            layui.table.reload('table_' + that.id,{});
            if($webUtil.isNotNull(that.accountPath)) {
                layui.table.reload('detail_' + that.id, {});
            }
        };
        this.refreshRule = function(){
            var that = this;
            layui.table.reload('table_check_' + that.id,{});
            if($webUtil.isNotNull(that.accountPath)) {
                layui.table.reload('detail_' + that.id, {});
            }
        };
    };
    var cs = new Class();
    exports(cs.MODULE_NAME,cs);
});