fix code
parent
87bd27f814
commit
6f22c73d99
|
@ -51,6 +51,7 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import { computed } from '@common/utils/vueTools'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
props: {
|
props: {
|
||||||
|
@ -72,29 +73,34 @@ export default {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
emits: ['btn-click'],
|
emits: ['btn-click'],
|
||||||
computed: {
|
setup(props, { emit }) {
|
||||||
maxPage() {
|
const maxPage = computed(() => {
|
||||||
return Math.ceil(this.count / this.limit) || 1
|
return Math.ceil(props.count / props.limit) || 1
|
||||||
},
|
})
|
||||||
pageEvg() {
|
const pageEvg = computed(() => {
|
||||||
return Math.floor(this.btnLength / 2)
|
return Math.floor(props.btnLength / 2)
|
||||||
},
|
})
|
||||||
pages() {
|
const pages = computed(() => {
|
||||||
if (this.maxPage <= this.btnLength) return Array.from({ length: this.maxPage }, (_, i) => i + 1)
|
if (maxPage <= props.btnLength) return Array.from({ length: maxPage }, (_, i) => i + 1)
|
||||||
let start =
|
let start = props.page - pageEvg > 1
|
||||||
this.page - this.pageEvg > 1
|
|
||||||
// eslint-disable-next-line @typescript-eslint/restrict-plus-operands
|
// eslint-disable-next-line @typescript-eslint/restrict-plus-operands
|
||||||
? this.maxPage - this.page < this.pageEvg + 1
|
? maxPage - props.page < pageEvg + 1
|
||||||
? this.maxPage - (this.btnLength - 1)
|
? maxPage - (props.btnLength - 1)
|
||||||
: this.page - this.pageEvg
|
: props.page - pageEvg
|
||||||
: 1
|
: 1
|
||||||
return Array.from({ length: this.btnLength }, (_, i) => start + i)
|
return Array.from({ length: props.btnLength }, (_, i) => start + i)
|
||||||
},
|
})
|
||||||
},
|
|
||||||
methods: {
|
const handleClick = (page) => {
|
||||||
handleClick(page) {
|
emit('btn-click', page)
|
||||||
this.$emit('btn-click', page)
|
}
|
||||||
},
|
|
||||||
|
return {
|
||||||
|
maxPage,
|
||||||
|
pageEvg,
|
||||||
|
pages,
|
||||||
|
handleClick,
|
||||||
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -120,6 +120,7 @@ export default {
|
||||||
handleRegisterEvent(action) {
|
handleRegisterEvent(action) {
|
||||||
let eventHub = window.key_event
|
let eventHub = window.key_event
|
||||||
let name = action == 'on' ? 'on' : 'off'
|
let name = action == 'on' ? 'on' : 'off'
|
||||||
|
// eslint-disable-next-line @typescript-eslint/unbound-method
|
||||||
eventHub[name](HOTKEY_COMMON.focusSearchInput.action, this.handleFocusInput)
|
eventHub[name](HOTKEY_COMMON.focusSearchInput.action, this.handleFocusInput)
|
||||||
},
|
},
|
||||||
handleFocusInput() {
|
handleFocusInput() {
|
||||||
|
|
Loading…
Reference in New Issue