1
duan
2024-08-21 f71a02229c1ba00fbecaead19256593ffb052753
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
$(function () {
    initTimeControl();
    initBillInspectFinishedCombobox();
    initBillInspectFinishedTable();
    initBillInspectFinishedClick();
})
 
function initBillInspectFinishedCombobox() {
    var $option = $('<option value = "-1" >==全部==</option>');
    var $inspectArea = $('#divBillInspectFinishedWhere').find('select[name=area]');
    $inspectArea.empty();
    $inspectArea.append($option);
    var data = ajaxSame('../../GlobalM/Statement/GetInspectArea', null, 'post', 'json');
    for (var i in data) {
        $option = $('<option value = "' + data[i].Id + '" >' + data[i].Text + '</option>');
        $inspectArea.append($option);
    }
    $($inspectArea).find("option").eq(0).prop("selected", true);
    
    $inspectObjectType = $('#divBillInspectFinishedWhere').find('select[name=type]');
    $inspectObjectType.empty();
    var data = ajaxSame('../../GlobalM/Statement/GetInspectObjectType', null, 'post', 'json');
    for (var i in data) {
        $option = $('<option value = "' + data[i].Id + '" >' + data[i].Text + '</option>');
        $inspectObjectType.append($option);
    }
    $($inspectObjectType).find("option").eq(0).prop("selected", true);
}
 
function initBillInspectFinishedTable() {
    $('#tabBillInspectFinishedTable').empty();
    var param = getBillInspectFinishedSearchParam();
    console.info(param);
    $('#tabBillInspectFinishedTable').datagrid({
        singleSelect: true,
        url: '../../GlobalM/Bill/GetFalseInspectBook',
        queryParams: param,
        idField: 'Id',
        animate: true,
        pagination: true,
        rownumbers: true,
        pagePosition: 'bottom',
        pageSize: 10,
        pageNumber: 1,
        fitColumns: true,
        pageList: [2, 10, 15, 20, 30, 50],
        //toolbar: '#divBillInspectFinishedWhere',
        //数据格式
        columns: [[
            { title: '序号', width: 30, field: 'Id', hidden: true, },
            { title: '序号', width: 30, field: 'BillId', hidden: true, },
            { checkbox: true, field: 'CreateDIXId', },
            { title: '设备类别', field: 'MachineTypeName', },
            { title: '设备编码', field: 'MachineCode', },
            { title: '设备名称', field: 'MachineName', },
            { title: '设备区域', field: 'MachineArea', },
            { title: '设备位置', field: 'MachineLocation', },
            { title: '点检类别', field: 'DIXTypeName', },
            { title: '点检频率', field: 'DIXFrequencyName', },
            {
                title: '设备状态', width: 80, field: 'MachinaStatu', formatter: function (value, row, index) {
                    if (value == '1') {
                        return "使用中";
                    } else if (value == '2') {
                        return "备用中";
                    } else if (value == '3') {
                        return "维修中";
                    } else if (value == '4') {
                        return "闲置中";
                    } else if (value == '5') {
                        return "报废";
                    }
                },
            },
            {
                title: '点检时间', width: 160, field: 'DIXTime', fixed: true,
                formatter: function (value, row, index) {
                    return toDateStr(value);
                },
            },
            {
                title: '总判定', width: 80, field: 'FinalJudge', formatter: function (value, row, index) {
                    if (value == 1) {
                        return '<span>OK</span>';
                    } else if (value == 2) {
                        return '<span style="color:red;font-weight:bold;">NG</span>';
                    } else if (value == 3) {
                        return '<span style="color:gray;">维修</span>';
                    }
                },
            },
            {
                title: '状态', width: 80, field: 'Status', formatter: function (value, row, index) {
                    if (value == 1) {
                        return '已提交';
                    } else if (value == 0) {
                        return '未提交';
                    }
                },
            },
        ]],
        loadFilter: function (data) {
            if (data.Code == 200) {
                return data;
            } else {
                alert(data.Message);
            }
        },
        onLoadSuccess: function () {
            var selectedList = $('#selectBillInspectFinishedSelected').val();
            var powerArray = selectedList.split(',');
            for (var i = 0; i < powerArray.length; i++) {
                if (powerArray[i] == '') continue;
                $(this).datagrid('selectRecord', powerArray[i]);
            }
        },
        onCheck: function (index, row) {
            var selectedList = $('#selectBillInspectFinishedSelected').val();
            var oldStr = ',' + row.Id;
            if (isContainsArr(selectedList, oldStr, ',')) return;//当包含字串时,不再新增
            selectedList = selectedList + oldStr;
            $('#selectBillInspectFinishedSelected').val(selectedList);
        },
        onUncheck: function (index, row) {
            var selectedList = $('#selectBillInspectFinishedSelected').val();
            var oldStr = ',' + row.Id;
            if (isContainsArr(selectedList, oldStr, ',')) selectedList = arrStrRemoveStr(selectedList, oldStr, ',');
            $('#selectBillInspectFinishedSelected').val(selectedList);
        },
        onSelectAll: function (rows) {
            var selectedList = $('#selectBillInspectFinishedSelected').val();
            var oldStr = '';
            for (var i in rows) {
                oldStr = ',' + rows[i].Id;
                if (isContainsArr(selectedList, oldStr, ',')) continue;
                selectedList = selectedList + oldStr;
            }
            $('#selectBillInspectFinishedSelected').val(selectedList);
        },
        onUnselectAll: function (rows) {
            var selectedList = $('#selectBillInspectFinishedSelected').val();
            var oldStr = '';
            for (var i in rows) {
                oldStr = ',' + rows[i].Id;
                if (isContainsArr(selectedList, oldStr, ',')) selectedList = arrStrRemoveStr(selectedList, oldStr, ',');
            }
            $('#selectBillInspectFinishedSelected').val(selectedList);
        },
    });
}
 
 
 
 
 
