| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228 | 
							- <template>
 
- 	<view class="dateContainer">
 
- 		<view class="topSection">
 
- 			<view class="title">{{title}}</view>
 
- 			<view class="dateItems">
 
- 				<view class="item" v-for="(item, idx) in dateItems" :key="idx" :style="`color: ${item.value == defaultParameter.dateType ? '#454545' : '#999999'};`"
 
- 				 @click="screenAction(item.value)">
 
- 					{{item.title}}
 
- 				</view>
 
- 			</view>
 
- 		</view>
 
- 		<view class="botttomSection" @click="screenAction(4)">
 
- 			<view class="bottomItem">
 
- 				<view class="leftText">起</view>
 
- 				<view class="dateText">{{beginDate | visitTimeFilter}}</view>
 
- 				<image class="rightIcon" src="../../static/icons/more.png" mode=""></image>
 
- 			</view>
 
- 			<view class="bottomItem">
 
- 				<view class="leftText">终</view>
 
- 				<view class="dateText">{{endDate | visitTimeFilter}}</view>
 
- 				<image class="rightIcon" src="../../static/icons/more.png" mode=""></image>
 
- 			</view>
 
- 		</view>
 
- 		<dm-calendar-picker-view ref='calendarPickerView' @confirmSelDate='confirmSelDate'></dm-calendar-picker-view>
 
- 	</view>
 
- </template>
 
- <script>
 
- 	import dmCalendarPickerView from './dmCalendarPickerView.vue'
 
- 	import moment from '../../static/moment.min.js'
 
- 	import {
 
- 		displayDateFormatChi
 
- 	} from '../../static/format.js'
 
- 	export default {
 
- 		props: {
 
- 			title: {
 
- 				type: String,
 
- 				default: '筛选日期'
 
- 			},
 
- 			defaultParameter: {
 
- 				type: Object,
 
- 				default () {
 
- 					return {
 
- 						'dateType': '1',
 
- 						'startDate': '',
 
- 						'endDate': '',
 
- 						'terminal': '0'
 
- 					}
 
- 				}
 
- 			},
 
- 			modelValue: {
 
- 				type: [Number, String],
 
- 				default: '0'
 
- 			},
 
- 		},
 
- 		data() {
 
- 			return {
 
- 				dateItems: [{
 
- 						title: '今日',
 
- 						value: 1
 
- 					},
 
- 					{
 
- 						title: '近7日',
 
- 						value: 2
 
- 					},
 
- 					{
 
- 						title: '近30天',
 
- 						value: 3
 
- 					},
 
- 				],
 
- 				beginDate: null,
 
- 				endDate: null
 
- 			}
 
- 		},
 
- 		mounted() {
 
- 		},
 
- 		methods: {
 
- 			screenAction(val) {
 
- 				if (val < 4) {
 
- 					this.$emit('screenDateAction', val)
 
- 				} else {
 
- 					this.$refs.calendarPickerView.show()
 
- 				}
 
- 			},
 
- 			confirmSelDate(e) {
 
- 				const startDate = e.startDate;
 
- 				const endDate = e.endDate;
 
- 				var start = ''
 
- 				var end = ''
 
- 				if (moment(startDate).isBefore(endDate)) {
 
- 					start = startDate;
 
- 					end = endDate;
 
- 				} else {
 
- 					start = endDate;
 
- 					end = startDate;
 
- 				}
 
- 				this.$emit('screenDateAction', 4, start, end)
 
- 			},
 
- 			displayDate() {
 
- 				var dateType = parseInt(this.defaultParameter.dateType)
 
- 				let curDate = (new Date()).getTime();
 
- 				this.beginDate = null
 
- 				this.endDate = null
 
- 				if (dateType == 1) {
 
- 					this.beginDate = curDate
 
- 					this.endDate = curDate
 
- 				} else if (dateType == 2) {
 
- 					this.endDate = curDate
 
- 					this.beginDate = this.getBeginDate(6)
 
- 				} else if (dateType == 3) {
 
- 					this.endDate = curDate
 
- 					this.beginDate = this.getBeginDate(29)
 
- 				} else if (dateType == 4) {
 
- 					this.beginDate = this.stringToStamp(this.defaultParameter.startDate)
 
- 					this.endDate = this.stringToStamp(this.defaultParameter.endDate)
 
- 				}
 
- 			},
 
- 			getBeginDate(days) {
 
- 				let curDate = (new Date()).getTime();
 
- 				let beginDay = curDate - days * 24 * 60 * 60 * 1000
 
- 				return beginDay
 
- 			},
 
- 			stringToStamp(val) {
 
- 				// var timeStr = val.replace('-', '/') + ' ' + '00:00:00'
 
- 				var timeStr = val.replace(/-/g,'/') + " " + '00:00:00'
 
- 				var stamp = new Date(timeStr).getTime()
 
- 				return stamp
 
- 			}
 
- 		},
 
- 		filters: {
 
- 			visitTimeFilter(val) {
 
- 				return displayDateFormatChi(val)
 
- 			},
 
- 		},
 
- 		watch: {
 
- 			defaultParameter: {
 
- 				handler(e) {
 
- 					this.displayDate()
 
- 				},
 
- 				deep: true,
 
- 				immediate: true
 
- 			}
 
- 		},
 
- 		components: {
 
- 			dmCalendarPickerView
 
- 		}
 
- 	}
 
- </script>
 
- <style scoped lang="scss">
 
- 	.dateContainer {
 
- 		width: 100%;
 
- 		font-family: Verdana;
 
- 		padding: 0 30rpx;
 
- 		box-sizing: border-box;
 
- 		.topSection {
 
- 			width: 100%;
 
- 			display: flex;
 
- 			justify-content: space-between;
 
- 			align-items: center;
 
- 			.title {
 
- 				color: #454545;
 
- 				font-size: 32rpx;
 
- 				font-weight: bold;
 
- 			}
 
- 			.dateItems {
 
- 				display: flex;
 
- 				justify-content: flex-end;
 
- 				font-size: 28rpx;
 
- 				color: #999999;
 
- 				.item {
 
- 					margin-left: 20rpx;
 
- 				}
 
- 			}
 
- 		}
 
- 		.botttomSection {
 
- 			background-color: #F1F5F9;
 
- 			border-radius: 16rpx;
 
- 			width: 100%;
 
- 			height: 94rpx;
 
- 			display: flex;
 
- 			justify-content: space-between;
 
- 			padding: 0 30rpx;
 
- 			box-sizing: border-box;
 
- 			margin-top: 22rpx;
 
- 			.bottomItem {
 
- 				display: flex;
 
- 				justify-content: flex-start;
 
- 				align-items: center;
 
- 				.leftText {
 
- 					color: #999999;
 
- 					font-size: 28rpx;
 
- 					font-weight: bold;
 
- 					margin-right: 12rpx;
 
- 				}
 
- 				.dateText {
 
- 					color: #333333;
 
- 					font-size: 28rpx;
 
- 					margin-right: 20rpx;
 
- 				}
 
- 				.rightIcon {
 
- 					width: 15rpx;
 
- 					height: 24rpx;
 
- 				}
 
- 			}
 
- 		}
 
- 	}
 
- </style>
 
 
  |