| | |
| | | * @Author: lzhe lzhe@example.com |
| | | * @Date: 2024-04-26 09:36:18 |
| | | * @LastEditors: lzhe lzhe@example.com |
| | | * @LastEditTime: 2024-11-27 15:44:14 |
| | | * @LastEditTime: 2024-12-06 10:47:53 |
| | | * @FilePath: /smart-web/src/views/mdc/status-record.vue |
| | | * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE |
| | | --> |
| | |
| | | // } |
| | | }, |
| | | mounted() { |
| | | var date = new Date(); |
| | | var threeDaysInMilliseconds = 3 * 24 * 60 * 60 * 1000; |
| | | var threeDaysAgo = new Date(date.getTime() - threeDaysInMilliseconds); |
| | | this.searchInfo.startDate = threeDaysAgo.toLocaleDateString().replace(/\//g,"-"); |
| | | this.searchInfo.endDate = date.toLocaleDateString().replace(/\//g,"-"); |
| | | this.setDate(); //设置开始,结束日期 |
| | | this.getTableData(); |
| | | }, |
| | | methods: { |
| | | setDate() { |
| | | var date = new Date(); |
| | | var threeDaysInMilliseconds = 3 * 24 * 60 * 60 * 1000; |
| | | var threeDaysAgo = new Date(date.getTime() - threeDaysInMilliseconds); |
| | | |
| | | // 辅助函数,用于将数字格式化为两位数 |
| | | function padZero(num) { |
| | | return num < 10 ? '0' + num : num; |
| | | } |
| | | |
| | | // 构建当前日期的字符串 |
| | | var currentYear = date.getFullYear(); |
| | | var currentMonth = padZero(date.getMonth() + 1); // 月份从0开始,所以需要加1 |
| | | var currentDay = padZero(date.getDate()); |
| | | this.searchInfo.startDate = currentYear + '-' + currentMonth + '-' + currentDay; |
| | | |
| | | // 构建三天前日期的字符串 |
| | | var previousYear = threeDaysAgo.getFullYear(); |
| | | var previousMonth = padZero(threeDaysAgo.getMonth() + 1); |
| | | var previousDay = padZero(threeDaysAgo.getDate()); |
| | | this.searchInfo.endDate = previousYear + '-' + previousMonth + '-' + previousDay; |
| | | }, |
| | | handleCurrentChange(val) { |
| | | this.current = val; |
| | | this.getTableData(); |