Skip to content

Commit

Permalink
fix: 修复时间选择器手动输入无效的问题 (#89)
Browse files Browse the repository at this point in the history
# Reviewed, transaction id: 15228
  • Loading branch information
Carlmac authored Aug 14, 2024
1 parent ac9b794 commit 7ca1ea2
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/dashboard-front/src/language/lang.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ const lang: ILANG = {
'访问地址': ['Access URL'],
'子路径': ['Subpath'],
'选择日期时间范围': ['Select date and time range'],
'输入的时间错误': ['Invalid Time Format'],
'隐藏示例': ['Hide example'],
'显示示例': ['Show example'],
'创建时间': ['Create Time'],
Expand Down
16 changes: 15 additions & 1 deletion src/dashboard-front/src/views/operate-data/access-log/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@
:use-shortcut-text="true"
:clearable="false"
:shortcut-selected-index="shortcutSelectedIndex"
@shortcut-change="handleShortcutChange" @change="handlePickerChange" />
@shortcut-change="handleShortcutChange"
@change="handlePickerChange"
@pick-success="handlePickerConfirm"
/>
</bk-form-item>
<bk-form-item :label="t('环境')">
<bk-select
Expand Down Expand Up @@ -687,6 +690,17 @@ const handlePickerChange = () => {
});
};
// 处理用户自行输入日期,点击确认后的情况。v-model 不会自动更新,要从 picker 内部拿输入的日期。
const handlePickerConfirm = () => {
const internalValue = datePickerRef.value?.internalValue;
if (internalValue) {
dateTimeRange.value = internalValue;
handlePickerChange();
} else {
Message({ theme: 'warning', message: t('输入的时间错误'), delay: 2000, dismissable: false });
}
};
const handleStageChange = (value: number) => {
searchParams.value.stage_id = value;
pagination.value.current = 1;
Expand Down
8 changes: 7 additions & 1 deletion src/dashboard-front/src/views/operate-data/report/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,13 @@ const handleResourceChange = (value: any) => {
};
const handleTimeChange = () => {
getDataByDimension();
const internalValue = datePickerRef.value?.internalValue;
if (internalValue) {
dateTimeRange.value = internalValue;
getDataByDimension();
} else {
Message({ theme: 'warning', message: t('输入的时间错误'), delay: 2000, dismissable: false });
}
};
const handleShortcutChange = (value: any, index: number) => {
Expand Down
9 changes: 8 additions & 1 deletion src/dashboard-front/src/views/operate-records/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ import {
TableEmptyConfType,
} from './common/type';
import { fetchApigwAuditLogs } from '@/http';
import { Message } from 'bkui-vue';
const { t } = i18n.global;
const AccessLogStore = useAccessLog();
Expand Down Expand Up @@ -355,7 +356,13 @@ const getOpObjectTypeText = (type: string) => {
};
const handleTimeChange = () => {
setSearchTimeRange();
const internalValue = topDatePicker.value?.internalValue;
if (internalValue) {
dateTimeRange.value = internalValue;
setSearchTimeRange();
} else {
Message({ theme: 'warning', message: t('输入的时间错误'), delay: 2000, dismissable: false });
}
};
const handleTimeClear = () => {
Expand Down

0 comments on commit 7ca1ea2

Please sign in to comment.