Commit 364b6029 by LJM

add

parent 56e7358b
Showing with 160 additions and 36 deletions
......@@ -259,9 +259,6 @@
}
}
},
created() {
this.getOrigin();
},
methods: {
/**
* 点击遮罩层触发
......@@ -641,6 +638,8 @@
if (res.err_code === 0) {
this.tallyData = res.data;
if (res.data.detail.length > 0) {
this.getOrigin(); //获取产地
// 使用 map 方法生成表单数组
this.form = res.data.detail.map((item) => ({
tally_status: item.tally_status, //理货状态
......
<template>
<view class="unboxing">
<view class="input-box row bothSide verCenter">
<input class="uni-input" placeholder="输入或扫描入箱号" placeholder-style="color:#000;font-weight: bold;" v-model="box_sn" @input="handleInput($event)" />
<input class="uni-input" placeholder="输入或扫描入箱号" placeholder-style="color:#000;font-weight: bold;" v-model="box_sn" @input="handleInput($event,1)" />
<template v-if="tallyData.detail && tallyData.detail.length > 0">
<view class="btn1 row rowCenter verCenter" @click="closeBox()">重新封箱</view>
</template>
......@@ -9,6 +9,31 @@
<view class="btn row rowCenter verCenter" @click="unboxing()">开 箱</view>
</template>
</view>
<view class="column-box row bothSide verCenter" style="margin-bottom: 0;">
<view class="row verCenter">
<view class="select-box">
<picker @change="bindPickerChange" :value="index" :range="item">
<view class="wrap row verCenter bothSide">
<view class="uni-input">{{ item[index] }}</view>
<text class="iconfont icon-sanjiaoxing1 uni-arrow"></text>
</view>
</picker>
</view>
<view class="input-box row verCenter">
<!-- 其他 -->
<template v-if="index == 0">
<input class="uni-input" placeholder="输入或扫描" placeholder-style="color:#000;font-weight: bold;" v-model="goods_type" @input="handleInput($event,2)" />
</template>
<!-- digikey等供应商-->
<template v-else>
<input class="uni-input" placeholder="输入或扫描" placeholder-style="color:#000;font-weight: bold;" v-model="keyword" @input="handleInput($event,2)" />
</template>
</view>
</view>
<view class="action-bar">
<view class="btn1 row rowCenter verCenter" @click="identifyQrCodeNumAndSn()">扫 描</view>
</view>
</view>
<!-- 列表 -->
<view class="list" v-if="tallyData && tallyData.detail">
<scroll-view scroll-y="true" class="scroll-Y">
......@@ -112,8 +137,8 @@
</view>
</uni-popup>
<!-- 关单封箱弹窗 -->
<uni-popup ref="inputDialog" type="dialog" :mask-click="true">
<uni-popup-dialog ref="inputClose" mode="input" :title="title" v-model="gross_weight" confirmText="新箱子" cancelText="不需要换箱" placeholder="请输入毛重" @close="dialogInputClose" @confirm="dialogInputConfirm" :before-close="true"></uni-popup-dialog>
<uni-popup ref="inputDialog" type="dialog" :mask-click="true" @maskClick="maskClick">
<uni-popup-dialog ref="inputClose" mode="input" :title="title" v-model="gross_weight" value="" confirmText="新箱子" cancelText="不需要换箱" placeholder="请输入毛重" @close="dialogInputClose" @confirm="dialogInputConfirm" :before-close="true"></uni-popup-dialog>
</uni-popup>
</view>
</template>
......@@ -127,7 +152,9 @@
data() {
return {
box_sn: '',
keyword: '',
tallyData: {}, //理货信息
goods_type: '', //商品型号
image_list: [], //图片列表
filter_status: [], //控制状态
origin_list: [], //产地
......@@ -135,8 +162,10 @@
origin: '', //搜索国家携带的参数
form: {},
title: '',
gross_weight: ''
gross_weight: '',
index: 0,
item: ['其他', 'DigiKey', 'Rochester', 'TME', 'Chip1stop', 'Mouser'],
net_weight_total: 0 //净重合计
};
},
watch: {
......@@ -152,15 +181,59 @@
},
methods: {
/**
* 点击遮罩层触发
*/
maskClick() {
this.$refs.inputDialog.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;
},
bindPickerChange: function(e) {
console.log('picker发送选择改变,携带值为', e.detail.value);
this.index = e.detail.value;
},
/**
* @param {Object} event 输入框监听
*/
handleInput: debounce(function(event) {
handleInput: debounce(function(event, type) {
var value = event.target.value;
if (type == 1) {
if (value) {
this.unboxing();
}
} else if (type == 2) {
if (value) {
this.identifyQrCodeNumAndSn();
}
} else if (type == 3) {
this.origin_list = []; //数组清空
this.getOrigin();
}
}, 500),
/**
*筛选过滤出选中的元素
*/
filterChange(index) {
this.$set(this.filter_status, index, (this.filter_status[index] = !this.filter_status[index]));
let filter_arr = this.findIndex(this.filter_status, true);
let name = filter_arr.map(i => this.origin_list[i]);
this.form[this.curr].origin = name[0];
this.$forceUpdate();
this.$refs.popup.close();
},
/**
* 开箱
*/
unboxing() {
......@@ -304,18 +377,68 @@
});
},
/**
* 识别
*/
identifyQrCodeNumAndSn() {
if (!this.box_sn) {
uni.showModal({
title: '',
content: '请先取箱号!并将打印的箱号贴于外箱上',
showCancel: false
});
return false;
}
if (this.index == 0) {
//区分其他
this.getTallyData();
} else {
let codeTypeByIndex = {
1: 'DigiKey',
2: 'Rochester',
3: 'TME',
4: 'Chip1stop',
5: 'Mouser'
};
let codeType = codeTypeByIndex[this.index] || '';
let device = uni.getDeviceInfo();
//匹配到内容才开始调接口
if (!this.isRequestSent) {
this.isRequestSent = true; // 设置标志,防止重复发送请求
this.request(API.scanQrCode, 'POST', { data: this.keyword, type: codeType, device: device.deviceModel }, true).then(res => {
this.isRequestSent = false; // 请求完成后重置标志
if (res.code === 0) {
//如果后台搜索到型号则替换输入框的值
let model = res.data.model || res.data.model2;
if (model) {
this.keyword = model; //兼容TME
this.goods_type = model; //赋值检索出来的型号
}
this.getTallyData();
} else {
uni.showToast({
title: res.msg,
icon: 'none'
});
}
});
}
}
},
/**
* 获取锁定理货信息
*
*/
getTallyData() {
this.request(API.getTallyData, 'POST', { box_sn: this.box_sn }, true).then(res => {
this.request(API.getTallyData, 'POST', { box_sn: this.box_sn, goods_type: this.goods_type }, true).then(res => {
if (res.err_code === 0) {
this.tallyData = res.data;
if (res.data.detail.length > 0) {
this.getOrigin();
this.getOrigin(); //获取产地
// 使用 map 方法生成表单数组
this.form = res.data.detail.map((item) => ({
tally_status: item.tally_status, //理货状态
tally_num: item.tally_num, // 入库数量
origin: item.origin, // 原产地
net_weight: item.net_weight, // 净重
......@@ -328,11 +451,17 @@
this.image_list = res.data.detail.map(() => new Array()); //图片特殊处理
//还原理货的图片
res.data.detail.forEach((item, index) => {
if (item.goods_check_pic) {
this.image_list[index] = item.goods_check_pic.split(',');
}
});
} else {
uni.showToast({
title: '查询不到该箱号信息',
icon: 'none'
});
}
} else {
uni.showToast({
......@@ -403,7 +532,7 @@
content: '确定取消该商品理货吗?',
success: (res) => {
if (res.confirm) {
this.request(API.cancelTallyDetail, 'POST', { wstydl_id: this.form[index].wstydl_id, box_sn: box_sn }, true).then(res => {
this.request(API.cancelTallyDetail, 'POST', { wstydl_id: this.form[index].wstydl_id, box_sn: this.box_sn }, true).then(res => {
if (res.err_code === 0) {
this.getTallyData(1);
} else {
......@@ -423,7 +552,10 @@
* 关单封箱
*/
closeBox() {
this.title = `箱号${this.box_sn}已经全部验货完毕是否更换新的箱子?`;
this.net_weight_total = this.form
.filter(item => item.tally_status === 3) // 筛选出 tally_status 等于 3 的数据
.reduce((acc, curr) => acc + parseFloat(curr.net_weight), 0); // 将 net_weight 转换为数字并计算总和
this.title = `入仓号${this.erp_order_sn}已经全部验货完毕是否更换新的箱子?\n\n总净重:${this.net_weight_total}`;
this.$refs.inputDialog.open();
},
/**
......@@ -437,6 +569,22 @@
});
return false;
}
// 判断 val 是否为数字
if (isNaN(val)) {
uni.showToast({
title: '请输入合法数字',
icon: 'error'
});
return false;
}
if (Number(val) < Number(this.net_weight_total)) {
uni.showToast({
title: '毛重不能小于总净重',
icon: 'none'
});
return false;
}
this.request(API.closeBox, 'POST', { box_sn: this.box_sn, gross_weight: val }, true).then(res => {
if (res.err_code === 0) {
uni.showToast({
......@@ -461,31 +609,8 @@
* 不需要换箱
*/
dialogInputClose() {
if (!this.gross_weight) {
uni.showToast({
title: '请输入毛重',
icon: 'error'
});
return false;
}
this.request(API.closeBox, 'POST', { box_sn: this.box_sn, gross_weight: this.gross_weight }, true).then(res => {
if (res.err_code === 0) {
uni.showToast({
title: '操作成功',
icon: 'success',
duration: 2000
});
setTimeout(() => {
this.$refs.inputDialog.close();
this.tallyData = [];
}, 2000);
} else {
uni.showToast({
title: res.err_msg,
icon: 'none'
});
}
});
}
}
};
......
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