Преглед на файлове

花材打标签自动获得焦点,自动弹出数字键

shizhongqi преди 4 години
родител
ревизия
30fa3a6d99
променени са 2 файла, в които са добавени 69 реда и са изтрити 20 реда
  1. 34 10
      ghsApp/src/admin/item/detail.vue
  2. 35 10
      ghsApp/src/admin/item/list.vue

+ 34 - 10
ghsApp/src/admin/item/detail.vue

@@ -144,7 +144,7 @@
 			<div class="app-modal-input-wrap">
 			<div class="app-modal-input-wrap">
 			<div class="inp-list-line">
 			<div class="inp-list-line">
 				<div class="line-input">
 				<div class="line-input">
-				<input type="number" style="width:200upx;text-align:center;" :focus="printFocus" v-model="printNum" :adjust-position="false" class="inp-input" />
+				<input type="number" style="width:61.8%;text-align:center;" @focus="focus" @blur="blur" :focus="printFocus" v-model="printNum" :adjust-position="false" class="inp-input" />
 				</div>
 				</div>
 			</div>
 			</div>
 			</div>
 			</div>
@@ -236,40 +236,64 @@ export default {
   watch:{
   watch:{
   },
   },
   methods: {
   methods: {
-    doPrintLabel(id){
+    focus() {
+			//this.printFocus = true
+		},
+		blur() {
+			this.printFocus = false
+		},
+		doPrintLabel(id){
 			this.printItemId = id
 			this.printItemId = id
-      this.printLabelShow = true
-      this.printFocus = true
-			//this.$refs.inputDialog.open()
+			this.printLabelShow = true
+      this.printNum = null
+
+			setTimeout(x => {
+				this.$nextTick(() => this.setFocus()); // just watch out with going too fast !!!
+			}, 200);
+		},
+		setFocus() {
+			this.printFocus = true
 		},
 		},
 		dialogInputConfirm(val) {
 		dialogInputConfirm(val) {
 			let that=this;
 			let that=this;
-      console.log(val)
 			if (val.index == 0) {
 			if (val.index == 0) {
-				this.printLabelShow = false
-        this.printFocus = false
+				that.printLabelShow = false
+				that.printFocus = false
 				return
 				return
 			}
 			}
-			//this.$refs.inputDialog.close()
 
 
-			let currentNum = Number(this.printNum)
+			let currentNum = this.printNum
 			let itemId = this.printItemId
 			let itemId = this.printItemId
+      if (currentNum == null) {
+				that.$msg('打印数量未填写')
+				that.printFocus = true
+				return
+			}
 			if (currentNum <= 0) {
 			if (currentNum <= 0) {
 				that.$msg('打印数量不能小于等于0')
 				that.$msg('打印数量不能小于等于0')
+				that.printFocus = true
 				return
 				return
 			}
 			}
 			if (itemId == 0) {
 			if (itemId == 0) {
 				that.$msg('打印的花材id出错')
 				that.$msg('打印的花材id出错')
+				that.printLabelShow = false
+				that.printFocus = false
 				return
 				return
 			}
 			}
+
 			print({id:itemId,num:currentNum}).then(res=>{
 			print({id:itemId,num:currentNum}).then(res=>{
 				if(res.code == 1){
 				if(res.code == 1){
 					that.$msg(res.msg)
 					that.$msg(res.msg)
 				} else if(res.code == 0){
 				} else if(res.code == 0){
+					that.printLabelShow = false
+					that.printFocus = false
 					that.$msg(res.msg)
 					that.$msg(res.msg)
 				}
 				}
 			})
 			})
 		},
 		},
+    fastSubmit(){
+      this.dialogInputConfirm({index: 1})
+    },
     notModify(){
     notModify(){
       this.$msg('不可修改')
       this.$msg('不可修改')
     },
     },

+ 35 - 10
ghsApp/src/admin/item/list.vue

@@ -55,7 +55,7 @@
 			<div class="app-modal-input-wrap">
 			<div class="app-modal-input-wrap">
 			<div class="inp-list-line">
 			<div class="inp-list-line">
 				<div class="line-input">
 				<div class="line-input">
-				<input type="number" style="width:200upx;text-align:center;" :focus="printFocus" v-model="printNum" :adjust-position="false" class="inp-input" />
+				<input type="number" ref="input" style="width:61.8%;text-align:center;" @focus="focus" @blur="blur" :focus="printFocus" v-model="printNum" :adjust-position="false" class="inp-input" />
 				</div>
 				</div>
 			</div>
 			</div>
 			</div>
 			</div>
@@ -120,42 +120,67 @@ export default {
 		})
 		})
 	},
 	},
 	methods: {
 	methods: {
+		focus() {
+			//this.printFocus = true
+		},
+		blur() {
+			this.printFocus = false
+		},
 		doPrintLabel(id){
 		doPrintLabel(id){
 			this.printItemId = id
 			this.printItemId = id
-			//this.$refs.inputDialog.open()
 			this.printLabelShow = true
 			this.printLabelShow = true
+			this.printNum = null
+
+			setTimeout(x => {
+				this.$nextTick(() => this.setFocus()); // just watch out with going too fast !!!
+			}, 200);
+		},
+		setFocus() {
 			this.printFocus = true
 			this.printFocus = true
+
+			//let that=this;
+			//that.$refs.input.focus()
+			//that.$refs.input.$el.focus()
+			//that.$refs.input.$el.children[0].focus();
 		},
 		},
 		dialogInputConfirm(val) {
 		dialogInputConfirm(val) {
+			console.log(val)
 			let that=this;
 			let that=this;
 			if (val.index == 0) {
 			if (val.index == 0) {
-				this.printLabelShow = false
-				this.printFocus = true
+				that.printLabelShow = false
+				that.printFocus = false
 				return
 				return
-			} 
-			//this.$refs.inputDialog.close()
+			}
 
 
-			let currentNum = Number(this.printNum)
+			let currentNum = this.printNum
 			let itemId = this.printItemId
 			let itemId = this.printItemId
+			if (currentNum == null) {
+				that.$msg('打印数量未填写')
+				that.printFocus = true
+				return
+			}
 			if (currentNum <= 0) {
 			if (currentNum <= 0) {
 				that.$msg('打印数量不能小于等于0')
 				that.$msg('打印数量不能小于等于0')
+				that.printFocus = true
 				return
 				return
 			}
 			}
 			if (itemId == 0) {
 			if (itemId == 0) {
 				that.$msg('打印的花材id出错')
 				that.$msg('打印的花材id出错')
+				that.printLabelShow = false
+				that.printFocus = false
 				return
 				return
 			}
 			}
+
 			print({id:itemId,num:currentNum}).then(res=>{
 			print({id:itemId,num:currentNum}).then(res=>{
 				if(res.code == 1){
 				if(res.code == 1){
 					that.$msg(res.msg)
 					that.$msg(res.msg)
 				} else if(res.code == 0){
 				} else if(res.code == 0){
+					that.printLabelShow = false
+					that.printFocus = false
 					that.$msg(res.msg)
 					that.$msg(res.msg)
 				}
 				}
 			})
 			})
 		},
 		},
-		testFunc() {
-				console.log(1111)
-		},
 		moreToDo(item){
 		moreToDo(item){
 			let that=this;
 			let that=this;
 			let doList = ['复制花材', '销售记录']
 			let doList = ['复制花材', '销售记录']