修改"下一个"按钮的状态
This commit is contained in:
@@ -20,6 +20,7 @@
|
||||
value-format="YYYY-MM-DD"
|
||||
:shortcuts="shortcuts"
|
||||
/>
|
||||
|
||||
<el-button :disabled="backDisabled" type="primary" :icon="DArrowLeft" @click="preClick"></el-button>
|
||||
<el-button type="primary" :icon="VideoPause" @click="nowTime">当前</el-button>
|
||||
<el-button :disabled="preDisabled" type="primary" :icon="DArrowRight" @click="next"></el-button>
|
||||
@@ -35,7 +36,7 @@ interface Props {
|
||||
theCurrentTime?: boolean
|
||||
initialInterval?: number
|
||||
initialTimeValue?: any
|
||||
timeKeyList?: string[] //日期下拉
|
||||
timeKeyList?: string[] //日期下拉
|
||||
}
|
||||
|
||||
const props = withDefaults(defineProps<Props>(), {
|
||||
@@ -98,10 +99,7 @@ const filteredTimeOptions = computed(() => {
|
||||
return timeOptions.value
|
||||
}
|
||||
|
||||
return timeOptions.value.filter((option: any) =>
|
||||
props.timeKeyList.includes(option.value.toString())
|
||||
)
|
||||
|
||||
return timeOptions.value.filter((option: any) => props.timeKeyList.includes(option.value.toString()))
|
||||
})
|
||||
|
||||
onMounted(() => {
|
||||
@@ -143,6 +141,11 @@ const emitChange = () => {
|
||||
timeValue: timeValue.value,
|
||||
timeFlag: timeFlag.value
|
||||
})
|
||||
|
||||
// preClick 操作后不执行按钮状态检查
|
||||
if (!isUserAction) {
|
||||
checkButtonStatus()
|
||||
}
|
||||
})
|
||||
}
|
||||
// 选择时间范围
|
||||
@@ -186,8 +189,17 @@ const timeChange = (e: number) => {
|
||||
emitChange()
|
||||
}
|
||||
|
||||
// 添加按钮状态检查方法
|
||||
const checkButtonStatus = () => {
|
||||
// 添加一个标志来跟踪是否由用户操作触发
|
||||
let isUserAction = true
|
||||
|
||||
// 修改 checkButtonStatus 方法
|
||||
const checkButtonStatus = (forceEnable = false) => {
|
||||
// 如果是强制启用,则直接启用
|
||||
if (forceEnable) {
|
||||
preDisabled.value = false
|
||||
return
|
||||
}
|
||||
|
||||
if (timeValue.value && timeValue.value.length >= 2) {
|
||||
const endTime = timeValue.value[1]
|
||||
const currentDate = window.XEUtils.toDateString(new Date(), 'yyyy-MM-dd')
|
||||
@@ -270,8 +282,10 @@ const preClick = () => {
|
||||
// var temp = NowgetEndTime()
|
||||
// timeStatus(temp, endTime)
|
||||
|
||||
// 触发 change 事件
|
||||
// 触发 change 事件,但临时标记为用户操作
|
||||
isUserAction = true
|
||||
emitChange()
|
||||
isUserAction = false
|
||||
}
|
||||
//下一个
|
||||
const next = () => {
|
||||
|
||||
Reference in New Issue
Block a user