|
|
@@ -13,6 +13,10 @@
|
|
|
@endcomponent
|
|
|
</span>
|
|
|
<div class="row m-2 card">
|
|
|
+ <audio src="{{asset('sound/warning_otherBarcode.mp3')}}" controls="controls" preload id="soundWarning" hidden>
|
|
|
+ </audio>
|
|
|
+ <audio src="{{asset('sound/ding.mp3')}}" controls="controls" preload id="soundDing" hidden>
|
|
|
+ </audio>
|
|
|
<div class="card-body col-12">
|
|
|
<div class="col-12">
|
|
|
<p class="text-muted small" v-if="inputMode=='regular'">常规:可输入效期,相同条码记录不会合并</p>
|
|
|
@@ -30,11 +34,11 @@
|
|
|
<div class="col-12 row">
|
|
|
<div class="col-6">
|
|
|
<div v-if="inputMode=='regular'">
|
|
|
- <div class="btn btn-sm btn-outline-primary">手动输入</div>
|
|
|
- <div class="btn btn-sm btn-outline-danger">扫描输入</div>
|
|
|
+ <div class="btn btn-sm btn-outline-primary" v-if="status.barcodeDisable" @click="status.barcodeDisable=false">手动输入</div>
|
|
|
+ <div class="btn btn-sm btn-outline-danger" v-if="!status.barcodeDisable" @click="status.barcodeDisable=true">扫描输入</div>
|
|
|
</div>
|
|
|
- <input type="text" id="barcode" class="form-control" placeholder="扫入条码"
|
|
|
- {{--:disabled="status.barcodeDisable" @focusin="focusOutDocument" @focusout="focusDocument" v-model="inputting.barcode"--}}>
|
|
|
+ <input type="text" id="barcode" class="form-control" placeholder="扫入条码" :class="inputMode=='regular' ? '' : 'mt-2'"
|
|
|
+ :disabled="status.barcodeDisable" v-model="inputting.barcode" {{-- @focusin="focusOutDocument" @focusout="focusDocument" --}}>
|
|
|
|
|
|
<div v-if="inputMode=='regular'">
|
|
|
<div class="card-title">生产日期:</div>
|
|
|
@@ -50,7 +54,7 @@
|
|
|
<div class="card-title" id="amountLabel">手动输入数量:</div>
|
|
|
<div class="input-group mt-n2 mb-2">
|
|
|
<input type="number" id="amount" style='height: 40px;font-size: 1.6em;color:blue;font-weight: bolder;padding: 3px;text-align: center' class="form-control" placeholder=""
|
|
|
- {{--:disabled="status.amountDisable" v-model="inputting.amount" @focusin="focusOutDocument" @focusout="focusDocument" @keyup="oninputEnter"--}}>
|
|
|
+ :disabled="status.amountDisable" v-model="inputting.amount"{{-- @focusin="focusOutDocument" @focusout="focusDocument" @keyup="oninputEnter"--}}>
|
|
|
</div>
|
|
|
|
|
|
<div class="card-title">格口号:</div>
|
|
|
@@ -63,7 +67,7 @@
|
|
|
{{--v-model="inputting.batch_number" @focusin="focusOutDocument" @focusout="focusDocument" @keyup="oninputEnter"--}}>
|
|
|
</div>
|
|
|
</div>
|
|
|
- <div class="col-12" v-if="commitButtonVisible && inputMode=='regular'" >
|
|
|
+ <div class="col-12" v-if="status.commitButtonVisible && inputMode=='regular'" >
|
|
|
<button class="btn btn-success btn form-control" {{--@click="commitGoods"--}}>确定</button>
|
|
|
</div>
|
|
|
</div>
|
|
|
@@ -152,7 +156,17 @@
|
|
|
@endforeach
|
|
|
],
|
|
|
inputMode : 'regular',
|
|
|
- commitButtonVisible:false,
|
|
|
+ status:{
|
|
|
+ barcodeDisable : true,
|
|
|
+ commitButtonVisible:false,
|
|
|
+ scanEndInputted:false,
|
|
|
+ amountDisable : false,
|
|
|
+ },
|
|
|
+ focusing : 'document',
|
|
|
+ inputting:{
|
|
|
+ barcode : '',
|
|
|
+ amount : '',
|
|
|
+ },
|
|
|
},
|
|
|
mounted(){
|
|
|
$('#container').removeClass('d-none');
|
|
|
@@ -180,11 +194,191 @@
|
|
|
restorationColumn: 'id',
|
|
|
});
|
|
|
header.init();
|
|
|
+ this.scanListening();
|
|
|
},
|
|
|
methods:{
|
|
|
switchMenu(menuName){
|
|
|
this.inputMode = menuName;
|
|
|
- }
|
|
|
+ this.inputting.barcode='';
|
|
|
+ if (menuName === 'regular') {
|
|
|
+ this.amountDisable = false;
|
|
|
+ $('#amountLabel').text('输入数量:');
|
|
|
+ } else {
|
|
|
+ this.amountDisable = true;
|
|
|
+ $('#amountLabel').text('自动扫入数量:');
|
|
|
+ }
|
|
|
+ },
|
|
|
+ scanListening: function () {
|
|
|
+ let _this = this;
|
|
|
+ $(document).on('keypress', function (e) {
|
|
|
+ if(_this.focusing!=='document'){return}
|
|
|
+ if(!_this.status.barcodeDisable){return}
|
|
|
+ if (e.keyCode !== 13) {
|
|
|
+ if(_this.status.scanEndInputted){
|
|
|
+ _this.inputting.barcode='';
|
|
|
+ _this.status.scanEndInputted=false;
|
|
|
+ }
|
|
|
+ _this.inputting.barcode += String.fromCharCode(e.keyCode);
|
|
|
+ } else {
|
|
|
+ if(_this.inputting.barcode.length<=1){
|
|
|
+ window.tempTip.setDuration(4500);
|
|
|
+ window.tempTip.show('未扫入条码,请检查扫码枪设置,尝试调至“直接键盘输出”模式');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ _this.status.scanEndInputted = true;
|
|
|
+ _this.showCommitButton();
|
|
|
+ _this.autoFillBin();
|
|
|
+ switch(_this.inputMode){
|
|
|
+ case 'increasing': _this.commitGoodsOnIncreasingMode();break;
|
|
|
+ case 'multiIncreasing': _this.commitGoodsOnMultiIncreasingMode();break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+ showCommitButton: function () {
|
|
|
+ if(this.inputting.barcode && this.inputting.amount && this.inputting.bin_number){
|
|
|
+ this.commitButtonVisible=true;
|
|
|
+ }
|
|
|
+ },
|
|
|
+ autoFillBin: function () {
|
|
|
+ let data = this;
|
|
|
+ let isNotRepeatingBarcode=this.goodses.every(function(goods){
|
|
|
+ if(goods.barcode===data.inputting.barcode){
|
|
|
+ data.inputting.bin=goods.bin;
|
|
|
+ data.status.binDisable=true;
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ });
|
|
|
+ if(isNotRepeatingBarcode){
|
|
|
+ data.status.binDisable=false;
|
|
|
+ }
|
|
|
+ },
|
|
|
+ commitGoodsOnIncreasingMode: function () {
|
|
|
+ let data = this;
|
|
|
+
|
|
|
+ function doIt() {
|
|
|
+ let repeatedBarcode = data.repeatedIncreasingBarcodeFromSaved();
|
|
|
+
|
|
|
+ function increase() {
|
|
|
+ data.inputting.bin = repeatedBarcode.bin;
|
|
|
+ repeatedBarcode.amount++;
|
|
|
+ data.inputting.amount = repeatedBarcode.amount;
|
|
|
+ window.tempTip.setDuration(500);
|
|
|
+ window.tempTip.showSuccess(repeatedBarcode.amount);
|
|
|
+ data.focusDocument();
|
|
|
+ data.audioDing();
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!repeatedBarcode) {
|
|
|
+ data.focusOutDocument();
|
|
|
+ data.alertVibrate();
|
|
|
+ window.tempTip.setInputType('number');
|
|
|
+ window.tempTip.inputVal('该商品第一件递增请输入隔口号:', function (bin) {
|
|
|
+ if (bin === '') {
|
|
|
+ window.tempTip.setDuration(1500);
|
|
|
+ window.tempTip.show('未输入隔口号,请重新扫描');
|
|
|
+ data.alertVibrate();
|
|
|
+ data.focusDocument();
|
|
|
+ return
|
|
|
+ }
|
|
|
+ data.inputting.bin = bin;
|
|
|
+ data.inputting.amount = 1;
|
|
|
+ data.goodses.unshift(JSON.parse(JSON.stringify(data.inputting)));
|
|
|
+ data.status.binDisable = true;
|
|
|
+ window.tempTip.setDuration(500);
|
|
|
+ window.tempTip.showSuccess('保存成功');
|
|
|
+ data.focusDocument();
|
|
|
+ data.audioDing();
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ increase();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (data.lastScannedBarcode !== data.inputting.barcode && data.lastScannedBarcode) {
|
|
|
+ data.audioWarning_otherBarcode();
|
|
|
+ data.focusOutDocument();
|
|
|
+ window.tempTip.confirm('扫到其它条码,是否切换至新条码并记录?', doIt, function () {
|
|
|
+ data.inputting.barcode = data.lastScannedBarcode;
|
|
|
+ // data.cleanInputs();
|
|
|
+ data.focusDocument();
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ doIt()
|
|
|
+ }
|
|
|
+ },
|
|
|
+ commitGoodsOnMultiIncreasingMode: function () {
|
|
|
+ let data = this;
|
|
|
+ let repeatedBarcode=this.repeatedIncreasingBarcodeFromSaved();
|
|
|
+ function increase(){
|
|
|
+ data.inputting.bin=repeatedBarcode.bin;
|
|
|
+ repeatedBarcode.amount++;
|
|
|
+ data.inputting.amount=repeatedBarcode.amount;
|
|
|
+ window.tempTip.setDuration(500);
|
|
|
+ window.tempTip.showSuccess(repeatedBarcode.amount);
|
|
|
+ data.focusDocument();
|
|
|
+ data.audioDing();
|
|
|
+ }
|
|
|
+ if(!repeatedBarcode){
|
|
|
+ data.focusOutDocument();
|
|
|
+ data.alertVibrate();
|
|
|
+ window.tempTip.setInputType('number');
|
|
|
+ window.tempTip.inputVal('该商品第一件递增请输入隔口号:',function(bin){
|
|
|
+ if(bin===''){
|
|
|
+ window.tempTip.setDuration(1500);
|
|
|
+ window.tempTip.show('未输入隔口号,请重新扫描');
|
|
|
+ data.alertVibrate();
|
|
|
+ data.focusDocument();return}
|
|
|
+ data.inputting.bin=bin;
|
|
|
+ data.inputting.amount=1;
|
|
|
+ data.goodses.unshift(JSON.parse(JSON.stringify(data.inputting)));
|
|
|
+ data.status.binDisable=true;
|
|
|
+ window.tempTip.setDuration(500);
|
|
|
+ window.tempTip.showSuccess('保存成功');
|
|
|
+ data.focusDocument();
|
|
|
+ data.audioDing();
|
|
|
+ })
|
|
|
+ }else{
|
|
|
+ increase();
|
|
|
+ }
|
|
|
+ },
|
|
|
+ oninputEnter:function(e){
|
|
|
+ if (e.key === 'Enter') {
|
|
|
+ this.focusDocument();
|
|
|
+ }
|
|
|
+ },
|
|
|
+ focusDocument: function () {
|
|
|
+ this.focusing = 'document';
|
|
|
+ this.showCommitButton();
|
|
|
+ },
|
|
|
+ focusOutDocument: function () {
|
|
|
+ this.focusing = '';
|
|
|
+ this.autoFillBin();
|
|
|
+ },
|
|
|
+ audioWarning_otherBarcode: function () {
|
|
|
+ let audio = document.getElementById('soundWarning');
|
|
|
+ audio.currentTime = 0;//重新播放
|
|
|
+ if(audio.paused){
|
|
|
+ audio.play();// 播放
|
|
|
+ }
|
|
|
+ this.alertVibrate();
|
|
|
+
|
|
|
+ },
|
|
|
+ audioDing: function () {
|
|
|
+ let audio = document.getElementById('soundDing');
|
|
|
+ audio.currentTime = 0;//重新播放
|
|
|
+ audio.play();// 播放
|
|
|
+ //手机震动
|
|
|
+ function startVibrate(duration) {
|
|
|
+ if (navigator.vibrate) {
|
|
|
+ navigator.vibrate(duration);
|
|
|
+ } else if (navigator.webkitVibrate) {
|
|
|
+ navigator.webkitVibrate(duration);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ startVibrate(500);
|
|
|
+ },
|
|
|
},
|
|
|
});
|
|
|
</script>
|