今日和本月改为昨日,默认昨日

This commit is contained in:
liyuetong
2021-09-17 15:44:15 +08:00
parent a024d38d47
commit 0d7b45b5e6
3 changed files with 107 additions and 61 deletions

View File

@@ -13,5 +13,42 @@ export default {
//获取“多少天数”之前的时间 例如28天前 即days=28
let currentTime = new Date().getTime()
return new Date(currentTime - 1000 * 60 * 60 * 24 * days)
},
/**
* 获取上个月
*/
getLastMonth:function(){
var nowDate = new Date();
var year = nowDate.getFullYear();
var month = nowDate.getMonth();
if(month == 0){
month = 12;
year = year - 1;
}
if (month <= 9) {
month = '0' + month
}
var yyyyMM = year+"-"+month;
console.log(yyyyMM);
return yyyyMM
},
/**
* 获取上个月月底日期
*/
getLastMonthAndDay:function(){
var nowDate = new Date();
var year = nowDate.getFullYear();
var month = nowDate.getMonth();
if(month == 0){
month = 12;
year = year - 1;
}
if (month <= 9) {
month = '0' + month
}
var lastDay = new Date(year,month,0);
var yyyyMMdd = year+"-"+month+"-"+lastDay.getDate();
console.log(yyyyMMdd);
return yyyyMMdd
}
}

View File

