From b136c0a80500d929897a8e24f920efad47e2e307 Mon Sep 17 00:00:00 2001
From: haoxuan <haoxuan>
Date: 星期三, 01 十一月 2023 19:03:01 +0800
Subject: [PATCH] 变更公海 的接口传参修改
---
src/components/wordInput.vue | 45 ++++++++++++++++++++++++++++++++++++++++-----
1 files changed, 40 insertions(+), 5 deletions(-)
diff --git a/src/components/wordInput.vue b/src/components/wordInput.vue
index 8e9408a..852d6f2 100644
--- a/src/components/wordInput.vue
+++ b/src/components/wordInput.vue
@@ -9,6 +9,7 @@
@paste="paste"
@mousewheel="mousewheel"
@input="inputEvent"
+ @compositionend="compositionend"
v-for="(item, index) in codeList"
>
<input
@@ -94,6 +95,10 @@
// },
},
methods: {
+ compositionend(e){
+ e.preventDefault()
+ this.batchInsert(e.data,e.target)
+ },
// 瑙e喅涓�涓緭鍏ユ杈撳叆澶氫釜瀛楃
inputEvent(e) {
var index = e.target.dataset.index * 1;
@@ -147,6 +152,14 @@
}
},
keyup(e) {
+ if (e.ctrlKey || e.shiftKey){
+ // 蹇界暐缁勫悎閿椂鐨勫瓧绗﹁緭鍏�
+ return;
+ }
+ if (e.isComposing || e.keyCode === 229) {
+ // 蹇界暐杈撳叆娉曞悎鎴愪簨浠� 蹇界暐IME鍔犲伐杩囩殑鍊�
+ return;
+ }
var index = e.target.dataset.index * 1;
var el = e.target;
// console.log(this.input);
@@ -175,6 +188,8 @@
}
},
mousewheel(e) {
+ // 闃叉瑙﹀彂澶栭儴婊氬姩鏉�
+ e.preventDefault()
var index = e.target.dataset.index;
if (e.wheelDelta > 0) {
if (this.input[index] * 1 < 9) {
@@ -191,14 +206,34 @@
}
}
},
+ /**
+ * 鎵归噺娣诲姞瀛楃
+ * @param str 瀛楃涓�
+ * @param currentInputElement 褰撳墠杈撳叆鐨刬nput鍏冪礌
+ */
+ batchInsert(str,currentInputElement){
+ const charList = str.split('');
+
+ let currentIndex = currentInputElement.dataset.index * 1;
+
+ let activeInputElement =currentInputElement
+ charList.forEach((ele,idx)=>{
+ this.$set(this.input, currentIndex+idx, ele);
+ activeInputElement = activeInputElement?.nextElementSibling
+ })
+ activeInputElement?.focus()
+ },
paste(e) {
// 褰撹繘琛岀矘璐存椂
e.clipboardData.items[0].getAsString((str) => {
- if (str.toString().length === 6) {
- this.pasteResult = str.split("");
- document.activeElement.blur();
- this.$emit("complete", this.input);
- }
+ // if (str.toString().length === 6) {
+ // this.pasteResult = str.split("");
+ // document.activeElement.blur();
+ // this.$emit("complete", this.input);
+ // }
+
+ this.batchInsert(str,e.target)
+ this.$emit("complete", this.input);
});
},
save() {
--
Gitblit v1.8.0