| | |
| | | format="yyyy-MM-dd" value-format="yyyy-MM-dd HH:mm:ss" |
| | | @change="selectDate" |
| | | ></el-date-picker> |
| | | <el-button-group class="date-shortcuts"> |
| | | <el-button size="mini" @click="setDateRange(7)">近7天</el-button> |
| | | <el-button size="mini" @click="setDateRange(30)">近30天</el-button> |
| | | </el-button-group> |
| | | </el-form-item> |
| | | <section> |
| | | <el-button type="primary" @click="search">搜索</el-button> |
| | |
| | | } |
| | | this.search() |
| | | }, |
| | | setDateRange (days) { |
| | | const end = new Date() |
| | | end.setHours(23, 59, 59, 999) |
| | | const start = new Date() |
| | | start.setTime(start.getTime() - 3600 * 1000 * 24 * (days - 1)) |
| | | start.setHours(0, 0, 0, 0) |
| | | const formatDate = (date) => { |
| | | const y = date.getFullYear() |
| | | const m = String(date.getMonth() + 1).padStart(2, '0') |
| | | const d = String(date.getDate()).padStart(2, '0') |
| | | return `${y}-${m}-${d}` |
| | | } |
| | | this.value1 = [`${formatDate(start)} 00:00:00`, `${formatDate(end)} 00:00:00`] |
| | | this.searchForm.startDate = this.value1[0] |
| | | this.searchForm.endDate = this.value1[1] |
| | | this.search() |
| | | }, |
| | | // 页码变更处理 |
| | | handlePageChange (pageIndex) { |
| | | this.__checkApi() |
| | |
| | | } |
| | | } |
| | | } |
| | | .date-shortcuts { |
| | | margin-left: 10px; |
| | | } |
| | | </style> |