@@ -4,7 +4,7 @@
<div class='pt10 pb10' style='background-color: #f5f5f5'>
<div class='m-filterDate'>
<div class='number'>
<span :class="[currentIndex? 'checked' : 'unChecked']" @click='selectThisMonth(currentIndex)'>本月</span>
<!-- <span :class="[currentIndex? 'checked' : 'unChecked']" @click='selectThisMonth(currentIndex)'>本月</span> -->
</div>
<div class='filterTime'>
<FieldDatePicter
@@ -45,6 +45,7 @@ import { uploadImg } from '@/api/ebiz/sale/sale'
import backgroundImg from '../../../assets/images/laurelClub/posters-background-img.png'
import crownImg from '@/assets/images/laurelClub/crown.png'
import nameCardImg from '../../../assets/images/laurelClub/posters-name-card-img.png'
import beforeDate from '@/assets/js/utils/getBeforeDate.js'
export default {
name: 'exclusivePosters',
@@ -55,7 +56,7 @@ export default {
// 选择时间模块使用到的数据对象
datePickerObj: {
filterDate: '', // 当前的时间(年月)
maxDate: new Date(), // 可以选择的最大时间
maxDate: new Date(beforeDate.getLastMonth()), // 可以选择的最大时间
minDate: new Date('2019-10') // 可以选择的最小时间
},
// 海报canvas绘图工具中使用到的数据对象
@@ -76,7 +77,7 @@ export default {
},
mounted() {
//默认展示当月数据
this.datePickerObj.filterDate = this.getCurrentDateFunc()
this.datePickerObj.filterDate = beforeDate.getLastMonth()
// this.canvasHeight = this.$refs.element.offsetHeight
// 调用获取当前海报数据的方法
this.queryPosterDataFunc()

View File

@@ -3,8 +3,8 @@
<div class="pt10 pb10 bgf5" style="background-color: #f5f5f5">
<div class="m-filterDate">
<div class="number">
<span :class="[currentIndex == '0' ? 'checkedLeft' : 'unCheckedLeft']" @click="switchDayOrMonth(1)"></span>
<span :class="[currentIndex == '1' ? 'checkedRight' : 'unCheckedRight']" @click="switchDayOrMonth(0)">本月</span>
<span :class="[currentIndex == '0' ? 'checkedLeft' : 'unCheckedLeft']" @click="switchDayOrMonth(1)"></span>
<!-- <span :class="[currentIndex == '1' ? 'checkedRight' : 'unCheckedRight']" @click="switchDayOrMonth(0)">本月</span> -->
</div>
<div class="filterTime">
<FieldDatePicter
@@ -128,6 +128,7 @@ import FieldDatePicter from '@/components/ebiz/FieldDatePicter'
import { getBranchByUser } from '@/api/ebiz/billingDetail/billingDetail'
import { queryPersonal, queryTeamList } from '@/api/ebiz/laurelClub/laurelClub'
import crownImg from '@/assets/images/laurelClub/crown.png'
import beforeDate from '@/assets/js/utils/getBeforeDate.js'
// 当前时间
const currentDate = new Date()
@@ -183,7 +184,7 @@ export default {
currentIndex: '0', //0 当月 1当天
theads: ['姓名', '预收佣金(元)', '承保佣金(元)', '桂冠差距(元)', '上月桂冠冠级', '双冠差距(元)', '上月双冠冠级'],
tableData: [],
maxDate: new Date(),
maxDate: new Date(beforeDate.getLastMonth()),
minDate: new Date('2019-10'),
filterDate: '',
postDate: '', //实际给后台传的时间
@@ -243,7 +244,8 @@ export default {
} else {
this.postDate = date.year + '-' + date.month + '-' + date.date
}
//选择当月,当天时,日期选择器默认到当年当月
//选择当月,当天时,日期选择器默认到当年当月--之前逻辑
//今日和本月改为昨日,默认昨日--现有逻辑
this.filterDate = date.year + '-' + date.month
this.dateFlag = index == 0 ? 'm' : 'd'
this.currentIndex = index == 0 ? 1 : 0
@@ -282,8 +284,10 @@ export default {
month = '0' + month
}
//默认展示当天数据
this.postDate = date.getFullYear() + '-' + month + '-' + date.getDate()
this.filterDate = date.getFullYear() + '-' + month
// this.postDate = date.getFullYear() + '-' + month + '-' + date.getDate()
// this.filterDate = date.getFullYear() + '-' + month
this.postDate = beforeDate.getLastMonth()
this.filterDate = beforeDate.getLastMonth()
this.dateFlag = 'd'
this.currentIndex = '0'
//数据重置--结束
@@ -504,14 +508,15 @@ export default {
}
},
created() {
let date = new Date()
let month = date.getMonth() + 1
if (month <= 9) {
month = '0' + month
}
// let date = new Date()
// let month = date.getMonth() + 1
// if (month <= 9) {
// month = '0' + month
// }
//默认展示当天数据
this.postDate = date.getFullYear() + '-' + month + '-' + date.getDate()
this.filterDate = date.getFullYear() + '-' + month
// this.postDate = date.getFullYear() + '-' + month + '-' + date.getDate()
this.postDate = beforeDate.getLastMonth()
this.filterDate = beforeDate.getLastMonth()
this.initDataPersonal()
window.addEventListener('scroll', this.handleScroll)
}
@@ -546,52 +551,55 @@ export default {
flex-shrink: 0;
margin: 0 7px;
font-size: 12px;
.unCheckedLeft {
background-color: #fff;
color: #333333;
border: 1px solid #2e4591;
border-radius: 6px 0 0 6px;
width: 54px;
height: 24px;
line-height: 24px;
display: inline-block;
text-align: center;
border-right: 0;
}
.checkedLeft {
background-color: #2e4591;
color: #fff;
border: 1px solid #2e4591;
border-radius: 6px 0 0 6px;
width: 54px;
height: 24px;
line-height: 24px;
display: inline-block;
text-align: center;
}
.unCheckedRight {
background-color: #fff;
color: #333333;
border: 1px solid #2e4591;
border-radius: 0 6px 6px 0;
width: 54px;
height: 24px;
line-height: 24px;
display: inline-block;
text-align: center;
}
.checkedRight {
background-color: #2e4591;
color: #fff;
border: 1px solid #2e4591;
border-radius: 0 6px 6px 0;
width: 54px;
height: 24px;
line-height: 24px;
display: inline-block;
text-align: center;
}
.unCheckedLeft {
background-color: #fff;
color: #333333;
border: 1px solid #2e4591;
border-radius: 6px;
// border-radius: 6px 0 0 6px;
width: 54px;
height: 24px;
line-height: 24px;
display: inline-block;
text-align: center;
// border-right: 0;
}
.checkedLeft {
background-color: #2e4591;
color: #fff;
border: 1px solid #2e4591;
border-radius: 6px;
// border-radius: 6px 0 0 6px;
width: 54px;
height: 24px;
line-height: 24px;
display: inline-block;
text-align: center;
}
.unCheckedRight {
background-color: #fff;
color: #333333;
border: 1px solid #2e4591;
border-radius: 0 6px 6px 0;
width: 54px;
height: 24px;
line-height: 24px;
display: inline-block;
text-align: center;
}
.checkedRight {
background-color: #2e4591;
color: #fff;
border: 1px solid #2e4591;
border-radius: 0 6px 6px 0;
width: 54px;
height: 24px;
line-height: 24px;
display: inline-block;
text-align: center;
}
}
.filterTime {
width: 70px;
margin-right: 5px;