Merge remote-tracking branch 'origin/main'

This commit is contained in:
jianghanbo 2024-10-22 15:58:30 +08:00
commit 2655d5469a
2 changed files with 103 additions and 4 deletions

View File

@ -33,7 +33,7 @@ export function postAddProductApi(data) {
// 商品排期详情 // 商品排期详情
export function getProductSchedules(data) { export function getProductSchedules(data) {
return request({ return request({
url: `/admin/products/productschedules?id=${data}`, url: `/admin/products/productschedules?id=${data.id}&date=${data.date}`,
method: "get", method: "get",
}); });
} }

View File

@ -1,6 +1,18 @@
<template> <template>
<div class="pro_scheduling"> <div class="pro_scheduling">
<el-calendar v-model="value"> <div class="pick">
<span>{{ yue ? yue : dDate }}</span>
<el-date-picker
v-model="yue"
value-format="yyyy-MM"
format="yyyy 年 MM 月"
type="month"
placeholder="选择日期"
@change="changeYue"
>
</el-date-picker>
</div>
<el-calendar v-model="yue">
<template #dateCell="{ date }"> <template #dateCell="{ date }">
<div> <div>
<div>{{ date.getDate() }}</div> <div>{{ date.getDate() }}</div>
@ -77,6 +89,8 @@ export default {
num: "", num: "",
id: "", id: "",
}, },
yue: "",
dDate: "",
rules: { rules: {
num: [ num: [
{ {
@ -93,9 +107,19 @@ export default {
this.getList(); this.getList();
}, },
methods: { methods: {
async getList() { async getList(val) {
const res = await getProductSchedules(this.formData.id); const date = this.value; // 使
const year = date.getFullYear();
const month = String(date.getMonth() + 1).padStart(2, "0");
const formattedDate = `${year}-${month}`;
this.dDate = formattedDate;
const param = {
id: this.formData.id,
date: val ? val : formattedDate,
};
const res = await getProductSchedules(param);
if (res && res.error === 0) { if (res && res.error === 0) {
this.appointments = {}; //
res.data.forEach((item) => { res.data.forEach((item) => {
this.$set(this.appointments, item.date, { this.$set(this.appointments, item.date, {
books_num: item.books_num, books_num: item.books_num,
@ -104,11 +128,50 @@ export default {
}); });
} }
}, },
changeYue() {
this.getList(this.yue);
},
isDateAvailable(date) { isDateAvailable(date) {
const today = new Date(); const today = new Date();
today.setHours(0, 0, 0, 0); today.setHours(0, 0, 0, 0);
return date >= today; return date >= today;
}, },
isDateAvailable(date) {
const today = new Date();
today.setHours(0, 0, 0, 0);
//
const selectedYear = this.yue
? new Date(this.yue).getFullYear()
: today.getFullYear();
const selectedMonth = this.yue
? new Date(this.yue).getMonth()
: today.getMonth();
//
const dateYear = date.getFullYear();
const dateMonth = date.getMonth();
//
if (
dateYear > selectedYear ||
(dateYear === selectedYear && dateMonth > selectedMonth)
) {
return true;
}
//
if (
dateYear === selectedYear &&
dateMonth === selectedMonth &&
date >= today
) {
return true;
}
//
return false;
},
bookDate(date) { bookDate(date) {
console.log(`预约日期: ${date.toLocaleDateString()}`); console.log(`预约日期: ${date.toLocaleDateString()}`);
this.dialogVisible = true; this.dialogVisible = true;
@ -151,6 +214,14 @@ export default {
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
.pick {
position: relative;
top: 20px;
left: -327px;
span {
margin-right: 20px;
}
}
.pro_scheduling { .pro_scheduling {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
@ -175,4 +246,32 @@ export default {
font-size: 14px; font-size: 14px;
margin-top: 10px; margin-top: 10px;
} }
::v-deep .el-calendar-table:not(.is-range) td.prev,
::v-deep .el-calendar-table:not(.is-range) td.next {
cursor: not-allowed;
pointer-events: none;
// display: none;
}
// ::v-deep .el-calendar-table:not(.is-range) td.prev {
// /**/
// visibility: hidden;
// }
.prev > .el-calendar-day > .dateContent {
display: none;
}
.next > .el-calendar-day > .dateContent {
display: none;
}
//
::v-deep .el-calendar-table:not(.is-range) td.next {
/*隐藏下个月的日期*/
visibility: hidden;
}
//
::v-deep .el-calendar__button-group {
display: none;
}
::v-deep .el-calendar__title {
display: none;
}
</style> </style>