pms-front/src/views/worklog/components/leftMonth.vue

168 lines
3.6 KiB
Vue
Raw Normal View History

<template>
<div class="leftBox">
<div class="topBox">
<el-date-picker
v-model="selectedDate"
type="month"
format="yyyy年MM月"
:clearable="false"
style="margin-bottom: 10px; width: 150px"
@change="changeMonth"
prefix-icon="false"
/>
<div>
<i
class="el-icon-arrow-left"
style="font-size: 18px; font-weight: bold"
@click="preMonth"
></i>
<i
class="el-icon-arrow-right"
style="font-size: 18px; font-weight: bold"
@click="nextMonth"
></i>
</div>
</div>
2025-03-26 09:58:58 +00:00
<el-calendar v-model="selectedDate">
<template #dateCell="{ data }">
<div
:key="data.day"
:id="data.day"
@click="searchLog(data, isOverDay(data.day))"
:class="{
dayBox: true,
disabled: isOverDay(data.day),
}"
>
{{ data.day.split("-")[2] }}
</div>
</template>
</el-calendar>
</div>
</template>
<script>
import { workLogApi, projectApi } from "@/utils/api";
export default {
name: "LeftMonth",
data() {
return {
selectedDate: this.moment(new Date()).format("YYYY-MM-DD"),
2025-03-26 09:58:58 +00:00
nowDay: this.moment(new Date()).format("YYYY-MM-DD"),
};
},
methods: {
changeMonth() {},
preMonth() {
this.selectedDate = this.moment(this.selectedDate)
.subtract(1, "months")
.format("YYYY-MM-DD");
},
nextMonth() {
this.selectedDate = this.moment(this.selectedDate)
.add(1, "months")
.format("YYYY-MM-DD");
},
2025-03-26 09:58:58 +00:00
searchLog(data, overDay) {
this.$nextTick(() => {
if (overDay) {
this.$message({
message: "不能超过当前时间",
type: "warning",
});
this.$emit("setDisableTable", true);
} else {
this.$emit("setDisableTable", false);
this.$emit("searchDay", data.day + " 00:00:00");
}
});
},
isOverDay(data) {
return new Date(data).getTime() > new Date(this.nowDay).getTime();
},
}
};
</script>
<style scoped lang="scss">
.leftBox ::v-deep .el-calendar__header {
display: none;
}
.leftBox ::v-deep .el-date-editor {
.el-input__inner {
border: none;
padding-left: 0;
font-size: 18px;
color: #333333;
font-weight: 600;
}
}
.leftBox ::v-deep .el-calendar__body {
padding: 0 !important;
thead {
th {
font-family: PingFang SC;
font-weight: 400;
font-size: 16px;
color: #999999;
}
}
tbody {
td {
border: none;
padding: 10px 0;
2025-03-26 09:58:58 +00:00
background-color: #fff;
.el-calendar-day {
text-align: center;
padding: 0 !important;
font-size: 16px;
2025-03-26 09:58:58 +00:00
background-color: #fff;
span {
font-family: cursive !important;
}
}
&.next,
&.prev {
color: #333 !important;
}
&.is-selected .el-calendar-day {
border-radius: 50% !important;
background-color: #4096ff;
color: #fff;
}
.el-calendar-day {
height: 40px;
width: 40px;
line-height: 40px;
border-radius: 50% !important;
&:hover {
background-color: #88bdfd;
color: #fff;
}
}
}
}
}
.topBox {
display: flex;
flex-direction: row;
justify-content: space-between;
align-items: center;
i {
margin-right: 10px;
cursor: pointer;
}
}
2025-03-26 09:58:58 +00:00
.leftBox ::v-deep .disabled {
background-color: #fff !important;
color: #c0c4cc;
cursor: not-allowed;
border-radius: 50% !important;
background-color: #fff;
}
</style>