diff --git a/components/calendar/components/month/index.js b/components/calendar/components/month/index.js index 439542a..8ec8d44 100644 --- a/components/calendar/components/month/index.js +++ b/components/calendar/components/month/index.js @@ -38,7 +38,10 @@ VantComponent({ type: null, observer: 'setDays', }, - allowSameDay: Boolean, + allowSameDay: { + type: Boolean, + observer: true, + }, showSubtitle: Boolean, showMonthTitle: Boolean, }, @@ -55,15 +58,11 @@ VantComponent({ } }, setDays() { - // console.log(this.data.index) const days = []; const startDate = new Date(this.data.date); const year = startDate.getFullYear(); const month = startDate.getMonth(); - const totalDay = getMonthEndDay( - startDate.getFullYear(), - startDate.getMonth() + 1 - ); + const totalDay = getMonthEndDay(startDate.getFullYear(), startDate.getMonth() + 1); for (let day = 1; day <= totalDay; day++) { const date = new Date(year, month, day); const type = this.getDayType(date); diff --git a/components/calendar/components/month/index.wxss b/components/calendar/components/month/index.wxss index 725e737..380019c 100644 --- a/components/calendar/components/month/index.wxss +++ b/components/calendar/components/month/index.wxss @@ -1 +1 @@ -@import '../../../common/index.wxss';.van-calendar{display:-webkit-flex;display:flex;-webkit-flex-direction:column;flex-direction:column;height:100%;background-color:#fff;background-color:var(--calendar-background-color,#fff)}.van-calendar__month-title{text-align:center;height:44px;height:var(--calendar-header-title-height,44px);font-weight:500;font-weight:var(--font-weight-bold,500);font-size:14px;font-size:var(--calendar-month-title-font-size,14px);line-height:44px;line-height:var(--calendar-header-title-height,44px)}.van-calendar__days{position:relative;display:-webkit-flex;display:flex;-webkit-flex-wrap:wrap;flex-wrap:wrap;-webkit-user-select:none;user-select:none}.van-calendar__month-mark{position:absolute;top:50%;left:50%;z-index:0;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%);pointer-events:none;color:rgba(242,243,245,.8);color:var(--calendar-month-mark-color,rgba(242,243,245,.8));font-size:160px;font-size:var(--calendar-month-mark-font-size,160px)}.van-calendar__day,.van-calendar__selected-day{display:-webkit-flex;display:flex;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center;text-align:center}.van-calendar__day{position:relative;width:14.285%;height:64px;height:var(--calendar-day-height,64px);font-size:16px;font-size:var(--calendar-day-font-size,16px)}.van-calendar__day--end,.van-calendar__day--multiple-middle,.van-calendar__day--multiple-selected,.van-calendar__day--start,.van-calendar__day--start-end{color:#fff;color:var(--calendar-range-edge-color,#fff);background-color:#ee0a24;background-color:var(--calendar-range-edge-background-color,#ee0a24)}.van-calendar__day--start{border-radius:4px 0 0 4px;border-radius:var(--border-radius-md,4px) 0 0 var(--border-radius-md,4px)}.van-calendar__day--end{border-radius:0 4px 4px 0;border-radius:0 var(--border-radius-md,4px) var(--border-radius-md,4px) 0}.van-calendar__day--multiple-selected,.van-calendar__day--start-end{border-radius:4px;border-radius:var(--border-radius-md,4px)}.van-calendar__day--middle{color:#ee0a24;color:var(--calendar-range-middle-color,#ee0a24)}.van-calendar__day--middle:after{position:absolute;top:0;right:0;bottom:0;left:0;background-color:currentColor;content:"";opacity:.1;opacity:var(--calendar-range-middle-background-opacity,.1)}.van-calendar__day--disabled{cursor:default;color:#c8c9cc;color:var(--calendar-day-disabled-color,#c8c9cc)}.van-calendar__bottom-info,.van-calendar__top-info{position:absolute;right:0;left:0;font-size:10px;font-size:var(--calendar-info-font-size,10px);line-height:14px;line-height:var(--calendar-info-line-height,14px)}@media (max-width:350px){.van-calendar__bottom-info,.van-calendar__top-info{font-size:9px}}.van-calendar__top-info{top:6px}.van-calendar__bottom-info{bottom:4px}.van-calendar__selected-day{width:54px;width:var(--calendar-selected-day-size,54px);height:54px;height:var(--calendar-selected-day-size,54px);color:#fff;color:var(--calendar-selected-day-color,#fff);background-color:#ee0a24;background-color:var(--calendar-selected-day-background-color,#ee0a24);border-radius:4px;border-radius:var(--border-radius-md,4px)} \ No newline at end of file +@import '../../../common/index.wxss';.van-calendar{display:-webkit-flex;display:flex;-webkit-flex-direction:column;flex-direction:column;height:100%;background-color:#fff;background-color:var(--calendar-background-color,#fff)}.van-calendar__month-title{text-align:center;height:44px;height:var(--calendar-header-title-height,44px);font-weight:500;font-weight:var(--font-weight-bold,500);font-size:14px;font-size:var(--calendar-month-title-font-size,14px);line-height:44px;line-height:var(--calendar-header-title-height,44px)}.van-calendar__days{position:relative;display:-webkit-flex;display:flex;-webkit-flex-wrap:wrap;flex-wrap:wrap;-webkit-user-select:none;user-select:none}.van-calendar__month-mark{position:absolute;top:50%;left:50%;z-index:0;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%);pointer-events:none;color:rgba(242,243,245,.8);color:var(--calendar-month-mark-color,rgba(242,243,245,.8));font-size:160px;font-size:var(--calendar-month-mark-font-size,160px)}.van-calendar__day,.van-calendar__selected-day{display:-webkit-flex;display:flex;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center;text-align:center}.van-calendar__day{position:relative;width:14.285%;height:64px;height:var(--calendar-day-height,64px);font-size:16px;font-size:var(--calendar-day-font-size,16px)}.van-calendar__day--end,.van-calendar__day--multiple-middle,.van-calendar__day--multiple-selected,.van-calendar__day--start,.van-calendar__day--start-end{color:#fff;color:var(--calendar-range-edge-color,#fff);background-color:#008AFF;background-color:var(--calendar-range-edge-background-color,#008AFF)}.van-calendar__day--start{border-radius:4px 0 0 4px;border-radius:var(--border-radius-md,4px) 0 0 var(--border-radius-md,4px)}.van-calendar__day--end{border-radius:0 4px 4px 0;border-radius:0 var(--border-radius-md,4px) var(--border-radius-md,4px) 0}.van-calendar__day--multiple-selected,.van-calendar__day--start-end{border-radius:4px;border-radius:var(--border-radius-md,4px)}.van-calendar__day--middle{color:#008AFF;color:var(--calendar-range-middle-color,#008AFF)}.van-calendar__day--middle:after{position:absolute;top:0;right:0;bottom:0;left:0;background-color:currentColor;content:"";opacity:.1;opacity:var(--calendar-range-middle-background-opacity,.1)}.van-calendar__day--disabled{cursor:default;color:#c8c9cc;color:var(--calendar-day-disabled-color,#c8c9cc)}.van-calendar__bottom-info,.van-calendar__top-info{position:absolute;right:0;left:0;font-size:10px;font-size:var(--calendar-info-font-size,10px);line-height:14px;line-height:var(--calendar-info-line-height,14px)}@media (max-width:350px){.van-calendar__bottom-info,.van-calendar__top-info{font-size:9px}}.van-calendar__top-info{top:6px}.van-calendar__bottom-info{bottom:4px}.van-calendar__selected-day{width:54px;width:var(--calendar-selected-day-size,54px);height:54px;height:var(--calendar-selected-day-size,54px);color:#fff;color:var(--calendar-selected-day-color,#fff);background-color:#ee0a24;background-color:var(--calendar-selected-day-background-color,#ee0a24);border-radius:4px;border-radius:var(--border-radius-md,4px)} \ No newline at end of file diff --git a/components/calendar/index.js b/components/calendar/index.js index 8da8b0f..93f175a 100644 --- a/components/calendar/index.js +++ b/components/calendar/index.js @@ -40,7 +40,10 @@ VantComponent({ this.scrollIntoView(); }, }, - allowSameDay: Boolean, + allowSameDay: { + type: Boolean, + value: true, + }, confirmDisabledText: String, type: { type: String, @@ -202,7 +205,7 @@ VantComponent({ } else if (compareToStart === -1) { this.select([date, null]); } else if (allowSameDay) { - this.select([date, date]); + this.select([date, date], true); } } else { this.select([date, null]); @@ -242,10 +245,7 @@ VantComponent({ if (!valid) { // auto selected to max range if showConfirm if (this.data.showConfirm) { - this.emit([ - date[0], - getDayByOffset(date[0], this.data.maxRange - 1), - ]); + this.emit([ date[0], getDayByOffset(date[0], this.data.maxRange - 1) ]); } else { this.emit(date); } diff --git a/xtends/statics/agent-report/index.js b/xtends/statics/agent-report/index.js index 2f369c4..ed7a976 100644 --- a/xtends/statics/agent-report/index.js +++ b/xtends/statics/agent-report/index.js @@ -34,15 +34,13 @@ Scene({ min.setFullYear(min.getFullYear() - 1, min.getMonth(), min.getDate()) min.setHours(0, 0, 0) var minDate = min.getTime() - var max = new Date(new Date().getTime() + 24 * 60 * 60 * 1000) - max.setHours(0, 0, 0) - var maxDate = max.getTime() var today = new Date() today.setHours(0, 0, 0) - var vdate = [today.getTime(), maxDate] - var vdateString = util.formatDate(today, 'Y-M-D') + '至' + util.formatDate(max, 'Y-M-D') + var maxDate = today.getTime() + var vdate = [today.getTime(), today.getTime()] + var vdateString = util.formatDate(today, 'Y-M-D') this.data.form.dimensionDateStart = util.formatDate(today, 'Y-M-D') - this.data.form.dimensionDateEnd = util.formatDate(max, 'Y-M-D') + this.data.form.dimensionDateEnd = util.formatDate(today, 'Y-M-D') this.setData({ height: app.globalData.fragmentHeight - 404, minDate, maxDate, vdate, vdateString }) this.fetchStatisticsInfo() }, @@ -55,7 +53,12 @@ Scene({ onSelect: function({detail}) { var start = new Date(detail[0]) var end = new Date(detail[1]) - var vdateString = util.formatDate(start, 'Y-M-D') + '至' + util.formatDate(end, 'Y-M-D') + var vdateString = '' + if(start.getTime() == end.getTime()){ + vdateString = util.formatDate(start, 'Y-M-D') + } else { + vdateString = util.formatDate(start, 'Y-M-D') + '至' + util.formatDate(end, 'Y-M-D') + } this.data.form.dimensionDateStart = util.formatDate(start, 'Y-M-D') this.data.form.dimensionDateEnd = util.formatDate(end, 'Y-M-D') this.setData({ show: false, vdateString }) diff --git a/xtends/statics/gross-report/index.js b/xtends/statics/gross-report/index.js index dd0cab9..ebf3638 100644 --- a/xtends/statics/gross-report/index.js +++ b/xtends/statics/gross-report/index.js @@ -34,15 +34,13 @@ Scene({ min.setFullYear(min.getFullYear() - 1, min.getMonth(), min.getDate()) min.setHours(0, 0, 0) var minDate = min.getTime() - var max = new Date(new Date().getTime() + 24 * 60 * 60 * 1000) - max.setHours(0, 0, 0) - var maxDate = max.getTime() var today = new Date() today.setHours(0, 0, 0) - var vdate = [today.getTime(), maxDate] - var vdateString = util.formatDate(today, 'Y-M-D') + '至' + util.formatDate(max, 'Y-M-D') + var maxDate = today.getTime() + var vdate = [today.getTime(), today.getTime()] + var vdateString = util.formatDate(today, 'Y-M-D') this.data.form.dimensionDateStart = util.formatDate(today, 'Y-M-D') - this.data.form.dimensionDateEnd = util.formatDate(max, 'Y-M-D') + this.data.form.dimensionDateEnd = util.formatDate(today, 'Y-M-D') this.setData({ height: app.globalData.fragmentHeight - 404, minDate, maxDate, vdate, vdateString }) this.fetchStatisticsInfo() }, @@ -55,7 +53,12 @@ Scene({ onSelect: function({detail}) { var start = new Date(detail[0]) var end = new Date(detail[1]) - var vdateString = util.formatDate(start, 'Y-M-D') + '至' + util.formatDate(end, 'Y-M-D') + var vdateString = '' + if(start.getTime() == end.getTime()){ + vdateString = util.formatDate(start, 'Y-M-D') + } else { + vdateString = util.formatDate(start, 'Y-M-D') + '至' + util.formatDate(end, 'Y-M-D') + } this.data.form.dimensionDateStart = util.formatDate(start, 'Y-M-D') this.data.form.dimensionDateEnd = util.formatDate(end, 'Y-M-D') this.setData({ show: false, vdateString }) diff --git a/xtends/statics/index/index.js b/xtends/statics/index/index.js index 2ce3ceb..acddc01 100644 --- a/xtends/statics/index/index.js +++ b/xtends/statics/index/index.js @@ -50,18 +50,15 @@ Scene({ min.setFullYear(min.getFullYear() - 1, min.getMonth(), min.getDate()) min.setHours(0, 0, 0) var minDate = min.getTime() - var max = new Date(new Date().getTime() + 24 * 60 * 60 * 1000) - max.setHours(0, 0, 0) - var maxDate = max.getTime() var today = new Date() today.setHours(0, 0, 0) - var vdate = [today.getTime(), maxDate] - var vdateString = util.formatDate(new Date(), 'Y-M-D') + '至' + util.formatDate(max, 'Y-M-D') + var vdate = [today.getTime(), today.getTime()] + var vdateString = util.formatDate(new Date(), 'Y-M-D') this.data.form1.dimensionDateStart = util.formatDate(today, 'Y-M-D') - this.data.form1.dimensionDateEnd = util.formatDate(max, 'Y-M-D') + this.data.form1.dimensionDateEnd = util.formatDate(today, 'Y-M-D') this.data.form2.dimensionDateStart = util.formatDate(today, 'Y-M-D') - this.data.form2.dimensionDateEnd = util.formatDate(max, 'Y-M-D') - this.setData({ minDate, maxDate, vdate, vdateString1: vdateString, vdateString2: vdateString }) + this.data.form2.dimensionDateEnd = util.formatDate(today, 'Y-M-D') + this.setData({ minDate, maxDate: today.getTime(), vdate, vdateString1: vdateString, vdateString2: vdateString }) this.fetchSummaryInfo(false) this.fetchStatisticsInfo(true) }, @@ -86,21 +83,28 @@ Scene({ onClose: function() { this.setData({ show: false }) }, + getDateString: function(start, end){ + var vdateString1 = '' + if(start.getTime() == end.getTime()){ + vdateString1 = util.formatDate(start, 'Y-M-D') + } else { + vdateString1 = util.formatDate(start, 'Y-M-D') + '至' + util.formatDate(end, 'Y-M-D') + } + return vdateString1 + }, onSelect: function({detail}) { var start = new Date(detail[0]) var end = new Date(detail[1]) wx.showLoading({ title: '加载中', mask: true }) if(this.data.selectId == 'form1') { - var vdateString1 = util.formatDate(start, 'Y-M-D') + '至' + util.formatDate(end, 'Y-M-D') this.data.form1.dimensionDateStart = util.formatDate(start, 'Y-M-D') this.data.form1.dimensionDateEnd = util.formatDate(end, 'Y-M-D') - this.setData({ show: false, vdateString1 }) + this.setData({ show: false, vdateString1: this.getDateString(start, end) }) this.fetchSummaryInfo(true) } else { - var vdateString2 = util.formatDate(start, 'Y-M-D') + '至' + util.formatDate(end, 'Y-M-D') this.data.form2.dimensionDateStart = util.formatDate(start, 'Y-M-D') this.data.form2.dimensionDateEnd = util.formatDate(end, 'Y-M-D') - this.setData({ show: false, vdateString2 }) + this.setData({ show: false, vdateString2: this.getDateString(start, end) }) this.fetchStatisticsInfo(true) } }, diff --git a/xtends/statics/index/index.wxml b/xtends/statics/index/index.wxml index 3d7da3e..f83fef5 100644 --- a/xtends/statics/index/index.wxml +++ b/xtends/statics/index/index.wxml @@ -123,6 +123,5 @@ - - + diff --git a/xtends/statics/purchase-report/index.js b/xtends/statics/purchase-report/index.js index 8ead22e..562f67c 100644 --- a/xtends/statics/purchase-report/index.js +++ b/xtends/statics/purchase-report/index.js @@ -33,15 +33,13 @@ Scene({ min.setFullYear(min.getFullYear() - 1, min.getMonth(), min.getDate()) min.setHours(0, 0, 0) var minDate = min.getTime() - var max = new Date(new Date().getTime() + 24 * 60 * 60 * 1000) - max.setHours(0, 0, 0) - var maxDate = max.getTime() var today = new Date() today.setHours(0, 0, 0) - var vdate = [today.getTime(), maxDate] - var vdateString = util.formatDate(today, 'Y-M-D') + '至' + util.formatDate(max, 'Y-M-D') + var maxDate = today.getTime() + var vdate = [today.getTime(), today.getTime()] + var vdateString = util.formatDate(today, 'Y-M-D') this.data.form.dimensionDateStart = util.formatDate(today, 'Y-M-D') - this.data.form.dimensionDateEnd = util.formatDate(max, 'Y-M-D') + this.data.form.dimensionDateEnd = util.formatDate(today, 'Y-M-D') this.setData({ height: app.globalData.fragmentHeight - 304, minDate, maxDate, vdate, vdateString }) this.fetchStatisticsInfo() }, @@ -55,7 +53,12 @@ Scene({ wx.showLoading({ title: '加载中', mask: true }) var start = new Date(detail[0]) var end = new Date(detail[1]) - var vdateString = util.formatDate(start, 'Y-M-D') + '至' + util.formatDate(end, 'Y-M-D') + var vdateString = '' + if(start.getTime() == end.getTime()){ + vdateString = util.formatDate(start, 'Y-M-D') + } else { + vdateString = util.formatDate(start, 'Y-M-D') + '至' + util.formatDate(end, 'Y-M-D') + } this.data.form.dimensionDateStart = util.formatDate(start, 'Y-M-D') this.data.form.dimensionDateEnd = util.formatDate(end, 'Y-M-D') this.setData({ show: false, vdateString }) diff --git a/xtends/statics/purchase-report/index.wxml b/xtends/statics/purchase-report/index.wxml index ddb53f6..4eaa5e4 100644 --- a/xtends/statics/purchase-report/index.wxml +++ b/xtends/statics/purchase-report/index.wxml @@ -7,7 +7,7 @@ - 出货信息 + 收货信息 {{vdateString}} diff --git a/xtends/statics/sale-report/index.js b/xtends/statics/sale-report/index.js index 304c786..5dd6e77 100644 --- a/xtends/statics/sale-report/index.js +++ b/xtends/statics/sale-report/index.js @@ -50,15 +50,13 @@ Scene({ min.setFullYear(min.getFullYear() - 1, min.getMonth(), min.getDate()) min.setHours(0, 0, 0) var minDate = min.getTime() - var max = new Date(new Date().getTime() + 24 * 60 * 60 * 1000) - max.setHours(0, 0, 0) - var maxDate = max.getTime() var today = new Date() today.setHours(0, 0, 0) - var vdate = [today.getTime(), maxDate] - var vdateString = util.formatDate(today, 'Y-M-D') + '至' + util.formatDate(max, 'Y-M-D') + var maxDate = today.getTime() + var vdate = [today.getTime(), today.getTime()] + var vdateString = util.formatDate(today, 'Y-M-D') this.data.form.dimensionDateStart = util.formatDate(today, 'Y-M-D') - this.data.form.dimensionDateEnd = util.formatDate(max, 'Y-M-D') + this.data.form.dimensionDateEnd = util.formatDate(today, 'Y-M-D') this.setData({ height: app.globalData.fragmentHeight - 494, minDate, maxDate, vdate, vdateString }) this.fetchStatisticsInfo() }, @@ -78,7 +76,12 @@ Scene({ onSelect: function({detail}) { var start = new Date(detail[0]) var end = new Date(detail[1]) - var vdateString = util.formatDate(start, 'Y-M-D') + '至' + util.formatDate(end, 'Y-M-D') + var vdateString = '' + if(start.getTime() == end.getTime()){ + vdateString = util.formatDate(start, 'Y-M-D') + } else { + vdateString = util.formatDate(start, 'Y-M-D') + '至' + util.formatDate(end, 'Y-M-D') + } this.data.form.dimensionDateStart = util.formatDate(start, 'Y-M-D') this.data.form.dimensionDateEnd = util.formatDate(end, 'Y-M-D') this.setData({ show: false, vdateString })