Commit 48cd7771 by LJM

bug

parent 83bac40f
...@@ -188,245 +188,254 @@ ...@@ -188,245 +188,254 @@
</view> </view>
</view> </view>
</view> </view>
<view class="fix-btn row verCenter"><view class="btn1 row rowCenter verCenter" @click="stockShelfByBatchSnAction()">上 架</view></view> <view class="fix-btn row verCenter">
<view class="btn1 row rowCenter verCenter" @click="stockShelfByBatchSnAction()">上 架</view>
</view>
</view> </view>
</template> </template>
<script> <script>
import { API } from '@/util/api.js'; import { API } from '@/util/api.js';
import debounce from 'lodash/debounce'; import debounce from 'lodash/debounce';
export default { export default {
data() { data() {
return { return {
isZY: false, //区分是否自营 isZY: false, //区分是否自营
isInputFocus: false, isInputFocus: false,
is_submit: true, is_submit: true,
input_flag: false, input_flag: false,
index: 0, index: 0,
curr: 0, curr: 0,
item: ['货品信息', '其他信息'], item: ['货品信息', '其他信息'],
array: ['入库批次号'], array: ['入库批次号'],
detail: {}, detail: {},
workingRuleList: {}, //,//推荐库位 workingRuleList: {}, //,//推荐库位
workingRule: '', //推荐库位 workingRule: '', //推荐库位
searchParams: { searchParams: {
stock_in_batch_sn: '' //入库批次 stock_in_batch_sn: '' //入库批次
}, },
formParams: { formParams: {
position_code: '', //库位编码 position_code: '', //库位编码
qty_on_shelf: '', qty_on_shelf: '',
tally_id: '' tally_id: ''
} }
}; };
},
onLoad(options) {
this.searchParams.stock_in_batch_sn = options.stock_in_batch_sn;
this.formParams.tally_id = options.tally_id;
},
onShow() {
this.getData();
},
mounted() {
setTimeout(() => {
this.isInputFocus = true;
}, 2000);
},
methods: {
tab(index) {
this.curr = index;
}, },
/** onLoad(options) {
* 单号搜索 this.searchParams.stock_in_batch_sn = options.stock_in_batch_sn;
* @param {Object} event this.formParams.tally_id = options.tally_id;
*/
handleInput: debounce(function(event) {
var val = event.target.value;
if (val) {
this.input_flag = true;
} else {
this.input_flag = false;
}
this.getData();
}, 500),
/**
* 清空数据
*/
clearInput() {
this.input_flag = false;
this.searchParams.stock_in_batch_sn = '';
this.getData();
}, },
/** onShow() {
* 监听上架数量 this.getData();
*/
inputNumChange: debounce(function(event, pending_shelf_qty) {
//如果是退货入库就不请求推荐规则
if (this.formParams.position_code && this.formParams.qty_on_shelf && this.detail.stock_in_type != 2 && this.detail.quality == 1) {
this.getWorkingRuleList();
}
var pending_shelf_qty = Number(pending_shelf_qty);
var val = event.target.value * 1;
if (val > pending_shelf_qty) {
this.formParams.qty_on_shelf = pending_shelf_qty;
}
}, 500),
/**
* 监听库位编码
*/
inputPositionCodeChange: debounce(function(event) {
this.getWhPositionList();
//如果是退货入库就不请求推荐规则
if (this.formParams.position_code && this.formParams.qty_on_shelf && this.detail.stock_in_type != 2 && this.detail.quality == 1) {
this.getWorkingRuleList();
}
}, 500),
bindPickerChange: function(e, type) {
console.log('picker发送选择改变,携带值为', e.detail.value);
this.index = e.detail.value;
}, },
/** mounted() {
*点击推荐库位就赋值到库位 setTimeout(() => {
*/ this.isInputFocus = true;
assignment(val) { }, 2000);
this.formParams.position_code = val;
}, },
/** methods: {
* 获取详情数据 tab(index) {
*/ this.curr = index;
getData() { },
this.request(API.getStockShelfInfoByBatchSn, 'POST', { ...this.searchParams }, false).then(res => { /**
if (res.code === 0) { * 单号搜索
this.detail = res.data; * @param {Object} event
this.formParams.qty_on_shelf = res.data.pending_shelf_qty; */
this.formParams.tally_id = res.data.tally_id; handleInput: debounce(function(event) {
this.isZY = res.data.sku_id > 0 ? true : false; var val = event.target.value;
if (!this.isZY) { if (val) {
this.item.splice(1, 1); this.input_flag = true;
} else {
this.input_flag = false;
}
this.getData();
}, 500),
/**
* 清空数据
*/
clearInput() {
this.input_flag = false;
this.searchParams.stock_in_batch_sn = '';
this.getData();
},
/**
* 监听上架数量
*/
inputNumChange: debounce(function(event, pending_shelf_qty) {
//如果是退货入库就不请求推荐规则
if (this.formParams.position_code && this.formParams.qty_on_shelf && this.detail.stock_in_type != 2 && this.detail.quality == 1) {
this.getWorkingRuleList();
}
var pending_shelf_qty = Number(pending_shelf_qty);
var val = event.target.value * 1;
if (val > pending_shelf_qty) {
this.formParams.qty_on_shelf = pending_shelf_qty;
}
}, 500),
/**
* 监听库位编码
*/
inputPositionCodeChange: debounce(function(event) {
this.getWhPositionList();
//如果是退货入库就不请求推荐规则
if (this.formParams.position_code && this.formParams.qty_on_shelf && this.detail.stock_in_type != 2 && this.detail.quality == 1) {
this.getWorkingRuleList();
}
}, 500),
bindPickerChange: function(e, type) {
console.log('picker发送选择改变,携带值为', e.detail.value);
this.index = e.detail.value;
},
/**
*点击推荐库位就赋值到库位
*/
assignment(val) {
this.formParams.position_code = val;
},
/**
* 获取详情数据
*/
getData() {
this.request(API.getStockShelfInfoByBatchSn, 'POST', { ...this.searchParams }, false).then(res => {
if (res.code === 0) {
this.detail = res.data;
this.formParams.qty_on_shelf = res.data.pending_shelf_qty;
this.formParams.tally_id = res.data.tally_id;
this.isZY = res.data.sku_id > 0 ? true : false;
if (!this.isZY) {
this.item.splice(1, 1);
}
if (res.data.stock_in_type != 2) {
this.getWorkingRuleList();
} else {
//如果为不良品就不请求库位接口
if (res.data.quality == 1) {
this.getWhPositionList(1);
}
}
} }
if (res.data.stock_in_type != 2) { });
this.getWorkingRuleList(); },
} else { /**
//如果为不良品就不请求库位接口 * @param {Object} type
if (res.data.quality == 1) { * type 退货入库
this.getWhPositionList(1); */
getWhPositionList(type) {
this.request(API.getWhPositionList, 'POST', { warehouse_id: this.detail.warehouse_id, stock_in_type: this.detail.stock_in_type }, false).then(res => {
if (res.code === 0) {
if (type == 1) {
this.workingRuleList.prefix = '推荐';
this.workingRule = res.data.list.map(item => item.position_code).join(',');
} else {
var position_code = this.formParams.position_code;
this.is_submit = res.data.list.some(function(obj) {
return obj.position_code === position_code;
});
} }
} else {
uni.showToast({
title: res.msg,
icon: 'error'
});
} }
} });
}); },
}, /**
/** * 查询可用的上架规则
* @param {Object} type */
* type 退货入库 getWorkingRuleList() {
*/ var params = {
getWhPositionList(type) { num: this.formParams.qty_on_shelf,
this.request(API.getWhPositionList, 'POST', { warehouse_id: this.detail.warehouse_id, stock_in_type: this.detail.stock_in_type }, false).then(res => { warehouse_id: this.detail.warehouse_id,
if (res.code === 0) { com_name: this.detail.com_name,
if (type == 1) { supplier_name: this.detail.supplier_name,
this.workingRuleList.prefix = '推荐'; stock_type: this.detail.stock_type || '',
this.workingRule = res.data.list.map(item => item.position_code).join(','); sku_id: this.detail.sku_id || '',
picking_other_attr: this.detail.picking_other_attr || '',
picking_mode: this.detail.picking_mode || '',
packing: this.detail.packing || '',
encap: this.detail.encap || '',
stock_in_batch_sn: this.detail.stock_in_batch_sn || ''
};
this.request(API.getWorkingRuleList, 'POST', params, false).then(res => {
if (res.code === 0) {
if (res.data.list.length > 0) {
this.workingRuleList = res.data;
this.workingRule = res.data.list.map(item => item.position_code).join(',');
} else {
this.workingRuleList = '';
this.workingRule = '';
}
} else { } else {
var position_code = this.formParams.position_code; uni.showToast({
this.is_submit = res.data.list.some(function(obj) { title: res.msg,
return obj.position_code === position_code; icon: 'error'
}); });
} }
} else { });
},
/**
* 上架
*/
stockShelfByBatchSnAction() {
if (!this.formParams.qty_on_shelf) {
uni.showToast({ uni.showToast({
title: res.msg, title: '请填写上架数量',
icon: 'error' icon: 'error'
}); });
return false;
} }
}); if (!this.formParams.position_code) {
},
/**
* 查询可用的上架规则
*/
getWorkingRuleList() {
var params = {
num: this.formParams.qty_on_shelf,
warehouse_id: this.detail.warehouse_id,
com_name: this.detail.com_name,
supplier_name: this.detail.supplier_name
};
this.request(API.getWorkingRuleList, 'POST', params, false).then(res => {
if (res.code === 0) {
if (res.data.list.length > 0) {
this.workingRuleList = res.data;
this.workingRule = res.data.list.map(item => item.position_code).join(',');
} else {
this.workingRuleList = '';
this.workingRule = '';
}
} else {
uni.showToast({ uni.showToast({
title: res.msg, title: '请输入库位编码',
icon: 'error' icon: 'error'
}); });
return false;
} }
}); var pending_shelf_qty = Number(this.detail.pending_shelf_qty);
},
/**
* 上架
*/
stockShelfByBatchSnAction() {
if (!this.formParams.qty_on_shelf) {
uni.showToast({
title: '请填写上架数量',
icon: 'error'
});
return false;
}
if (!this.formParams.position_code) {
uni.showToast({
title: '请输入库位编码',
icon: 'error'
});
return false;
}
var pending_shelf_qty = Number(this.detail.pending_shelf_qty);
this.request(API.stockShelfByBatchSnAction, 'POST', this.formParams, true).then(res => { this.request(API.stockShelfByBatchSnAction, 'POST', this.formParams, true).then(res => {
if (res.code === 0) { if (res.code === 0) {
if (Number(this.formParams.qty_on_shelf) == pending_shelf_qty) { if (Number(this.formParams.qty_on_shelf) == pending_shelf_qty) {
uni.showToast({ uni.showToast({
title: '上架成功', title: '上架成功',
icon: 'success' icon: 'success'
}); });
setTimeout(() => { setTimeout(() => {
uni.navigateBack({ uni.navigateBack({
delta: 1 delta: 1
});
}, 2000);
} else {
uni.showModal({
title: '提示',
content: '上架成功,点击确定可继续上架',
showCancel: true,
success: res => {
if (res.confirm) {
this.getData();
} else if (res.cancel) {
uni.navigateBack({
delta: 1
});
}
}
}); });
}, 2000); }
} else { } else {
uni.showModal({ uni.showModal({
title: '提示', itle: '提示',
content: '上架成功,点击确定可继续上架', content: res.msg,
showCancel: true, showCancel: false
success: res => {
if (res.confirm) {
this.getData();
} else if (res.cancel) {
uni.navigateBack({
delta: 1
});
}
}
}); });
} }
} else { });
uni.showModal({ }
itle: '提示',
content: res.msg,
showCancel: false
});
}
});
} }
} };
};
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
@import '@/assets/css/putaway/single.scss'; @import '@/assets/css/putaway/single.scss';
</style> </style>
\ No newline at end of file
...@@ -44,7 +44,9 @@ ...@@ -44,7 +44,9 @@
</view> </view>
</template> </template>
<template v-else-if="curr == 1"> <template v-else-if="curr == 1">
<view class="box-info row bothSide"><view class="title row bothSide verCenter">容器:</view></view> <view class="box-info row bothSide">
<view class="title row bothSide verCenter">容器:</view>
</view>
<view class="search-bar row bothSide verCenter"> <view class="search-bar row bothSide verCenter">
<view class="row verCenter"> <view class="row verCenter">
<text class="iconfont icon-juxing1"></text> <text class="iconfont icon-juxing1"></text>
...@@ -133,7 +135,9 @@ ...@@ -133,7 +135,9 @@
<text class="label">仓库备注:</text> <text class="label">仓库备注:</text>
<text class="desc">{{ item.remark }}</text> <text class="desc">{{ item.remark }}</text>
</view> </view>
<view class="row" style="justify-content: flex-end;width: 100%;"><view class="btn row rowCenter verCenter" @click="showDrawer(1, item)">选择</view></view> <view class="row" style="justify-content: flex-end;width: 100%;">
<view class="btn row rowCenter verCenter" @click="showDrawer(1, item)">选择</view>
</view>
</view> </view>
</view> </view>
<!-- 无数据展示 --> <!-- 无数据展示 -->
...@@ -612,618 +616,555 @@ ...@@ -612,618 +616,555 @@
</template> </template>
<script> <script>
import { API } from '@/util/api.js'; import { API } from '@/util/api.js';
import { createArray } from '@/util/util.js'; import { createArray } from '@/util/util.js';
import debounce from 'lodash/debounce'; import debounce from 'lodash/debounce';
export default {
data() {
return {
isFocus: true,
is_batch: true, //是否开启批量
history_id: [], //批量记录id
search_keyword: '', //批量搜索值
noexebshowFalg: true, //控制是否会触发生命周期
company_id: uni.getStorageSync('company_id') || '',
stock_out_sn: '', //标题显示出库单号
lock_ids: [], //出库id集合
all_flag: false, //全选标记
input_flag_box_name: false,
input_flag_stock_in_batch_sn: false,
input_flag_container_sn: false,
page: 1,
limit: 1000,
curr: 0,
index: -1,
warehouse_id: '', //仓库id
array: ['深圳市猎芯科技有限公司', '深贸电子有限公司'],
itemArr: ['按货品复核', '按容器复核'],
print_style: ['基本样式', '不带D/C'],
print_style_index: 0,
list: [],
filter_list: [], //筛选已选中的列表
filter_id: [], //过滤处理的id
detail: {}, //按货品拣货详情
detailContainer: {}, //按容器拣货详情
stock_out_item_ids: '', //复核任务ids
packList: [], //箱信息
packConfigList: [], //箱配置列表
image_list: [], //图片列表
maxNum: 10, //最大上传图片数量
searchParams: {
stock_out_id: '',
box_name: '001',
stock_in_batch_sn: '',
container_sn: ''
},
formParams: {
recheck_qty: ''
},
//打印货品标签参数集合
rePrintTagParams: {
stock_out_item_id: '',
print_type: 0,
recheck_num: ''
}
};
},
onNavigationBarButtonTap(e) {
if (e.index == 0) {
uni.navigateTo({
url: '/pages/stockRecheck/record?stock_out_sn=' + this.stock_out_sn
});
}
},
onLoad(options) {
this.searchParams.stock_out_id = options.stock_out_id || '';
this.warehouse_id = options.warehouse_id || '';
this.stock_out_sn = options.stock_out_sn || '';
},
onShow() {
if (this.noexebshowFalg) {
this.getData();
}
},
methods: {
/**
* 批量扫描监听
* @param {Object} e
*/
switchChange(e) {
console.log('switch 发生 change 事件,携带值为', e.detail.value);
this.is_batch = e.detail.value;
//重置相关数据
this.history_id = [];
this.list = [];
this.page = 1;
this.filter_id = [];
this.search_keyword = ''; export default {
this.searchParams.stock_in_batch_sn = ''; data() {
return {
//再次获取焦点 isFocus: true,
this.isFocus = false; is_batch: true, //是否开启批量
setTimeout(() => { history_id: [], //批量记录id
this.isFocus = true; search_keyword: '', //批量搜索值
}, 1000); noexebshowFalg: true, //控制是否会触发生命周期
company_id: uni.getStorageSync('company_id') || '',
this.getData(); stock_out_sn: '', //标题显示出库单号
}, lock_ids: [], //出库id集合
/** all_flag: false, //全选标记
* 打印货品标签样式切换监听 input_flag_box_name: false,
input_flag_stock_in_batch_sn: false,
* @param {Object} e input_flag_container_sn: false,
*/ page: 1,
bindPickerChange: function(e) { limit: 1000,
this.print_style_index = e.detail.value; curr: 0,
this.rePrintTagParams.print_type = e.detail.value; index: -1,
}, warehouse_id: '', //仓库id
bindPickerBoxChange: function(e, index) { array: ['深圳市猎芯科技有限公司', '深贸电子有限公司'],
console.log('picker发送选择改变,携带值为', e.detail.value); itemArr: ['按货品复核', '按容器复核'],
this.index = e.detail.value; print_style: ['基本样式', '不带D/C'],
var packConfigList = this.packConfigList[e.detail.value]; print_style_index: 0,
this.$set(this.packList[index], 'length', packConfigList.length); list: [],
this.$set(this.packList[index], 'width', packConfigList.width); filter_list: [], //筛选已选中的列表
this.$set(this.packList[index], 'hight', packConfigList.hight); filter_id: [], //过滤处理的id
}, detail: {}, //按货品拣货详情
/** detailContainer: {}, //按容器拣货详情
* 找出false对应的下标 stock_out_item_ids: '', //复核任务ids
* @param {Object} arr packList: [], //箱信息
* @param {Object} target packConfigList: [], //箱配置列表
*/ image_list: [], //图片列表
findIndex(arr, target) { maxNum: 10, //最大上传图片数量
const result = []; searchParams: {
arr.map((item, index) => { stock_out_id: '',
if (item === target) { box_name: '001',
result.push(index); stock_in_batch_sn: '',
container_sn: ''
},
formParams: {
recheck_qty: ''
},
//打印货品标签参数集合
rePrintTagParams: {
stock_out_item_id: '',
print_type: 0,
recheck_num: ''
} }
}); };
return result;
}, },
/** onNavigationBarButtonTap(e) {
* 筛选过滤出选中的元素 if (e.index == 0) {
*/ uni.navigateTo({
filterChange(index) { url: '/pages/stockRecheck/record?stock_out_sn=' + this.stock_out_sn
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].stock_out_item_id);
//开启了批量搜索,如果取消勾选则删除
if (this.is_batch) {
if (!this.filter_list[index]) {
this.history_id.splice(index, 1);
this.searchParams.stock_in_batch_sn = this.history_id.join(',');
//当检测到全部取消的时候不应该调用接口
if (this.history_id.length == 0) {
this.list = [];
this.search_keyword = '';
return false;
}
//搜索之后添加选择状态
this.getData(data => {
if (data.length > 0) {
const list = data;
list.forEach((item, index) => {
this.filterChange(index);
});
this.search_keyword = '';
}
});
}
}
},
/**
* 全选
*/
allChnage() {
this.all_flag = !this.all_flag;
this.filter_list = createArray(this.list.length, this.all_flag);
if (this.all_flag) {
this.filter_id = this.list.map(function(item) {
return item.stock_out_item_id;
}); });
} else {
this.filter_id = [];
} }
}, },
/** onLoad(options) {
*打印货品标签 this.searchParams.stock_out_id = options.stock_out_id || '';
*/ this.warehouse_id = options.warehouse_id || '';
rePrintTag(type) { this.stock_out_sn = options.stock_out_sn || '';
if (type == 1) { },
this.rePrintTagParams.stock_out_item_id = this.detail.stock_out_item_id; onShow() {
this.rePrintTagParams.recheck_num = this.formParams.recheck_qty; if (this.noexebshowFalg) {
} else { this.getData();
if (this.filter_id.length == 0) {
uni.showToast({
title: '请勾选数据',
icon: 'error'
});
return false;
}
this.rePrintTagParams.stock_out_item_id = this.filter_id.join(','); //出库明细ids
} }
this.request(API.RePrintTag, 'POST', this.rePrintTagParams, true).then(res => {
if (res.code === 0) {
uni.showToast({
title: '操作成功',
icon: 'success'
});
} else {
uni.showToast({
title: res.msg,
icon: 'none'
});
}
});
}, },
/** methods: {
* 选择图片 /**
*/ * 批量扫描监听
chooseImageChange() { * @param {Object} e
this.noexebshowFalg = false; */
// 使用 chooseImage选择图片 switchChange(e) {
uni.chooseImage({ console.log('switch 发生 change 事件,携带值为', e.detail.value);
count: this.maxNum, this.is_batch = e.detail.value;
sizeType: ['original', 'compressed'], //重置相关数据
sourceType: ['album', 'camera'], this.history_id = [];
success: chooseImageRes => { this.list = [];
console.log('选择图片成功:', chooseImageRes); this.page = 1;
this.filter_id = [];
// 显示loading this.search_keyword = '';
uni.showLoading({ this.searchParams.stock_in_batch_sn = '';
title: '上传中...'
});
// 获取选择的图片路径数组 //再次获取焦点
const imagePaths = chooseImageRes.tempFilePaths; this.isFocus = false;
setTimeout(() => {
this.isFocus = true;
}, 1000);
// 判断选择的图片数量是否超过最大限制数量 this.getData();
let maxNum = Number(imagePaths.length) + Number(this.image_list.length); //当前上传的+已经上传的 },
if (maxNum > this.maxNum) { /**
uni.hideLoading(); * 打印货品标签样式切换监听
uni.showToast({
title: '图片不超过' + this.maxNum + '张', * @param {Object} e
icon: 'none' */
}); bindPickerChange: function(e) {
return false; this.print_style_index = e.detail.value;
this.rePrintTagParams.print_type = e.detail.value;
},
bindPickerBoxChange: function(e, index) {
console.log('picker发送选择改变,携带值为', e.detail.value);
this.index = e.detail.value;
var packConfigList = this.packConfigList[e.detail.value];
this.$set(this.packList[index], 'length', packConfigList.length);
this.$set(this.packList[index], 'width', packConfigList.width);
this.$set(this.packList[index], 'hight', packConfigList.hight);
},
/**
* 找出false对应的下标
* @param {Object} arr
* @param {Object} target
*/
findIndex(arr, target) {
const result = [];
arr.map((item, index) => {
if (item === target) {
result.push(index);
} }
});
return result;
},
/**
* 筛选过滤出选中的元素
*/
filterChange(index) {
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].stock_out_item_id);
// 遍历图片路径数组,对每张图片进行压缩 //开启了批量搜索,如果取消勾选则删除
imagePaths.forEach(imagePath => { if (this.is_batch) {
// 使用compressImage 压缩图片 if (!this.filter_list[index]) {
uni.compressImage({ this.history_id.splice(index, 1);
src: imagePath, this.searchParams.stock_in_batch_sn = this.history_id.join(',');
quality: 50, //压缩质量,范围0~100,数值越小,质量越低,压缩率越高
success: compressedRes => {
console.log('压缩图片成功:', compressedRes);
// 获取压缩后的图片路径
const compressedImagePath = compressedRes.tempFilePath;
// 在这里处理压缩后的图片,上传到服务器 //当检测到全部取消的时候不应该调用接口
uni.uploadFile({ if (this.history_id.length == 0) {
url: API.upload + '?sys_type=4', this.list = [];
filePath: compressedImagePath, this.search_keyword = '';
name: 'file', return false;
header: { }
'Content-Type': 'multipart/form-data'
}, //搜索之后添加选择状态
success: uploadFileRes => { this.getData(data => {
console.log('服务器上传图片成功:', uploadFileRes); console.log(data)
uni.hideLoading(); if (data.length > 0) {
let data = JSON.parse(uploadFileRes.data); const list = data;
if (data.code === 0) { list.forEach((item, index) => {
this.image_list.push({ this.filterChange(index);
pic_id: data.data.oss_image_id,
small_image_url: data.data.small_image_url,
big_image_url: data.data.big_image_url
});
} else {
uni.showToast({
title: data.msg,
icon: 'none'
});
}
},
fail: error => {
console.log('上传图片失败:', error);
uni.hideLoading();
}
}); });
}, this.search_keyword = '';
fail: err => {
console.log('压缩图片失败:', err);
} }
}); });
}); }
} }
}); },
}, /**
/** * 全选
* 删除图片 */
* @param {Object} index allChnage() {
*/ this.all_flag = !this.all_flag;
deletePic(index) { this.filter_list = createArray(this.list.length, this.all_flag);
this.image_list.splice(index, 1); if (this.all_flag) {
}, this.filter_id = this.list.map(function(item) {
/** return item.stock_out_item_id;
* 预览图片
* @param {Object} img
* @param {Object} index
*/
previewChange(arr, index) {
var data = arr.map(item => {
return item.big_image_url;
});
this.noexebshowFalg = false;
uni.previewImage({
current: index,
urls: data
});
},
/**
* 自动补齐3位
* @param {Object} num
*/
autoFillInt(num) {
return String(num + 1).padStart(3, '0');
},
/**
* 获取箱信息
*/
getPackList() {
this.request(API.getPackList, 'POST', { stock_out_id: this.searchParams.stock_out_id }, false).then(res => {
if (res.code === 0) {
this.packList = res.data.list;
} else {
uni.showToast({
title: res.msg,
icon: 'error'
}); });
}
});
},
/**
* 获取箱配置
*/
getBoxConfigList() {
this.request(API.getBoxConfigList, 'POST', { stock_out_id: this.searchParams.stock_out_id }, false).then(res => {
if (res.code === 0) {
this.packConfigList = res.data.list;
} else { } else {
uni.showToast({ this.filter_id = [];
title: res.msg,
icon: 'error'
});
} }
}); },
}, /**
/** *打印货品标签
* 刷新数字 */
*/ rePrintTag(type) {
refresh() {
this.searchParams.box_name = this.autoFillInt(Number(this.searchParams.box_name));
},
/**
* 清空数据
*/
clearInput(type) {
if (type == 1) {
this.searchParams.box_name = '';
this.input_flag_box_name = false;
} else if (type == 2) {
this.searchParams.stock_in_batch_sn = '';
this.input_flag_stock_in_batch_sn = false;
} else if (type == 3) {
this.searchParams.container_sn = '';
this.input_flag_container_sn = false;
}
this.getData();
},
/**
* 单号搜索
* @param {Object} event
*/
handleInput: debounce(function(type, val) {
if (val) {
if (type == 1) { if (type == 1) {
//箱号 this.rePrintTagParams.stock_out_item_id = this.detail.stock_out_item_id;
this.input_flag_box_name = true; this.rePrintTagParams.recheck_num = this.formParams.recheck_qty;
this.getData(); } else {
} else if (type == 2) { if (this.filter_id.length == 0) {
//入库批次号 开启批量扫描 uni.showToast({
if (this.is_batch) { title: '请勾选数据',
this.input_flag_stock_in_batch_sn = false; icon: 'error'
});
return false;
}
this.rePrintTagParams.stock_out_item_id = this.filter_id.join(','); //出库明细ids
}
//记录历史搜索批次号 this.request(API.RePrintTag, 'POST', this.rePrintTagParams, true).then(res => {
if (!this.history_id.includes(val)) { if (res.code === 0) {
this.history_id.push(val); uni.showToast({
} title: '操作成功',
icon: 'success'
});
} else {
uni.showToast({
title: res.msg,
icon: 'none'
});
}
});
},
/**
* 选择图片
*/
chooseImageChange() {
this.noexebshowFalg = false;
// 使用 chooseImage选择图片
uni.chooseImage({
count: this.maxNum,
sizeType: ['original', 'compressed'],
sourceType: ['album', 'camera'],
success: chooseImageRes => {
console.log('选择图片成功:', chooseImageRes);
this.searchParams.stock_in_batch_sn = this.history_id.join(','); // 显示loading
uni.showLoading({
title: '上传中...'
});
this.getData((data, msg) => { // 获取选择的图片路径数组
//回调data里数据,加是否选中交互 const imagePaths = chooseImageRes.tempFilePaths;
if (data.length > 0) {
this.is_batch_active = true;
const list = data;
list.forEach((item, index) => {
this.filterChange(index);
});
}
//如果后台有消息返回,就提示 // 判断选择的图片数量是否超过最大限制数量
if (msg) { let maxNum = Number(imagePaths.length) + Number(this.image_list.length); //当前上传的+已经上传的
uni.showModal({ if (maxNum > this.maxNum) {
title: '提示', uni.hideLoading();
content: msg, uni.showToast({
confirmText: '关闭', title: '图片不超过' + this.maxNum + '张',
showCancel: false, icon: 'none'
success: res => { });
let index_history_id = this.history_id.indexOf(val); return false;
this.history_id.splice(index_history_id, 1); }
try { // 遍历图片路径数组,对每张图片进行压缩
//再次获取焦点 imagePaths.forEach(imagePath => {
this.isFocus = false; // 使用compressImage 压缩图片
setTimeout(() => { uni.compressImage({
this.isFocus = true; src: imagePath,
this.search_keyword = ''; //清空入库批次号 quality: 50, //压缩质量,范围0~100,数值越小,质量越低,压缩率越高
this.$forceUpdate(); success: compressedRes => {
}, 500); console.log('压缩图片成功:', compressedRes);
} catch (e) { // 获取压缩后的图片路径
//TODO handle the exception const compressedImagePath = compressedRes.tempFilePath;
}
}
});
return false;
} else {
uni.showToast({
icon: 'success'
});
}
//执行最后再次获取焦点 // 在这里处理压缩后的图片,上传到服务器
try { uni.uploadFile({
this.isFocus = false; url: API.upload + '?sys_type=4',
setTimeout(() => { filePath: compressedImagePath,
this.isFocus = true; name: 'file',
this.search_keyword = ''; //清空入库批次号 header: {
this.$forceUpdate(); 'Content-Type': 'multipart/form-data'
}, 500); },
} catch (e) { success: uploadFileRes => {
//TODO handle the exception console.log('服务器上传图片成功:', uploadFileRes);
} uni.hideLoading();
let data = JSON.parse(uploadFileRes.data);
if (data.code === 0) {
this.image_list.push({
pic_id: data.data.oss_image_id,
small_image_url: data.data.small_image_url,
big_image_url: data.data.big_image_url
});
} else {
uni.showToast({
title: data.msg,
icon: 'none'
});
}
},
fail: error => {
console.log('上传图片失败:', error);
uni.hideLoading();
}
});
},
fail: err => {
console.log('压缩图片失败:', err);
}
});
});
}
});
},
/**
* 删除图片
* @param {Object} index
*/
deletePic(index) {
this.image_list.splice(index, 1);
},
/**
* 预览图片
* @param {Object} img
* @param {Object} index
*/
previewChange(arr, index) {
var data = arr.map(item => {
return item.big_image_url;
});
this.noexebshowFalg = false;
uni.previewImage({
current: index,
urls: data
});
},
/**
* 自动补齐3位
* @param {Object} num
*/
autoFillInt(num) {
return String(num + 1).padStart(3, '0');
},
/**
* 获取箱信息
*/
getPackList() {
this.request(API.getPackList, 'POST', { stock_out_id: this.searchParams.stock_out_id }, false).then(res => {
if (res.code === 0) {
this.packList = res.data.list;
} else {
uni.showToast({
title: res.msg,
icon: 'error'
}); });
}
});
},
/**
* 获取箱配置
*/
getBoxConfigList() {
this.request(API.getBoxConfigList, 'POST', { stock_out_id: this.searchParams.stock_out_id }, false).then(res => {
if (res.code === 0) {
this.packConfigList = res.data.list;
} else { } else {
this.input_flag_stock_in_batch_sn = true; uni.showToast({
this.getData(); title: res.msg,
setTimeout(() => { icon: 'error'
if (this.searchParams.stock_in_batch_sn.length == 15) { });
this.showDrawer(1, this.list[0]);
}
}, 800);
} }
} else if (type == 3) { });
//容器 },
this.input_flag_container_sn = true; /**
this.getData(); * 刷新数字
} */
} else { refresh() {
this.searchParams.box_name = this.autoFillInt(Number(this.searchParams.box_name));
},
/**
* 清空数据
*/
clearInput(type) {
if (type == 1) { if (type == 1) {
this.searchParams.box_name = '';
this.input_flag_box_name = false; this.input_flag_box_name = false;
} else if (type == 2) { } else if (type == 2) {
this.searchParams.stock_in_batch_sn = '';
this.input_flag_stock_in_batch_sn = false; this.input_flag_stock_in_batch_sn = false;
} else if (type == 3) { } else if (type == 3) {
this.searchParams.container_sn = '';
this.input_flag_container_sn = false; this.input_flag_container_sn = false;
} }
} this.getData();
}, 500), },
/** /**
* tab切换 * 单号搜索
* @param {Object} index * @param {Object} event
*/ */
tab(index) { handleInput: debounce(function(type, val) {
this.curr = index; if (val) {
this.image_list = []; if (type == 1) {
this.getData(); //箱号
}, this.input_flag_box_name = true;
/** this.getData();
* 获取列表数据 } else if (type == 2) {
*/ //入库批次号 开启批量扫描
getData(callback) { if (this.is_batch) {
if (this.curr == 0) { this.input_flag_stock_in_batch_sn = false;
//按货品复核
var URL = API.getRecheckTaskItems; //记录历史搜索批次号
} else if (this.curr == 1) { if (!this.history_id.includes(val)) {
//按容器复核 this.history_id.push(val);
var URL = API.getContainerTaskList; }
}
//赋值title this.searchParams.stock_in_batch_sn = this.history_id.join(',');
uni.setNavigationBarTitle({
title: this.stock_out_sn + '复核' this.getData((data, msg) => {
}); //回调data里数据,加是否选中交互
this.request(URL, 'POST', { page: this.page, limit: this.limit, ...this.searchParams }, false).then(res => { if (data.length > 0) {
if (res.code === 0) { this.is_batch_active = true;
//过滤出待复核不为0的数据 const list = data;
if (this.curr == 0) { list.forEach((item, index) => {
var filteredList = res.data.list.filter(item => item.no_recheck_qty > 0); this.filterChange(index);
this.list = filteredList; });
} else if (this.curr == 1) { }
var filteredList = res.data.list.filter(item => item.total_check_num > 0);
this.list = filteredList; //如果后台有消息返回,就提示
if (msg) {
uni.showModal({
title: '提示',
content: msg,
confirmText: '关闭',
showCancel: false,
success: res => {
let index_history_id = this.history_id.indexOf(val);
this.history_id.splice(index_history_id, 1);
try {
//再次获取焦点
this.isFocus = false;
setTimeout(() => {
this.isFocus = true;
this.search_keyword = ''; //清空入库批次号
this.$forceUpdate();
}, 500);
} catch (e) {
//TODO handle the exception
}
}
});
return false;
} else {
uni.showToast({
icon: 'success'
});
}
//执行最后再次获取焦点
try {
this.isFocus = false;
setTimeout(() => {
this.isFocus = true;
this.search_keyword = ''; //清空入库批次号
this.$forceUpdate();
}, 500);
} catch (e) {
//TODO handle the exception
}
});
} else {
this.input_flag_stock_in_batch_sn = true;
this.getData();
setTimeout(() => {
if (this.searchParams.stock_in_batch_sn.length == 15) {
this.showDrawer(1, this.list[0]);
}
}, 800);
}
} else if (type == 3) {
//容器
this.input_flag_container_sn = true;
this.getData();
} }
this.filter_list = createArray(filteredList.length, false); //创建状态数组
typeof callback == 'function' && callback(filteredList, res.data.notice_msg);
} else { } else {
uni.showToast({ if (type == 1) {
title: res.msg, this.input_flag_box_name = false;
icon: 'none' } else if (type == 2) {
}); this.input_flag_stock_in_batch_sn = false;
} else if (type == 3) {
this.input_flag_container_sn = false;
}
} }
}); }, 500),
}, /**
/** * tab切换
*按货品复核-单个复核 * @param {Object} index
*/ */
markChecked(stock_out_item_id, recheck_qty, box_name) { tab(index) {
if (!this.searchParams.box_name) { this.curr = index;
uni.showToast({ this.image_list = [];
title: '输入打包箱号', this.getData();
icon: 'error' },
/**
* 获取列表数据
*/
getData(callback) {
if (this.curr == 0) {
//按货品复核
var URL = API.getRecheckTaskItems;
} else if (this.curr == 1) {
//按容器复核
var URL = API.getContainerTaskList;
}
//赋值title
uni.setNavigationBarTitle({
title: this.stock_out_sn + '复核'
}); });
return false; this.request(URL, 'POST', { page: this.page, limit: this.limit, ...this.searchParams }, false).then(res => {
} if (res.code === 0) {
if (Number(this.formParams.recheck_qty) <= 0) { //过滤出待复核不为0的数据
uni.showToast({ if (this.curr == 0) {
title: '输入复核数量', var filteredList = res.data.list.filter(item => item.no_recheck_qty > 0);
icon: 'error' this.list = filteredList;
} else if (this.curr == 1) {
var filteredList = res.data.list.filter(item => item.total_check_num > 0);
this.list = filteredList;
}
this.filter_list = createArray(filteredList.length, false); //创建状态数组
typeof callback == 'function' && callback(filteredList, res.data.notice_msg);
} else {
uni.showToast({
title: res.msg,
icon: 'none'
});
}
}); });
return false; },
} /**
*按货品复核-单个复核
//图片集合 */
var pic_ids = this.image_list.map(item => { markChecked(stock_out_item_id, recheck_qty, box_name) {
return item.pic_id; if (!this.searchParams.box_name) {
});
this.request(API.markChecked, 'POST', { stock_out_item_id: stock_out_item_id, recheck_qty: recheck_qty, box_name: box_name, pic_ids: pic_ids.join(',') }, true).then(res => {
if (res.code === 0) {
uni.showToast({ uni.showToast({
title: '复核成功', title: '输入打包箱号',
icon: 'success' icon: 'error'
});
setTimeout(() => {
this.getData();
this.closeDrawer(1);
this.filter_id = []; //清空
}, 2000);
} else {
uni.showModal({
itle: '提示',
content: res.msg,
showCancel: false
}); });
return false;
} }
}); if (Number(this.formParams.recheck_qty) <= 0) {
},
/**
* 按容器复核-一键复核
*/
multiMarkChecked() {
if (!this.searchParams.box_name) {
uni.showToast({
title: '输入打包箱号',
icon: 'error'
});
return false;
}
//图片集合
var pic_ids = this.image_list.map(item => {
return item.pic_id;
});
this.request(API.multiMarkChecked, 'POST', { stock_out_item_ids: this.stock_out_item_ids.join(','), box_name: this.searchParams.box_name, pic_ids: pic_ids.join(',') }, true).then(res => {
if (res.code === 0) {
uni.showToast({ uni.showToast({
title: '一键复核成功', title: '输入复核数量',
icon: 'success' icon: 'error'
});
setTimeout(() => {
this.getData();
this.closeDrawer(2);
this.closeDrawer(0);
this.filter_id = []; //清空
}, 2000);
} else {
uni.showModal({
itle: '提示',
content: res.msg,
showCancel: false
}); });
return false;
} }
});
}, //图片集合
/** var pic_ids = this.image_list.map(item => {
* 保存打包信息 return item.pic_id;
*/ });
updatePackInfo() {
if (this.packList.length > 0) { this.request(API.markChecked, 'POST', { stock_out_item_id: stock_out_item_id, recheck_qty: recheck_qty, box_name: box_name, pic_ids: pic_ids.join(',') }, true).then(res => {
var parmas = {
pack_list: JSON.stringify(this.packList)
};
this.request(API.updatePackInfo, 'POST', parmas, true).then(res => {
if (res.code === 0) { if (res.code === 0) {
uni.showToast({ uni.showToast({
title: '保存成功', title: '复核成功',
icon: 'success' icon: 'success'
}); });
setTimeout(() => { setTimeout(() => {
this.closeBox(); this.getData();
this.closeDrawer(1);
this.filter_id = []; //清空
}, 2000); }, 2000);
} else { } else {
uni.showModal({ uni.showModal({
...@@ -1233,73 +1174,137 @@ export default { ...@@ -1233,73 +1174,137 @@ export default {
}); });
} }
}); });
} },
}, /**
/** * 按容器复核-一键复核
* 展示箱信息 */
*/ multiMarkChecked() {
showBox() { if (!this.searchParams.box_name) {
this.getPackList(); //获取箱信息
this.getBoxConfigList(); //获取箱配置
this.index = -1;
this.$refs.showBoxInfo.open();
},
/**
* 关闭弹窗
*/
closeBox() {
this.$refs.showBoxInfo.close();
},
/**
* 打开弹窗
* @param {Object} type
* @param {Object} data
*/
showDrawer(type, data) {
if (type == 1) {
//按货品复核
this.$refs.showRight.open();
this.detail = data;
this.formParams.recheck_qty = data.no_recheck_qty;
this.image_list = []; //清空图片列表
} else if (type == 2) {
//按容器复核
this.$refs.showRightPack.open();
this.detailContainer = data;
this.image_list = []; //清空图片列表
this.stock_out_item_ids = data.list.map(function(item) {
return item.stock_out_item_id;
});
} else if (type == 0) {
//一键复核
if (this.filter_id.length == 0) {
uni.showToast({ uni.showToast({
title: '请勾选数据', title: '输入打包箱号',
icon: 'error' icon: 'error'
}); });
return false; return false;
} }
this.stock_out_item_ids = this.filter_id;
this.$refs.showRightAll.open(); //图片集合
this.image_list = []; //清空图片列表 var pic_ids = this.image_list.map(item => {
} return item.pic_id;
}, });
closeDrawer(type) {
if (type == 1) { this.request(API.multiMarkChecked, 'POST', { stock_out_item_ids: this.stock_out_item_ids.join(','), box_name: this.searchParams.box_name, pic_ids: pic_ids.join(',') }, true).then(res => {
//按货品复核 if (res.code === 0) {
this.$refs.showRight.close(); uni.showToast({
} else if (type == 2) { title: '一键复核成功',
//按容器复核 icon: 'success'
this.$refs.showRightPack.close(); });
} else if (type == 0) { setTimeout(() => {
//一键复核 this.getData();
this.$refs.showRightAll.close(); this.closeDrawer(2);
this.closeDrawer(0);
this.filter_id = []; //清空
}, 2000);
} else {
uni.showModal({
itle: '提示',
content: res.msg,
showCancel: false
});
}
});
},
/**
* 保存打包信息
*/
updatePackInfo() {
if (this.packList.length > 0) {
var parmas = {
pack_list: JSON.stringify(this.packList)
};
this.request(API.updatePackInfo, 'POST', parmas, true).then(res => {
if (res.code === 0) {
uni.showToast({
title: '保存成功',
icon: 'success'
});
setTimeout(() => {
this.closeBox();
}, 2000);
} else {
uni.showModal({
itle: '提示',
content: res.msg,
showCancel: false
});
}
});
}
},
/**
* 展示箱信息
*/
showBox() {
this.getPackList(); //获取箱信息
this.getBoxConfigList(); //获取箱配置
this.index = -1;
this.$refs.showBoxInfo.open();
},
/**
* 关闭弹窗
*/
closeBox() {
this.$refs.showBoxInfo.close();
},
/**
* 打开弹窗
* @param {Object} type
* @param {Object} data
*/
showDrawer(type, data) {
if (type == 1) {
//按货品复核
this.$refs.showRight.open();
this.detail = data;
this.formParams.recheck_qty = data.no_recheck_qty;
this.image_list = []; //清空图片列表
} else if (type == 2) {
//按容器复核
this.$refs.showRightPack.open();
this.detailContainer = data;
this.image_list = []; //清空图片列表
this.stock_out_item_ids = data.list.map(function(item) {
return item.stock_out_item_id;
});
} else if (type == 0) {
//一键复核
if (this.filter_id.length == 0) {
uni.showToast({
title: '请勾选数据',
icon: 'error'
});
return false;
}
this.stock_out_item_ids = this.filter_id;
this.$refs.showRightAll.open();
this.image_list = []; //清空图片列表
}
},
closeDrawer(type) {
if (type == 1) {
//按货品复核
this.$refs.showRight.close();
} else if (type == 2) {
//按容器复核
this.$refs.showRightPack.close();
} else if (type == 0) {
//一键复核
this.$refs.showRightAll.close();
}
} }
} }
} };
};
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
@import '@/assets/css/stockRecheck/sort.scss'; @import '@/assets/css/stockRecheck/sort.scss';
</style> </style>
\ No newline at end of file
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