|
@@ -17,6 +17,13 @@ const props = defineProps({
|
|
|
type: Number,
|
|
|
default: 0,
|
|
|
},
|
|
|
+ length: {
|
|
|
+ type: Number,
|
|
|
+ default: 6,
|
|
|
+ validator(value: number) {
|
|
|
+ return value > 0
|
|
|
+ },
|
|
|
+ },
|
|
|
label: {
|
|
|
type: String,
|
|
|
default: '总数',
|
|
@@ -25,16 +32,12 @@ const props = defineProps({
|
|
|
const numberBoxes = ref<HTMLInputElement[] | undefined[]>([])
|
|
|
const numberItems = computed(() => {
|
|
|
let numberString = props.countNumber.toString()
|
|
|
- if (numberString.length > 6) {
|
|
|
- ElMessage({
|
|
|
- message: `${props.label}过大`,
|
|
|
- type: 'error',
|
|
|
- duration: 2 * 1000,
|
|
|
- })
|
|
|
- numberString = '999999'
|
|
|
+ if (numberString.length > props.length) {
|
|
|
+ ElMessage.error(`${props.label}过大`)
|
|
|
+ numberString = '9'.repeat(props.length)
|
|
|
}
|
|
|
- numberString = '000000' + numberString
|
|
|
- return numberString.slice(-6).split('')
|
|
|
+ numberString = '0'.repeat(props.length) + numberString
|
|
|
+ return numberString.slice(-props.length).split('')
|
|
|
})
|
|
|
watch(numberItems, items => {
|
|
|
for (let index = 0; index < numberBoxes.value.length; index++) {
|