liuxiaolong
2019-05-09 0d1d88cdb668e75ea8609417ac18ae19947e9525
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
getPageContext('SubjectList').bind('initfn',{},function(){
    var c = $(this);
    
    var jqgrid=$("#SubjectGrid", c);
    var dictrictId=null;
    
    //启用选项卡
    categoryTab(c,jqgrid,"sccaName");
    
    ScEmphasisManager.getJwclient(pageSession.user.orgId,{
        callback:function(data){
            if(data==null)data=false;
            jw_client=data;
            if(!jw_client){
                ScEmphasisManager.getDictrictId(pageSession.user.orgId,{
                    callback:function(data2){
                        dictrictId=data2;
                    },async:false
                });
            }
            
        },async:false
    });
    function optionFmt(cellvalue, options, rowObject){
        var retrun_html="";
        if("2".in_acl()){
            retrun_html +="<a href=\"javascript:$('#ediSubjectOption',getPageContext('SubjectList'))." +
            "triggerHandler('click',[{scsuId:'"+rowObject.scsuId+"'}])\"  class='btn btn-success btn-xs'><span class='fa fa-white fa-edit'> 修改</span> </a>";
        }
        if("8".in_acl()){
            retrun_html +="<a href=\"javascript:$('#delSubjectOption',getPageContext('SubjectList'))." +
            "triggerHandler('click',[{scsuId:'"+rowObject.scsuId+"',sccaName:'"+rowObject.sccaName+"'}])\"  class='btn btn-danger  btn-xs grid-row-mp'><span class='fa fa-white fa-trash'> 删除</span> </a>";
        }
        return retrun_html;
    }
    jqgrid.landyjgrid( {
        colNames : [ 'ID', '检查项类别', '检查项名称','检查项内容','检查方法','更新时间','操作'],
        colModel : [ 
                     {name : 'scsuId',index : 'scsuId',width : 80,hidden:true},
                     {name : 'sccaName',index : 'sccaName',width : 80,align:'center',sortable:false},
                     {name : 'scsuName',index : 'scsuName',width : 120,sortable:false,align : "center"},
                     {name : 'scsuContent',index : 'scsuContent',width : 180,sortable:false,align : "center"},
                     {name : 'scsuMethod',index : 'scsuMethod',width : 80,sortable:false,align : "center"},
                     {name : 'modifyTime',index : 'modifyTime',width : 80,align : "center",formatter:'dateFmatter',align:'center',sortable:false},
                     {name : 'caozuo',index : 'caozuo',width : 120,align : "center",formatter:optionFmt,sortable:false}
                  ],
        altRows:true, 
        rowNum : 20,
        rowList : [10, 20, 50, 100 ,500],
        pager : '#SubjectGridPager',
        sortname : '',
        viewrecords : true,
        sortorder : "asc",
        shrinkToFit :true,
        queryType : "SubjectListQuery",
        autoLoad : true,
        multiselect : true,
        height:300,
        onBuildAdditionQueryFields : function() {
            $(this).clearCondition();
            var a = LandyJquery.grid.buildGridSearchConditionsByForm("subjectListQueryForm", c);
            a.push({fieldName:'isValid',fieldType:'String',fieldStringValue:"Y"});
            
            var orgId = [];
            if(null != dictrictId){
                orgId.push(dictrictId);
            }
            orgId.push(pageSession.user.orgId);
            
            a.push({fieldName:'orgId',fieldType:'String[]',fieldStringValue:orgId});
            $(this).addConditions(a);
        }
    });
     $(".i-checks", c).each(function() {
         $(this).iCheck({
             checkboxClass: 'icheckbox_square-green',
             radioClass: 'iradio_square-green',
         });
    });
    
    //--------------------------------增加操作addNewsBtn
    $("#addSubjectBtn",c).bind("click", function() {//为新增按钮添加一个单击事件
        $.landydialog.openByUrl({
            autoOpen: false,
            height: 700,
            width: 650,
            modal: true,
            title:"新增检查项",
            buttons:{
            },
            open:function(event, ui) {
                var dc = $.landydialog.getDialogContext();
                //$("#selectCategoryName",dc).html(getCategoryNameList());
                $("#saveBtn",dc).bind("click",function(){
                    if($("#subjectForm",dc).validationEngine({returnIsValid:true}) == true){
                        var boxes = $("input[type=checkbox]",dc);
                        var scsuRequied ="";
                        for(var i=0;i<boxes.length;i++){
                            if(boxes[i].checked){
                                scsuRequied +=boxes[i].value+",";
                            }
                        }
                        if(scsuRequied.charAt(scsuRequied.length-1)==","){
                            scsuRequied = scsuRequied.substring(0, scsuRequied.length-1);
                        }
                        $("#scsuRequied",dc).val(scsuRequied);
                        var model = LandyJquery.data.getFormValues('subjectForm',dc);
                        if(!isNotNull(model.scsuSccaId.trim())){
                            prompt("检查项分类不能为空");
                            return;
                        }else if(!isNotNull(model.scsuName.trim())){
                            prompt("检查项目不能为空");
                            return;
                        }else if(!isNotNull(model.scsuContent.trim())){
                            prompt("检查项目内容不能为空");
                            return;
                        }else if(!isNotNull(model.scsuMethod.trim())){
                            prompt("检查方法不能为空");
                            return;
                        }
                        /*else if(!isNotNull(model.scsuScore.trim())){
                            prompt("检查评分不能为空");
                            return;
                        }*/
                        model.scsuIsValid = "Y";
                        ScSubjectManager.save(model,{
                            callback:function(data){
                                prompt('保存成功');
                                $.landydialog.closeDialog();
                                jqgrid.landyjgrid().trigger("reloadGrid");
                            }
                        });
                    }else{
                        prompt("录入错误");
                    }
                    
                });
                $('#cancelBtn',dc).bind('click',function(){
                    dc.dialog("close");
                });
            }
        },"check/subjectbuild/subject_add.jsp");
    });
    
    //--------------------------------添加检查项类别addCategoryBtn
    $("#addCheckCategoryBtn",c).bind("click", function() {//为新增按钮添加一个单击事件
        $.landydialog.openByUrl({
            autoOpen: false,
            height: 550,
            width: 590,
            modal: true,
            title:"新增编辑类别",
            buttons:{
            },
            open:function(event, ui) {
                var dc = $.landydialog.getDialogContext();
                var CategoryGrid=$("#CategoryGrid", dc);
                var EditrowId = null;
                
                function categoryEditFmt(cellvalue, options, rowObject){
                    var return_html ="<a href=\"javascript:$('#clickDialogCategoryEditBtn')." +
                    "triggerHandler('click',[{rowId:'"+options.rowId+"'}])\"  class='glyphicon glyphicon-edit' style='color: #000000'>  </a>";
                    
                    
                    return_html +="<a href=\"javascript:$('#clickDialogCategoryDelBtn')." +
                    "triggerHandler('click',[{sccaId:'"+rowObject.sccaId+"',sccaName:'"+rowObject.sccaName+"',rowId:'"+options.rowId+"'}])\"  class='glyphicon glyphicon-remove' style='color: #000000'></a>";
                    return return_html;
                }
                
                CategoryGrid.landyjgrid({
                    colNames : [ 'ID', 'sccaName', '操作'],
                    colModel : [ 
                                 {name : 'sccaId',index : 'sccaId',width : 80,hidden:true},
                                 {name : 'sccaName',index : 'sccaName',width : 226,align:'left',"sortable":"true"},
                                 {name : '',index : '',width : 91,formatter:categoryEditFmt},
                              ],
                    sortable:true,  
                    sortname:'sccaName',
                    pager : '#CategoryGridPager',
                    sortorder:'asc',
                    shrinkToFit :true,
                    queryType : "ScCategoryListQuery",
                    autoLoad : true,
                    height:300,
                    exportExcel:false,
                    pgbuttons:false,
                    viewrecords:false,
                    pginput:false,
                    gridComplete: function () {
                    $(this).closest('.ui-jqgrid-view').find('div.ui-jqgrid-hdiv').hide();
                    },
                    onBuildAdditionQueryFields : function() {
                    }
                 });
                
                //--------------------------------保存操作saveCategory
                $("#saveCategory",dc).bind("click",function(event,data){
                    if($("#categoryForm",dc).validationEngine({returnIsValid:true}) == true){
                        var model = LandyJquery.data.getFormValues('categoryForm',dc);
                        ScCategoryManager.save(model,{
                            callback:function(data){
                                    if($("#sccaId").val()=="")
                                        CategoryGrid.addRow(data,"first");
                                    else{
                                        CategoryGrid.setCell(EditrowId,'sccaName',data.sccaName,null,null,false);
                                        CategoryGrid.updateChangedData(EditrowId,'sccaName',data.sccaName);
                                        EditrowId = null;
                                    }
                                    LandyJquery.data.clearFormValues("categoryForm", dc);
                            },
                        });
                     }else{
                        prompt("录入错误");
                     }
                 });
                
                //--------------------------------修改操作editCategory
                 $("#clickDialogCategoryEditBtn").bind("click",function(event,data){
                    EditrowId = data.rowId;
                    var model =CategoryGrid.getRowDataByRowId(EditrowId);
                    LandyJquery.data.setFormValues('categoryForm',model,dc);
                 });
                
                 //--------------------------------删除操作delCategory
                 $("#clickDialogCategoryDelBtn").bind("click",function(event,data){
                        var sccaId = data.sccaId;
                        LandyJquery.dialog.confirm("是否确认删除\"<span style='color:red'>"+data.sccaName+"</span>\"检查项类别!",function(){
                            ScCategoryManager.removeByPk(sccaId,{
                                callback:function(){
                                    CategoryGrid.deleteRow(data.rowId);
                                    //更新tab选择框类别
                                    sccaId = "sccaId_"+sccaId;
                                    if($('#'+sccaId+'').length>0){
                                        $('#'+sccaId+'').remove();
                                    }
                                }
                            });
                        });
                 });
                 
                 $('#saveBtn',dc).bind('click',function(){
                        dc.dialog("close");
                 });
                 
                 $('#cancelBtn',dc).bind('click',function(){
                        dc.dialog("close");
                 });
            }
        },"check/subjectbuild/category_add.jsp");
    });
    
    $("#ediSubjectOption",c).bind("click", function(event,data) {//为新增按钮添加一个单击事件
        $.landydialog.openByUrl({
            autoOpen: false,
            height: 720,
            width: 650,
            modal: true,
            title:"编辑检查项",
            buttons:{
            },
            open:function(event, ui) {
                var scsuId = data.scsuId;
                var dc = $.landydialog.getDialogContext();
                var boxes = $("input[type=checkbox]",dc);
                //$("#selectCategoryName",dc).html(getCategoryNameList());
                if(isNotNull(scsuId,true)){
                    ScSubjectManager.get(scsuId,{
                        callback:function(model){
                            LandyJquery.data.setFormValues('subjectForm',model,dc);
                            var strArray = model.scsuRequied.split(",");
                            if(strArray.length>0){
                                for(var i=0;i<boxes.length;i++){
                                    for(var j=0;j<strArray.length;j++){
                                        if(boxes[i].value==strArray[j]){
                                            boxes[i].checked=true;
                                        }
                                    }
                                }
                            }
                        },async:false
                    });
                }
                
                
                $("#saveBtn",dc).bind("click",function(){
                    if($("#subjectForm",dc).validationEngine({returnIsValid:true}) == true){
                        var scsuRequied ="";
                        for(var i=0;i<boxes.length;i++){
                            if(boxes[i].checked){
                                scsuRequied +=boxes[i].value+",";
                            }
                        }
                        if(scsuRequied.charAt(scsuRequied.length-1)==","){
                            scsuRequied = scsuRequied.substring(0, scsuRequied.length-1);
                        }
                        $("#scsuRequied",dc).val(scsuRequied);
                        var model = LandyJquery.data.getFormValues('subjectForm',dc);
                        if(!isNotNull(model.scsuSccaId.trim())){
                            prompt("检查项分类不能为空");
                            return;
                        }else if(!isNotNull(model.scsuName.trim())){
                            prompt("检查项目不能为空");
                            return;
                        }else if(!isNotNull(model.scsuContent.trim())){
                            prompt("检查项目内容不能为空");
                            return;
                        }else if(!isNotNull(model.scsuMethod.trim())){
                            prompt("检查方法不能为空");
                            return;
                        }
                        /*else if(!isNotNull(model.scsuScore.trim())){
                            prompt("检查评分不能为空");
                            return;
                        }*/
                        ScSubjectManager.save(model,{
                            callback:function(data){
                                prompt('保存成功');
                                $.landydialog.closeDialog();
                                jqgrid.landyjgrid().trigger("reloadGrid");
                            }
                        });
                    }else{
                        prompt("录入错误");
                    }
                    
                });
                
                $('#cancelBtn',dc).bind('click',function(){
                    dc.dialog("close");
                });
            }
        },"check/subjectbuild/subject_add.jsp");
    });
 
    
    //查询
    $("#searchBtn",c).click(function(){
        jqgrid.landyjgrid().trigger("reloadGrid");
    });
    
    /**为页面添加查询按钮的回车事件*/
    c.keydown(function (e) {
        if (e.keyCode == '13') {
            $('#searchBtn', c).trigger('click');
            e.preventDefault ? e.preventDefault() : (e.returnValue = false);
        }
    });
    
    
    //--------------------------------删除操作delSubjectOption
    $("#delSubjectOption",c).bind("click",function(event,data){
        var scsuId = data.scsuId;
        if(isNotNull(scsuId,true)){
            LandyJquery.dialog.confirm("是否确认删除\"<span style='color:red'>"+data.sccaName+"</span>\"检查项!",function(){
                ScSubjectManager.removeByPk(scsuId,{
                    callback:function(){
                        jqgrid.landyjgrid().trigger("reloadGrid");
                    }
                });
            });
        }else{
            prompt("请选择需要删除的数据");
        }
    });
    
 
    c.bind('resizeTab',{},function(){
 
        /****
         * 要减掉的高度
         * queryBut_head 头标题
         * queryBut 按钮区域
         * categoryTab 类别选项卡
         * queryConditions 查询条件
         * emphasisTop 月度重点
         */
        resizeTab_c(jqgrid,c);
 
    });
    //下发按钮
    $("#xiafaBtn",c).bind("click", function() {
        var rid=jqgrid.getGridParam("selarrrow");
        
        var selarrowIds=[];
        var sccaNames=[];
            for(var i=0;i<rid.length;i++){
                selarrowIds.push(jqgrid.jqGrid('getRowData',rid[i]).scsuId);
                sccaNames.push(jqgrid.jqGrid('getRowData',rid[i]).sccaName);
        }
        var count=0;
        for(var k=0;k<sccaNames.length;k++){
            if(sccaNames[k]!=sccaNames[0]){
                count=1;
                break;
            }
        }
        if(count!=1){
            xiafa_openStep(selarrowIds);
        }else{
            prompt("检查项类别不一致,请重新选择");
        }
    });
    
    //测试组织机构
    
    $("#orgTree",c).bind("click", function() {
        
        
    });
});