| | |
| | | let timeListEnum = ['TODAY', 'CURRENT_WEEK', 'CURRENT_MONTH', 'CURRENT_YEAR']; |
| | | let checked = ref('month'); |
| | | |
| | | // 根据 周期 获取时间段 |
| | | function getDateRange(date_enum) { |
| | | // 设置对应的日期范围 |
| | | switch (date_enum) { |
| | | case 'today': |
| | | dateRange.value = [dayjs().startOf('day').format(timeFormat), dayjs().endOf('day').format(timeFormat)] |
| | | break |
| | | case 'week': |
| | | dateRange.value = [dayjs().startOf('week').format(timeFormat), dayjs().format(timeFormat)] |
| | | break |
| | | case 'month': |
| | | dateRange.value = [dayjs().startOf('month').format(timeFormat), dayjs().format(timeFormat)] |
| | | break |
| | | case 'year': |
| | | dateRange.value = [dayjs().startOf('year').format(timeFormat), dayjs().format(timeFormat)] |
| | | break |
| | | } |
| | | } |
| | | |
| | | let timeClick = (item, index) => { |
| | | if (checked.value === item){ |
| | | if (checked.value === item) { |
| | | checked.value = null |
| | | searchForm.date_enum = undefined |
| | | }else{ |
| | | dateRange.value = [] |
| | | } else { |
| | | checked.value = item |
| | | searchForm.date_enum = timeListEnum[index] |
| | | getDateRange(item) |
| | | } |
| | | dateRange.value = [] |
| | | handleSearch() |
| | | }; |
| | | } |
| | | // 搜索 |
| | | const handleSearch = () => { |
| | | if (!dateRange.value) { |
| | | dateRange.value = []; |
| | | } |
| | | if (dateRange.value && dateRange.value.length) { |
| | | // 有值时 清除 日 本周 本月 本年状态 |
| | | checked.value = ''; |
| | | searchForm.date_enum = ''; |
| | | } |
| | | // if (dateRange.value && dateRange.value.length) { |
| | | // // 有值时 清除 日 本周 本月 本年状态 |
| | | // checked.value = ''; |
| | | // searchForm.date_enum = ''; |
| | | // } |
| | | // 提交至store |
| | | let params = { |
| | | ...searchForm, |
| | |
| | | dateRange.value = dateArray; |
| | | const find = store.state.tags.bsTagList.find(i => i.path === '/job/jobstatistics') |
| | | find && (find.query = {}) |
| | | } else { |
| | | getDateRange('month') |
| | | } |
| | | // 查询一次 |
| | | handleSearch() |