|
@@ -10,9 +10,14 @@
|
|
|
</template>
|
|
|
<template #date-cell="{ data }">
|
|
|
<!-- 仅工作日显示角标 -->
|
|
|
- <div :class="`day-cell ${getDayClass(data.day)}`" v-if="data.type === 'current-month'">
|
|
|
+ <div
|
|
|
+ :class="`day-cell ${getDayClass(data.day)}`"
|
|
|
+ v-if="data.type === 'current-month'"
|
|
|
+ @mouseover="onMouseOver(data)"
|
|
|
+ @mouseout="onMouseOut(data)"
|
|
|
+ >
|
|
|
<p :class="data.isSelected ? 'is-selected' : ''">
|
|
|
- {{ data.day.split('-')[2] }}
|
|
|
+ {{ dayReportMap[data.day]?.show }}
|
|
|
</p>
|
|
|
</div>
|
|
|
|
|
@@ -34,6 +39,12 @@
|
|
|
<script setup lang="ts">
|
|
|
import request from '@/config/axios'
|
|
|
import moment from 'moment'
|
|
|
+import { getUserInfo } from '@/utils/tool'
|
|
|
+
|
|
|
+const message = useMessage()
|
|
|
+
|
|
|
+// 获取用户信息
|
|
|
+const userInfo = getUserInfo()
|
|
|
|
|
|
const $emit = defineEmits<{
|
|
|
(e: 'click', v: string | object): void
|
|
@@ -43,12 +54,33 @@ const calendar = ref()
|
|
|
const todayValue = ref(new Date())
|
|
|
|
|
|
watch(todayValue, () => {
|
|
|
- $emit('click', dayReportMap.value[moment(todayValue.value).format('YYYY-MM-DD')])
|
|
|
+ // console.log(
|
|
|
+ // 'dayReportMap.value',
|
|
|
+ // moment(todayValue.value).format('YYYY-MM-DD'),
|
|
|
+ // dayReportMap.value
|
|
|
+ // )
|
|
|
+ // 如果选中的是今天之后的日期,则不进行点击及跳转
|
|
|
+ const isAfterToday = moment(todayValue.value).isAfter(moment())
|
|
|
+ if (isAfterToday) {
|
|
|
+ todayValue.value = new Date()
|
|
|
+ message.info('仅可对今日及之前的日志进行填报!')
|
|
|
+ } else {
|
|
|
+ $emit('click', dayReportMap.value[moment(todayValue.value).format('YYYY-MM-DD')])
|
|
|
+ }
|
|
|
})
|
|
|
|
|
|
const selectDate = (val) => {
|
|
|
if (!calendar.value) return
|
|
|
calendar.value.selectDate(val)
|
|
|
+ if (val === 'prev-month') {
|
|
|
+ nowMonths.value = moment(nowMonths.value).subtract(1, 'months').format('YYYY-MM')
|
|
|
+ } else if (val === 'next-month') {
|
|
|
+ nowMonths.value = moment(nowMonths.value).add(1, 'months').format('YYYY-MM')
|
|
|
+ }
|
|
|
+ const timer = setTimeout(() => {
|
|
|
+ initDailyReportData()
|
|
|
+ clearTimeout(timer)
|
|
|
+ }, 128)
|
|
|
}
|
|
|
|
|
|
onMounted(() => {
|
|
@@ -56,7 +88,7 @@ onMounted(() => {
|
|
|
const timer = setTimeout(() => {
|
|
|
$emit('click', dayReportMap.value[moment(todayValue.value).format('YYYY-MM-DD')])
|
|
|
clearTimeout(timer)
|
|
|
- }, 200)
|
|
|
+ }, 128)
|
|
|
})
|
|
|
|
|
|
interface ItemState {
|
|
@@ -90,12 +122,11 @@ const leaveMap = {
|
|
|
}
|
|
|
|
|
|
const dailyReportAttendances = ref<ItemState[]>([])
|
|
|
-const nowTime: any = ref(moment().format('YYYY-MM'))
|
|
|
-const dailyReportCount = ref<number>(0)
|
|
|
+const nowMonths: any = ref(moment().format('YYYY-MM'))
|
|
|
|
|
|
// const dictMap: any = getDictOptions(DICT_TYPE.ADM_ATTENDANCE_STATUS)
|
|
|
const getWorkDayList = async (): Promise<any> => {
|
|
|
- const nowTimeObj = moment(nowTime.value)
|
|
|
+ const nowTimeObj = moment(nowMonths.value)
|
|
|
const urlApi = `/adm/workday/list`
|
|
|
const params = {
|
|
|
dateDay: [
|
|
@@ -105,17 +136,9 @@ const getWorkDayList = async (): Promise<any> => {
|
|
|
}
|
|
|
return await request.get({ url: urlApi, params })
|
|
|
}
|
|
|
-const getDailyReportList = async (): Promise<any> => {
|
|
|
- const nowTimeObj = moment(nowTime.value)
|
|
|
- const urlApi = `/adm/report/query-month`
|
|
|
- const params = {
|
|
|
- reportYear: nowTimeObj.format('YYYY'),
|
|
|
- reportMonth: nowTimeObj.format('MM')
|
|
|
- }
|
|
|
- return await request.get({ url: urlApi, params })
|
|
|
-}
|
|
|
+
|
|
|
const getAttendanceSheetListMine = async (): Promise<any> => {
|
|
|
- const nowTimeObj = moment(nowTime.value)
|
|
|
+ const nowTimeObj = moment(nowMonths.value)
|
|
|
const urlApi = `/adm/attendance-sheet/list-me`
|
|
|
const params = {
|
|
|
attendanceTime: [
|
|
@@ -126,18 +149,27 @@ const getAttendanceSheetListMine = async (): Promise<any> => {
|
|
|
return await request.get({ url: urlApi, params })
|
|
|
}
|
|
|
|
|
|
+// 日报统计
|
|
|
+const getLogList = async (): Promise<any> => {
|
|
|
+ const nowTimeObj = moment(nowMonths.value)
|
|
|
+ const urlApi = `/adm/report/list`
|
|
|
+ const params = {
|
|
|
+ reportType: 'daily',
|
|
|
+ reportYear: nowTimeObj.format('YYYY'),
|
|
|
+ reportMonth: Number(nowTimeObj.format('MM')),
|
|
|
+ userId: userInfo.id ?? ''
|
|
|
+ }
|
|
|
+ return await request.get({ url: urlApi, params })
|
|
|
+}
|
|
|
+
|
|
|
const dayReportMap: any = ref({})
|
|
|
const initDailyReportData = async (): Promise<any> => {
|
|
|
- //日报统计
|
|
|
- const dailyReports: [] = await getDailyReportList()
|
|
|
- const dailyReportMap: Map<string, Map<string, string>> = new Map()
|
|
|
- dailyReports.forEach((item) => {
|
|
|
- dailyReportMap[moment(item['fillingDate']).format('YYYY-MM-DD')] = {
|
|
|
- id: item['id'],
|
|
|
- statu: '99'
|
|
|
- }
|
|
|
+ // 获取已填写的日志
|
|
|
+ const logList = await getLogList()
|
|
|
+ const logObj = {}
|
|
|
+ logList?.forEach((item) => {
|
|
|
+ logObj[moment(item.reportStartDate).format('YYYY-MM-DD')] = item
|
|
|
})
|
|
|
- dailyReportCount.value = dailyReports.length
|
|
|
//考勤统计
|
|
|
const attendances: [] = await getAttendanceSheetListMine()
|
|
|
const attendanceState: Map<string, string> = new Map()
|
|
@@ -148,13 +180,13 @@ const initDailyReportData = async (): Promise<any> => {
|
|
|
}
|
|
|
})
|
|
|
//节假日统计
|
|
|
- const workdays: [] = await getWorkDayList()
|
|
|
- const dailyReportList: ItemState[] = []
|
|
|
+ const workdays: any[] = await getWorkDayList()
|
|
|
+ const dailyReportList: any[] = []
|
|
|
workdays.forEach((item) => {
|
|
|
const date = moment(item['dateDay']).format('YYYY-MM-DD')
|
|
|
const _dailyReportMap = dailyReportList[date]
|
|
|
const _attendanceState = attendanceState[date]
|
|
|
-
|
|
|
+ const isLog = logObj[date] ?? false
|
|
|
if (_dailyReportMap) {
|
|
|
dailyReportList.push({
|
|
|
id: _dailyReportMap['id'],
|
|
@@ -164,7 +196,9 @@ const initDailyReportData = async (): Promise<any> => {
|
|
|
week: item['week'],
|
|
|
dayOfWeek: item['dayOfWeek'],
|
|
|
isworkday: item['isworkday'],
|
|
|
- state: _dailyReportMap['state']
|
|
|
+ state: _dailyReportMap['state'],
|
|
|
+ isLog,
|
|
|
+ holidayRemark: item['holidayRemark']
|
|
|
})
|
|
|
} else if (_attendanceState) {
|
|
|
dailyReportList.push({
|
|
@@ -175,7 +209,9 @@ const initDailyReportData = async (): Promise<any> => {
|
|
|
week: item['week'],
|
|
|
dayOfWeek: item['dayOfWeek'],
|
|
|
isworkday: item['isworkday'],
|
|
|
- state: _attendanceState
|
|
|
+ state: _attendanceState,
|
|
|
+ isLog,
|
|
|
+ holidayRemark: item['holidayRemark']
|
|
|
})
|
|
|
} else {
|
|
|
dailyReportList.push({
|
|
@@ -186,13 +222,15 @@ const initDailyReportData = async (): Promise<any> => {
|
|
|
week: item['week'],
|
|
|
dayOfWeek: item['dayOfWeek'],
|
|
|
isworkday: item['isworkday'],
|
|
|
- state: item['isworkday'] === 0 ? '' : '-1'
|
|
|
+ state: item['isworkday'] === 0 ? '' : '-1',
|
|
|
+ isLog,
|
|
|
+ holidayRemark: item['holidayRemark']
|
|
|
})
|
|
|
}
|
|
|
})
|
|
|
dailyReportAttendances.value = dailyReportList
|
|
|
dailyReportList.forEach((item) => {
|
|
|
- dayReportMap.value[item.date] = item
|
|
|
+ dayReportMap.value[item.date] = { ...item, show: item.date.split('-')[2] }
|
|
|
})
|
|
|
}
|
|
|
|
|
@@ -220,6 +258,19 @@ const getDayClass = (data) => {
|
|
|
}
|
|
|
return ''
|
|
|
}
|
|
|
+
|
|
|
+// 鼠标移入移出事件
|
|
|
+const onMouseOver = (data) => {
|
|
|
+ const isLog = dayReportMap.value[data.day]?.isLog ? true : false
|
|
|
+ if (isLog) {
|
|
|
+ dayReportMap.value[data.day].show = '已填'
|
|
|
+ } else {
|
|
|
+ dayReportMap.value[data.day].show = dayReportMap.value[data.day]?.holidayRemark ?? '未填'
|
|
|
+ }
|
|
|
+}
|
|
|
+const onMouseOut = (data) => {
|
|
|
+ dayReportMap.value[data.day].show = data.day.split('-')[2]
|
|
|
+}
|
|
|
</script>
|
|
|
<style lang="scss" scoped>
|
|
|
.OaCalendar {
|