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
getPageContext('ProblemList').bind('initfn',{},function(){
    var c = $(this);
    var problemId="";
    var f_isValid="N"
    var jqgrid=$("#problemListGrid", c);
    $("#lineTable", c).hide();
    var rolesArray = pageSession.roles;
    var roleNames =[];
    var schoolId=null;
    for(var i=0;i<rolesArray.length;i++){
        roleNames.push(rolesArray[i].name);
    }
    function optionFmt(cellvalue, options, rowObject){
         var retrun_html=""; 
         if(rowObject.scprState=="N" && contains(roleNames,rowObject.sccfRole)){ 
                retrun_html+="<a href=\"javascript:$('#ediProblemHistoryOption',getPageContext('ProblemList'))." +
                "triggerHandler('click',[{scprId:'"+rowObject.scprId+"'}])\"  class='btn btn-danger btn-xs'><span class='fa fa-white fa-edit'> 修改</span> </a>";
                retrun_html+="&nbsp;&nbsp;<a href=\"javascript:$('#showProblemHistoryOption',getPageContext('ProblemList'))." +
                "triggerHandler('click',[{scprId:'"+rowObject.scprId+"'}])\" class='btn btn-success btn-xs' ><span class='fa fa-white fa-search'> 查看</a>";
            
            return retrun_html;
         }else{
                retrun_html+="<a href=\"javascript:$('#showProblemHistoryOption',getPageContext('ProblemList'))." +
                "triggerHandler('click',[{scprId:'"+rowObject.scprId+"'}])\" class='btn btn-success btn-xs' ><span class='fa fa-white fa-search'> 查看</a>";
             return retrun_html;
        }
     }
        
    ScEmphasisManager.getJwclient(pageSession.user.orgId,{
        callback:function(data){
            if(data==null)data=false;
            jw_client=data;
            if(!jw_client){
                ScEmphasisManager.getSchoolId(pageSession.user.orgId,{
                    callback:function(data2){
                        schoolId=data2;
                    },async:false
                });
            }
        },async:false
    });
    
     function getTime(d){
             var month=d.getMonth()+1;
            month =(month<10 ? "0"+month:month);
            var day = (d.getDate()<10 ? "0"+d.getDate():d.getDate());
            var hours = (d.getHours()<10 ? "0"+d.getHours():d.getHours());
            var minutes = (d.getMinutes()<10 ? "0"+d.getMinutes():d.getMinutes());
            var seconds = (d.getSeconds()<10 ? "0"+d.getSeconds():d.getSeconds());
            var YMDHMS = d.getFullYear() + "-" +month + "-" + day + " " + hours + ":" + minutes + ":" + seconds; 
            return YMDHMS;
         }
    
    jqgrid.landyjgrid( {
        colNames : [ 'ID','sccfRole', 'state','问题详情','操作'],
        colModel : [ 
                     {name : 'scprId',index : 'scprId',width : 80,hidden:true},
                     {name : 'sccfRole',index : 'sccfRole',width : 80,hidden:true},
                     {name : 'scprState',index : 'scprState',width : 80,hidden:true},
                     {name : 'scosProblem',index : 'scosProblem',width : 180,align:'center',sortable:false},
                     {name : 'caozuo',index : 'caozuo',width : 60,align : "center",formatter:optionFmt,sortable:false}
                  ],
        altRows:true, 
        rowNum : 20,
        rownumbers:true,
        rowList : [10, 20, 50, 100 ,500],
        pager : '#problemListGridPager',
        sortname : 'scprId',
        viewrecords : true,
        sortorder : "asc",
        shrinkToFit :true,
        queryType : "Problem_GetTrackListQuery",
        autoLoad : true,
        multiselect : false,
        height:300,
        onBuildAdditionQueryFields : function() {
            $(this).clearCondition();
            var conditions = [];
            conditions.push({fieldName:'scprState',fieldType:'String',fieldStringValue:f_isValid});
        
            var orgIds = [];
            if(null != schoolId){
                orgIds.push(schoolId);
            }
            orgIds.push(pageSession.user.orgId);
            
            
            conditions.push({fieldName:'orgId',fieldType:'String[]',fieldStringValue:orgIds});
            $(this).addConditions(conditions);
        }
    });
    
    $("#solve",c).click(function(){
        $(this).css({
            "color" : "green",
        });
        $("#noSolve",c).removeAttr("style");
        f_isValid = "Y";
        $("#problem_left",c).width("100%");
        c.trigger('resizeTab');
        jqgrid.landyjgrid().trigger("reloadGrid");
    });
    $("#noSolve",c).click(function(){
        $(this).css({
            "color" : "green",
        });
        $("#solve",c).removeAttr("style");
        f_isValid = "N";
        $("#problem_left",c).width("100%");
        c.trigger('resizeTab');
        jqgrid.landyjgrid().trigger("reloadGrid");
    });
    
    $('#categoryTab',c).on("click","a",function (e) {
        e.preventDefault();
        $(this).tab('show');
    });
    
    //--------------------------------添加检查项类别addNewsBtn
    
    $("#showProblemHistoryOption",c).bind("click", function(event,data) {//为新增按钮添加一个单击事件
        $("#lineTable", c).hide();
        
        showRight(data);
        
        problemId = data.scprId;
        
    });
    
    function showRight(data){
        //添加时间轴
        $("#tttline",c).children().remove();
        ScProblemHistoryManager.getHisotryByPrId(data.scprId,{
            callback:function(data){
                for(var i=0;i<data.length;i++){
                    
                    $("#tttline",c).append("<li><b></b><span>"+getTime(data[i].scphDate)+"</span><p>"+data[i].scphContent+"</p></li>");
                }
                $("#problem_right",c).show();
                $("#problem_left",c).width("60%");
                c.trigger('resizeTab');
            },async:false
        });
    }
    
    $("#ediProblemHistoryOption",c).bind("click", function(event,data) {//为新增按钮添加一个单击事件
        problemId = data.scprId;
        //添加时间轴
        showRight(data);
        //设置初始值
        $("#scemContent",c).val("");
        $("input[type=radio][value=N]").attr("checked",'checked');
        $("#lineTable", c).show();
        
    });
 
    //保存事件
    $("#saveBtn",c).bind("click",function(){
        var scemContent = $("#scemContent",c).val();
        var problemState = $("input[name='problemState']:checked").val();
        if(!isNotNull(scemContent.trim())){
            prompt("记录明细不能为空");
            return;
        }
        
        ScProblemHistoryManager.saveHisotryByPrId(problemId,problemState,scemContent,{
            callback:function(){
                prompt("保存成功");
                if(problemState=="Y"){
                    $("#solve",c).trigger("click");
                    $('#showProblemHistoryOption',getPageContext('ProblemList')).triggerHandler('click',[{'scprId':problemId}]);
                }else if(problemState=="N"){
                    $("#noSolve",c).trigger("click");
                    $('#ediProblemHistoryOption',getPageContext('ProblemList')).triggerHandler('click',[{'scprId':problemId}]);
                }
            },async:false
        });
        
    });
    //查询
    $("#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);
            
        }
    });
    c.bind('resizeTab',{},function(){
        resizeTab_c(jqgrid,c);
        
    });
    
});