物流管理问题修改

master
zhangdi 2 days ago
parent 4b2d71345c
commit c870d44475
  1. 1
      README.md
  2. 3
      manifest.json
  3. 330
      pages/logistics/delivery.vue
  4. 142
      pages/logistics/intoStock.vue
  5. 406
      pages/logistics/packaging.vue
  6. 68
      pages/logistics/weighing.vue

@ -0,0 +1 @@
打包证书密码 zhgd_pda

@ -102,6 +102,9 @@
"router" : {
"mode" : "hash",
"base" : "./"
},
"devServer" : {
"https" : false
}
}
}

@ -24,6 +24,8 @@
</view>
</view>
</uni-forms-item>
<!-- 1. 物料箱条码 (使用 oneInput) -->
<uni-forms-item label="物料箱条码:" label-width="100px">
<template #label>
<view class="required-label">
@ -35,40 +37,20 @@
<view class="input-box">
<input
type="text"
v-model="boxCode"
@confirm="handleBoxConfirm"
v-model="oneInput"
@input="oneInputBlur"
placeholder="物料箱条码"
class="uni-input-border"
confirm-type="done"
:focus="boxInputFocus"
:key="'box-' + boxInputFocus"
/>
</view>
</view>
<!-- <button
@click="handleSubmit"
:disabled="!startData || !endCenter"
class="submit-btn"
:class="{ 'btn-disabled': !startData || !endCenter }"
>
配送
</button> -->
</view>
<!-- <view v-if="boxData" class="box-info">
<view class="info-section">
<text class="info-text">
包含订单:
<text class="info-value">{{ boxData.quantity }}</text>
</text>
<text class="info-text">
对应中心:
<text class="info-value-center">{{ boxData.wcName }}</text>
</text>
</view>
<button @click="detailsFn()" class="details-btn">
明细 <text class="arrow"></text>
</button>
</view> -->
</uni-forms-item>
<!-- 2. 起点站点/区域 (使用 twoInput) -->
<uni-forms-item
label="起点站点:"
label-width="100px"
@ -82,18 +64,21 @@
</template>
<input
type="text"
v-model="startCode"
@confirm="handleStartConfirm"
v-model="twoInput"
@input="twoInputBlur"
placeholder="站点码"
class="uni-input-border"
confirm-type="done"
:focus="startInputFocus"
:key="'start-' + startInputFocus"
/>
<view v-if="startData" class="start-confirm">
<text class="check-icon"></text>
<text class="confirm-text">已确认: {{ startData.stationName }}</text>
</view>
</uni-forms-item>
<!-- 叫料模式下的起点选择 (保持 Picker 不变但逻辑需适配) -->
<uni-forms-item label="起点区域:" label-width="100px" v-else>
<template #label>
<view class="required-label">
@ -135,6 +120,8 @@
>暂无可配送物料</text
>
</uni-forms-item>
<!-- 3. 终点区域 (使用 therrInput 用于叫料模式的扫码) -->
<uni-forms-item
label="终点区域:"
label-width="150px"
@ -176,27 +163,32 @@
</text>
</view>
</picker>
<!-- 终点区域选择 - 无数据时显示提示 -->
<view v-else class="empty-tip-picker">
<text class="empty-text">暂无数据</text>
</view>
</uni-forms-item>
<!-- 叫料模式下的终点扫码 -->
<uni-forms-item label="终点区域:" label-width="150px" v-else>
<template #label>
<view class="required-label">
<text class="required-mark">*</text>
<text>终点区域</text>
</view>
<input
type="text"
v-model="endStationCode"
placeholder="请扫描区域码"
class="uni-input-border"
confirm-type="done"
/>
</template>
<input
type="text"
v-model="therrInput"
@input="therrInputBlur"
placeholder="请扫描区域码"
class="uni-input-border"
confirm-type="done"
:focus="endInputFocus"
:key="'end-' + endInputFocus"
/>
</uni-forms-item>
</uni-forms>
<view class="footer-action">
<button
@click="handleSubmit"
@ -212,38 +204,47 @@
<script>
import ifrm from "@/pages/index/ifrm";
import inputBlur from '@/mixin/inputBlur.js'; // mixin
export default {
mixins: [inputBlur], // mixin
components: {
ifrm,
},
data() {
return {
boxCode: "",
startCode: "",
// boxCode, startCode, endStationCode mixin oneInput, twoInput, therrInput
boxData: null,
startData: null,
showDetails: false,
//
boxInputFocus: true,
startInputFocus: false,
endInputFocus: false, //
mockBoxes: {},
workCenters: [],
yieldOrderList: [], //
yieldOrderList: [],
scanMode: "bind",
hasData: false,
workCenters: [], //
endAreas: [], //
endCenter: "", //
endArea: "", //
endCenterIndex: 0, //
endAreaIndex: 0, //
startAreas: [], //
startStations: [], //
startArea: "蓝色周转盒放置区", //
startStation: "", //
startAreaIndex: 0, //
startStationIndex: 0, //
endStationCode: "", //
workCenters: [],
endAreas: [],
endCenter: "",
endArea: "",
endCenterIndex: 0,
endAreaIndex: 0,
startAreas: [],
startStations: [],
startArea: "蓝色周转盒放置区",
startStation: "",
startAreaIndex: 0,
startStationIndex: 0,
// endStationCode therrInput
};
},
computed: {
@ -252,25 +253,10 @@ export default {
return !this.startData || !this.endCenter;
}
if (this.scanMode == "unbind") {
return !this.endStationCode || !this.startStation;
//
return !this.startStation || !this.therrInput;
}
// //
// if (!this.endCenterIndex) {
// return false;
// }
// //
// if (this.scanMode == "bind") {
// console.log(4444444, !this.startData);
// // startData
// return !this.startData;
// } else if (this.scanMode == "unbind") {
// console.log(3333333333, !this.startStationIndex);
// // startStation
// return !this.startStationIndex;
// }
// return false;
return true;
},
},
mounted() {
@ -280,17 +266,82 @@ export default {
this.$refs.ifrm.topMenuClick(btn);
},
methods: {
// mixin
oneInputData(val) {
if (!val) return;
const code = val.trim();
this.handleBoxConfirmLogic(code);
},
// mixin
twoInputData(val) {
if (!val) return;
const code = val.trim();
this.handleStartConfirmLogic(code);
},
// mixin ()
therrInputData(val) {
if (!val) return;
// 使 therrInput
//
console.log("终点区域扫码结果:", val);
},
// handleBoxConfirm
handleBoxConfirmLogic(code) {
if (!code) return;
this.$u.api
.getQuantityLocation({ boxBarcode: code })
.then((res) => {
this.boxData = res.data;
uni.showToast({ title: '物料箱识别成功', icon: 'none' });
//
this.boxInputFocus = false;
if (this.scanMode === 'bind') {
this.startInputFocus = true;
} else {
//
// Picker(picker)
this.boxInputFocus = true;
}
})
.catch(err => {
uni.showToast({ title: err || '查询失败', icon: 'none' });
this.clearOneInput();
this.boxInputFocus = false;
this.$nextTick(() => { this.boxInputFocus = true; });
});
},
// handleStartConfirm
handleStartConfirmLogic(code) {
if (!code) return;
this.$u.api
.getStationName({ stationCode: code })
.then((res) => {
this.startData = res.data;
uni.showToast({ title: '起点站点确认', icon: 'none' });
// (Picker)
this.startInputFocus = false;
})
.catch(err => {
uni.showToast({ title: err || '站点查询失败', icon: 'none' });
this.clearTwoInput();
this.startInputFocus = false;
this.$nextTick(() => { this.startInputFocus = true; });
});
},
//
handleStartAreaChange(e) {
const index = e.detail.value;
this.startArea = this.startAreas[index].name;
this.startAreaIndex = index;
//
this.startStation = "";
this.startStationIndex = 0;
// stationCodeList
this.getStartStationsList(this.startAreas[index].id);
},
@ -303,46 +354,35 @@ export default {
//
getStartAreasList() {
uni.showLoading({
title: "加载中...",
mask: true,
});
uni.showLoading({ title: "加载中...", mask: true });
this.$u.api
.getStationRegion()
.then((res) => {
uni.hideLoading();
const list = res.data || [];
this.startAreas = list.map((area) => ({
id: area.stationRegion,
name: area.stationRegion,
stationCodeList: area.stationCodeList || [],
}));
// ""
const targetRegion = this.startAreas.find(
(item) => item.name == "蓝色周转盒放置区"
);
if (targetRegion) {
//
const targetIndex = this.startAreas.findIndex(
(item) => item.id === targetRegion.id
);
if (targetIndex !== -1) {
this.startArea = targetRegion.name;
this.startAreaIndex = targetRegion.id;
//
const stationCodeList = targetRegion.stationCodeList || [];
if (stationCodeList && stationCodeList.length > 0) {
this.startStations = stationCodeList.map((code) => ({
id: code,
name: code,
}));
//
this.startStation = stationCodeList[0];
this.startStationIndex = 0;
}
@ -350,36 +390,26 @@ export default {
} else {
this.startArea = "蓝色周转盒放置区";
this.startAreaIndex = "蓝色周转盒放置区";
this.startStation = null
this.startStation = null;
}
})
.catch((err) => {
uni.hideLoading();
uni.showToast({
title: "加载区域列表失败",
icon: "none",
});
uni.showToast({ title: "加载区域列表失败", icon: "none" });
});
},
// ID
getStartStationsList(areaId) {
if (!areaId) {
this.startStations = [];
return;
}
// startAreas stationCodeList
const area = this.startAreas.find((item) => item.id === areaId);
if (area && area.stationCodeList && area.stationCodeList.length > 0) {
// stationCodeList picker
this.startStations = area.stationCodeList.map((code, index) => ({
id: code,
name: code,
}));
//
if (this.startStations.length > 0) {
this.startStation = this.startStations[0].name;
this.startStationIndex = 0;
@ -390,28 +420,21 @@ export default {
this.startStationIndex = 0;
}
},
//
handleEndChange(e) {
const index = e.detail.value;
const selectedWorkCenter = this.workCenters[index];
this.endCenter = selectedWorkCenter.name;
this.endCenterIndex = selectedWorkCenter.id;
//
this.endArea = "";
this.endAreaIndex = 0;
// stationRegionList
if (
selectedWorkCenter.stationRegionList &&
selectedWorkCenter.stationRegionList.length > 0
) {
// stationRegionList
const firstItem = selectedWorkCenter.stationRegionList[0];
if (typeof firstItem === "object") {
//
this.endAreas = selectedWorkCenter.stationRegionList.map(
(region) => ({
id: region.id,
@ -419,7 +442,6 @@ export default {
})
);
} else {
//
this.endAreas = selectedWorkCenter.stationRegionList.map(
(region, idx) => ({
id: idx,
@ -427,8 +449,6 @@ export default {
})
);
}
//
if (this.endAreas.length > 0) {
this.endArea = this.endAreas[0].name;
this.endAreaIndex = this.endAreas[0].id;
@ -438,27 +458,25 @@ export default {
}
},
//
handleAreaChange(e) {
const index = e.detail.value;
this.endArea = this.endAreas[index].name;
this.endAreaIndex = index;
},
handleModeChange(mode) {
this.scanMode = mode;
this.hasData = false;
//
this.boxCode = "";
this.boxData = null;
this.boxInputFocus = true;
// 使 mixin
this.clearInput();
//
this.startCode = "";
this.boxData = null;
this.startData = null;
this.boxInputFocus = true;
this.startInputFocus = false;
this.endInputFocus = false;
//
this.startArea = "";
this.startStation = "";
this.startAreaIndex = 0;
@ -466,14 +484,12 @@ export default {
this.startAreas = [];
this.startStations = [];
//
this.endCenter = "";
this.endArea = "";
this.endCenterIndex = 0;
this.endAreaIndex = 0;
this.endAreas = [];
//
if (mode === "unbind") {
this.getStartAreasList();
}
@ -482,43 +498,18 @@ export default {
icon: "none",
});
},
//
detailsFn() {
this.showDetails = true;
this.$u.api
.boxbarcodeDetails({ boxBarcode: this.boxData.boxBarcode,isDetail:false })
.boxbarcodeDetails({ boxBarcode: this.boxData.boxBarcode, isDetail: false })
.then((res) => {
this.yieldOrderList = res.data.yieldOrderList;
});
},
handleBoxConfirm() {
const code = this.boxCode.trim();
if (!code) return;
this.$u.api
.getQuantityLocation({ boxBarcode: this.boxCode })
.then((res) => {
this.boxData = res.data;
this.boxInputFocus = false;
this.startInputFocus = true;
});
},
handleStartConfirm() {
const code = this.startCode.trim();
if (!code) return;
this.$u.api
.getStationName({ stationCode: this.startCode })
.then((res) => {
console.log("起点站点", res.data);
this.startData = res.data;
this.startInputFocus = false;
});
},
//
getWorkCenterList() {
this.$u.api.getWorkCenter().then((res) => {
console.log(res.data);
this.workCenters = res.data.map((c) => ({
id: c.id,
name: c.wcName,
@ -528,61 +519,66 @@ export default {
},
handleSubmit() {
uni.showLoading({
title: "提交中...",
});
let startStationCode = "";
uni.showLoading({ title: "提交中..." });
let query_ = {
boxBarcode: this.boxBarcode || "", //
// startStationCode: startStationCode, //
// endWcId: this.endCenterIndex, //
// endStationCode: this.endStationCode, //
// stationRegion: this.endArea,
boxBarcode: this.oneInput || (this.boxData ? this.boxData.boxBarcode : ""),
};
if (this.scanMode === "bind") {
// startData
if (!this.startData) {
uni.hideLoading();
uni.showToast({ title: '请扫描起点站点', icon: 'none' });
return;
}
query_.startStationCode = this.startData.stationCode;
query_.endWcId = this.endCenterIndex;
query_.stationRegion = this.endArea;
} else if (this.scanMode === "unbind") {
//
if (!this.startStation) {
uni.hideLoading();
uni.showToast({ title: '请选择起点站点', icon: 'none' });
return;
}
if (!this.therrInput) {
uni.hideLoading();
uni.showToast({ title: '请扫描终点区域', icon: 'none' });
return;
}
query_.startStationCode = this.startStation;
query_.endStationCode = this.endStationCode;
}
if (this.scanMode == "unbind" && this.endStationCode == "") {
uni.showToast({
title: `请选择终点区域!`,
icon: "none",
});
return;
query_.endStationCode = this.therrInput; // 使 mixin
}
this.$u.api
.boxBindingTesk(query_)
.then((res) => {
uni.showToast({
title: `成功配送${this.endCenter}!`,
title: `成功配送!`,
icon: "none",
});
uni.hideLoading();
this.boxCode = "";
//
this.clearInput();
this.boxData = null;
this.startCode = "";
this.startData = null;
this.endCenter = "";
this.endArea = "";
this.boxInputFocus = true;
this.startInputFocus = false;
this.endInputFocus = false;
})
.catch((err) => {
uni.hideLoading();
uni.showToast({ title: err || '提交失败', icon: 'none' });
});
},
},
};
</script>
<style scoped>
.page-container {
display: flex;

@ -1,39 +1,45 @@
<template>
<ifrm>
<uni-forms ref="wrForm" class="formBox" label-position="top">
<!-- 1. 物料箱条码 (使用 oneInput) -->
<uni-forms-item label="物料箱条码:" label-width="100px">
<view class="bottom-input-row">
<view class="weight-input-wrapper">
<view class="input-box">
<input
type="text"
v-model="boxCode"
@confirm="handleBoxConfirm"
v-model="oneInput"
@input="oneInputBlur"
placeholder="物料箱条码"
class="uni-input-border"
confirm-type="done"
:focus="boxInputFocus"
:key="'box-' + boxInputFocus"
/>
</view>
</view>
</view>
</uni-forms-item>
<!-- 2. 起点站点 (使用 twoInput) -->
<uni-forms-item label="起点站点:" label-width="100px">
<input
type="text"
v-model="startCode"
@confirm="handleStartConfirm"
v-model="twoInput"
@input="twoInputBlur"
placeholder="站点码"
class="uni-input-border"
confirm-type="done"
:focus="startInputFocus"
:key="'start-' + startInputFocus"
/>
<view v-if="startData" class="start-confirm">
<text class="check-icon"></text>
<text class="confirm-text">已确认: {{ startData.stationName }}</text>
</view>
</uni-forms-item>
<!-- 3. 终点区域 (保持 Picker 不变) -->
<uni-forms-item label="终点区域:" label-width="150px">
<picker
mode="selector"
@ -58,39 +64,87 @@
</view>
</ifrm>
</template>
<script>
import ifrm from "@/pages/index/ifrm";
import inputBlur from '@/mixin/inputBlur.js'; // mixin
export default {
mixins: [inputBlur], // mixin
components: {
ifrm,
},
data() {
return {
boxCode: "",
boxInputFocus:true,
startCode: "", //
startInputFocus: true, //
// boxCode, startCode mixin oneInput, twoInput
boxInputFocus: true,
startInputFocus: false,
startData: null,
workCenters: [], //
workCenters: [],
endCenterIndex: null,
endCenter: "", //
endCenter: "",
};
},
mounted() {
this.getWorkCenterList();
},
methods: {
handleBoxConfirm() {
const code = this.boxCode.trim();
// mixin
oneInputData(val) {
if (!val) return;
const code = val.trim();
this.handleBoxConfirmLogic(code);
},
// mixin
twoInputData(val) {
if (!val) return;
const code = val.trim();
this.handleStartConfirmLogic(code);
},
// handleBoxConfirm
handleBoxConfirmLogic(code) {
if (!code) return;
// this.$u.api
// .getQuantityLocation({ boxBarcode: this.boxCode })
// .then((res) => {
// this.boxData = res.data;
this.boxInputFocus = false;
this.startInputFocus = true;
// });
// API
// this.$u.api.getQuantityLocation({ boxBarcode: code }).then((res) => { ... });
uni.showToast({ title: '物料箱已扫描', icon: 'none' });
//
this.boxInputFocus = false;
this.startInputFocus = true;
},
// handleStartConfirm
handleStartConfirmLogic(code) {
if (!code) return;
this.$u.api
.getStationName({ stationCode: code })
.then((res) => {
console.log("起点站点", res.data);
this.startData = res.data;
uni.showToast({ title: '起点确认成功', icon: 'none' });
//
this.startInputFocus = false;
//
// this.clearTwoInput();
// this.startInputFocus = false;
// this.boxInputFocus = true;
})
.catch(err => {
uni.showToast({ title: err || '站点查询失败', icon: 'none' });
this.clearTwoInput();
this.startInputFocus = false;
this.$nextTick(() => { this.startInputFocus = true; });
});
},
//
getWorkCenterList() {
this.$u.api.getWorkCenter().then((res) => {
@ -105,35 +159,22 @@ export default {
(item) => item.name && item.name.includes("输送线终点")
);
if (defaultItemIndex !== -1) {
this.endCenterIndex = this.workCenters[defaultItemIndex].id; // Picker
this.endCenterIndex = this.workCenters[defaultItemIndex].id;
this.endCenter = this.workCenters[defaultItemIndex].name;
}
});
},
handleEndChange(e) {
const index = e.detail.value;
const selectedWorkCenter = this.workCenters[index];
this.endCenter = selectedWorkCenter.name;
this.endCenterIndex = selectedWorkCenter.id;
//
this.endArea = "";
this.endAreaIndex = 0;
},
handleStartConfirm() {
const code = this.startCode.trim();
if (!code) return;
this.$u.api
.getStationName({ stationCode: this.startCode })
.then((res) => {
console.log("起点站点", res.data);
this.startData = res.data;
this.startInputFocus = false;
});
},
handleSubmit() {
if (this.startCode == "") {
// 使 mixin oneInput twoInput
if (!this.twoInput) {
uni.showToast({
title: `请扫描起点区域!`,
icon: "none",
@ -147,14 +188,17 @@ export default {
});
return;
}
uni.showLoading({
title: "提交中...",
});
let query = {
boxBarcode: this.boxCode || "", //
endWcId: this.endCenterIndex,
startStationCode: this.startCode,
boxBarcode: this.oneInput || "", // 使 mixin
endWcId: this.endCenterIndex,
startStationCode: this.twoInput, // 使 mixin
};
this.$u.api
.boxBindingTesk(query)
.then((res) => {
@ -164,17 +208,21 @@ export default {
});
uni.hideLoading();
this.startCode = "";
this.boxCode = ""
//
this.clearInput(); // mixin
this.startData = null;
this.startInputFocus = true;
this.boxInputFocus = true;
this.startInputFocus = false;
})
.catch((err) => {
uni.hideLoading();
this.startCode = "";
this.boxCode = ""
uni.showToast({ title: err || '提交失败', icon: 'none' });
// 便
this.clearInput();
this.startData = null;
this.startInputFocus = true;
this.boxInputFocus = true;
this.startInputFocus = false;
});
},
},

@ -19,6 +19,8 @@
</view>
</view>
</uni-forms-item>
<!-- 物料箱条码输入 -->
<uni-forms-item label="物料箱条码:" label-width="100px">
<template #label>
<view class="custom-label">
@ -35,22 +37,21 @@
<view class="bottom-input-row">
<view class="weight-input-wrapper">
<view class="input-box">
<!-- 修改点 1: 使用 mixin oneInput oneInputBlur -->
<input
type="text"
v-model="boxCode"
@confirm="handleBoxConfirm"
v-model="oneInput"
@input="oneInputBlur"
placeholder="物料箱条码"
class="uni-input-border"
confirm-type="done"
:focus="boxInputFocus"
:key="'box-' + boxInputFocus"
/>
<view v-if="boxCode" class="clear-icon" @click="clearBoxInput"
>清空</view
>
<view v-if="oneInput" class="clear-icon" @click="clearBoxInput">清空</view>
</view>
</view>
</view>
<view v-if="activeBox" class="box-stats">
<view class="stats-left">
<text class="stats-label">当前物料箱</text>
@ -66,33 +67,32 @@
}}</text
>
</view>
<!-- <view class="stats-item">
<text class="stats-label">总重量</text>
<text class="stats-value-weight">{{ totalWeight }} g</text>
</view> -->
</view>
</view>
</uni-forms-item>
<!-- 流程卡输入 -->
<uni-forms-item
:label="
scanMode === 'bind' ? `扫描流程卡(装箱):` : `扫描流程卡(解绑):`
"
label-width="200px"
>
<!-- 修改点 2: 使用 mixin twoInput twoInputBlur -->
<input
type="text"
v-model="cardCode"
@confirm="handleCardConfirm"
v-model="twoInput"
@input="twoInputBlur"
:disabled="!activeBox"
placeholder="流程卡号"
class="uni-input-border"
:class="{ 'input-disabled': !activeBox }"
confirm-type="done"
:focus="cardInputFocus"
:key="'card-' + cardInputFocus"
/>
</uni-forms-item>
</uni-forms>
<scroll-view class="orders-scroll" scroll-y>
<view class="orders-header">
<view class="orders-left">
@ -122,10 +122,6 @@
class="order-card"
:class="{ 'order-latest': index === 0 }"
>
<!-- <view v-if="index === 0" class="latest-badge">最新</view> -->
<!-- <view class="delete-btn" @tap="handleDeleteOrder(order, index)">
<text class="delete-icon"></text>
</view> -->
<view class="order-header">
<text class="order-no">{{ order.woOrder }}流程卡号</text>
<text class="order-no">{{ order.cardNo }}</text>
@ -148,7 +144,10 @@
<script>
import ifrm from "@/pages/index/ifrm";
import inputBlur from '@/mixin/inputBlur.js';
export default {
mixins: [inputBlur], // mixin
components: {
ifrm,
},
@ -157,13 +156,13 @@ export default {
},
data() {
return {
// oneInput, twoInput, oldOneInput mixin
list: ["绑定", "解绑"],
current: 1,
boxInfo: {
yieldOrderList: [],
},
boxCode: "",
cardCode: "",
// boxCode cardCode mixin oneInput/twoInput
activeBox: null,
orders: [],
boxInputFocus: true,
@ -188,163 +187,107 @@ export default {
}
return this.boxInfo.yieldOrderList.reduce((sum, o) => {
const weight = Number(o.actualWeighing) || 0;
// 0
return weight >= 0 ? sum + weight : sum;
}, 0);
},
},
methods: {
//
clearBoxInput() {
this.boxCode = "";
// key input focus
this.clearOneInput(); // mixin
this.boxInputFocus = false;
this.$nextTick(() => {
this.boxInputFocus = true;
});
},
handleOneClickUnbind() {
if (!this.activeBox) {
uni.showToast({
title: "请先扫描物料箱",
icon: "none",
});
return;
}
uni.showModal({
title: "确认解绑",
content: `确定要解绑物料箱 ${this.activeBox} 中的所有流程卡吗?`,
success: (res) => {
if (res.confirm) {
this.$u.api
.boxUnbind({ boxBarcode: this.activeBox })
.then(() => {
this.boxInfo.yieldOrderList = [];
this.activeBox = null;
this.boxCode = "";
uni.showToast({
title: "解绑成功",
icon: "success",
});
this.boxInputFocus = true;
this.cardInputFocus = false;
})
.catch((err) => {
uni.showToast({
title: err || "解绑失败",
icon: "error",
});
});
}
},
});
},
handleModeChange(mode) {
this.scanMode = mode;
this.hasData = false;
//
this.boxInfo = {
yieldOrderList: [],
};
this.boxCode = "";
this.cardCode = "";
this.activeBox = null;
this.orders = [];
this.boxInputFocus = true;
this.cardInputFocus = false;
uni.showToast({
title: `已切换到${mode === "bind" ? "绑定" : "解绑"}模式`,
icon: "none",
});
},
handleDeleteOrder(order, index) {
uni.showModal({
title: "确认删除",
content: `确定要删除流程卡 ${order.cardNo} 吗?`,
success: (res) => {
if (res.confirm) {
this.boxInfo.yieldOrderList.splice(index, 1);
uni.showToast({
title: "删除成功",
icon: "success",
});
}
},
});
// mixin
oneInputData(val) {
// val mixin
if (!val) return;
const code = val.trim();
this.handleBoxConfirmLogic(code);
},
//
handleBoxConfirm() {
const code = this.boxCode.trim();
// handleBoxConfirm
handleBoxConfirmLogic(code) {
if (!code) return;
this.$u.api
.boxbarcodeDetails({ boxBarcode: this.boxCode, isDetail: false })
.boxbarcodeDetails({ boxBarcode: code, isDetail: false })
.then((res) => {
this.boxInfo = res.data;
if (this.boxInfo.yieldOrderList == null) {
this.boxInfo.yieldOrderList = [];
}
});
this.activeBox = code;
// ,
uni.showToast({
title: `物料箱 ${code} 已就绪`,
icon: "none",
});
this.boxCode = "";
this.boxInputFocus = false;
this.cardInputFocus = true;
},
handleCardConfirm() {
const code = this.cardCode;
if (this.cardCode) {
if (!this.activeBox) {
this.activeBox = code;
uni.showToast({
title: "请先扫描物料箱条码",
title: `物料箱 ${code} 已就绪`,
icon: "none",
});
//
this.boxInputFocus = false;
this.$nextTick(() => {
this.boxInputFocus = true;
});
return;
}
this.cardInputFocus = true;
})
.catch(err => {
uni.showToast({ title: err || '查询失败', icon: 'none' });
// 便
this.oneInput = '';
this.oldOneInput = '';
this.boxInputFocus = false;
this.$nextTick(() => { this.boxInputFocus = true; });
});
},
uni.showLoading({
title: "查询中...",
mask: true,
// mixin
twoInputData(val) {
// val mixin
if (!val) return;
const code = val.trim();
this.handleCardConfirmLogic(code);
},
// handleCardConfirm
handleCardConfirmLogic(code) {
if (!this.activeBox) {
uni.showToast({
title: "请先扫描物料箱条码",
icon: "none",
});
//
this.cardInputFocus = false;
this.boxInputFocus = true;
return;
}
this.$u.api
.queryCardNo({ cardNo: this.cardCode })
.then((res) => {
uni.hideLoading();
//
if (this.scanMode === "bind") {
// === ===
//
if (
this.boxInfo.yieldOrderList.some(
(o) => o.cardNo === this.cardCode
)
) {
uni.showToast({
title: `订单 ${this.cardCode} 已在该箱中!`,
icon: "none",
});
this.cardCode = "";
this.cardInputFocus = false;
this.$nextTick(() => {
this.cardInputFocus = true;
});
return;
}
uni.showLoading({
title: "查询中...",
mask: true,
});
//
this.$u.api
.queryCardNo({ cardNo: code })
.then((res) => {
uni.hideLoading();
if (this.scanMode === "bind") {
// === ===
if (
this.boxInfo.yieldOrderList.some(
(o) => o.cardNo === code
)
) {
uni.showToast({
title: `订单 ${code} 已在该箱中!`,
icon: "none",
});
} else {
//
this.boxInfo.yieldOrderList.push(res.data);
// >=0
const currentWeight = this.boxInfo.yieldOrderList.reduce(
(sum, o) => {
const weight = Number(o.actualWeighing) || 0;
@ -358,21 +301,18 @@ export default {
title: `请注意箱子已超重!!!!!`,
icon: "none",
});
//
this.boxInfo.yieldOrderList.pop();
} else {
//
this.$u.api
.boxBinding({
boxBarcode: this.activeBox,
orderIdList: [this.cardCode],
orderIdList: [code],
})
.then((bindRes) => {
.then(() => {
uni.showToast({
title: `流程卡 ${code} 装箱绑定成功`,
icon: "none",
});
//
this.refreshBoxInfo();
})
.catch((bindErr) => {
@ -380,44 +320,32 @@ export default {
title: bindErr || "绑定失败",
icon: "error",
});
//
this.boxInfo.yieldOrderList.pop();
});
}
} else if (this.scanMode === "unbind") {
// === ===
//
const orderIndex = this.boxInfo.yieldOrderList.findIndex(
(o) => o.cardNo === this.cardCode
);
if (orderIndex === -1) {
uni.showToast({
title: `订单 ${this.cardCode} 不在该箱中!`,
icon: "none",
});
this.cardCode = "";
this.cardInputFocus = false;
this.$nextTick(() => {
this.cardInputFocus = true;
});
return;
}
//
}
} else if (this.scanMode === "unbind") {
// === ===
const orderIndex = this.boxInfo.yieldOrderList.findIndex(
(o) => o.cardNo === code
);
if (orderIndex === -1) {
uni.showToast({
title: `订单 ${code} 不在该箱中!`,
icon: "none",
});
} else {
this.$u.api
.boxUnbind({
// boxBarcode: this.activeBox,
orderIdList: [this.cardCode],
orderIdList: [code],
})
.then((unbindRes) => {
.then(() => {
uni.showToast({
title: `流程卡 ${code} 解绑成功`,
icon: "none",
});
//
this.boxInfo.yieldOrderList.splice(orderIndex, 1);
//
this.refreshBoxInfo();
})
.catch((unbindErr) => {
@ -427,62 +355,98 @@ export default {
});
});
}
this.cardCode = "";
this.cardInputFocus = false;
this.$nextTick(() => {
this.cardInputFocus = true;
});
})
.catch((err) => {
uni.hideLoading();
uni.showToast({
title: err,
icon: "error",
});
this.cardCode = "";
this.cardInputFocus = false;
this.$nextTick(() => {
this.cardInputFocus = true;
});
}
// 便
this.twoInput = '';
this.oldTwoInput = '';
this.cardInputFocus = false;
this.$nextTick(() => {
this.cardInputFocus = true;
});
}
})
.catch((err) => {
uni.hideLoading();
uni.showToast({
title: err,
icon: "error",
});
this.twoInput = '';
this.oldTwoInput = '';
this.cardInputFocus = false;
this.$nextTick(() => {
this.cardInputFocus = true;
});
});
},
//
refreshBoxInfo() {
this.$u.api
.boxbarcodeDetails({ boxBarcode: this.activeBox, isDetail: false })
.then((res) => {
this.boxInfo = res.data;
if (this.boxInfo.yieldOrderList == null) {
this.boxInfo.yieldOrderList = [];
}
handleOneClickUnbind() {
if (!this.activeBox) {
uni.showToast({
title: "请先扫描物料箱",
icon: "none",
});
return;
}
uni.showModal({
title: "确认解绑",
content: `确定要解绑物料箱 ${this.activeBox} 中的所有流程卡吗?`,
success: (res) => {
if (res.confirm) {
this.$u.api
.boxUnbind({ boxBarcode: this.activeBox })
.then(() => {
this.boxInfo.yieldOrderList = [];
this.activeBox = null;
this.clearOneInput(); // 使 mixin
uni.showToast({
title: "解绑成功",
icon: "success",
});
this.boxInputFocus = true;
this.cardInputFocus = false;
})
.catch((err) => {
uni.showToast({
title: err || "解绑失败",
icon: "error",
});
});
}
},
});
},
handleResetBox() {
handleModeChange(mode) {
this.scanMode = mode;
this.hasData = false;
this.boxInfo = {
yieldOrderList: [],
};
this.clearInput(); // 使 mixin clearInput
this.activeBox = null;
this.boxCode = "";
this.orders = [];
this.boxInputFocus = true;
this.cardInputFocus = false;
uni.showToast({
title: `已切换到${mode === "bind" ? "绑定" : "解绑"}模式`,
icon: "none",
});
},
//
handleSubmit() {
refreshBoxInfo() {
this.$u.api
.boxBinding({
boxBarcode: this.activeBox, //
orderIdList: this.boxInfo.yieldOrderList.map((o) => o.cardNo),
})
.boxbarcodeDetails({ boxBarcode: this.activeBox, isDetail: false })
.then((res) => {
uni.showToast({
title: `装箱成功`,
icon: "none",
});
this.cardCode = "";
this.boxInfo.yieldOrderList = [];
this.boxInfo = res.data;
if (this.boxInfo.yieldOrderList == null) {
this.boxInfo.yieldOrderList = [];
}
});
},
// handleBoxConfirm handleCardConfirm
},
};
</script>

@ -3,33 +3,18 @@
<u-sticky offset-top="0">
<uni-forms ref="wrForm" class="formBox">
<uni-forms-item>
<input
class="uni-input-border"
v-model="processCardNo"
placeholder="请扫描流程卡号"
placeholder-class="input-placeholder"
@confirm="handleCardNoConfirm"
/>
<input class="uni-input-border" v-model="processCardNo" placeholder="请扫描流程卡号"
placeholder-class="input-placeholder" :focus="processFocus" @input="handleCardNoConfirm" />
</uni-forms-item>
<uni-forms-item>
<view class="bottom-input-row">
<view class="weight-input-wrapper">
<view class="input-box">
<input
class="input-field"
v-model="weight"
type="digit"
placeholder="重量 (克)"
placeholder-class="input-placeholder"
/>
<input class="input-field" v-model="weight" type="digit" placeholder="重量 (克)"
placeholder-class="input-placeholder" />
</view>
</view>
<button
class="submit-btn"
:class="{ disabled: !canSubmit }"
:disabled="!canSubmit"
@tap="handleSubmit"
>
<button class="submit-btn" :class="{ disabled: !canSubmit }" :disabled="!canSubmit" @tap="handleSubmit">
提交
</button>
</view>
@ -84,8 +69,11 @@ export default {
data() {
return {
processCardNo: "",
oldProcessCardNo: '',
processFocus:true,
weight: "",
tableObj: {},
time: null,
orderInfo: {
orderNo: "",
materialCode: "",
@ -109,13 +97,40 @@ export default {
this.$refs.ifrm.topMenuClick(btn);
},
methods: {
handleCardNoConfirm() {
if (this.processCardNo) {
//
this.$u.api.queryCardNo({cardNo:this.processCardNo}).then((res) => {
this.tableObj = res.data;
});
clearInput(){
this.oldProcessCardNo = ''
this.processCardNo = ''
},
handleCardNoConfirm(e) {
clearTimeout(this.time)
if (e.detail.value.length == 0) {
this.oldProcessCardNo = ''
this.processCardNo = e.detail.value
}
if (e.detail.value.length < this.oldProcessCardNo.length) {
this.processCardNo = e.detail.value
this.oldProcessCardNo = this.processCardNo
return
}
this.time = setTimeout(() => {
if (this.processCardNo.length >= 1) {
uni.showLoading({
title: '请稍候...'
})
this.processCardNo = e.detail.value.slice(this.oldProcessCardNo.length)
this.oldProcessCardNo = this.processCardNo
this.$u.api.queryCardNo({ cardNo: this.processCardNo }).then((res) => {
this.tableObj = res.data;
this.clearInput()
uni.hideLoading()
}).catch(err=>{
uni.hideLoading()
this.clearInput()
})
}
}, 1500);
},
//
handleSubmit() {
@ -241,5 +256,4 @@ export default {
.submit-btn.disabled {
opacity: 0.5;
}
</style>

Loading…
Cancel
Save