119 lines
4.8 KiB
JavaScript
119 lines
4.8 KiB
JavaScript
/**
|
|
入驻小区
|
|
**/
|
|
(function (vc) {
|
|
var DEFAULT_PAGE = 1;
|
|
var DEFAULT_ROWS = 10;
|
|
vc.extends({
|
|
data: {
|
|
aStaffDetailAttendanceInfo: {
|
|
staffId: '',
|
|
attendances: [],
|
|
curDate: '',
|
|
maxDay: '',
|
|
curYear: '',
|
|
curMonth: ''
|
|
}
|
|
},
|
|
_initMethod: function () {
|
|
let _date = new Date(new Date());
|
|
$that.aStaffDetailAttendanceInfo.curMonth = _date.getMonth() + 1
|
|
$that.aStaffDetailAttendanceInfo.curYear = _date.getFullYear();
|
|
$that.aStaffDetailAttendanceInfo.curDate = _date.getFullYear() + "-" + (_date.getMonth() + 1);
|
|
$that.aStaffDetailAttendanceInfo.maxDay = new Date(_date.getFullYear(), _date.getMonth() + 1, 0).getDate();
|
|
vc.initDateMonth('queryAttendanceDate', function (_value) {
|
|
$that.aStaffDetailAttendanceInfo.curDate = _value;
|
|
let _values = _value.split('-');
|
|
$that.aStaffDetailAttendanceInfo.curYear = _values[0];
|
|
$that.aStaffDetailAttendanceInfo.curMonth = _values[1];
|
|
});
|
|
},
|
|
_initEvent: function () {
|
|
vc.on('aStaffDetailAttendance', 'switch', function (_data) {
|
|
$that.aStaffDetailAttendanceInfo.staffId = _data.staffId;
|
|
$that._loadStaffAttendances()
|
|
});
|
|
},
|
|
methods: {
|
|
_getAttendanceState: function (_day) {
|
|
let _attendance = $that._getDayAttendance(_day);
|
|
if (!_attendance) {
|
|
return "<span style='color:rgb(220, 53, 69)'>未考勤</span>";
|
|
}
|
|
return "<span style='color:rgb(18, 150, 219)'>" + _attendance.stateName + "</span>";
|
|
},
|
|
_getAttendanceDetail: function (_day) {
|
|
let _attendance = $that._getDayAttendance(_day);
|
|
if (!_attendance) {
|
|
let _date = new Date();
|
|
let _taskYear = $that.aStaffDetailAttendanceInfo.curYear
|
|
let _taskMonth = $that.aStaffDetailAttendanceInfo.curMonth;
|
|
if (_taskYear == _date.getFullYear() && parseInt(_taskMonth) == (_date.getMonth() + 1) && _day > _date.getDate()) {
|
|
return [{
|
|
rest: '未到时间',
|
|
}];
|
|
}
|
|
return [{
|
|
rest: '无需考勤',
|
|
}];
|
|
}
|
|
return _attendance.attendanceClassesTaskDetails;
|
|
},
|
|
_getDayAttendance: function (_day) {
|
|
let _attendance = null;
|
|
if (!$that.aStaffDetailAttendanceInfo.attendances) {
|
|
return _attendance;
|
|
}
|
|
$that.aStaffDetailAttendanceInfo.attendances.forEach(item => {
|
|
if (item.taskDay == _day) {
|
|
_attendance = item;
|
|
}
|
|
});
|
|
return _attendance;
|
|
},
|
|
_getBgColor: function (_curDay) {
|
|
return "#fff"
|
|
},
|
|
_loadStaffAttendances: function () {
|
|
if (!$that.aStaffDetailAttendanceInfo.staffId) {
|
|
return;
|
|
}
|
|
if (!$that.aStaffDetailAttendanceInfo.curDate) {
|
|
return;
|
|
}
|
|
let param = {
|
|
params: {
|
|
page: 1,
|
|
row: 1000,
|
|
date: $that.aStaffDetailAttendanceInfo.curDate,
|
|
staffId: $that.aStaffDetailAttendanceInfo.staffId
|
|
}
|
|
};
|
|
//发送get请求
|
|
vc.http.apiGet('/attendanceClasses.queryAdminAttendanceClasses',
|
|
param,
|
|
function (json, res) {
|
|
let _json = JSON.parse(json);
|
|
$that.aStaffDetailAttendanceInfo.attendances = _json.data;
|
|
},
|
|
function (errInfo, error) {
|
|
console.log('请求失败处理');
|
|
}
|
|
);
|
|
},
|
|
_checkInLog: function (_day) {
|
|
let _curMonth = $that.aStaffDetailAttendanceInfo.curMonth;
|
|
if (_curMonth < 10) {
|
|
_curMonth = "0" + _curMonth;
|
|
}
|
|
if (_day < 10) {
|
|
_day = "0" + _day;
|
|
}
|
|
vc.emit('staffAttendanceDetail', 'openModel', {
|
|
staffId: $that.aStaffDetailAttendanceInfo.staffId,
|
|
date: $that.aStaffDetailAttendanceInfo.curYear + "-" + _curMonth + '-' + _day
|
|
});
|
|
},
|
|
}
|
|
});
|
|
})(window.vc); |