Commit e1972a83 by LJM

移动端拣货打印标签显示异常

parent 9517a3e0
Showing with 681 additions and 672 deletions
......@@ -56,12 +56,12 @@
<!-- 出库单状态为全部锁库,则显示【释放】、【选择】按钮 -->
<template v-if="item.stock_out_status == 3">
<view class="btn1 row rowCenter verCenter" @click="cancelTake(item.stock_out_id)">释放</view>
<navigator :url="'/pages/picking/sort?stock_out_id=' + item.stock_out_id + '&stock_out_sn=' + item.stock_out_sn" hover-class="none" class="btn3 row rowCenter verCenter">选择</navigator>
<navigator :url="'/pages/picking/sort?stock_out_id=' + item.stock_out_id + '&stock_out_sn=' + item.stock_out_sn+'&warehouse_id='+item.warehouse_id" hover-class="none" class="btn3 row rowCenter verCenter">选择</navigator>
</template>
<!--出库单状态为部分拣货-->
<template v-if="item.stock_out_status == 4">
<navigator :url="'/pages/picking/sort?stock_out_id=' + item.stock_out_id + '&stock_out_sn=' + item.stock_out_sn" hover-class="none" class="btn3 row rowCenter verCenter">选择</navigator>
<navigator :url="'/pages/picking/sort?stock_out_id=' + item.stock_out_id + '&stock_out_sn=' + item.stock_out_sn+'&warehouse_id='+item.warehouse_id" hover-class="none" class="btn3 row rowCenter verCenter">选择</navigator>
</template>
<!--出库单状态为全部拣货-->
......@@ -80,124 +80,124 @@
</template>
<script>
import { API } from '@/util/api.js';
import debounce from 'lodash/debounce';
export default {
data() {
return {
input_flag: false,
index: 0,
array: ['出库单号'],
list: [],
page: 1,
limit: 20,
hasMoreData: true, //是否分页加载
searchParams: {
stock_out_sn: '' //出库单号
import { API } from '@/util/api.js';
import debounce from 'lodash/debounce';
export default {
data() {
return {
input_flag: false,
index: 0,
array: ['出库单号'],
list: [],
page: 1,
limit: 20,
hasMoreData: true, //是否分页加载
searchParams: {
stock_out_sn: '' //出库单号
}
};
},
onNavigationBarButtonTap(e) {
if (e.index == 0) {
uni.reLaunch({
url: '/pages/index/index'
});
}
};
},
onNavigationBarButtonTap(e) {
if (e.index == 0) {
uni.reLaunch({
url: '/pages/index/index'
});
}
},
onReachBottom() {
if (!this.hasMoreData) {
return;
}
this.page++;
this.getData();
},
onShow() {
this.getData();
},
methods: {
bindPickerChange: function(e) {
console.log('picker发送选择改变,携带值为', e.detail.value);
this.index = e.detail.value;
},
/**
* 清空数据
*/
clearInput() {
this.input_flag = false;
this.searchParams.stock_out_sn = '';
onReachBottom() {
if (!this.hasMoreData) {
return;
}
this.page++;
this.getData();
},
/**
* 单号搜索
* @param {Object} event
*/
handleInput: debounce(function(event) {
this.resetChange();
var val = event.target.value;
this.searchParams.stock_out_sn = '';
if (val) {
this.input_flag = true;
this.searchParams.stock_out_sn = val;
} else {
this.input_flag = false;
}
onShow() {
this.getData();
}, 500),
/**
* 释放已领取拣货单
*/
cancelTake(stock_out_id) {
this.request(API.cancelTake, 'POST', { stock_out_id: stock_out_id }, true).then(res => {
if (res.code === 0) {
uni.showToast({
title: '释放成功',
icon: 'success'
});
setTimeout(() => {
this.getData();
this.filter_id = [];
}, 2000);
},
methods: {
bindPickerChange: function(e) {
console.log('picker发送选择改变,携带值为', e.detail.value);
this.index = e.detail.value;
},
/**
* 清空数据
*/
clearInput() {
this.input_flag = false;
this.searchParams.stock_out_sn = '';
this.getData();
},
/**
* 单号搜索
* @param {Object} event
*/
handleInput: debounce(function(event) {
this.resetChange();
var val = event.target.value;
this.searchParams.stock_out_sn = '';
if (val) {
this.input_flag = true;
this.searchParams.stock_out_sn = val;
} else {
uni.showModal({
itle: '提示',
content: res.msg,
showCancel: false
});
this.input_flag = false;
}
});
},
/**
* 获取列表数据
*/
getData() {
this.request(API.getTakedList, 'POST', { page: this.page, limit: this.limit, ...this.searchParams }, false).then(res => {
if (res.code === 0) {
if (res.data.list.length > 0) {
this.hasMoreData = true;
this.list = this.list.concat(res.data.list);
this.getData();
}, 500),
/**
* 释放已领取拣货单
*/
cancelTake(stock_out_id) {
this.request(API.cancelTake, 'POST', { stock_out_id: stock_out_id }, true).then(res => {
if (res.code === 0) {
uni.showToast({
title: '释放成功',
icon: 'success'
});
setTimeout(() => {
this.getData();
this.filter_id = [];
}, 2000);
} else {
this.hasMoreData = false;
uni.showModal({
itle: '提示',
content: res.msg,
showCancel: false
});
}
} else {
uni.showToast({
title: res.msg,
icon: 'error'
});
}
});
},
/**
* 重置
*/
resetChange() {
this.list = [];
this.page = 1;
});
},
/**
* 获取列表数据
*/
getData() {
this.request(API.getTakedList, 'POST', { page: this.page, limit: this.limit, ...this.searchParams }, false).then(res => {
if (res.code === 0) {
if (res.data.list.length > 0) {
this.hasMoreData = true;
this.list = this.list.concat(res.data.list);
} else {
this.hasMoreData = false;
}
} else {
uni.showToast({
title: res.msg,
icon: 'error'
});
}
});
},
/**
* 重置
*/
resetChange() {
this.list = [];
this.page = 1;
}
}
}
};
};
</script>
<style scoped lang="scss">
@import '@/assets/css/picking/me.scss';
</style>
@import '@/assets/css/picking/me.scss';
</style>
\ No newline at end of file
......@@ -130,7 +130,9 @@
<text class="desc">{{ item.remark }}</text>
</view>
<template v-if="item.lock_qty !== item.pick_qty">
<view class="row" style="width: 100%;justify-content: flex-end;"><view class="btn row rowCenter verCenter" @click="showDrawer(1, item)">拣货</view></view>
<view class="row" style="width: 100%;justify-content: flex-end;">
<view class="btn row rowCenter verCenter" @click="showDrawer(1, item)">拣货</view>
</view>
</template>
</view>
</view>
......@@ -329,7 +331,7 @@
</view>
<!-- 拆货打印标签-->
<view class="print row verCenter" v-if="warehouse_id == 9">
<text class="t1" @click="rePrintTag(1)">货打印标签</text>
<text class="t1" @click="rePrintTag(1)">货打印标签</text>
<view class="print-type-box row rowCenter verCenter">
<picker @change="bindPickerChange" :value="print_style_index" :range="print_style" class="row rowCenter verCenter">
<view class="row rowCenter verCenter">
......@@ -339,7 +341,9 @@
</picker>
</view>
</view>
<view class="btn row verCenter bothSide"><view class="btn1 row rowCenter verCenter" @click="pick(detail.lock_id, formParams.pick_qty, detail.stock_out_item_id)">拣 货</view></view>
<view class="btn row verCenter bothSide">
<view class="btn1 row rowCenter verCenter" @click="pick(detail.lock_id, formParams.pick_qty, detail.stock_out_item_id)">拣 货</view>
</view>
</view>
</uni-drawer>
<!-- 按容器拣货详情弹窗 -->
......@@ -467,7 +471,9 @@
</view>
</scroll-view>
</view>
<view class="btn row verCenter bothSide"><view class="btn1 row rowCenter verCenter" @click="makeMultiPickingFinish()">拣 货</view></view>
<view class="btn row verCenter bothSide">
<view class="btn1 row rowCenter verCenter" @click="makeMultiPickingFinish()">拣 货</view>
</view>
</view>
</uni-drawer>
<!-- 批量拣货弹窗 -->
......@@ -520,613 +526,614 @@
</template>
<script>
import { API } from '@/util/api.js';
import debounce from 'lodash/debounce';
import { createArray } from '@/util/util.js';
import { API } from '@/util/api.js';
import debounce from 'lodash/debounce';
import { createArray } from '@/util/util.js';
export default {
data() {
return {
isFocus: false,
is_batch: true, //是否开启批量
is_batch_active: false, //是否开启批量激活s
history_id: [], //批量记录id
search_keyword: '', //批量搜索值
noexebshowFalg: true, //控制是否会触发生命周期
stock_out_sn: '', //标题显示出库单号
lock_ids: [], //出库id集合
input_flag_position_name: false,
input_flag_stock_in_batch_sn: false,
input_flag_container_sn: false,
filter_list: [], //筛选已选中的列表
filter_id: [], //过滤处理的id
page: 1,
limit: 1000,
curr: 0,
itemArr: ['按货品拣货', '按容器拣货'],
list: [],
detail: {}, //按货品拣货详情
detailContainer: {}, //按容器拣货详情
picked_num: '', //应拣数量
image_list: [], //图片列表
maxNum: 10, //最大上传图片数量
warehouse_id: '', //仓库id
print_style: ['基本样式', '不带D/C'],
print_style_index: 0,
searchParams: {
stock_out_id: '',
position_name: '',
stock_in_batch_sn: '',
container_sn: ''
},
formParams: {
pick_qty: '',
pick_remark: ''
},
//打印货品标签参数集合
rePrintTagParams: {
stock_out_item_id: '',
print_type: 0,
recheck_num: ''
export default {
data() {
return {
isFocus: false,
is_batch: true, //是否开启批量
is_batch_active: false, //是否开启批量激活s
history_id: [], //批量记录id
search_keyword: '', //批量搜索值
noexebshowFalg: true, //控制是否会触发生命周期
stock_out_sn: '', //标题显示出库单号
lock_ids: [], //出库id集合
input_flag_position_name: false,
input_flag_stock_in_batch_sn: false,
input_flag_container_sn: false,
filter_list: [], //筛选已选中的列表
filter_id: [], //过滤处理的id
page: 1,
limit: 1000,
curr: 0,
itemArr: ['按货品拣货', '按容器拣货'],
list: [],
detail: {}, //按货品拣货详情
detailContainer: {}, //按容器拣货详情
picked_num: '', //应拣数量
image_list: [], //图片列表
maxNum: 10, //最大上传图片数量
warehouse_id: '', //仓库id
print_style: ['基本样式', '不带D/C'],
print_style_index: 0,
searchParams: {
stock_out_id: '',
position_name: '',
stock_in_batch_sn: '',
container_sn: ''
},
formParams: {
pick_qty: '',
pick_remark: ''
},
//打印货品标签参数集合
rePrintTagParams: {
stock_out_item_id: '',
print_type: 0,
recheck_num: ''
}
};
},
onNavigationBarButtonTap(e) {
if (e.index == 0) {
uni.navigateTo({
url: '/pages/picking/record?stock_out_sn=' + this.stock_out_sn
});
}
};
},
onNavigationBarButtonTap(e) {
if (e.index == 0) {
uni.navigateTo({
url: '/pages/picking/record?stock_out_sn=' + this.stock_out_sn
});
}
},
onLoad(options) {
this.stock_out_sn = options.stock_out_sn || '';
this.searchParams.stock_out_id = options.stock_out_id || '';
this.warehouse_id = options.warehouse_id || '';
},
onShow() {
if (this.noexebshowFalg) {
this.getData();
}
},
methods: {
/**
* 打印货品标签样式切换监听
* @param {Object} e
*/
bindPickerChange: function(e) {
this.print_style_index = e.detail.value;
this.rePrintTagParams.print_type = e.detail.value;
},
/**
* 批量扫描监听
* @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.is_batch_active = false;
onLoad(options) {
this.stock_out_sn = options.stock_out_sn || '';
this.searchParams.stock_out_id = options.stock_out_id || '';
this.warehouse_id = options.warehouse_id || '';
},
onShow() {
if (this.noexebshowFalg) {
this.getData();
}
},
methods: {
/**
* 打印货品标签样式切换监听
this.search_keyword = '';
this.searchParams.stock_in_batch_sn = '';
* @param {Object} e
*/
bindPickerChange: function(e) {
this.print_style_index = e.detail.value;
this.rePrintTagParams.print_type = e.detail.value;
},
/**
* 批量扫描监听
* @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.is_batch_active = false;
this.getData();
},
/**
* 单号搜索
* @param {Object} event
*/
handleInput: debounce(function(type, val) {
if (val) {
if (type == 1) {
this.input_flag_position_name = true;
this.getData();
//再次获取焦点
this.isFocus = false;
setTimeout(() => {
this.isFocus = true;
this.$forceUpdate();
}, 1500);
} else if (type == 2) {
//入库批次号 开启批量扫描
if (this.is_batch) {
this.input_flag_stock_in_batch_sn = false;
this.search_keyword = '';
this.searchParams.stock_in_batch_sn = '';
//记录历史搜索批次号
if (!this.history_id.includes(val)) {
this.history_id.push(val);
}
this.searchParams.stock_in_batch_sn = this.history_id.join(',');
this.getData();
},
/**
* 单号搜索
* @param {Object} event
*/
handleInput: debounce(function(type, val) {
if (val) {
if (type == 1) {
this.input_flag_position_name = true;
this.getData();
//再次获取焦点
this.isFocus = false;
setTimeout(() => {
this.isFocus = true;
this.$forceUpdate();
}, 1500);
} else if (type == 2) {
//入库批次号 开启批量扫描
if (this.is_batch) {
this.input_flag_stock_in_batch_sn = false;
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 (!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);
//如果后台有消息返回,就提示
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
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'
});
}
});
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;
//执行最后再次获取焦点
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();
setTimeout(() => {
if (this.searchParams.stock_in_batch_sn.length == 15) {
this.showDrawer(1, this.list[0]);
if (this.searchParams.container_sn != '') {
this.showDrawer(2, this.list[0]);
}
}, 800);
}
} else {
if (type == 1) {
this.input_flag_position_name = false;
this.getData();
} else if (type == 2) {
this.searchParams.stock_in_batch_sn = '';
this.input_flag_stock_in_batch_sn = false;
this.getData();
} else if (type == 3) {
this.input_flag_container_sn = false;
this.getData();
}
}
}, 500),
/**
* tab切换
* @param {Object} index
*/
tab(index) {
this.curr = index;
this.getData();
this.image_list = [];
},
/**
* 展开弹窗
* @param {Object} type
* @param {Object} data
*/
showDrawer(type, data) {
if (type == 1) {
//按货品拣货
this.formParams.pick_remark = '';
this.$refs.showRight.open();
this.detail = data;
this.picked_num = Number(data.lock_qty) - Number(data.pick_qty);
this.formParams.pick_qty = Number(data.lock_qty) - Number(data.pick_qty);
this.image_list = []; //清空图片列表
} else if (type == 2) {
//按容器拣货
this.formParams.pick_remark = '';
this.$refs.showRightPack.open();
this.detailContainer = data;
this.image_list = []; //清空图片列表
this.lock_ids = data.list.map(function(item) {
return item.lock_id;
});
} else if (type == 3) {
this.input_flag_container_sn = true;
this.getData();
setTimeout(() => {
if (this.searchParams.container_sn != '') {
this.showDrawer(2, this.list[0]);
}
}, 800);
//批量拣货
if (this.filter_id == 0) {
uni.showToast({
title: '请选择拣货任务',
icon: 'none'
});
return false;
}
this.formParams.pick_remark = '';
this.$refs.showRightPackMultiPick.open();
this.image_list = []; //清空图片列表
}
} else {
},
/**
* 关闭弹窗
* @param {Object} type
*/
closeDrawer(type) {
if (type == 1) {
this.input_flag_position_name = false;
this.getData();
//按货品拣货
this.$refs.showRight.close();
} else if (type == 2) {
this.searchParams.stock_in_batch_sn = '';
this.input_flag_stock_in_batch_sn = false;
this.getData();
//按容器拣货
this.$refs.showRightPack.close();
} else if (type == 3) {
this.input_flag_container_sn = false;
this.getData();
//批量拣货
this.$refs.showRightPackMultiPick.close();
}
}
}, 500),
/**
* tab切换
* @param {Object} index
*/
tab(index) {
this.curr = index;
this.getData();
this.image_list = [];
},
/**
* 展开弹窗
* @param {Object} type
* @param {Object} data
*/
showDrawer(type, data) {
if (type == 1) {
//按货品拣货
this.formParams.pick_remark = '';
this.$refs.showRight.open();
this.detail = data;
this.picked_num = Number(data.lock_qty) - Number(data.pick_qty);
this.formParams.pick_qty = Number(data.lock_qty) - Number(data.pick_qty);
this.image_list = []; //清空图片列表
} else if (type == 2) {
//按容器拣货
this.formParams.pick_remark = '';
this.$refs.showRightPack.open();
this.detailContainer = data;
this.image_list = []; //清空图片列表
this.lock_ids = data.list.map(function(item) {
return item.lock_id;
},
/**
* 找出false对应的下标
* @param {Object} arr
* @param {Object} target
*/
findIndex(arr, target) {
const result = [];
arr.map((item, index) => {
if (item === target) {
result.push(index);
}
});
} else if (type == 3) {
//批量拣货
if (this.filter_id == 0) {
uni.showToast({
title: '请选择拣货任务',
icon: 'none'
});
return false;
}
this.formParams.pick_remark = '';
this.$refs.showRightPackMultiPick.open();
this.image_list = []; //清空图片列表
}
},
/**
* 关闭弹窗
* @param {Object} type
*/
closeDrawer(type) {
if (type == 1) {
//按货品拣货
this.$refs.showRight.close();
} else if (type == 2) {
//按容器拣货
this.$refs.showRightPack.close();
} else if (type == 3) {
//批量拣货
this.$refs.showRightPackMultiPick.close();
}
},
/**
* 找出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].lock_id);
this.rePrintTagParams.stock_out_item_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(',');
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].lock_id);
this.rePrintTagParams.stock_out_item_id = filter_arr.map(i => this.list[i].stock_out_item_id);
//当检测到全部取消的时候不应该调用接口
if (this.history_id.length == 0) {
this.list = [];
this.search_keyword = '';
return false;
}
//开启了批量搜索,如果取消勾选则删除
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(',');
//搜索之后添加选择状态
this.getData(data => {
if (data.length > 0) {
const list = data;
list.forEach((item, index) => {
this.filterChange(index);
});
//当检测到全部取消的时候不应该调用接口
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 = '';
}
});
}
}
}
},
/**
* 选择图片
*/
chooseImageChange() {
this.noexebshowFalg = false;
// 使用 chooseImage选择图片
uni.chooseImage({
count: this.maxNum,
sizeType: ['original', 'compressed'],
sourceType: ['album', 'camera'],
success: chooseImageRes => {
console.log('选择图片成功:', chooseImageRes);
},
/**
* 选择图片
*/
chooseImageChange() {
this.noexebshowFalg = false;
// 使用 chooseImage选择图片
uni.chooseImage({
count: this.maxNum,
sizeType: ['original', 'compressed'],
sourceType: ['album', 'camera'],
success: chooseImageRes => {
console.log('选择图片成功:', chooseImageRes);
// 显示loading
uni.showLoading({
title: '上传中...'
});
// 显示loading
uni.showLoading({
title: '上传中...'
});
// 获取选择的图片路径数组
const imagePaths = chooseImageRes.tempFilePaths;
// 判断选择的图片数量是否超过最大限制数量
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;
}
// 获取选择的图片路径数组
const imagePaths = chooseImageRes.tempFilePaths;
// 遍历图片路径数组,对每张图片进行压缩
imagePaths.forEach(imagePath => {
// 使用compressImage 压缩图片
uni.compressImage({
src: imagePath,
quality: 50, //压缩质量,范围0~100,数值越小,质量越低,压缩率越高
success: compressedRes => {
console.log('压缩图片成功:', compressedRes);
// 获取压缩后的图片路径
const compressedImagePath = compressedRes.tempFilePath;
// 判断选择的图片数量是否超过最大限制数量
let maxNum = Number(imagePaths.length) + Number(this.image_list.length); //当前上传的+已经上传的
if (maxNum > this.maxNum) {
uni.hideLoading();
// 在这里处理压缩后的图片,上传到服务器
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
});
},
/**
*打印货品标签
*/
rePrintTag(type) {
if (type == 1) {
this.rePrintTagParams.stock_out_item_id = this.detail.stock_out_item_id;
this.rePrintTagParams.recheck_num = this.formParams.pick_qty;
} else {
if (this.filter_id.length == 0) {
uni.showToast({
title: '图片不超过' + this.maxNum + '张',
icon: 'none'
title: '请勾选数据',
icon: 'error'
});
return false;
}
this.rePrintTagParams.stock_out_item_id = this.rePrintTagParams.stock_out_item_id.join(','); //出库明细ids
}
// 遍历图片路径数组,对每张图片进行压缩
imagePaths.forEach(imagePath => {
// 使用compressImage 压缩图片
uni.compressImage({
src: imagePath,
quality: 50, //压缩质量,范围0~100,数值越小,质量越低,压缩率越高
success: compressedRes => {
console.log('压缩图片成功:', compressedRes);
// 获取压缩后的图片路径
const compressedImagePath = compressedRes.tempFilePath;
// 在这里处理压缩后的图片,上传到服务器
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);
}
this.request(API.RePrintTag, 'POST', this.rePrintTagParams, true).then(res => {
if (res.code === 0) {
uni.showToast({
title: '操作成功',
icon: 'success'
});
});
}
});
},
/**
* 删除图片
* @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
});
},
/**
*打印货品标签
*/
rePrintTag(type) {
if (type == 1) {
this.rePrintTagParams.stock_out_item_id = this.detail.stock_out_item_id;
this.rePrintTagParams.recheck_num = this.formParams.pick_qty;
} else {
if (this.filter_id.length == 0) {
uni.showToast({
title: '请勾选数据',
icon: 'error'
});
return false;
} else {
uni.showToast({
title: res.msg,
icon: 'none'
});
}
});
},
/**
* 监听拣货数量
*/
handleInputNumber: debounce(function(event, num) {
var num = Number(num);
var val = event.target.value * 1;
if (val > num) {
this.formParams.pick_qty = num;
}
this.rePrintTagParams.stock_out_item_id = this.rePrintTagParams.stock_out_item_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'
});
}, 500),
/**
* 获取列表数据
*/
getData(callback) {
if (this.curr == 0) {
//按货品拣货
var URL = API.getLockedList;
} else if (this.curr == 1) {
//按容器拣货
var URL = API.getLockedContainerList;
}
});
},
/**
* 监听拣货数量
*/
handleInputNumber: debounce(function(event, num) {
var num = Number(num);
var val = event.target.value * 1;
if (val > num) {
this.formParams.pick_qty = num;
}
}, 500),
/**
* 获取列表数据
*/
getData(callback) {
if (this.curr == 0) {
//按货品拣货
var URL = API.getLockedList;
} else if (this.curr == 1) {
//按容器拣货
var URL = API.getLockedContainerList;
}
//赋值title
uni.setNavigationBarTitle({
title: this.stock_out_sn + '拣货'
});
//赋值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.lock_qty - item.pick_qty > 0);
this.list = filteredList;
} else if (this.curr == 1) {
var filteredList = res.data.list.filter(item => item.total_lock_num - item.total_pick_num > 0);
this.list = filteredList;
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.lock_qty - item.pick_qty > 0);
this.list = filteredList;
} else if (this.curr == 1) {
var filteredList = res.data.list.filter(item => item.total_lock_num - item.total_pick_num > 0);
this.list = filteredList;
}
this.filter_list = createArray(this.list.length, false); //创建状态数组
typeof callback == 'function' && callback(res.data.list, res.data.notice_msg);
} else {
uni.showToast({
title: res.msg,
icon: 'none'
});
}
this.filter_list = createArray(this.list.length, false); //创建状态数组
typeof callback == 'function' && callback(res.data.list, res.data.notice_msg);
} else {
uni.showToast({
title: res.msg,
icon: 'none'
});
});
},
/**
* 清空数据
*/
clearInput(type) {
if (type == 1) {
this.searchParams.position_name = '';
this.input_flag_position_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;
}
});
},
/**
* 清空数据
*/
clearInput(type) {
if (type == 1) {
this.searchParams.position_name = '';
this.input_flag_position_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();
},
/**
* 按货品拣货提交
*/
pick(lock_id, pick_qty, stock_out_item_id) {
var num = Number(this.detail.lock_qty) - Number(this.detail.pick_qty);
var pick_qty_num = pick_qty * 1;
var pic_ids = this.image_list.map(item => {
return item.pic_id;
});
this.request(API.pick, 'POST', { lock_id: lock_id, pick_qty: pick_qty, stock_out_item_id: stock_out_item_id, pic_ids: pic_ids.join(','), pick_remark: this.formParams.pick_remark }, true).then(res => {
if (res.code === 0) {
uni.showToast({
title: '拣货成功',
icon: 'success'
});
setTimeout(() => {
this.getData();
if (pick_qty_num == num) {
this.searchParams.stock_in_batch_sn = '';
this.closeDrawer(1);
} else {
this.picked_num = Number(this.picked_num) - pick_qty_num;
}
}, 2000);
this.getData();
},
/**
* 按货品拣货提交
*/
pick(lock_id, pick_qty, stock_out_item_id) {
var num = Number(this.detail.lock_qty) - Number(this.detail.pick_qty);
var pick_qty_num = pick_qty * 1;
var pic_ids = this.image_list.map(item => {
return item.pic_id;
});
this.request(API.pick, 'POST', { lock_id: lock_id, pick_qty: pick_qty, stock_out_item_id: stock_out_item_id, pic_ids: pic_ids.join(','), pick_remark: this.formParams.pick_remark }, true).then(res => {
if (res.code === 0) {
uni.showToast({
title: '拣货成功',
icon: 'success'
});
setTimeout(() => {
this.getData();
if (pick_qty_num == num) {
this.searchParams.stock_in_batch_sn = '';
this.closeDrawer(1);
} else {
this.picked_num = Number(this.picked_num) - pick_qty_num;
}
}, 2000);
} else {
uni.showModal({
itle: '提示',
content: res.msg,
showCancel: false
});
}
});
},
/**
* 按容器拣货提交 || 批量拣货
*/
makeMultiPickingFinish() {
//图片集合
var pic_ids = this.image_list.map(item => {
return item.pic_id;
});
var lock_ids = '';
var flag = false;
if (this.filter_id.length > 0 && this.lock_ids.length == 0) {
//批量拣货
lock_ids = this.filter_id.join(',');
flag = true;
} else {
uni.showModal({
itle: '提示',
content: res.msg,
showCancel: false
});
//按容器拣货
lock_ids = this.lock_ids.join(',');
flag = false;
}
});
},
/**
* 按容器拣货提交 || 批量拣货
*/
makeMultiPickingFinish() {
//图片集合
var pic_ids = this.image_list.map(item => {
return item.pic_id;
});
var lock_ids = '';
var flag = false;
if (this.filter_id.length > 0 && this.lock_ids.length == 0) {
//批量拣货
lock_ids = this.filter_id.join(',');
flag = true;
} else {
//按容器拣货
lock_ids = this.lock_ids.join(',');
flag = false;
this.request(API.makeMultiPickingFinish, 'POST', { stock_out_id: this.searchParams.stock_out_id, lock_ids: lock_ids, pic_ids: pic_ids.join(','), pick_remark: this.formParams.pick_remark }, true).then(res => {
if (res.code === 0) {
uni.showToast({
title: '拣货成功',
icon: 'success'
});
setTimeout(() => {
if (flag) {
this.history_id = [];
this.filter_id = [];
this.search_keyword = '';
this.searchParams.stock_in_batch_sn = '';
this.is_batch_active = false;
this.closeDrawer(3);
} else {
this.closeDrawer(2);
}
this.getData();
}, 2000);
} else {
uni.showModal({
itle: '提示',
content: res.msg,
showCancel: false
});
}
});
}
this.request(API.makeMultiPickingFinish, 'POST', { stock_out_id: this.searchParams.stock_out_id, lock_ids: lock_ids, pic_ids: pic_ids.join(','), pick_remark: this.formParams.pick_remark }, true).then(res => {
if (res.code === 0) {
uni.showToast({
title: '拣货成功',
icon: 'success'
});
setTimeout(() => {
if (flag) {
this.history_id = [];
this.filter_id = [];
this.search_keyword = '';
this.searchParams.stock_in_batch_sn = '';
this.is_batch_active = false;
this.closeDrawer(3);
} else {
this.closeDrawer(2);
}
this.getData();
}, 2000);
} else {
uni.showModal({
itle: '提示',
content: res.msg,
showCancel: false
});
}
});
}
}
};
};
</script>
<style scoped lang="scss">
@import '@/assets/css/picking/sort.scss';
.disabled-color {
background: #eaeaef !important;
}
</style>
@import '@/assets/css/picking/sort.scss';
.disabled-color {
background: #eaeaef !important;
}
</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