Files
wcs/PDA/PDA/pages/productionLineCallOut/productionLineCallOut.vue
2025-02-26 15:10:15 +08:00

766 lines
19 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<view class="bg-image">
<uni-popup ref="popup" type="dialog">
<view class="popup-content">
<view class="info-item">
<label>物料编码</label>
<text>{{fixedInfo.matCode}}</text>
</view>
<view class="info-item">
<label>物料名称</label>
<text>{{fixedInfo.matName}}</text>
</view>
<view class="info-item">
<label>物料规格</label>
<text>{{fixedInfo.matSpec}}</text>
</view>
<view class="input-item" style="background-color: wheat;">
<label>数量</label>
<input ref="inputRef" v-model.number="inputValue" type="number" placeholder="输入数量" />
</view>
<view class="button-group">
<button @click="hidePopup">取消</button>
<button @click="saveData">保存</button>
</view>
</view>
</uni-popup>
<view class="diy-flex-row">
<view style="flex: 3">
<!-- 占位 -->
</view>
<view style="flex: 80;margin: 5rpx;">
<view class="diy-flex-row">
<view class="rightImageContainer" style="flex: 12;padding-top: 20rpx;">
<image style="width: 60rpx;height: 60rpx" src="/static/scan.png" />
</view>
<view class="uni-input-wrapper" style="flex: 60;">
<input ref="inputMatCode" class="uni-input" style="font-size: 50rpx; padding: 10rpx;"
:placeholder="placeholderText" v-model="matCodeCondition" @blur="queryMatList"></input>
</view>
<view style="flex: 3;">
</view>
<view style="flex: 30;">
<button @click="analysisScanCode(this.shelfCode)">查询</button>
</view>
</view>
</view>
<view style="flex: 2">
<!-- 占位 -->
</view>
</view>
<view class="diy-flex-column" style="margin-top: 5rpx;">
<view class="diy-flex-inforow">
<view style="width: 740;">货架码:{{shelfCode}}</view>
</view>
<view class="diy-flex-inforow">
<view style="width: 740;">工位码:{{locationCode}}</view>
</view>
</view>
<view class="diy-flex-column" style="margin-top: 5rpx;">
<scroll-view class="scroll-view" scroll-y="true">
<view v-for="(item, index) in cardData" :key="index" @touchstart="cardTouchStart"
@touchmove="cardTouchMove" @longpress="longpress(item)">
<Card :item="item" :currentIndex="index" :cardData="cardData" />
</view>
</scroll-view>
</view>
<view
style="position: fixed; bottom: 0; left: 0; width: 100%; display: flex; justify-content: space-between; align-items: center; z-index: 100;">
<!-- 货架区域选择 -->
<view class="picker-container1" style="position: relative;">
<picker ref="shelfAreaPicker" :range="shelfAreaOptions" range-key="locationAreaName"
:value="selectedShelfAreaIndex" @change="onShelfAreaChange" style="font-size: 35rpx;">
<view class="uni-input">{{shelfAreaOptions[selectedShelfAreaIndex].locationAreaName}}</view>
</picker>
</view>
<!-- 货架类型选择 -->
<view class="picker-container" style="position: relative;">
<picker ref="shelfTypePicker" :range="shelfTypeOptions" range-key="text" :value="selectedShelfTypeIndex"
@change="onShelfTypeChange" style="font-size: 35rpx;width: 200rpx;">
<view class="uni-input">{{shelfTypeOptions[selectedShelfTypeIndex].text}}</view>
</picker>
</view>
<!-- 货架送回按钮 -->
<button style="width: 200rpx;margin: 2rpx; background: green; color: white;"
@click="sendBackShelf">货架送回</button>
</view>
</view>
</template>
<script>
import bindSelectMat from '@/pages/bindSelectMat/bindSelectMat.vue';
import {
recive
} from '../../src/libs/Broadcast.js';
import {
unregisterReceiver
} from '../../src/libs/Broadcast.js';
import {
getConfig
} from '@/config.js';
import {
saveConfig
} from '@/config.js';
import {
getServerIPAndPort
} from '@/config.js';
import Card from '@/components/Card.vue';
import {
ref,
onMounted,
nextTick
} from 'vue';
import uniPopup from '@/node_modules/@dcloudio/uni-ui/lib/uni-popup/uni-popup';
import {
getCurrentInstance
} from 'vue';
export default {
components: {
uniPopup,
Card
},
setup() {
const {
proxy
} = getCurrentInstance();
// 不能修改的信息
const fixedInfo = ref({
infoId: 0,
matCode: '示例名称',
matName: '这是一段示例描述',
matSpec: '',
matQty: 0,
stocktakingQty: 0,
});
const popup = ref(null);
const inputValue = ref('');
const showPopup = (info) => {
fixedInfo.infoId = info.id;
console.log(fixedInfo.infoId);
fixedInfo.value.matName = info.matName;
fixedInfo.value.matCode = info.matCode;
fixedInfo.value.matSpec = info.matSpec;
fixedInfo.value.matQty = info.matQty;
inputValue.value = fixedInfo.value.matQty;
popup.value.open();
};
const hidePopup = () => {
popup.value.close();
};
const saveData = () => {
if (inputValue.value == fixedInfo.value.matQty) {
uni.showToast({
title: '本次修改未修改数量',
icon: 'none',
duration: 2500
});
hidePopup();
return;
}
if (inputValue.value < 0) {
uni.showToast({
title: '您所输入的数量应该大于等于0',
icon: 'none',
duration: 2500
});
return;
}
var serverIPAndPort = getServerIPAndPort();
//调用接口进行数量的修改
uni.request({
url: 'http://' + serverIPAndPort +
'/PDAProductionLineCallOut/updateMatDetailCurrentInfoForCallOut', // 请求的接口地址
method: 'POST', // 设置请求方式为 POST
data: {
"matQty": inputValue.value,
"matDetailCurrentInfoId": fixedInfo.infoId,
"userName": getConfig('userName', 'admin'),
"deviceType": "PDA"
},
header: {
'Content-Type': 'application/json', // 如果需要以JSON格式发送数据
},
success: (res) => {
// 请求成功的回调函数
if (res.statusCode === 200) {
//接口返回数据为200 表示获取成功!
if (res.data.code == 200) {
hidePopup();
uni.showToast({
title: '修改成功!',
icon: 'none',
duration: 2000
});
proxy.getCurrentMatInfo();
} else {
uni.showToast({
title: '修改失败:' + res.data.message,
icon: 'none',
duration: 2500
});
}
} else {
uni.showToast({
title: '服务器返回错误状态码' + res.statusCode,
icon: 'none',
duration: 2500
});
}
},
fail: (err) => {
// 请求失败的回调函数
uni.showToast({
title: '请求失败:' + err.errMsg,
icon: 'none',
duration: 3000
});
this.clear();
},
complete: (event) => {
// 请求完成的回调函数(无论成功或失败都会调用)
}
});
};
return {
fixedInfo,
popup,
inputValue,
showPopup,
hidePopup,
saveData
};
},
data() {
return {
locationId: 0,
locationCode: '',
shelfId: 0,
shelfCode: '',
userName: '', //当前登录的用户名
recordCount: 0,
placeholderText: '请先扫描货架码',
matCodeCondition: '', //物料编码搜索条件
cardData: null,
//监控滑动的位置
touchStartX: 0,
touchStartY: 0,
isMove: false, //滑动标识 是否滑动
// 货架区域选项
shelfAreaOptions: [{
id: 1,
locationAreaName: '请先扫货架码'
}],
selectedShelfAreaIndex: 0, // 选择的货架区域索引
// 货架类型选项
shelfTypeOptions: [{
id: 1,
value: 'empty',
text: '空货架'
},
{
id: 2,
value: 'notEmpty',
text: '非空货架'
},
// ... 其他选项
],
selectedShelfTypeIndex: 1, // 选择的货架类型索引
}
},
onShow: function() {
this.userName = getConfig('userName', 'admin');
const self = this; // 保存this的引用
recive(function(res) {
console.log("Success:" + res.data);
self.analysisScanCode(res.data);
}, function(err) {
console.log("Error:", JSON.stringify(err)); // 正确打印错误信息
});
},
methods: {
// 货架区域选择改变时触发
onShelfAreaChange(e) {
this.selectedShelfAreaIndex = e.detail.value;
// 你可以在这里添加其他逻辑,比如更新状态或发送请求
},
// 货架类型选择改变时触发
onShelfTypeChange(e) {
this.selectedShelfTypeIndex = e.detail.value;
// 你可以在这里添加其他逻辑,比如更新状态或发送请求
},
// 货架送回按钮点击时触发
sendBackShelf() {
//货架码
if (this.shelfId == 0 || this.shelfId == null) {
uni.showToast({
title: '请先扫货架码!',
icon: 'none',
duration: 1500
});
return;
}
//货架送回区域是否选择
if (shelfAreaOptions[selectedShelfAreaIndex].locationAreaName = '请先扫货架码') {
uni.showToast({
title: '该位置未绑定货架区域,请确认!',
icon: 'none',
duration: 1500
});
return;
}
//请求送回货架
var serverIPAndPort = getServerIPAndPort();
uni.request({
url: 'http://' + serverIPAndPort +
'/pdaProductionLineCallOut/getShelfInfoForCallOut', // 请求的接口地址
method: 'POST', // 设置请求方式为 POST
data: {
"shelfCode": this.shelfCode,
"userName": this.userName,
"deviceType": "PDA"
},
header: {
'Content-Type': 'application/json', // 如果需要以JSON格式发送数据
},
success: (res) => {
// 请求成功的回调函数
if (res.statusCode === 200) {
//接口返回数据为200 表示获取成功!
if (res.data.code == 200) {
//未查询到信息
if (res.data.data == null) {
uni.showToast({
title: '获取失败,请扫码重试!',
icon: 'none',
duration: 1500
});
return;
}
//绑定货架等信息
this.shelfId = res.data.data.shelfId;
this.shelfCode = res.data.data.shelfCode;
this.locationId = res.data.data.locationId;
this.locationCode = res.data.data.locationCode;
this.shelfAreaOptions = res.data.data.locationAreas;
//获取数据
this.getCurrentMatInfo();
return;
} else {
uni.showToast({
title: '获取失败:' + res.data.message,
icon: 'none',
duration: 3500
});
this.clear();
}
} else {
uni.showToast({
title: '服务器返回错误状态码' + res.statusCode,
icon: 'none',
duration: 3000
});
this.clear();
}
},
fail: (err) => {
// 请求失败的回调函数
uni.showToast({
title: '请求失败:' + err.errMsg,
icon: 'none',
duration: 3000
});
this.clear();
},
complete: (event) => {
// 请求完成的回调函数(无论成功或失败都会调用)
console.log('请求完成', event);
}
});
},
analysisScanCode: function(encodedString) {
// 去除末尾的逗号和"..."(如果有的话)
encodedString = encodedString.replace(/,\s*\.\.\.$/, '');
this.shelfCode = encodedString;
//获取当前货架和所在工位的信息
var serverIPAndPort = getServerIPAndPort();
uni.request({
url: 'http://' + serverIPAndPort +
'/pdaProductionLineCallOut/getShelfInfoForCallOut', // 请求的接口地址
method: 'POST', // 设置请求方式为 POST
data: {
"shelfCode": this.shelfCode,
"userName": this.userName,
"deviceType": "PDA"
},
header: {
'Content-Type': 'application/json', // 如果需要以JSON格式发送数据
},
success: (res) => {
// 请求成功的回调函数
if (res.statusCode === 200) {
//接口返回数据为200 表示获取成功!
if (res.data.code == 200) {
//未查询到信息
if (res.data.data == null) {
uni.showToast({
title: '获取失败,请扫码重试!',
icon: 'none',
duration: 1500
});
return;
}
//绑定货架等信息
this.shelfId = res.data.data.shelfId;
this.shelfCode = res.data.data.shelfCode;
this.locationId = res.data.data.locationId;
this.locationCode = res.data.data.locationCode;
this.shelfAreaOptions = res.data.data.locationAreas;
//获取数据
this.getCurrentMatInfo();
return;
} else {
uni.showToast({
title: '获取失败:' + res.data.message,
icon: 'none',
duration: 3500
});
this.clear();
}
} else {
uni.showToast({
title: '服务器返回错误状态码' + res.statusCode,
icon: 'none',
duration: 3000
});
this.clear();
}
},
fail: (err) => {
// 请求失败的回调函数
uni.showToast({
title: '请求失败:' + err.errMsg,
icon: 'none',
duration: 3000
});
this.clear();
},
complete: (event) => {
// 请求完成的回调函数(无论成功或失败都会调用)
console.log('请求完成', event);
}
});
},
getCurrentMatInfo: function() {
if (this.shelfId == 0 || this.shelfId == null) {
uni.showToast({
title: '获取当前货架物料失败,请扫码重试!',
icon: 'none',
duration: 1500
});
return;
}
//获取当前货架和所在工位的信息
var serverIPAndPort = getServerIPAndPort();
uni.request({
url: 'http://' + serverIPAndPort +
'/matDetailCurrenInfo/getMatDetailCurrentInfos', // 请求的接口地址
method: 'POST', // 设置请求方式为 POST
data: {
"shelfCode": this.shelfCode,
"matCode": '',
"userName": this.userName,
"deviceType": "PDA",
"pageNumber": 1,
"pageSize": 300,
},
header: {
'Content-Type': 'application/json', // 如果需要以JSON格式发送数据
},
success: (res) => {
// 请求成功的回调函数
if (res.statusCode === 200) {
//接口返回数据为200 表示获取成功!
if (res.data.code == 200) {
//未查询到信息
if (res.data.data == null || res.data.data.count == 0) {
uni.showToast({
title: '该货架不存在绑定的物料信息!',
icon: 'none',
duration: 1500
});
return;
}
//有物料信息
this.cardData = res.data.data.lists;
this.recordCount = res.data.data.count;
uni.showToast({
title: '获取成功!',
icon: 'none',
duration: 500
});
} else {
uni.showToast({
title: '获取失败:' + res.data.message,
icon: 'none',
duration: 3500
});
this.clear();
}
} else {
uni.showToast({
title: '服务器返回错误状态码' + res.statusCode,
icon: 'none',
duration: 3000
});
this.clear();
}
},
fail: (err) => {
// 请求失败的回调函数
uni.showToast({
title: '请求失败:' + err.errMsg,
icon: 'none',
duration: 3000
});
this.clear();
},
complete: (event) => {
// 请求完成的回调函数(无论成功或失败都会调用)
console.log('请求完成', event);
}
});
},
//清空当前界面所有内容
clear: function() {
this.placeholderText = '请先扫描货架码';
this.cardData = null;
this.recordCount = 0;
},
//解决长按和滑动冲突的问题
cardTouchStart(e) {
this.isMove = false;
this.touchStartX = e.touches[0].clientX;
this.touchStartY = e.touches[0].clientY;
},
cardTouchMove(e) {
var deltaX = e.changedTouches[0].clientX - this.touchStartX;
var deltaY = e.changedTouches[0].clientY - this.touchStartY;
if (Math.abs(deltaX) > 5 || Math.abs(deltaY) > 5) {
this.isMove = true;
}
},
//长按
longpress(item) {
if (this.isMove == false) {
this.showPopup(item);
}
},
}
}
</script>
<style>
.picker-container1 {
border: 2rpx solid #000;
/* 设置边框宽度和颜色 */
padding: 2rpx;
/* 根据需要添加内边距 */
margin: 3rpx;
/* 根据需要添加外边距以分隔 pickers */
box-sizing: border-box;
/* 确保边框和内边距包含在总宽度内 */
width: calc(40% - 20rpx);
/* 设置宽度为父容器宽度的一半减去外边距 */
}
.picker-container {
border: 2rpx solid #000;
/* 设置边框宽度和颜色 */
padding: 2rpx;
/* 根据需要添加内边距 */
margin: 3rpx;
/* 根据需要添加外边距以分隔 pickers */
box-sizing: border-box;
/* 确保边框和内边距包含在总宽度内 */
width: calc(28% - 20rpx);
/* 设置宽度为父容器宽度的一半减去外边距 */
}
.uni-input {
width: 100%;
/* 确保输入框宽度与父容器一致 */
box-sizing: border-box;
/* 确保内边距和边框包含在总宽度内 */
}
.uni-input-wrapper {
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
flex-direction: row;
flex-wrap: nowrap;
background-color: #FFFFFF;
}
.mini-btn {
margin-right: 10rpx;
}
.bg-image {
background-image: url('/static/background.png');
/* 背景图片路径 */
background-size: cover;
/* 背景图片覆盖整个元素 */
background-position: center;
/* 背景图片居中 */
height: 100%;
/* 视图高度设置为100% */
width: 100%;
/* 视图宽度设置为100% */
position: fixed;
/* 视图定位为固定 */
top: 0;
left: 0;
/* z-index: -1; */
}
.diy-flex-row {
display: flex;
flex-direction: row;
margin-top: 10rpx;
margin-bottom: 10rpx;
font-size: 40rpx;
}
.diy-flex-column {
display: flex;
flex-direction: column;
}
.diy-flex-inforow {
display: flex;
flex-direction: row;
font-size: 40rpx;
font-weight: 500;
margin-top: 8rpx;
margin-bottom: 8rpx;
}
.scroll-view {
height: 73.7vh;
}
.popup-content {
padding: 20px;
background-color: rgba(0, 0, 0, 1);
background-color: white;
z-index: 2;
border-radius: 20rpx;
}
.input-item {
margin-bottom: 5rpx;
display: flex;
align-items: center;
/* 让内部元素垂直居中 */
}
.input-item label {
display: inline-block;
}
.input-item input {
display: inline-block;
background: wheat;
width: 280rpx;
}
.button-group {
display: flex;
justify-content: space-between;
margin-top: 20rpx;
}
.button-group button {
margin-top: 20rpx;
padding: 10rpx 10rpx;
border: none;
border-radius: 5px;
background-color: #007AFF;
color: #fff;
cursor: pointer;
}
.cardNoStocktaking {
border: 3rpx solid black;
border-radius: 15rpx;
margin: 8rpx;
padding: 8rpx;
background-color: beige;
}
.cardYesStocktaking {
border: 3rpx solid black;
border-radius: 15rpx;
margin: 8rpx;
padding: 8rpx;
background-color: seagreen;
}
</style>