56e5085f by zhangmeng

日期限制

1 parent 8db6cba7
...@@ -69,6 +69,7 @@ ...@@ -69,6 +69,7 @@
69 :disabled-date="disabledDateRZ" 69 :disabled-date="disabledDateRZ"
70 :placeholder="language==0?'选择日期':'Select date'" 70 :placeholder="language==0?'选择日期':'Select date'"
71 format="YYYY-MM-DD" 71 format="YYYY-MM-DD"
72 :clearable="false"
72 value-format="YYYY-MM-DD"/> 73 value-format="YYYY-MM-DD"/>
73 </span> 74 </span>
74 </li> 75 </li>
...@@ -161,21 +162,25 @@ onMounted(() => { ...@@ -161,21 +162,25 @@ onMounted(() => {
161 formTime.value = null 162 formTime.value = null
162 }).finally(()=>{ 163 }).finally(()=>{
163 console.log(formTime.value) 164 console.log(formTime.value)
164 if (formTime.value){ 165 getDateTime()
165 if (dayjs().isBefore(dayjs(formTime.value.hqStart))){
166 hotTime.value[0]=dayjs(formTime.value.hqStart).format('YYYY-MM-DD')
167 hotTime.value[1]=dayjs(formTime.value.hqEnd).add(1,'day').format('YYYY-MM-DD')
168 } else{
169 hotTime.value[0]=dayjs().format('YYYY-MM-DD')
170 hotTime.value[1]=dayjs().add(1,'day').format('YYYY-MM-DD')
171 }
172 }
173 166
174 getData() 167 getData()
175 }) 168 })
176 169
177 }) 170 })
178 171
172 function getDateTime(){
173 if (formTime.value){
174 if (dayjs().isBefore(dayjs(formTime.value.hqStart))){
175 hotTime.value[0]=dayjs(formTime.value.hqStart).format('YYYY-MM-DD')
176 hotTime.value[1]=dayjs(formTime.value.hqStart).add(1,'day').format('YYYY-MM-DD')
177 } else{
178 hotTime.value[0]=dayjs().format('YYYY-MM-DD')
179 hotTime.value[1]=dayjs().add(1,'day').format('YYYY-MM-DD')
180 }
181 }
182 }
183
179 function getData() { 184 function getData() {
180 loading.value = true 185 loading.value = true
181 getHotelById(route.params.hotelId).then(res => { 186 getHotelById(route.params.hotelId).then(res => {
...@@ -278,13 +283,12 @@ function goNext(room) { ...@@ -278,13 +283,12 @@ function goNext(room) {
278 }) 283 })
279 } 284 }
280 285
281 function getDaysBetween(e){ 286 function getDaysBetween(){
282 console.log(hotTime.value)
283 if (hotTime.value && hotTime.value.length==2){ 287 if (hotTime.value && hotTime.value.length==2){
284 const d1=dayjs(hotTime.value[0]).format('YYYY-MM-DD') 288 const d1=dayjs(hotTime.value[0]).format('YYYY-MM-DD')
285 const d2=dayjs(hotTime.value[1]).format('YYYY-MM-DD') 289 const d2=dayjs(hotTime.value[1]).format('YYYY-MM-DD')
286 if (d1==d2){ 290 if (d1==d2){
287 hotTime.value=[] 291 getDateTime()
288 return proxy.$modal.msgError(language.value==0?'入住时间跨度需要大于一天':'The duration of the stay must be more than one day.') 292 return proxy.$modal.msgError(language.value==0?'入住时间跨度需要大于一天':'The duration of the stay must be more than one day.')
289 }else{ 293 }else{
290 getData() 294 getData()
...@@ -292,19 +296,19 @@ function getDaysBetween(e){ ...@@ -292,19 +296,19 @@ function getDaysBetween(e){
292 } 296 }
293 } 297 }
294 298
295 // function disabledDateRZ(date) { 299 function disabledDateRZ(date) {
296 // //判读今天大与form.value.hqStart 300 //判读今天大与form.value.hqStart
297 // console.log(date) 301 console.log(date)
298 // if (formTime.value.hqStart) { 302 if (formTime.value.hqStart) {
299 // const today = dayjs().format('YYYY-MM-DD') 303 const today = dayjs().format('YYYY-MM-DD')
300 // if (formTime.value.hqStart < today) { 304 if (formTime.value.hqStart < today) {
301 // return !((date.getTime() >= dayjs(today).valueOf())&&(date.getTime() <= dayjs(formTime.value.hqEnd).valueOf())) 305 return !((date.getTime() >= dayjs(today).valueOf())&&(date.getTime() <= dayjs(formTime.value.hqEnd).valueOf()))
302 // } else { 306 } else {
303 // return !((date.getTime() >= dayjs(formTime.value.hqStart).valueOf())&&(date.getTime() <= dayjs(formTime.value.hqEnd).valueOf())) 307 return !((date.getTime() >= dayjs(formTime.value.hqStart).valueOf())&&(date.getTime() <= dayjs(formTime.value.hqEnd).valueOf()))
304 // } 308 }
305 // } 309 }
306 // // return true 310 // return true
307 // } 311 }
308 312
309 function goMap() { 313 function goMap() {
310 return 314 return
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!