本文记录的几个要点
1、结束时间不得比开始时间提前
2、当前月份之后不可选
3、开始时间为当月的第一天 eg: 01月01日 00:00:00
结束时间为当月的最后一天 eg: 12月31日 23:59:59
转化为时间戳格式入参
4、默认展示向前推12个月
eg: 2019-12 ~ 2020-12


效果图:(当前月份12月)

代码实现:

 <date-picker type="month" :value="leftTime" placeholder="请选择开始时间" :options="startTimeOption" @on-change="onStartTimeChange"></date-picker><date-picker type="month" :disabled = 'disabled' :value="rightTime" placeholder="请选择结束时间" :options="endTimeOption" @on-change="onEndTimeChange"></date-picker>
data() {return :{leftTime: getDate('yyyy-MM-dd', new Date().getTime() - 3600 * 1000 * 24 * 30 * 12), // 月份开始时间tempLeft: '',rightTime: getDate('yyyy-MM-dd', new Date().getTime()), // 月份结束时间tempRight: '',disabled: true, // 禁止使用第二个startTimeOption: {}, // 开始时间校验endTimeOption: { // 结束时间校验disabledDate (date) {return date && date.valueOf() > Date.now() - 86400000}}}
}
  methods: {// 时间选择 - 开始日期onStartTimeChange (startTime, type) {this.endTimeOption = {disabledDate (endTime) {return endTime < new Date(startTime) || endTime > Date.now()}}this.disabled = falsethis.tempLeft = getTime(startTime + '-01 00:00:00')if (this.tempRight && this.tempLeft) this.monthActive(1)},// 结束日期onEndTimeChange (endTime, type) {this.startTimeOption = {disabledDate (startTime) {return startTime > new Date(endTime) || startTime > Date.now()}}// endTime返回 2020-12var y = endTime.substring(0, 4)var m = endTime.substring(5, 8)this.tempRight = getTime(getDate('yyyy-MM-dd 23:59:59', new Date(y, m, 1 - 1).getTime()))if (this.tempRight && this.tempLeft) this.monthActive(1)}}// 入参monthActive (pageIndex) {   const data = {leftTime: this.tempLeft, // 这里是转化好的时间戳格式rightTime: this.tempRight,pageIndex: 1,pageSize: 10,type: 2}deviceOnlineData(data).then().catch()}
created() {// 把需要入参的值转化为时间戳格式方法和开始日期 结束日期 一样
}

iview选择月份 月初月末 时间戳格式相关推荐

  1. php 获得当月时间戳,php获取当前月与上个月月初及月末时间戳的方法

    本文实例讲述了php获取当前月与上个月月初及月末时间戳的方法.分享给大家供大家参考,具体如下: 当前月 $thismonth = date('m'); $thisyear = date('Y'); $ ...

  2. php当前月每天时间戳,php获取当前月与上个月月初及月末时间戳的方法

    本文实例讲述了php获取当前月与上个月月初及月末时间戳的方法.分享给大家供大家参考,具体如下: 当前月 $thismonth = date('m'); $thisyear = date('Y'); $ ...

  3. 用EXCEL实现时间戳格式和日期格互转

    时间戳转成正常日期的公式: C1=(A1+8*3600)/86400+70*365+19 其中A1表示当时的1249488000时间戳数值 其中C1就是所需的日期格式,C1单元格属性改成日期格式就可以 ...

  4. bootstrap-datetimepicker 只选择月份出现1899问题

    需求 最近在使用bootstrap-datetimepicker中,遇到一个需求,要求只能选择月份,本以为是件很简单的问题,即修改一下格式就可以 --> 'yyyy-mm'变为"mm& ...

  5. DateTime时间格式转换为Unix时间戳格式

    // DateTime时间格式转换为Unix时间戳格式 public int ConvertDateTimeInt(System.DateTime time) { System.DateTime st ...

  6. EXCEL实现时间戳格式和日期格互转

    EXCEL实现时间戳格式和日期格互转 reference2. https://blog.csdn.net/ch 时间戳转成正常日期的公式: D1=(A1+8*3600)/86400+70*365+19 ...

  7. Linux下时间戳格式和标准时间格式的转换

    转载地址:http://yinqingsong520.blog.163.com/blog/static/392100201010252595916/  做个备忘! 在LINUX系统中,有许多场合都使用 ...

  8. python datetime格式转换_分别用Excel和python进行日期格式转换成时间戳格式

    最近在处理一份驾驶行为方面的数据,其中要用到时间戳,因此就在此与大家一同分享学习一下. 1.什么是时间戳? 时间戳是指格林威治时间1970年01月01日00时00分00秒(北京时间1970年01月01 ...

  9. Excel中将时间格式转化成时间戳格式

    时间戳转成正常日期的公式: C1=(A1+8*3600)/86400+70*365+19 其中A1表示当时的1249488000时间戳数值 其中C1就是所需的日期格式,C1单元格属性改成日期格式就可以 ...

最新文章

  1. 字节跳动喜欢招聘这样的机器学习工程师
  2. 如何使用Nexus搭建Maven私服
  3. 如何使用github托管项目---快速入门(菜鸟教程)
  4. matlab jdbc mysql_Matlab连接MySQL(ODBC及JDBC驱动)
  5. php+curl+restapi,php – cURL适用于我的REST API,但不是Guzzle
  6. RESTful Web 服务 - 消息
  7. Qt入门之常用qt控件认知之QLabel
  8. MyBatis 缓存详解-一级缓存验证
  9. 160 - 5 ajj.2
  10. parrot linux iso下载,Parrot 4.7 发布,基于Debian的数字取证和隐私保护Linux发行版
  11. 如何将以字符表示的16进制数转换为机器码表示的16进制数
  12. 下载Bootstrap
  13. 纳米软件案例之陶瓷样品测试系统,原位观察力学测试纳米压痕仪-扫描电子显微镜SEM联用...
  14. 微信点餐系统的开发与实现
  15. SDWebImage第三方库加载图片生硬
  16. 图表美化设置圆角——《超级处理器》应用
  17. Sex and Gender
  18. 大聪明教你学Java | EasyExcel - 用更简单的方式操作Excel
  19. android换肤哪个简单,Android换肤
  20. pycharm:远程连接服务器调试代码(保姆级详细步骤)

热门文章

  1. 猜字游游戏,while执行10次(Python)
  2. 规则引擎:大厂营销系统资格设计全解
  3. 十道上市公司java面试试题
  4. INamingContainer接口解决多个自定义控件ID冲突
  5. Citrix无法访问本地磁盘
  6. 《HTML、CSS、JavaScript 网页制作从入门到精通》——第6章 使用表格
  7. 那些原生JavaScript
  8. Linux系统时间与RTC时间【转】
  9. python抓取中文网页乱码
  10. Hessian 使用入门