zhangjiaqing
8 天以前 1cef3adee31c6934c0da4b4f0b8a6f5ac03b364f
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
/**
 入驻小区
 **/
(function (vc) {
    var DEFAULT_PAGE = 1;
    var DEFAULT_ROWS = 10;
    vc.extends({
        data: {
            monthAttendanceManageInfo: {
                attendances: [],
                attendanceClassess: [],
                total: 0,
                records: 1,
                moreCondition: false,
                classesId: '',
                curDays: 30,
                conditions: {
                    classesId: '',
                    departmentName: '',
                    taskYear: '',
                    taskMonth: '',
                    date: ''
                }
            }
        },
        _initMethod: function () {
            //vc.component._listMonthAttendances(DEFAULT_PAGE, DEFAULT_ROWS);
            $that._listAttendanceClassess();
            $that._changeCurrentDay();
            vc.initDateMonth('queryDate', function (_value) {
                let _values = _value.split('-');
                $that.monthAttendanceManageInfo.conditions.taskYear = _values[0];
                $that.monthAttendanceManageInfo.conditions.taskMonth = _values[1];
                $that.monthAttendanceManageInfo.conditions.date = _value;
                $that._changeCurrentDay();
            })
        },
        _initEvent: function () {
            vc.on('monthAttendanceManage', 'listMonthAttendance', function (_param) {
                vc.component._listMonthAttendances(DEFAULT_PAGE, DEFAULT_ROWS);
            });
            vc.on('pagination', 'page_event', function (_currentPage) {
                vc.component._listMonthAttendances(_currentPage, DEFAULT_ROWS);
            });
        },
        methods: {
            _listMonthAttendances: function (_page, _rows) {
                vc.component.monthAttendanceManageInfo.conditions.page = _page;
                vc.component.monthAttendanceManageInfo.conditions.row = _rows;
                let param = {
                    params: $that.monthAttendanceManageInfo.conditions
                };
                //发送get请求
                vc.http.apiGet('/attendanceClass/getMonthAttendance',
                    param,
                    function (json, res) {
                        var _monthAttendanceManageInfo = JSON.parse(json);
                        vc.component.monthAttendanceManageInfo.total = _monthAttendanceManageInfo.total;
                        vc.component.monthAttendanceManageInfo.records = _monthAttendanceManageInfo.records;
                        vc.component.monthAttendanceManageInfo.attendances = _monthAttendanceManageInfo.data;
                        vc.emit('pagination', 'init', {
                            total: vc.component.monthAttendanceManageInfo.records,
                            dataCount: vc.component.monthAttendanceManageInfo.total,
                            currentPage: _page
                        });
                    },
                    function (errInfo, error) {
                        console.log('请求失败处理');
                    }
                );
            },
            //查询
            _queryMonthAttendanceMethod: function () {
                vc.component._listMonthAttendances(DEFAULT_PAGE, DEFAULT_ROWS);
            },
            //重置
            _resetMonthAttendanceMethod: function () {
                vc.component.monthAttendanceManageInfo.conditions.classesName = "";
                vc.component.monthAttendanceManageInfo.conditions.departmentName = "";
                vc.component.monthAttendanceManageInfo.conditions.date = vc.dateFormat(new Date());
                vc.component._listMonthAttendances(DEFAULT_PAGE, DEFAULT_ROWS);
            },
            _moreCondition: function () {
                if (vc.component.monthAttendanceManageInfo.moreCondition) {
                    vc.component.monthAttendanceManageInfo.moreCondition = false;
                } else {
                    vc.component.monthAttendanceManageInfo.moreCondition = true;
                }
            },
            _changeCurrentDay: function () {
                let _taskYear = $that.monthAttendanceManageInfo.conditions.taskYear;
                let _taskMonth = $that.monthAttendanceManageInfo.conditions.taskMonth;
                if (!_taskMonth || !_taskYear) {
                    let _date = new Date();
                    $that.monthAttendanceManageInfo.conditions.taskYear = _date.getFullYear();
                    $that.monthAttendanceManageInfo.conditions.taskMonth = _date.getMonth() + 1;
                    $that.monthAttendanceManageInfo.conditions.date = _date.getFullYear() + "-" + (_date.getMonth() + 1);
                    _taskYear = $that.monthAttendanceManageInfo.conditions.taskYear;
                    _taskMonth = $that.monthAttendanceManageInfo.conditions.taskMonth;
                }
                $that.monthAttendanceManageInfo.curDays = vc.daysInMonth(_taskYear, parseInt(_taskMonth) - 1);
            },
            _computeTableDivWidth: function () {
                let mainWidth = document.getElementsByTagName('body')[0].clientWidth - document.getElementById('menu-nav').offsetWidth;
                //let treeWidth = document.getElementsByClassName('room-floor-unit-tree')[0].offsetWidth;
                mainWidth = mainWidth - 20 - 15 - 20;
                //document.getElementsByClassName('hc-table-div')[0].style.width=mainWidth+'px';
                return mainWidth + 'px';
            },
            _listAttendanceClassess: function () {
                let param = {
                    params: {
                        page: 1,
                        row: 100
                    }
                };
                //发送get请求
                vc.http.apiGet('/attendanceClasses.listAttendanceClassess',
                    param,
                    function (json, res) {
                        let _attendanceClassesManageInfo = JSON.parse(json);
                        $that.monthAttendanceManageInfo.attendanceClassess = _attendanceClassesManageInfo.data;
                        if (_attendanceClassesManageInfo.data && _attendanceClassesManageInfo.data.length > 0) {
                            $that.monthAttendanceManageInfo.conditions.classesId = _attendanceClassesManageInfo.data[0].classesId;
                            $that._listMonthAttendances(DEFAULT_PAGE, DEFAULT_ROWS);
                        }
                    },
                    function (errInfo, error) {
                        console.log('请求失败处理');
                    }
                );
            },
            _getDayDetail: function (detail, day) {
                let _date = new Date();
                let _taskYear = $that.monthAttendanceManageInfo.conditions.taskYear;
                let _taskMonth = $that.monthAttendanceManageInfo.conditions.taskMonth;
                if (_taskYear == _date.getFullYear() && _taskMonth == (_date.getMonth() + 1) && day > _date.getDate()) {
                    return "未到时间";
                }
                if (!detail.hasOwnProperty(day)) {
                    return "无需考勤";
                }
                let _details = detail[day];
                if (!_details) {
                    return "无需考勤";
                }
                let _value = "";
                _details.forEach(element => {
                    if (element.specCd == '1001') {
                        _value += ('<div>上班:')
                    } else {
                        _value += "<div>下班:"
                    }
                    if (element.state != '10000') {
                        _value += (vc.timeFormat(element.checkTime) + '(' + element.stateName + ')</div>')
                    } else {
                        _value += (' - (' + element.stateName + ')</div>')
                    }
                });
                return _value;
            },
            _exportExcel: function () {
                //vc.jumpToPage('/callComponent/exportReportFee/exportData?pagePath=reportPayFeeDetail&' + vc.objToGetParam($that.reportPayFeeDetailInfo.conditions));
                vc.component.monthAttendanceManageInfo.conditions.communityId = vc.getCurrentCommunity().communityId;
                vc.component.monthAttendanceManageInfo.conditions.pagePath = 'monthAttendance';
                let param = {
                    params: vc.component.monthAttendanceManageInfo.conditions
                };
                //发送get请求
                vc.http.apiGet('/export.exportData', param,
                    function (json, res) {
                        let _json = JSON.parse(json);
                        vc.toast(_json.msg);
                        if (_json.code == 0) {
                            vc.jumpToPage('/#/pages/property/downloadTempFile?tab=下载中心')
                        }
                    },
                    function (errInfo, error) {
                        console.log('请求失败处理');
                    });
            }
        }
    });
})(window.vc);