-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6a89d52
commit 171b953
Showing
8 changed files
with
117 additions
and
359 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
...frontend/src/views/duty-rule-manage/index/components/content/components/PriorityInput.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
<template> | ||
<BkLoading :loading="loading"> | ||
<BkInput | ||
ref="inputRef" | ||
v-model="localValue" | ||
class="priority-input" | ||
:max="100" | ||
:min="1" | ||
placeholder="1~100" | ||
type="number" | ||
@blur="handleBlur" | ||
@keyup="handleEnter" /> | ||
</BkLoading> | ||
</template> | ||
<script setup lang="ts"> | ||
interface Props { | ||
requestHandler: (value: number) => Promise<void>; | ||
} | ||
const props = defineProps<Props>(); | ||
const localValue = defineModel<number>({ | ||
default: 1, | ||
}); | ||
const inputRef = ref(); | ||
const loading = ref(false); | ||
let isEnterKey = false; | ||
const updatePriority = async () => { | ||
loading.value = true; | ||
try { | ||
await props.requestHandler(localValue.value); | ||
} finally { | ||
loading.value = false; | ||
} | ||
}; | ||
const handleBlur = () => { | ||
if (isEnterKey) { | ||
isEnterKey = false; | ||
return; | ||
} | ||
updatePriority(); | ||
}; | ||
const handleEnter = (_: number, event: KeyboardEvent) => { | ||
if (event.key === 'Enter') { | ||
isEnterKey = true; | ||
updatePriority(); | ||
} | ||
}; | ||
onMounted(() => { | ||
inputRef.value.focus(); | ||
}); | ||
</script> | ||
<style lang="less" scoped> | ||
.priority-input { | ||
:deep(.bk-input--number-control) { | ||
display: none; | ||
} | ||
} | ||
</style> |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.