Commit 48cd7771 by LJM

bug

parent 83bac40f
......@@ -188,245 +188,254 @@
</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>
</template>
<script>
import { API } from '@/util/api.js';
import debounce from 'lodash/debounce';
import { API } from '@/util/api.js';
import debounce from 'lodash/debounce';
export default {
data() {
return {
isZY: false, //区分是否自营
isInputFocus: false,
is_submit: true,
input_flag: false,
index: 0,
curr: 0,
item: ['货品信息', '其他信息'],
array: ['入库批次号'],
detail: {},
workingRuleList: {}, //,//推荐库位
workingRule: '', //推荐库位
searchParams: {
stock_in_batch_sn: '' //入库批次
},
formParams: {
position_code: '', //库位编码
qty_on_shelf: '',
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;
export default {
data() {
return {
isZY: false, //区分是否自营
isInputFocus: false,
is_submit: true,
input_flag: false,
index: 0,
curr: 0,
item: ['货品信息', '其他信息'],
array: ['入库批次号'],
detail: {},
workingRuleList: {}, //,//推荐库位
workingRule: '', //推荐库位
searchParams: {
stock_in_batch_sn: '' //入库批次
},
formParams: {
position_code: '', //库位编码
qty_on_shelf: '',
tally_id: ''
}
};
},
/**
* 单号搜索
* @param {Object} event
*/
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();
onLoad(options) {
this.searchParams.stock_in_batch_sn = options.stock_in_batch_sn;
this.formParams.tally_id = options.tally_id;
},
/**
* 监听上架数量
*/
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;
onShow() {
this.getData();
},
/**
*点击推荐库位就赋值到库位
*/
assignment(val) {
this.formParams.position_code = val;
mounted() {
setTimeout(() => {
this.isInputFocus = true;
}, 2000);
},
/**
* 获取详情数据
*/
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);
methods: {
tab(index) {
this.curr = index;
},
/**
* 单号搜索
* @param {Object} event
*/
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();
},
/**
* 监听上架数量
*/
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 {
//如果为不良品就不请求库位接口
if (res.data.quality == 1) {
this.getWhPositionList(1);
});
},
/**
* @param {Object} type
* type 退货入库
*/
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 退货入库
*/
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(',');
});
},
/**
* 查询可用的上架规则
*/
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,
stock_type: this.detail.stock_type || '',
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 {
var position_code = this.formParams.position_code;
this.is_submit = res.data.list.some(function(obj) {
return obj.position_code === position_code;
uni.showToast({
title: res.msg,
icon: 'error'
});
}
} else {
});
},
/**
* 上架
*/
stockShelfByBatchSnAction() {
if (!this.formParams.qty_on_shelf) {
uni.showToast({
title: res.msg,
title: '请填写上架数量',
icon: 'error'
});
return false;
}
});
},
/**
* 查询可用的上架规则
*/
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 {
if (!this.formParams.position_code) {
uni.showToast({
title: res.msg,
title: '请输入库位编码',
icon: 'error'
});
return false;
}
});
},
/**
* 上架
*/
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);
var pending_shelf_qty = Number(this.detail.pending_shelf_qty);
this.request(API.stockShelfByBatchSnAction, 'POST', this.formParams, true).then(res => {
if (res.code === 0) {
if (Number(this.formParams.qty_on_shelf) == pending_shelf_qty) {
uni.showToast({
title: '上架成功',
icon: 'success'
});
setTimeout(() => {
uni.navigateBack({
delta: 1
this.request(API.stockShelfByBatchSnAction, 'POST', this.formParams, true).then(res => {
if (res.code === 0) {
if (Number(this.formParams.qty_on_shelf) == pending_shelf_qty) {
uni.showToast({
title: '上架成功',
icon: 'success'
});
setTimeout(() => {
uni.navigateBack({
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 {
uni.showModal({
title: '提示',
content: '上架成功,点击确定可继续上架',
showCancel: true,
success: res => {
if (res.confirm) {
this.getData();
} else if (res.cancel) {
uni.navigateBack({
delta: 1
});
}
}
itle: '提示',
content: res.msg,
showCancel: false
});
}
} else {
uni.showModal({
itle: '提示',
content: res.msg,
showCancel: false
});
}
});
});
}
}
}
};
};
</script>
<style scoped lang="scss">
@import '@/assets/css/putaway/single.scss';
</style>
@import '@/assets/css/putaway/single.scss';
</style>
\ No newline at end of file
......@@ -44,7 +44,9 @@
</view>
</template>
<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="row verCenter">
<text class="iconfont icon-juxing1"></text>
......@@ -133,7 +135,9 @@
<text class="label">仓库备注:</text>
<text class="desc">{{ item.remark }}</text>
</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>
<!-- 无数据展示 -->
......@@ -612,618 +616,555 @@
</template>
<script>
import { API } from '@/util/api.js';
import { createArray } from '@/util/util.js';
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 = [];
import { API } from '@/util/api.js';
import { createArray } from '@/util/util.js';
import debounce from 'lodash/debounce';
this.search_keyword = '';
this.searchParams.stock_in_batch_sn = '';
//再次获取焦点
this.isFocus = false;
setTimeout(() => {
this.isFocus = true;
}, 1000);
this.getData();
},
/**
* 打印货品标签样式切换监听
* @param {Object} e
*/
bindPickerChange: function(e) {
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);
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: ''
}
});
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);
//开启了批量搜索,如果取消勾选则删除
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;
onNavigationBarButtonTap(e) {
if (e.index == 0) {
uni.navigateTo({
url: '/pages/stockRecheck/record?stock_out_sn=' + this.stock_out_sn
});
} else {
this.filter_id = [];
}
},
/**
*打印货品标签
*/
rePrintTag(type) {
if (type == 1) {
this.rePrintTagParams.stock_out_item_id = this.detail.stock_out_item_id;
this.rePrintTagParams.recheck_num = this.formParams.recheck_qty;
} else {
if (this.filter_id.length == 0) {
uni.showToast({
title: '请勾选数据',
icon: 'error'
});
return false;
}
this.rePrintTagParams.stock_out_item_id = this.filter_id.join(','); //出库明细ids
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();
}
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'
});
}
});
},
/**
* 选择图片
*/
chooseImageChange() {
this.noexebshowFalg = false;
// 使用 chooseImage选择图片
uni.chooseImage({
count: this.maxNum,
sizeType: ['original', 'compressed'],
sourceType: ['album', 'camera'],
success: chooseImageRes => {
console.log('选择图片成功:', chooseImageRes);
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 = [];
// 显示loading
uni.showLoading({
title: '上传中...'
});
this.search_keyword = '';
this.searchParams.stock_in_batch_sn = '';
// 获取选择的图片路径数组
const imagePaths = chooseImageRes.tempFilePaths;
//再次获取焦点
this.isFocus = false;
setTimeout(() => {
this.isFocus = true;
}, 1000);
// 判断选择的图片数量是否超过最大限制数量
let maxNum = Number(imagePaths.length) + Number(this.image_list.length); //当前上传的+已经上传的
if (maxNum > this.maxNum) {
uni.hideLoading();
uni.showToast({
title: '图片不超过' + this.maxNum + '张',
icon: 'none'
});
return false;
this.getData();
},
/**
* 打印货品标签样式切换监听
* @param {Object} e
*/
bindPickerChange: function(e) {
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 => {
// 使用compressImage 压缩图片
uni.compressImage({
src: imagePath,
quality: 50, //压缩质量,范围0~100,数值越小,质量越低,压缩率越高
success: compressedRes => {
console.log('压缩图片成功:', compressedRes);
// 获取压缩后的图片路径
const compressedImagePath = compressedRes.tempFilePath;
//开启了批量搜索,如果取消勾选则删除
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(',');
// 在这里处理压缩后的图片,上传到服务器
uni.uploadFile({
url: API.upload + '?sys_type=4',
filePath: compressedImagePath,
name: 'file',
header: {
'Content-Type': 'multipart/form-data'
},
success: uploadFileRes => {
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();
}
//当检测到全部取消的时候不应该调用接口
if (this.history_id.length == 0) {
this.list = [];
this.search_keyword = '';
return false;
}
//搜索之后添加选择状态
this.getData(data => {
console.log(data)
if (data.length > 0) {
const list = data;
list.forEach((item, index) => {
this.filterChange(index);
});
},
fail: err => {
console.log('压缩图片失败:', err);
this.search_keyword = '';
}
});
});
}
}
});
},
/**
* 删除图片
* @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'
},
/**
* 全选
*/
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;
});
}
});
},
/**
* 获取箱配置
*/
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 {
uni.showToast({
title: res.msg,
icon: 'error'
});
this.filter_id = [];
}
});
},
/**
* 刷新数字
*/
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) {
},
/**
*打印货品标签
*/
rePrintTag(type) {
if (type == 1) {
//箱号
this.input_flag_box_name = true;
this.getData();
} else if (type == 2) {
//入库批次号 开启批量扫描
if (this.is_batch) {
this.input_flag_stock_in_batch_sn = false;
this.rePrintTagParams.stock_out_item_id = this.detail.stock_out_item_id;
this.rePrintTagParams.recheck_num = this.formParams.recheck_qty;
} else {
if (this.filter_id.length == 0) {
uni.showToast({
title: '请勾选数据',
icon: 'error'
});
return false;
}
this.rePrintTagParams.stock_out_item_id = this.filter_id.join(','); //出库明细ids
}
//记录历史搜索批次号
if (!this.history_id.includes(val)) {
this.history_id.push(val);
}
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'
});
}
});
},
/**
* 选择图片
*/
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里数据,加是否选中交互
if (data.length > 0) {
this.is_batch_active = true;
const list = data;
list.forEach((item, index) => {
this.filterChange(index);
});
}
// 获取选择的图片路径数组
const imagePaths = chooseImageRes.tempFilePaths;
//如果后台有消息返回,就提示
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);
// 判断选择的图片数量是否超过最大限制数量
let maxNum = Number(imagePaths.length) + Number(this.image_list.length); //当前上传的+已经上传的
if (maxNum > this.maxNum) {
uni.hideLoading();
uni.showToast({
title: '图片不超过' + this.maxNum + '张',
icon: 'none'
});
return false;
}
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'
});
}
// 遍历图片路径数组,对每张图片进行压缩
imagePaths.forEach(imagePath => {
// 使用compressImage 压缩图片
uni.compressImage({
src: imagePath,
quality: 50, //压缩质量,范围0~100,数值越小,质量越低,压缩率越高
success: compressedRes => {
console.log('压缩图片成功:', compressedRes);
// 获取压缩后的图片路径
const compressedImagePath = compressedRes.tempFilePath;
//执行最后再次获取焦点
try {
this.isFocus = false;
setTimeout(() => {
this.isFocus = true;
this.search_keyword = ''; //清空入库批次号
this.$forceUpdate();
}, 500);
} catch (e) {
//TODO handle the exception
}
// 在这里处理压缩后的图片,上传到服务器
uni.uploadFile({
url: API.upload + '?sys_type=4',
filePath: compressedImagePath,
name: 'file',
header: {
'Content-Type': 'multipart/form-data'
},
success: uploadFileRes => {
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 {
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);
uni.showToast({
title: res.msg,
icon: 'error'
});
}
} 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) {
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;
}
}
}, 500),
/**
* tab切换
* @param {Object} index
*/
tab(index) {
this.curr = index;
this.image_list = [];
this.getData();
},
/**
* 获取列表数据
*/
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 + '复核'
});
this.request(URL, 'POST', { page: this.page, limit: this.limit, ...this.searchParams }, false).then(res => {
if (res.code === 0) {
//过滤出待复核不为0的数据
if (this.curr == 0) {
var filteredList = res.data.list.filter(item => item.no_recheck_qty > 0);
this.list = filteredList;
} else if (this.curr == 1) {
var filteredList = res.data.list.filter(item => item.total_check_num > 0);
this.list = filteredList;
this.getData();
},
/**
* 单号搜索
* @param {Object} event
*/
handleInput: debounce(function(type, val) {
if (val) {
if (type == 1) {
//箱号
this.input_flag_box_name = true;
this.getData();
} else if (type == 2) {
//入库批次号 开启批量扫描
if (this.is_batch) {
this.input_flag_stock_in_batch_sn = false;
//记录历史搜索批次号
if (!this.history_id.includes(val)) {
this.history_id.push(val);
}
this.searchParams.stock_in_batch_sn = this.history_id.join(',');
this.getData((data, msg) => {
//回调data里数据,加是否选中交互
if (data.length > 0) {
this.is_batch_active = true;
const list = data;
list.forEach((item, index) => {
this.filterChange(index);
});
}
//如果后台有消息返回,就提示
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 {
uni.showToast({
title: res.msg,
icon: 'none'
});
if (type == 1) {
this.input_flag_box_name = false;
} else if (type == 2) {
this.input_flag_stock_in_batch_sn = false;
} else if (type == 3) {
this.input_flag_container_sn = false;
}
}
});
},
/**
*按货品复核-单个复核
*/
markChecked(stock_out_item_id, recheck_qty, box_name) {
if (!this.searchParams.box_name) {
uni.showToast({
title: '输入打包箱号',
icon: 'error'
}, 500),
/**
* tab切换
* @param {Object} index
*/
tab(index) {
this.curr = index;
this.image_list = [];
this.getData();
},
/**
* 获取列表数据
*/
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;
}
if (Number(this.formParams.recheck_qty) <= 0) {
uni.showToast({
title: '输入复核数量',
icon: 'error'
this.request(URL, 'POST', { page: this.page, limit: this.limit, ...this.searchParams }, false).then(res => {
if (res.code === 0) {
//过滤出待复核不为0的数据
if (this.curr == 0) {
var filteredList = res.data.list.filter(item => item.no_recheck_qty > 0);
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 => {
return item.pic_id;
});
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) {
},
/**
*按货品复核-单个复核
*/
markChecked(stock_out_item_id, recheck_qty, box_name) {
if (!this.searchParams.box_name) {
uni.showToast({
title: '复核成功',
icon: 'success'
});
setTimeout(() => {
this.getData();
this.closeDrawer(1);
this.filter_id = []; //清空
}, 2000);
} else {
uni.showModal({
itle: '提示',
content: res.msg,
showCancel: false
title: '输入打包箱号',
icon: 'error'
});
return false;
}
});
},
/**
* 按容器复核-一键复核
*/
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) {
if (Number(this.formParams.recheck_qty) <= 0) {
uni.showToast({
title: '一键复核成功',
icon: 'success'
});
setTimeout(() => {
this.getData();
this.closeDrawer(2);
this.closeDrawer(0);
this.filter_id = []; //清空
}, 2000);
} else {
uni.showModal({
itle: '提示',
content: res.msg,
showCancel: false
title: '输入复核数量',
icon: 'error'
});
return false;
}
});
},
/**
* 保存打包信息
*/
updatePackInfo() {
if (this.packList.length > 0) {
var parmas = {
pack_list: JSON.stringify(this.packList)
};
this.request(API.updatePackInfo, 'POST', parmas, true).then(res => {
//图片集合
var pic_ids = this.image_list.map(item => {
return item.pic_id;
});
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({
title: '保存成功',
title: '复核成功',
icon: 'success'
});
setTimeout(() => {
this.closeBox();
this.getData();
this.closeDrawer(1);
this.filter_id = []; //清空
}, 2000);
} else {
uni.showModal({
......@@ -1233,73 +1174,137 @@ export default {
});
}
});
}
},
/**
* 展示箱信息
*/
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) {
},
/**
* 按容器复核-一键复核
*/
multiMarkChecked() {
if (!this.searchParams.box_name) {
uni.showToast({
title: '请勾选数据',
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();
//图片集合
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({
title: '一键复核成功',
icon: 'success'
});
setTimeout(() => {
this.getData();
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>
<style scoped lang="scss">
@import '@/assets/css/stockRecheck/sort.scss';
</style>
@import '@/assets/css/stockRecheck/sort.scss';
</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