|
@@ -30,15 +30,15 @@
|
|
|
<view class="card">
|
|
<view class="card">
|
|
|
<view class="date-name">预约时间</view>
|
|
<view class="date-name">预约时间</view>
|
|
|
<view class="date-box">
|
|
<view class="date-box">
|
|
|
- <c-datepicker v-model="form.day" @change="bindDateChange"></c-datepicker>
|
|
|
|
|
|
|
+ <c-datepicker v-model="form.day" @change="bindDateChange" :beginDate="form.beginDate"></c-datepicker>
|
|
|
<view class="date-divide"></view>
|
|
<view class="date-divide"></view>
|
|
|
<view class="date-time-wrap">
|
|
<view class="date-time-wrap">
|
|
|
<view class="label">可选时间段</view>
|
|
<view class="label">可选时间段</view>
|
|
|
<view class="time-range" v-if="times.length > 0">
|
|
<view class="time-range" v-if="times.length > 0">
|
|
|
- <swiper class="picker-view" vertical :autoplay="false" :display-multiple-items="8">
|
|
|
|
|
|
|
+ <swiper class="picker-view" vertical :autoplay="false" :display-multiple-items="9">
|
|
|
<swiper-item v-for="(item, index) in times" :key="item.id">
|
|
<swiper-item v-for="(item, index) in times" :key="item.id">
|
|
|
<view class="picker-item" :hover-stay-time="100" hover-class="hover-active" :class="{active: index == current}" @click="pickeClick(item, index)">
|
|
<view class="picker-item" :hover-stay-time="100" hover-class="hover-active" :class="{active: index == current}" @click="pickeClick(item, index)">
|
|
|
- <view class="value">{{item.text}}</view>
|
|
|
|
|
|
|
+ <view class="value" :class="{not : !item.isCheck}">{{item.text}}</view>
|
|
|
<view class="tig" v-if="item.num">{{item.num}}/{{item.max}}</view>
|
|
<view class="tig" v-if="item.num">{{item.num}}/{{item.max}}</view>
|
|
|
<view class="stauts-wrap">
|
|
<view class="stauts-wrap">
|
|
|
<view class="mark" v-if="index == current">
|
|
<view class="mark" v-if="index == current">
|
|
@@ -81,34 +81,58 @@
|
|
|
blessingPositionId: '',
|
|
blessingPositionId: '',
|
|
|
blessingPositionName: '',
|
|
blessingPositionName: '',
|
|
|
num: '',
|
|
num: '',
|
|
|
|
|
+ beginDate: dayjs().format('YYYY-MM-DD'),
|
|
|
visitDate: dayjs().format('YYYY-MM-DD'),
|
|
visitDate: dayjs().format('YYYY-MM-DD'),
|
|
|
visitTime: ''
|
|
visitTime: ''
|
|
|
},
|
|
},
|
|
|
- current: 0,
|
|
|
|
|
|
|
+ current: null,
|
|
|
times: []
|
|
times: []
|
|
|
};
|
|
};
|
|
|
},
|
|
},
|
|
|
mounted() {
|
|
mounted() {
|
|
|
- this.initTimes()
|
|
|
|
|
|
|
+ this.initTimes(this.form.visitDate)
|
|
|
},
|
|
},
|
|
|
methods: {
|
|
methods: {
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 比较时间大小 时间
|
|
|
|
|
+ * @param {dayjs} time1
|
|
|
|
|
+ * @param {dayjs} time2
|
|
|
|
|
+ */
|
|
|
|
|
+ isLittleTime(time1, time2){
|
|
|
|
|
+ const diff = time1.diff(time2,'minutes' )
|
|
|
|
|
+ if(diff >= 0){
|
|
|
|
|
+ return false
|
|
|
|
|
+ }else{
|
|
|
|
|
+ return true
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
async initTimes(date = '') {
|
|
async initTimes(date = '') {
|
|
|
try{
|
|
try{
|
|
|
const res = await this.$api('signs.getOpenidVisitDateTime', {visitDate: date})
|
|
const res = await this.$api('signs.getOpenidVisitDateTime', {visitDate: date})
|
|
|
const timeStr = dayjs().unix()
|
|
const timeStr = dayjs().unix()
|
|
|
- this.current = 0;
|
|
|
|
|
|
|
+ this.current = null;
|
|
|
let isfuzhi = false
|
|
let isfuzhi = false
|
|
|
|
|
+
|
|
|
|
|
+ const time1 = dayjs()
|
|
|
|
|
+ const time2YMD = dayjs(date)
|
|
|
const times = res.data.map((item, index) => {
|
|
const times = res.data.map((item, index) => {
|
|
|
|
|
+ let isCheck = false // 点击
|
|
|
|
|
+ const _time2 = dayjs().year(time2YMD.year()).month(time2YMD.month()).day(time2YMD.day()).hour(item.visitTime.split(':')[0]).minute(item.visitTime.split(':')[1]).second(0);
|
|
|
// 自动选中未录满
|
|
// 自动选中未录满
|
|
|
- if(item.max > item.num && !isfuzhi) {
|
|
|
|
|
- isfuzhi = true;
|
|
|
|
|
- this.current = index
|
|
|
|
|
- this.form.visitTime = item.visitTime;
|
|
|
|
|
|
|
+ if(this.isLittleTime(time1 , _time2) && item.max > item.num) {
|
|
|
|
|
+ // 可以点击
|
|
|
|
|
+ isCheck = true
|
|
|
|
|
+ if(!isfuzhi){
|
|
|
|
|
+ isfuzhi = true;
|
|
|
|
|
+ this.current = index
|
|
|
|
|
+ this.form.visitTime = item.visitTime;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
// 获取item
|
|
// 获取item
|
|
|
- return { id: timeStr + '' + index, text: item.visitTime, visitTime: item.visitTime, max: item.max, num: item.num}
|
|
|
|
|
|
|
+ return { id: timeStr + '' + index, text: item.visitTime, visitTime: item.visitTime, max: item.max, num: item.num, isCheck: isCheck}
|
|
|
})
|
|
})
|
|
|
this.times = times
|
|
this.times = times
|
|
|
|
|
+ console.log(times, '---------')
|
|
|
}catch(e){
|
|
}catch(e){
|
|
|
//TODO handle the exception
|
|
//TODO handle the exception
|
|
|
}
|
|
}
|
|
@@ -137,6 +161,10 @@
|
|
|
this.initTimes(dateString)
|
|
this.initTimes(dateString)
|
|
|
},
|
|
},
|
|
|
pickeClick(item, index){
|
|
pickeClick(item, index){
|
|
|
|
|
+ if(!item.isCheck) {
|
|
|
|
|
+ this.$refs.uToast.show({type: 'error', message: '不能选择', position: 'top'})
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
if(item.num >= item.max) {
|
|
if(item.num >= item.max) {
|
|
|
this.$refs.uToast.show({type: 'error', message: '时段已经约满', position: 'top'})
|
|
this.$refs.uToast.show({type: 'error', message: '时段已经约满', position: 'top'})
|
|
|
return
|
|
return
|
|
@@ -156,6 +184,12 @@
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ if(!this.current && this.current != 0){
|
|
|
|
|
+ this.$refs.uToast.show({type: 'error', message: '请选择随访时间', position: 'top'})
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
this.$refs.uToast.show({
|
|
this.$refs.uToast.show({
|
|
|
type: 'loading',
|
|
type: 'loading',
|
|
|
message: '请稍后',
|
|
message: '请稍后',
|