Files
2024-03-21 15:38:10 +08:00

445 lines
11 KiB
Vue

<template>
<view class="content">
<view class="contentone">
<view class="onecontenttowone flex-start">
<view class="onecontenttowone_one">
选择休息时间
</view>
</view>
<view class="onecontenttowtow flex-between">
<view class="onecontenttowtow_item flex-between">
<view class=" flex-colum" v-for="(item,index) in reservationlist" :key="index"
:class="reservationshow == index ? 'onecontenttowtow_item_ones':'onecontenttowtow_item_one'"
@click="reservation(item,index)">
<text class="onecontenttowtow_item_one_textone">{{item.week}}</text>
<text class="onecontenttowtow_item_one_texttow">{{item.date.slice(5,10)}}</text>
</view>
</view>
<view class="onecontenttowtow_left flex-colum" @click="calendarshow = true">
<u-icon name="calendar" color="#b4b4b4" size="20"></u-icon>
<text class="onecontenttowtow_lefttext">选择</text>
</view>
</view>
<view class="onecontenttowthere flex-start">
<view v-for="(item,index) in listday_time" :key="index" @click="clicktime(item,index)"
:class="item.select?'onecontenttowthere_items':'onecontenttowthere_item'">
{{item.time}}
</view>
</view>
</view>
<view class="contentone" style="margin-top: 40rpx;">
<view class="onecontenttowone flex-start">
<view class="onecontenttowone_one">
我的休息时间
</view>
</view>
<view class="onecontenttowthere flex-start">
<view v-for="(item,index) in listday_xx" :key="index" class="onecontenttowthere_item">
{{item.time}}
</view>
</view>
</view>
<view class="contentbox" @click="staffsavestaffhours">
提交
</view>
<view class="positionfixed flex-between">
<view class="positionfixeditem flex-center positionfixeditems" @click="ange(1)">
<u-icon name="list-dot" color="#2979ff" size="14"></u-icon>
<text class="positionfixedtext">预约列表</text>
</view>
<view class="positionfixeditem flex-center" @click="ange(2)">
<u-icon name="clock" color="#2979ff" size="14"></u-icon>
<text class="positionfixedtext">修改时间</text>
</view>
</view>
<view :style="{height:height}"></view>
<u-calendar mode="single" @confirm="confirm" :show="calendarshow" @close="calendarshow = false"></u-calendar>
</view>
</template>
<script>
export default {
data() {
return {
height: '',
reservationshow: 0,
reservationlist: [],
calendarshow: false,
listday_time: [],
listday_xx: [],
listday_xxxxx: [],
day_time: '', //日期
day_hour: '', //小时
}
},
onLoad() {
// #ifdef MP-WEIXIN
wx.hideHomeButton()
// #endif
this.confirm() //初始时间
},
onShow() {},
mounted() {
var query = uni.createSelectorQuery().in(this).select('.positionfixed')
query.boundingClientRect(ele => {
var that = this;
uni.getSystemInfo({
success(res) {
that.height = ele.height + "px";
that = null;
}
})
}).exec();
},
methods: {
ange(w) {
if (w == 1) {
uni.reLaunch({
url: '/pages/stafflist/index'
})
} else {
uni.reLaunch({
url: '/pages/stafflist/time'
})
}
},
clicktime(d, p) {
this.listday_time[p].select = !d.select
let res = this.listday_time.filter((num, index) => {
return num.select !== false
})
this.listday_xx = [...this.listday_xxxxx, ...res]
},
reservation(a, b) {
this.reservationshow = b
this.day_time = a.date
this.staffbhoures() //获取预约时间
},
async staffsavestaffhours() { //提交
let hours_str = this.listday_xx.map(ele => {
return ele.time
});
let res = await this.api.staffsavestaffhours({
day_time: this.day_time,
hours_str: hours_str.toString()
})
if (res.code == 1) {
uni.showToast({
title: '修改成功',
icon: 'none'
});
}
},
async staffbhoures() {
let res = await this.api.staffbhoures({
day_time: this.day_time
})
this.listday_xxxxx = []
if (res.length != 0) {
this.listday_time = res.data.hours
let dataxx = res.data.hours.filter((num, index) => {
return num.select !== false
})
try {
if (res.data.xx.split(",").length > dataxx.length) {
this.listday_xxxxx = res.data.xx.split(",").slice(0, (res.data.xx.split(",").length -
dataxx
.length)).map(ele => {
return {
select: true,
time: ele
}
});
}
} catch (e) {
//TODO handle the exception
}
this.listday_xx = [...this.listday_xxxxx, ...dataxx]
} else {
this.listday_time = []
}
},
confirm(e) {
if (e) {
this.calendarshow = false
console.log(new Date(e[0]));
var now = new Date(e[0]);
} else {
//获取当前年月日
var now = new Date();
// var year = now.getFullYear(); //得到年份
// var month = now.getMonth() + 1; //得到月份
// var date = now.getDate(); //得到日期
// data = year + "年" + month + "月" + date + "日";
}
this.reservationlist = []
for (let i = 0; i < 7; i++) {
var date = new Date(now.getTime() + i * 24 * 3600 * 1000);
var year = date.getFullYear();
var month = (date.getMonth() + 1) > 9 ? (date.getMonth() + 1) : '0' + (date.getMonth() + 1);
var day = (date.getDate()) > 9 ? (date.getDate()) : '0' + (date.getDate());
var dt2 = new Date(now.getTime() + i * 24 * 3600 * 1000);
var weekDay = ["周日", "周一", "周二", "周三", "周四", "周五", "周六"];
// var weekDays = ["sun", "mon", "tue", "wed", "thu", "fri", "sat"];
this.reservationlist.push({
date: year + "-" + month + "-" + day,
// date: month + "-" + day,
// day: day,
// weekday: weekDays[dt2.getDay()],
week: weekDay[dt2.getDay()],
});
}
this.day_time = this.reservationlist[0].date
this.staffbhoures() //获取预约时间
}
}
}
</script>
<style lang="scss">
page {
background: #F6F6F6;
}
.content {
padding: 32rpx 28rpx 0 28rpx;
.contentbox {
width: 80%;
margin: 40rpx auto;
padding: 24rpx 0;
background: #2F87FD;
font-size: 36rpx;
font-family: PingFang SC-Bold, PingFang SC;
font-weight: bold;
color: #FFFFFF;
text-align: center;
border-radius: 48rpx;
}
.contentone {
background: #FFFFFF;
border-radius: 24rpx;
padding: 32rpx 28rpx;
.onecontenttowone {
.onecontenttowone_one {
font-family: Source Han Sans CN-Bold, Source Han Sans CN;
font-size: 28rpx;
font-weight: 500;
color: #333333;
}
}
.onecontenttowtow {
margin-top: 32rpx;
.onecontenttowtow_item {
flex: 1;
flex-wrap: nowrap;
.onecontenttowtow_item_one:nth-child(1) {
margin: 0 !important;
}
.onecontenttowtow_item_one {
padding: 6rpx;
.onecontenttowtow_item_one_textone {
font-size: 28rpx;
font-family: Source Han Sans CN-Medium, Source Han Sans CN;
font-weight: 500;
color: #333333;
}
.onecontenttowtow_item_one_texttow {
margin-top: 5rpx;
font-size: 24rpx;
font-family: Source Han Sans CN-Regular, Source Han Sans CN;
font-weight: 400;
color: #999999;
}
}
.onecontenttowtow_item_ones {
padding: 6rpx;
border-radius: 10rpx;
background: #2f87fd;
.onecontenttowtow_item_one_textone {
font-size: 28rpx;
font-family: Source Han Sans CN-Medium, Source Han Sans CN;
font-weight: 500;
color: #FFFFFF;
}
.onecontenttowtow_item_one_texttow {
margin-top: 5rpx;
font-size: 24rpx;
font-family: Source Han Sans CN-Regular, Source Han Sans CN;
font-weight: 400;
color: #FFFFFF;
}
}
}
.onecontenttowtow_left {
border-left: 1rpx solid #f9f9f9;
background: #FFFFFF;
padding-left: 24rpx;
box-shadow: -2rpx 0px 4rpx 2rpx rgba(193, 193, 193, 0.09);
.onecontenttowtow_lefttext {
font-size: 24rpx;
font-family: Source Han Sans CN-Regular, Source Han Sans CN;
font-weight: 400;
color: #999999;
}
}
}
.onecontenttowthere {
.onecontenttowthere_item {
width: 20%;
margin: 16rpx 2.5%;
text-align: center;
background: #F7F7F7;
border-radius: 8rpx;
border: 2rpx solid #F7F7F7;
padding: 8rpx 26rpx;
font-size: 28rpx;
font-family: Source Han Sans CN-Medium, Source Han Sans CN;
font-weight: 500;
color: #999999;
}
.onecontenttowthere_items {
width: 20%;
margin: 16rpx 2.5%;
background: #FFFFFF;
border: 2rpx solid #2F87FD;
text-align: center;
border-radius: 8rpx;
padding: 8rpx 26rpx;
font-size: 28rpx;
font-family: Source Han Sans CN-Medium, Source Han Sans CN;
font-weight: 500;
color: #2F87FD;
}
}
}
.contentitem {
width: 100%;
padding: 24rpx 32rpx;
background: #FFFFFF;
border-radius: 12rpx;
.onecontentitem {
height: 100%;
.onecontentitemone {
height: 100%;
justify-content: flex-start;
image {
width: 72rpx;
height: 72rpx;
}
}
.onecontentitemtow {
margin-left: 14rpx;
height: 100%;
.onecontentitemtowone {
.onecontentitemtowone_text {
font-size: 32rpx;
font-family: Source Han Sans CN-Regular, Source Han Sans CN;
font-weight: 400;
color: #333333;
}
.onecontentitemtowone_phone {
font-size: 28rpx;
font-family: Roboto-Regular, Roboto;
font-weight: 400;
color: #999999;
}
}
.onecontentitemtowtow {
font-size: 28rpx;
font-family: Source Han Sans CN-Regular, Source Han Sans CN;
font-weight: 400;
color: #999999;
}
.onecontentitemtowthere {
font-size: 28rpx;
font-family: Source Han Sans CN-Regular, Source Han Sans CN;
font-weight: 400;
color: #999999;
}
}
}
.onecontentitembox {
margin-top: 32rpx;
.onecontentitemboxone {
background: #2F87FD;
padding: 16rpx 58rpx;
border-radius: 8rpx;
font-size: 28rpx;
font-family: Source Han Sans CN-Medium, Source Han Sans CN;
font-weight: 500;
color: #FFFFFF;
}
.onecontentitemboxtow {
margin-left: 52rpx;
padding: 16rpx 58rpx;
border-radius: 8rpx;
border: 2rpx solid #2F87FD;
font-size: 28rpx;
font-family: Source Han Sans CN-Medium, Source Han Sans CN;
font-weight: 500;
color: #2F87FD;
}
}
}
.positionfixed {
position: fixed;
background: #FFFFFF;
width: 100%;
bottom: 0;
left: 0;
padding: 15rpx;
.positionfixeditems::after {
position: absolute;
content: '';
height: 50rpx;
left: 50%;
border-right: 1rpx solid #999;
}
.positionfixeditem {
padding: 20rpx 0;
text-align: center;
width: 50%;
font-size: 28rpx;
font-family: Source Han Sans CN-Regular, Source Han Sans CN;
font-weight: 400;
color: #333333;
.positionfixedtext {
margin-left: 10rpx;
}
}
}
}
</style>