function initBillInspectFinishedClick() {
 
    //点击查询按钮
    $('#btnBillInspectFinishedSearch').click(function () {
        var param = getBillInspectFinishedSearchParam();
        console.info(param);
        $('#tabBillInspectFinishedTable').datagrid('reload', param);
    });
 
 
    //点击流程履历
    $('#btnBillInspectFinishedProcess').click(function () {
        var rows = $('#tabBillInspectFinishedTable').datagrid('getSelections');
        if (rows.length != 1) { show('查看流程履历只能选择一行!'); return; }
        var BillId = rows[0].BillId
        var param = { BillId: BillId };
        var data = ajaxSame('../../GlobalM/WorkList/GetBillProcess', param, 'post', 'json');
        if (data.Code == 200) {
            //加载履历到dialog上
 
            var $table = $('<table style="font-weight:bolder;width:100%;"></table>');
            var $tr = $('');
            var $td = $('');
            for (var i in data.rows) {
                //创建tr
                if (data.rows[i].ActionType == 0) {
                    $tr = $('<tr style="background-color:gray;color:black;"></tr>');
                } else if (data.rows[i].ActionType == 1) {
                    $tr = $('<tr style="background-color:green;color:white;"></tr>');
                } else if (data.rows[i].ActionType == -1) {
                    $tr = $('<tr style="background-color:red;color:white;"></tr>');
                }
                $td = $('<td style="padding:6px;text-align:center;">' + data.rows[i].NodeName + '</td>');
                $tr.append($td);
                $td = $('<td style="padding:6px;text-align:center;">' + data.rows[i].OrderNo + '</td>');
                $tr.append($td);
                $td = $('<td style="padding:6px;text-align:center;">' + data.rows[i].UserNo + '</td>');
                $tr.append($td);
                $td = $('<td style="padding:6px;text-align:center;">' + data.rows[i].UserName + '</td>');
                $tr.append($td);
                $td = $('<td style="padding:6px;text-align:center;">' + data.rows[i].RoleName + '</td>');
                $tr.append($td);
                $td = $('<td style="padding:6px;text-align:center;">' + data.rows[i].Remark + '</td>');
                $tr.append($td);
                $td = $('<td style="padding:6px;text-align:center;">' + (data.rows[i].AppendixUrl == "" ? '' : '<a href="' + data.rows[i].AppendixUrl + '" target="_blank">附件</a>') + '</td>');
                $tr.append($td);
                $td = $('<td style="padding:6px;text-align:center;">' + data.rows[i].ApproveTimeStr + '</td>');
                $tr.append($td);
                $td = $('<td style="padding:6px;text-align:center;">' + data.rows[i].ActiveTimeStr + '</td>');
                $tr.append($td);
                //将tr添加到表格
                $table.append($tr);
            }
 
            $('#processBillInspectFinished').empty();
            $('#detailBillInspectFinished').empty();
 
            $('#processBillInspectFinished').append($table);
        } else {
            alert(data.Message);
        }
    });
    //点击表单详细
    $('#btnBillInspectFinishedDetail').click(function () {
        var rows = $('#tabBillInspectFinishedTable').datagrid('getSelections');
        if (rows.length != 1) { show('查看表单只能选择一行!'); return; }
        var BookId = rows[0].Id
        var param = { InspectBookId: BookId, ShowBtn: 1  };
        var data = ajaxSame('../../GlobalM/Bill/InspectFalseDetail', param, 'post', 'html');
 
        $('#processBillInspectFinished').empty();
        $('#detailBillInspectFinished').empty();
 
        $('#detailBillInspectFinished').append(data);
    });
 
    //点击修改履历
    $('#btnBillInspectFinishedUpdateNote').click(function () {
        var rows = $('#tabBillInspectFinishedTable').datagrid('getSelections');
        if (rows.length != 1) { show('查看表单只能选择一行!'); return; }
        var BookId = rows[0].Id
        var url = '../../GlobalM/Bill/ReckUpdateHistory?InspectBookId=' + BookId + '&FilterType=FALSE';
        var features2 = '';
        window.open(url, "修改履历", features2);  //打开新窗口
    });
}
function getBillInspectFinishedSearchParam() {
    var $div = $('div#divBillInspectFinishedWhere');
 
    var code = $div.find('input[name=code]').first().val();
    var areaid = $div.find('select[name=area]').first().val();
    var typeid = $div.find('select[name=type]').first().val();
 
 
    var timeBegin = $div.find('input[name=timeBegin]').first().val();
    var timeEnd = $div.find('input[name=timeEnd]').first().val();
    if (timeBegin != '') {
        timeBegin += ':00';
    } else {
        timeBegin = '1900/01/01 00:00:00';
    }
    if (timeEnd != '') {
        timeEnd += ':00';
    } else {
        timeEnd = '1900/01/01 00:00:00';
    }
    var param = { 
        InspectAreaId: areaid, InspectObjectTypeId: typeid, InspectObjectCode: code,
        TimeBegin: timeBegin, TimeEnd: timeEnd
    }
    return param;
}
 
 
 
