Commit 1ffa2413 by LJM

移动端-按货品上架,增加批量扫描方式

parent 8b8cd68e
Showing with 107 additions and 4 deletions
<template> <template>
<view class="putaway"> <view class="putaway">
<view class="search-box row bothSide verCenter"> <view class="row bothSide verCenter">
<view class="search-box row bothSide verCenter" style="width: 80%;">
<view class="sn row rowCenter verCenter"> <view class="sn row rowCenter verCenter">
<picker @change="bindPickerChange($event)" :value="index" :range="array"> <picker @change="bindPickerChange($event)" :value="index" :range="array">
<view class="row verCenter"> <view class="row verCenter">
...@@ -13,8 +14,13 @@ ...@@ -13,8 +14,13 @@
<view class="row verCenter"> <view class="row verCenter">
<text class="iconfont icon-juxing1"></text> <text class="iconfont icon-juxing1"></text>
<template v-if="index == 0"> <template v-if="index == 0">
<template v-if="is_batch">
<input class="uni-input" placeholder="请扫描入库标签" placeholder-style="color:#919399" focus v-model="search_keyword" @input="handleInput(1, $event)" maxlength="15" />
</template>
<template v-else>
<input class="uni-input" placeholder="请扫描入库标签" placeholder-style="color:#919399" focus v-model="searchParams.search_keyword" @input="handleInput(1, $event)" maxlength="15" /> <input class="uni-input" placeholder="请扫描入库标签" placeholder-style="color:#919399" focus v-model="searchParams.search_keyword" @input="handleInput(1, $event)" maxlength="15" />
</template> </template>
</template>
<template v-else-if="index == 1"> <template v-else-if="index == 1">
<input class="uni-input" placeholder="请扫描或输入号码" placeholder-style="color:#919399" focus v-model="searchParams.search_keyword" @input="handleInput(2, $event)" /> <input class="uni-input" placeholder="请扫描或输入号码" placeholder-style="color:#919399" focus v-model="searchParams.search_keyword" @input="handleInput(2, $event)" />
</template> </template>
...@@ -22,6 +28,12 @@ ...@@ -22,6 +28,12 @@
<text class="iconfont icon-a-juxing11" @click="clearInput()" v-if="input_flag"></text> <text class="iconfont icon-a-juxing11" @click="clearInput()" v-if="input_flag"></text>
</view> </view>
</view> </view>
<view class="row verCenter">
<switch @change="switchChange" :checked="is_batch" color="#1969f9" style="transform:scale(0.7);width: 77rpx;" />
<text style="font-size: 24rpx;white-space: nowrap;">批量扫描</text>
</view>
</view>
<view class="list row bothSide" v-if="list.length > 0"> <view class="list row bothSide" v-if="list.length > 0">
<view class="box box-width" v-for="(item, index) in list" :key="index" :class="{ curr: filter_list[index] }"> <view class="box box-width" v-for="(item, index) in list" :key="index" :class="{ curr: filter_list[index] }">
<view class="check-box-icon" @click="filterChange(index)"></view> <view class="check-box-icon" @click="filterChange(index)"></view>
...@@ -128,6 +140,9 @@ import debounce from 'lodash/debounce'; ...@@ -128,6 +140,9 @@ import debounce from 'lodash/debounce';
export default { export default {
data() { data() {
return { return {
is_batch: false, //是否开启批量
history_id: [],
search_keyword: '',
is_submit: true, is_submit: true,
input_flag: false, input_flag: false,
page: 1, page: 1,
...@@ -145,7 +160,8 @@ export default { ...@@ -145,7 +160,8 @@ export default {
}, },
searchParams: { searchParams: {
search_type: 1, //入库批次号 全量 search_type: 1, //入库批次号 全量
search_keyword: '' search_keyword: '',
is_full_sweep: 1
} }
}; };
}, },
...@@ -169,8 +185,30 @@ export default { ...@@ -169,8 +185,30 @@ export default {
} else { } else {
this.index = e.detail.value; this.index = e.detail.value;
this.searchParams.search_type = Number(e.detail.value) + 1; this.searchParams.search_type = Number(e.detail.value) + 1;
//批量扫描关闭
if (this.index == 1) {
this.is_batch = false;
}
} }
}, },
switchChange(e) {
console.log('switch 发生 change 事件,携带值为', e.detail.value);
this.is_batch = e.detail.value;
this.searchParams.is_full_sweep = this.is_batch ? 1 : 0;
//重置相关数据
this.history_id = [];
this.list = [];
this.page = 1;
this.filter_id = [];
if (!this.is_batch) {
this.search_keyword = '';
this.searchParams.search_keyword = '';
}
this.getData();
},
showDrawer() { showDrawer() {
if (this.filter_id.length == 0) { if (this.filter_id.length == 0) {
uni.showToast({ uni.showToast({
...@@ -222,6 +260,24 @@ export default { ...@@ -222,6 +260,24 @@ export default {
this.$set(this.filter_list, index, (this.filter_list[index] = !this.filter_list[index])); this.$set(this.filter_list, index, (this.filter_list[index] = !this.filter_list[index]));
let filter_arr = this.findIndex(this.filter_list, true); let filter_arr = this.findIndex(this.filter_list, true);
this.filter_id = filter_arr.map(i => this.list[i].tally_id); this.filter_id = filter_arr.map(i => this.list[i].tally_id);
//开启了批量搜索,如果取消勾选则删除
if (this.is_batch) {
if (!this.filter_list[index]) {
this.history_id.splice(index, 1);
this.searchParams.search_keyword = this.history_id.join(',');
//搜索之后添加选择状态
this.getData(data => {
if (data.length > 0) {
const list = data;
list.forEach((item, index) => {
this.filterChange(index);
});
this.search_keyword = '';
}
});
}
}
}, },
/** /**
* 全选 * 全选
...@@ -242,6 +298,9 @@ export default { ...@@ -242,6 +298,9 @@ export default {
*/ */
clearInput() { clearInput() {
this.input_flag = false; this.input_flag = false;
if (this.is_batch) {
this.search_keyword = '';
}
this.searchParams.search_keyword = ''; this.searchParams.search_keyword = '';
this.getData(); this.getData();
}, },
...@@ -250,10 +309,51 @@ export default { ...@@ -250,10 +309,51 @@ export default {
* @param {Object} event * @param {Object} event
*/ */
handleInput: debounce(function(type, event) { handleInput: debounce(function(type, event) {
var val = event.target.value; let val = event.target.value;
this.searchParams.search_keyword = '';
if (val) { if (val) {
if (type == 1) { if (type == 1) {
//入库批次号 如果开启了批量搜索就不要跳转详情
this.input_flag = true; this.input_flag = true;
if (this.is_batch) {
this.search_keyword = '';
this.search_keyword = val;
this.input_flag = false;
//记录历史搜索批次号
if (!this.history_id.includes(val)) {
this.history_id.push(val);
}
this.searchParams.search_keyword = this.history_id.join(',');
//搜索之后添加选择状态
this.getData(data => {
if (data.length > 0) {
const list = data;
list.forEach((item, index) => {
this.filterChange(index);
});
this.search_keyword = '';
//若识别物料标签不在上架任务中,则弹窗提示:该物料不在上架任务中,需关闭弹窗才可继续操作
let isInList = list.some(function(item) {
return item.stock_in_batch_sn === val;
});
if (!isInList) {
uni.showModal({
title: '提示',
content: '该物料不在上架任务中',
confirmText: '关闭',
showCancel: false,
success: res => {
var index_history_id = this.history_id.indexOf(val);
this.history_id.splice(index_history_id, 1);
}
});
}
}
});
} else {
this.searchParams.search_keyword = val;
this.getData(); this.getData();
setTimeout(() => { setTimeout(() => {
if (this.list.length == 1) { if (this.list.length == 1) {
...@@ -262,7 +362,9 @@ export default { ...@@ -262,7 +362,9 @@ export default {
}); });
} }
}, 1000); }, 1000);
}
} else if (type == 2) { } else if (type == 2) {
//全量搜索
this.input_flag = true; this.input_flag = true;
this.getData(); this.getData();
} }
...@@ -280,11 +382,12 @@ export default { ...@@ -280,11 +382,12 @@ export default {
/** /**
* 获取列表数据 * 获取列表数据
*/ */
getData() { getData(callback) {
this.request(API.getPendingShelfByBatchSn, 'POST', { page: this.page, limit: this.limit, ...this.searchParams }, false).then(res => { this.request(API.getPendingShelfByBatchSn, 'POST', { page: this.page, limit: this.limit, ...this.searchParams }, false).then(res => {
if (res.code === 0) { if (res.code === 0) {
this.list = res.data.list; this.list = res.data.list;
this.filter_list = createArray(this.list.length, false); this.filter_list = createArray(this.list.length, false);
typeof callback == 'function' && callback(res.data.list);
} else { } else {
uni.showToast({ uni.showToast({
title: res.msg, title: res.msg,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment