|
36 | 36 | value: x.value |
37 | 37 | })); |
38 | 38 |
|
| 39 | + // Get today's date in YYYY-MM-DD format |
| 40 | + const getTodayStr = () => { |
| 41 | + const d = new Date(); |
| 42 | + return d.getFullYear() + '-' + String(d.getMonth() + 1).padStart(2, '0') + '-' + String(d.getDate()).padStart(2, '0'); |
| 43 | + }; |
| 44 | +
|
39 | 45 | /** @type {import('$commonTypes').Pagination} */ |
40 | 46 | let pager = { page: firstPage, size: pageSize, count: 0 } |
41 | 47 |
|
|
64 | 70 | models: [], |
65 | 71 | template: '', |
66 | 72 | timeRange: TimeRange.Today, |
| 73 | + specificDate: '', |
67 | 74 | states: [] |
68 | 75 | }; |
69 | 76 |
|
|
87 | 94 | page: $page.url.searchParams.get("page"), |
88 | 95 | pageSize: $page.url.searchParams.get("pageSize") |
89 | 96 | }, { defaultPageSize: pageSize }); |
90 | | - innerTimeRange = convertTimeRange(searchOption.timeRange); |
| 97 | + innerTimeRange = convertTimeRange(searchOption.timeRange, searchOption.specificDate); |
91 | 98 |
|
92 | 99 | filter = { |
93 | 100 | ...filter, |
|
223 | 230 | models: selectedValues |
224 | 231 | }; |
225 | 232 | } else if (type === 'timeRange') { |
| 233 | + const timeRange = selectedValues.length > 0 ? selectedValues[0] : null; |
| 234 | + const isSpecificDay = timeRange === TimeRange.SpecificDay; |
226 | 235 | searchOption = { |
227 | 236 | ...searchOption, |
228 | | - timeRange: selectedValues.length > 0 ? selectedValues[0] : null |
| 237 | + timeRange, |
| 238 | + specificDate: isSpecificDay ? (searchOption.specificDate || getTodayStr()) : '' |
229 | 239 | }; |
230 | 240 | } |
231 | 241 | } |
|
242 | 252 | const models = searchOption.models; |
243 | 253 | const template = util.trim(searchOption.template) || null; |
244 | 254 | const states = getSearchStates(); |
245 | | - innerTimeRange = convertTimeRange(searchOption.timeRange); |
| 255 | + innerTimeRange = convertTimeRange(searchOption.timeRange, searchOption.specificDate); |
246 | 256 |
|
247 | 257 | filter = { |
248 | 258 | ...filter, |
|
382 | 392 | options={timeRangeOptions} |
383 | 393 | on:select={e => changeOption(e, 'timeRange')} |
384 | 394 | /> |
| 395 | + {#if searchOption.timeRange === TimeRange.SpecificDay} |
| 396 | + <Input |
| 397 | + type="date" |
| 398 | + bind:value={searchOption.specificDate} |
| 399 | + class="mt-2" |
| 400 | + /> |
| 401 | + {/if} |
385 | 402 | </Col> |
386 | 403 | <Col lg="1"> |
387 | 404 | <Button |
|
0 commit comments