function initTimeControl() {
    $.datetimepicker.setLocale('zh');
    $('.some_class').datetimepicker();
}
 
 
function reloadHomeIndexAttention() {
    $.ajax({
        url: '../../GlobalM/Bill/GetNeedDealtNum',
        data: null,
        type: 'POST',
        dataType: 'json',
        async: true,
        success: function (data) {
            var $span = $('#HomeIndexAttention', window.parent.document);
            $span.empty();
            console.info(data);
            if (data.Code == 200) {
                var arr = data.Message.split(',');
                var needDealt = parseInt(arr[0]);
                var isRepair = parseInt(arr[1]);
                var $temp = $('');
                if (needDealt > 0) {
                    $temp = $('<span>&nbsp;&nbsp;&nbsp;&nbsp;需待办:<span style="color:red;font-weight:bold;">' + needDealt + '<span><span>');
                } else {
                    $temp = $('<span>&nbsp;&nbsp;&nbsp;&nbsp;需待办:<span>' + needDealt + '<span><span>');
                }
                $span.append($temp);
                if (isRepair > 0) {
                    $temp = $('<span>&nbsp;&nbsp;&nbsp;&nbsp;需维修:<span style="color:red;font-weight:bold;">' + isRepair + '<span><span>');
                } else {
                    $temp = $('<span>&nbsp;&nbsp;&nbsp;&nbsp;需维修:<span>' + isRepair + '<span><span>');
                }
                $span.append($temp);
            } else {
 
            }
        },
        error: function (data) {
            result = data;
        },
    });
}