|
@@ -9,12 +9,16 @@
|
|
|
<el-icon><ArrowRightBold /></el-icon>
|
|
|
</div>
|
|
|
</div>
|
|
|
- <div class="content">
|
|
|
+
|
|
|
+ <div class="content" v-loading="isLoading">
|
|
|
<div
|
|
|
v-for="(item, index) in thisMonthLogs"
|
|
|
:key="item.week"
|
|
|
class="week-item"
|
|
|
- :style="{ backgroundColor: item.bgColor }"
|
|
|
+ :style="{
|
|
|
+ backgroundColor: item.bgColor,
|
|
|
+ border: item.endDate == checkItem ? `1.5px solid ${item.color}` : 'none'
|
|
|
+ }"
|
|
|
@click="goToWeeklyPage(item)"
|
|
|
>
|
|
|
<div class="left">
|
|
@@ -53,6 +57,7 @@ interface IProp {
|
|
|
}
|
|
|
const { onChange } = defineProps<IProp>()
|
|
|
|
|
|
+const isLoading = ref<boolean>(false)
|
|
|
// 所有的周日报和周划分
|
|
|
// const allWorkDayListAndLogs = ref<any>([])
|
|
|
// 本月日期
|
|
@@ -63,16 +68,16 @@ const thisMonthLogs = ref<any>([])
|
|
|
// 获取工作日列表
|
|
|
onMounted(async () => {
|
|
|
await initPageList()
|
|
|
- // console.log('thisMonthLogs', thisMonthLogs.value, moment().format('YYYY-MM-DD'))
|
|
|
|
|
|
+ // 初始化的时候进行一些选择
|
|
|
const nowLog = thisMonthLogs.value.find((item: any) =>
|
|
|
moment().isBetween(item.startDate, item.endDate)
|
|
|
)
|
|
|
goToWeeklyPage(nowLog)
|
|
|
|
|
|
// 订阅提交(暂存)事件,执行重置事件
|
|
|
- PubsubService.subscribe('sendWeeklyReportHandle-init', () => {
|
|
|
- initPageList()
|
|
|
+ PubsubService.subscribe('sendWeeklyReportHandle-init', async () => {
|
|
|
+ await initPageList()
|
|
|
})
|
|
|
})
|
|
|
|
|
@@ -92,7 +97,7 @@ const checkMonth = (type: 'prev' | 'next') => {
|
|
|
}
|
|
|
// 获取最近三个月的工作日列表详情
|
|
|
const workDayList = async () => {
|
|
|
- const monthRange = service.getMonthRange()
|
|
|
+ const monthRange = service.getMonthRange(thisMonth.value)
|
|
|
const workDays = await http.getWorkDayList(monthRange[0], monthRange[1])
|
|
|
const workDayObj = service.setWorkDayListToWeek(workDays)
|
|
|
return workDayObj
|
|
@@ -100,12 +105,13 @@ const workDayList = async () => {
|
|
|
|
|
|
// 合并工作日和周报列表并初始化页面
|
|
|
const initPageList = async () => {
|
|
|
+ isLoading.value = true
|
|
|
const workObj = await workDayList()
|
|
|
- const logList = await http.getLogList('weekly', thisMonth.value)
|
|
|
+ const logList = await http.getMonthLogList('weekly', thisMonth.value)
|
|
|
const allWorkDayListAndLogs = service.mergeWorkDayAndLogs(workObj, logList)
|
|
|
|
|
|
const pointer = moment(thisMonth.value).format('YYYY-M')
|
|
|
- thisMonthLogs.value = allWorkDayListAndLogs[pointer].map((item: any) => {
|
|
|
+ const thisMonthLog = allWorkDayListAndLogs[pointer].map((item: any) => {
|
|
|
// 默认未填
|
|
|
item.type = statusObj[1].type
|
|
|
item.icon = statusObj[1].icon
|
|
@@ -113,15 +119,15 @@ const initPageList = async () => {
|
|
|
item.bgColor = statusObj[1].bgColor
|
|
|
// 如果本周
|
|
|
const startOfWeek = moment().startOf('week')
|
|
|
- const endOfWeek = moment().endOf('week')
|
|
|
+ const endOfWeek = moment().endOf('week').add(1, 'day')
|
|
|
if (moment(item.startDate).isBetween(startOfWeek, endOfWeek)) {
|
|
|
item.icon = statusObj[2].icon
|
|
|
item.color = statusObj[2].color
|
|
|
item.bgColor = statusObj[2].bgColor
|
|
|
item.type = statusObj[2].type
|
|
|
}
|
|
|
- // 如果已填
|
|
|
- if (item.isLog.length > 0) {
|
|
|
+ // 如果已填,且不是暂存
|
|
|
+ if (item.isLog.length > 0 && !item.isLog[0].isTemp) {
|
|
|
const isLog = item.isLog[0]
|
|
|
item.id = isLog.id
|
|
|
item.icon = statusObj[0].icon
|
|
@@ -129,6 +135,11 @@ const initPageList = async () => {
|
|
|
item.bgColor = statusObj[0].bgColor
|
|
|
item.type = statusObj[0].type
|
|
|
}
|
|
|
+ // 如果已填但是是暂存
|
|
|
+ if (item.isLog.length > 0 && item.isLog[0].isTemp) {
|
|
|
+ // 啥也不做
|
|
|
+ item.type = '暂存'
|
|
|
+ }
|
|
|
// 如果未到
|
|
|
if (moment(item.startDate).isAfter(moment())) {
|
|
|
item.icon = statusObj[3].icon
|
|
@@ -138,6 +149,21 @@ const initPageList = async () => {
|
|
|
}
|
|
|
return item
|
|
|
})
|
|
|
+
|
|
|
+ isLoading.value = false
|
|
|
+
|
|
|
+ thisMonthLogs.value = thisMonthLog
|
|
|
+
|
|
|
+ const nowLog = thisMonthLog.find((item: any) =>
|
|
|
+ moment(checkItem.value).isBetween(
|
|
|
+ item.startDate,
|
|
|
+ moment(item.endDate).add(1, 'day'),
|
|
|
+ item.endDate
|
|
|
+ )
|
|
|
+ )
|
|
|
+ if (nowLog) {
|
|
|
+ itemOnChange(nowLog)
|
|
|
+ }
|
|
|
}
|
|
|
// 颜色列表
|
|
|
const weekTitleList = ['第一周', '第二周', '第三周', '第四周', '第五周']
|
|
@@ -149,21 +175,26 @@ const statusObj = [
|
|
|
]
|
|
|
// 跳转到周报填写或详情页面
|
|
|
// const { push } = useRouter()
|
|
|
+const checkItem = ref(moment())
|
|
|
const goToWeeklyPage = (item: any) => {
|
|
|
- // console.log('click item', item)
|
|
|
if (item.type == '未到') {
|
|
|
message.info('还未到这周!')
|
|
|
return
|
|
|
}
|
|
|
+ // 修改点击的item
|
|
|
+ checkItem.value = item.endDate
|
|
|
+ itemOnChange(item)
|
|
|
+}
|
|
|
+
|
|
|
+const itemOnChange = (item: any) => {
|
|
|
const dayOfWeek = item.data[item.data.length - 1]
|
|
|
const changeData: any = {
|
|
|
weekDate: [item.startDate, item.endDate],
|
|
|
year: dayOfWeek.year,
|
|
|
month: dayOfWeek.month,
|
|
|
week: dayOfWeek.week,
|
|
|
- isLog: item.type == '已填' ? item.isLog[0] : false
|
|
|
+ isLog: item.isLog.length > 0 ? item.isLog[0] : false
|
|
|
}
|
|
|
- // console.log('changeData', changeData)
|
|
|
onChange(changeData)
|
|
|
}
|
|
|
</script>
|