Commit 1ffa2413 by LJM

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

parent 8b8cd68e
Showing with 130 additions and 27 deletions
<template>
<view class="putaway">
<view class="search-box row bothSide verCenter">
<view class="sn row rowCenter verCenter">
<picker @change="bindPickerChange($event)" :value="index" :range="array">
<view class="row bothSide verCenter">
<view class="search-box row bothSide verCenter" style="width: 80%;">
<view class="sn row rowCenter verCenter">
<picker @change="bindPickerChange($event)" :value="index" :range="array">
<view class="row verCenter">
<view class="uni-input">{{ array[index] }}</view>
<view class="uni-arrow"></view>
</view>
</picker>
</view>
<view class="search-bar row bothSide verCenter">
<view class="row verCenter">
<view class="uni-input">{{ array[index] }}</view>
<view class="uni-arrow"></view>
<text class="iconfont icon-juxing1"></text>
<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" />
</template>
</template>
<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)" />
</template>
</view>
</picker>
</view>
<view class="search-bar row bothSide verCenter">
<view class="row verCenter">
<text class="iconfont icon-juxing1"></text>
<template v-if="index == 0">
<input class="uni-input" placeholder="请扫描入库标签" placeholder-style="color:#919399" focus v-model="searchParams.search_keyword" @input="handleInput(1, $event)" maxlength="15" />
</template>
<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)" />
</template>
<text class="iconfont icon-a-juxing11" @click="clearInput()" v-if="input_flag"></text>
</view>
<text class="iconfont icon-a-juxing11" @click="clearInput()" v-if="input_flag"></text>
</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="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>
......@@ -128,6 +140,9 @@ import debounce from 'lodash/debounce';
export default {
data() {
return {
is_batch: false, //是否开启批量
history_id: [],
search_keyword: '',
is_submit: true,
input_flag: false,
page: 1,
......@@ -145,7 +160,8 @@ export default {
},
searchParams: {
search_type: 1, //入库批次号 全量
search_keyword: ''
search_keyword: '',
is_full_sweep: 1
}
};
},
......@@ -169,8 +185,30 @@ export default {
} else {
this.index = e.detail.value;
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() {
if (this.filter_id.length == 0) {
uni.showToast({
......@@ -222,6 +260,24 @@ export default {
this.$set(this.filter_list, index, (this.filter_list[index] = !this.filter_list[index]));
let filter_arr = this.findIndex(this.filter_list, true);
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 {
*/
clearInput() {
this.input_flag = false;
if (this.is_batch) {
this.search_keyword = '';
}
this.searchParams.search_keyword = '';
this.getData();
},
......@@ -250,19 +309,62 @@ export default {
* @param {Object} event
*/
handleInput: debounce(function(type, event) {
var val = event.target.value;
let val = event.target.value;
this.searchParams.search_keyword = '';
if (val) {
if (type == 1) {
//入库批次号 如果开启了批量搜索就不要跳转详情
this.input_flag = true;
this.getData();
setTimeout(() => {
if (this.list.length == 1) {
uni.navigateTo({
url: '/pages/putaway/single?stock_in_batch_sn=' + this.list[0].stock_in_batch_sn + '&tally_id=' + this.list[0].tally_id
});
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);
}
}, 1000);
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();
setTimeout(() => {
if (this.list.length == 1) {
uni.navigateTo({
url: '/pages/putaway/single?stock_in_batch_sn=' + this.list[0].stock_in_batch_sn + '&tally_id=' + this.list[0].tally_id
});
}
}, 1000);
}
} else if (type == 2) {
//全量搜索
this.input_flag = true;
this.getData();
}
......@@ -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 => {
if (res.code === 0) {
this.list = res.data.list;
this.filter_list = createArray(this.list.length, false);
typeof callback == 'function' && callback(res.data.list);
} else {
uni.showToast({
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