<template>
|
<view>
|
<view class="nav_item form-container">
|
<form :modelValue="scanFormData">
|
<view class="form-group">
|
<label class="form-label">退货单号:</label>
|
<superwei-combox :candidates="itemOutNoList" placeholder="请选择退货单号"
|
v-model="scanFormData.itemOutNo"
|
@select="onOutNoChange"
|
class="picker form-input"
|
style="border: none;"></superwei-combox>
|
</view>
|
<view class="form-group">
|
<label class="form-label">物料条码:</label>
|
<input class="form-input" placeholder="请扫描物料条码" type="text"
|
v-model="scanFormData.barcode" :focus="focus1" @focus="getFocus"/>
|
</view>
|
<view class="form-group">
|
<label class="form-label">物料编码:</label>
|
<input class="form-input" disabled="true" type="text" v-model="scanFormData.itemNo"/>
|
</view>
|
<view class="form-group">
|
<label class="form-label">数量:</label>
|
<input class="form-input" type="text" v-model="scanFormData.quantity"/>
|
</view>
|
</form>
|
</view>
|
|
<view class="text" v-if="Message">
|
<text v-text="Message"></text>
|
</view>
|
|
<view class="container">
|
<view class="tab-bar">
|
<view
|
class="tab-item"
|
:class="{ active: currentTab === 0 }"
|
@click="changeTab(0)">
|
待退货的物料
|
</view>
|
<view
|
class="tab-item"
|
:class="{ active: currentTab === 1 }"
|
@click="changeTab(1)">
|
已扫条码
|
</view>
|
<view
|
class="tab-item"
|
:class="{ active: currentTab === 2 }"
|
@click="changeTab(2)">
|
退货单
|
</view>
|
</view>
|
|
<!-- 内容区域 -->
|
<scroll-view class="content">
|
<view v-if="currentTab === 0" class="tab-content">
|
<view class="list-container">
|
<uni-table ref="table" border emptyText="暂无更多数据">
|
<uni-tr>
|
<uni-th align="center" class="th" style="color: #FFFFFF;">库位</uni-th>
|
<uni-th align="center" class="th" style="color: #FFFFFF">物料编码</uni-th>
|
<uni-th align="center" class="th" style="color: #FFFFFF">待退数量</uni-th>
|
<uni-th align="center" class="th" style="color: #FFFFFF">名称</uni-th>
|
<uni-th align="center" class="th" style="color: #FFFFFF">规格</uni-th>
|
</uni-tr>
|
<uni-tr v-for="(item, index) in tableData" :key="index">
|
<uni-td align="center">
|
<input class="form-input" disabled="true" type="text" v-model="item.depot"/>
|
</uni-td>
|
<uni-td align="center">
|
<input class="form-input" disabled="true" type="text" v-model="item.itemNo"/>
|
</uni-td>
|
<uni-td>
|
<input class="form-input" disabled="true" type="text" v-model="item.qty"/>
|
</uni-td>
|
<uni-td>
|
<input class="form-input" disabled="true" type="text" v-model="item.itemName"/>
|
</uni-td>
|
<uni-td>
|
<input class="form-input" disabled="true" type="text" v-model="item.itemModel"/>
|
</uni-td>
|
</uni-tr>
|
</uni-table>
|
</view>
|
</view>
|
<view v-if="currentTab === 1" class="tab-content">
|
<view class="list-container">
|
<uni-table ref="table" border emptyText="暂无更多数据">
|
<uni-tr>
|
<uni-th align="center" class="th" style="color: #FFFFFF;">物料条码</uni-th>
|
<uni-th align="center" class="th" style="color: #FFFFFF">物料编码</uni-th>
|
<uni-th align="center" class="th" style="color: #FFFFFF">数量</uni-th>
|
<uni-th align="center" class="th" style="color: #FFFFFF">货位编码</uni-th>
|
<uni-th align="center" class="th" style="color: #FFFFFF">物料名称</uni-th>
|
<uni-th align="center" class="th" style="color: #FFFFFF">仓库编码</uni-th>
|
<uni-th align="center" class="th" style="color: #FFFFFF">规格型号</uni-th>
|
<uni-th align="center" class="th" style="color: #FFFFFF">单位</uni-th>
|
</uni-tr>
|
<uni-tr v-for="(item, index) in codeTableData" :key="index">
|
<uni-td align="center">
|
<input class="form-input" disabled="true" type="text" v-model="item.itemBarcode"/>
|
</uni-td>
|
<uni-td align="center">
|
<input class="form-input" disabled="true" type="text" v-model="item.itemNo"/>
|
</uni-td>
|
<uni-td>
|
<input class="form-input" disabled="true" type="text" v-model="item.quantity"/>
|
</uni-td>
|
<uni-td>
|
<input class="form-input" disabled="true" type="text" v-model="item.depotSectionCode"/>
|
</uni-td>
|
<uni-td>
|
<input class="form-input" disabled="true" type="text" v-model="item.itemName"/>
|
</uni-td>
|
<uni-td>
|
<input class="form-input" disabled="true" type="text" v-model="item.depotCode"/>
|
</uni-td>
|
<uni-td>
|
<input class="form-input" disabled="true" type="text" v-model="item.itemModel"/>
|
</uni-td>
|
<uni-td>
|
<input class="form-input" disabled="true" type="text" v-model="item.unit"/>
|
</uni-td>
|
</uni-tr>
|
</uni-table>
|
</view>
|
</view>
|
<view v-if="currentTab === 2" class="tab-content">
|
<form :modelValue="formData">
|
<view class="form-group">
|
<label class="form-label">出库单号:</label>
|
<input class="form-input" disabled="true" type="text" v-model="formData.itemOutNo"/>
|
</view>
|
<view class="form-group">
|
<label class="form-label">单据类型:</label>
|
<input class="form-input" disabled="true" type="text" v-model="formData.billTypeName"/>
|
</view>
|
<view class="form-group">
|
<label class="form-label">创建人:</label>
|
<input class="form-input" disabled="true" type="text" v-model="formData.createBy"/>
|
</view>
|
<view class="form-group">
|
<label class="form-label">创建时间:</label>
|
<input class="form-input" disabled="true" type="text" v-model="formData.createDate"/>
|
</view>
|
<view class="uni-form-item uni-column form-item edit">
|
<text class="form-label">退料仓库:</text>
|
<input class="form-input" disabled="true" type="text" v-model="formData.depotName"/>
|
</view>
|
<view class="form-group">
|
<checkbox-group
|
style="background-color: white;border-bottom: 1px solid #c7c7c7;">
|
<label>
|
<checkbox value="0" disabled="true" :checked="formData.fType == 1"/>
|
委外退货
|
</label>
|
</checkbox-group>
|
</view>
|
<view class="uni-form-item uni-column form-item edit">
|
<label class="form-label">退货原因:</label>
|
<input class="form-input" disabled="true" type="text" v-model="formData.reason"/>
|
</view>
|
<view class="uni-form-item uni-column form-item edit">
|
<view class="form-group">
|
<label class="form-label">退料方式:</label>
|
<input class="form-input" disabled="true" type="text" v-model="formData.fmrmode"/>
|
</view>
|
</view>
|
<view class="form-group">
|
<label class="form-label">供应商编码:</label>
|
<input class="form-input" disabled="true" type="text" v-model="formData.suppNo"/>
|
</view>
|
<view class="uni-form-item uni-column form-item edit">
|
<label class="form-label">供应商名称:</label>
|
<input class="form-input" disabled="true" type="text" v-model="formData.suppName"/>
|
</view>
|
<view class="form-group">
|
<label class="form-label">审核人:</label>
|
<input class="form-input" disabled="true" type="text" v-model="formData.checkUserFname"/>
|
</view>
|
<view class="form-group">
|
<label class="form-label">审核时间:</label>
|
<input class="form-input" disabled="true" type="text" v-model="formData.checkDate"/>
|
</view>
|
<view class="form-group">
|
<label class="form-label">备注:</label>
|
<input class="form-input" disabled="true" type="text" v-model="formData.remark"/>
|
</view>
|
</form>
|
</view>
|
</scroll-view>
|
</view>
|
|
<view class="plus-button">
|
<button type="warn" @click="SaveBarCodes">确认</button>
|
</view>
|
</view>
|
</template>
|
|
<script>
|
import {
|
broadcastScan
|
} from '@/utils/scanCode.js';
|
import {updateMessage} from "../../../utils/message";
|
|
export default {
|
data() {
|
return {
|
formData: {},
|
focus1: false,
|
scanFormData: {},
|
tableData: [],
|
codeTableData: [],
|
currentTab: 0, // 当前激活的 Tab
|
itemOutNoList: [],
|
|
Message: '',
|
messageId: 0,
|
messageId1: 0,
|
messageCenter: {},
|
}
|
},
|
methods: {
|
SaveBarCodes() {
|
|
if (!this.scanFormData.barcode) {
|
|
}
|
|
let userName = this.$loginInfo.account;
|
|
this.$post({
|
url: "/MesInvItemOuts/ScanCode",
|
data: {
|
billNo: this.scanFormData.itemOutNo,
|
barcode: this.scanFormData.barcode,
|
userName: userName
|
}
|
}).then(res => {
|
if (res.data.tbBillList) {
|
this.ToErp();
|
} else {
|
this.getItem();
|
}
|
this.getScanBarcode();
|
});
|
},
|
getScanBarcode() {
|
this.$post({
|
url: "/MesInvItemOuts/GetScanBarcode",
|
data: {
|
id: this.formData.id
|
}
|
}).then(res => {
|
this.codeTableData = res.data.tbBillList;
|
});
|
},
|
onOutNoChange(event) {
|
this.scanFormData.itemOutNo = event;
|
|
this.focus1 = true;
|
|
this.getItem();
|
|
this.$post({
|
url: "/MesInvItemOuts/GetPage",
|
data: {
|
billNo: this.scanFormData.itemOutNo,
|
pageIndex: 1,
|
limit: 1,
|
}
|
}).then(res => {
|
this.formData = res.data.tbBillList[0];
|
this.formData.billTypeName = "出库单";
|
|
this.getScanBarcode();
|
});
|
},
|
changeTab(index) {
|
this.currentTab = index;
|
},
|
|
//SetNFlag
|
setNFlag() {
|
this.$post({
|
url: "/MesInvItemOuts/SetNFlag",
|
data: {
|
userName: this.formData.createBy,
|
billNo: this.formData.itemOutNo,
|
id: this.formData.id,
|
}
|
}).then(res => {
|
|
let entity = {
|
id: this.messageId1,
|
resultData: JSON.stringify(res.data),
|
dealWith: res.data.tbBillList ? 1 : 0,
|
result: res.data.tbBillList ? 1 : 0,
|
}
|
updateMessage(entity)
|
.then(resultMessage => {
|
this.Message += resultMessage; // 输出最终的更新后的消息
|
})
|
.catch(error => {
|
this.Message += "消息回写发生错误"; // 处理可能的错误
|
});
|
});
|
},
|
|
ToErp() {
|
this.Message = "";
|
|
let userName = this.$loginInfo.account;
|
this.Message = "正在推送采购退料单[" + this.formData.itemOutNo + "]到ERP.... 请稍后";
|
this.$post({
|
url: '/MesInvItemOuts/SaveMessageCenter',
|
data: {
|
id: this.formData.id,
|
userName: userName,
|
billNo: this.formData.itemOutNo,
|
type: "A"
|
}
|
}).then(res => {
|
this.messageCenter = res.data.tbBillList;
|
this.sendPostRequest(this.messageCenter);
|
});
|
},
|
|
sendPostRequest(e) {
|
this.$sendPostRequest(e).then(res => {
|
|
//记录一下MES的回调
|
this.saveMessage("A", {
|
url: this.$store.state.serverInfo.serverAPI + '/MesInvItemOuts/Audit',
|
data: {billNo: this.formData.itemOutNo}
|
}, 2);
|
|
this.saveMessage("A", {
|
url: this.$store.state.serverInfo.serverAPI + '/MesInvItemOuts/SetNFlag',
|
data: {billNo: this.formData.itemOutNo}
|
}, 3);
|
|
if (res.state == 200) {
|
this.Message += " 正在执行MES回调!请稍后"
|
//执行MES回调
|
this.audit();
|
this.setNFlag();
|
} else {
|
this.Message += " ERP返回信息:" + res.msg;
|
//更新接口记录表
|
this.messageCenter.result = 0;
|
this.messageCenter.dealWith = 0;
|
this.messageCenter.status = 1;
|
this.messageCenter.resultData = res.msg;
|
updateMessage(this.messageCenter)
|
.then(resultMessage => {
|
this.Message += resultMessage; // 输出最终的更新后的消息
|
})
|
.catch(error => {
|
this.Message += "消息回写发生错误"; // 处理可能的错误
|
});
|
}
|
});
|
},
|
//审核的MES回调
|
audit() {
|
this.$post({
|
url: "/MesInvItemOuts/Audit",
|
data: {
|
userName: this.formData.createBy,
|
billNo: this.formData.itemOutNo,
|
id: this.formData.id,
|
}
|
}).then(res => {
|
if (res.data.tbBillList) {
|
this.Message += " 审核成功!";
|
} else {
|
this.Message += " 审核失败:";
|
}
|
|
let entity = {
|
id: this.messageId,
|
resultData: JSON.stringify(res.data),
|
dealWith: res.data.tbBillList ? 1 : 0,
|
result: res.data.tbBillList ? 1 : 0,
|
}
|
updateMessage(entity)
|
.then(resultMessage => {
|
this.Message += resultMessage; // 输出最终的更新后的消息
|
})
|
.catch(error => {
|
this.Message += "消息回写发生错误"; // 处理可能的错误
|
});
|
});
|
},
|
|
saveMessage(s, item, seq) {
|
|
let title = "采购退料单" + this.formData.itemOutNo + "审核";
|
let tableName = "MES_INV_ITEM_OUTS_" + s;
|
|
if (s == "B") {
|
title = "采购退料单" + this.formData.itemOutNo + "反审核";
|
}
|
|
let entity = {
|
data: JSON.stringify(item.data),
|
url: item.url,
|
pid: this.messageCenter.id,
|
dealWith: 0,
|
result: 0,
|
status: 1,
|
seq: seq,
|
createBy: this.$loginInfo.account,
|
title: title,
|
route: this.formData.itemOutNo,
|
tableName: tableName,
|
contentType: "application/json",
|
}
|
|
this.$post({
|
url: "/MessageCenter/Insert",
|
data: entity
|
}).then(res => {
|
|
if (seq == 1) {
|
this.messageId = res.data.tbBillList;
|
} else {
|
this.messageId1 = res.data.tbBillList;
|
}
|
|
});
|
},
|
|
|
getItemOutNo() {
|
this.$post({
|
url: "/MesInvItemOuts/GetItemOutNo"
|
}).then(res1 => {
|
this.itemOutNoList = res1.data.tbBillList;
|
});
|
},
|
|
getItem() {
|
this.$post({
|
url: "/MesInvItemOuts/GetSumItem",
|
data: {
|
billNo: this.scanFormData.itemOutNo,
|
barcode: this.scanFormData.barcode,
|
}
|
}).then(res => {
|
this.tableData = res.data.tbBillList.sumItem;
|
this.scanFormData.itemNo = res.data.tbBillList.itemNo
|
this.scanFormData.quantity = res.data.tbBillList.quantity
|
console.log(res);
|
});
|
},
|
|
getFocus() {
|
this.focus1 = true;
|
},
|
|
// 主动触发扫描
|
openScan() {
|
broadcastScan.triggerScan();
|
},
|
getScanCode(code) {
|
let parseData = code.trim();
|
console.log('自定义扫描的结果回调函数:' + parseData);
|
if (this.focus1) {
|
this.scanFormData.barcode = parseData;
|
this.SaveBarCodes();
|
}
|
}
|
},
|
onLoad(options) {
|
this.getItemOutNo();
|
// init传入一个回调函数做参数,在扫描时候会将数据传入此方法里,然后处理此方法的自定义业务逻辑
|
broadcastScan.init(this.getScanCode);
|
},
|
onUnload() {
|
broadcastScan.stop();
|
},
|
// 在页面展示时触发,用于处理页面显示相关的逻辑,可能会多次执行,包括页面首次展示和从后台切换到前台时
|
onShow() {
|
broadcastScan.start();
|
},
|
onHide() {
|
broadcastScan.stop();
|
},
|
}
|
</script>
|
|
<style>
|
.form-group {
|
display: flex;
|
align-items: center;
|
border-bottom: 1px solid #c9c9c9;
|
}
|
|
.form-label {
|
margin-bottom: 0;
|
padding: 5px;
|
}
|
|
.form-input {
|
flex: 1;
|
margin-bottom: 0;
|
padding: 5px;
|
}
|
|
.picker {
|
flex: 1;
|
margin-bottom: 0;
|
padding: 5px;
|
font-size: 12px;
|
}
|
|
.uni-form-item {
|
display: flex;
|
border-bottom: 1px solid #c9c9c9;
|
}
|
|
.edit {
|
background-color: white;
|
}
|
|
/* 默认样式 */
|
.list-container {
|
height: 60vh;
|
/* 设置列表容器的高度为剩余空间,并减去表单容器的高度 */
|
overflow-y: auto;
|
/* 允许列表容器垂直滚动 */
|
padding: 10px;
|
/* 可选:添加一些内边距,使列表内容更美观 */
|
}
|
|
/* 在小屏幕设备上,重置高度为适应屏幕 */
|
@media (max-width: 768px) {
|
.list-container {
|
height: calc(100vh - 500px);
|
/* 适当调整高度 */
|
}
|
}
|
|
|
.form-container {
|
padding: 10px;
|
/* 可选:添加一些内边距,使表单内容更美观 */
|
}
|
|
.th {
|
background-color: lightskyblue;
|
color: #FFFFFF;
|
}
|
|
.text {
|
background-color: #ffee6f;
|
}
|
|
.plus-button {
|
line-height: 59px;
|
font-size: 24px;
|
cursor: pointer;
|
z-index: 1000;
|
margin-bottom: 10px;
|
}
|
|
.overlay {
|
position: fixed;
|
top: 0;
|
left: 0;
|
width: 100%;
|
height: 100%;
|
background-color: rgba(0, 0, 0, 0.5);
|
display: flex;
|
justify-content: center;
|
align-items: center;
|
}
|
|
.popup {
|
background-color: #fff;
|
padding: 20px;
|
border: 1px solid #ccc;
|
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
|
width: 68vw;
|
/* 设置宽度为视口宽度的80% */
|
height: 25vh;
|
/* 设置高度为视口高度的80% */
|
}
|
|
.container {
|
display: flex;
|
flex-direction: column;
|
}
|
|
.tab-bar {
|
display: flex;
|
justify-content: space-around;
|
background-color: #f5f5f5;
|
padding: 10px;
|
border-bottom: 1px solid #ccc;
|
}
|
|
.tab-item {
|
flex: 1;
|
text-align: center;
|
padding: 10px;
|
border-radius: 5px;
|
background-color: #fff;
|
color: #007aff;
|
cursor: pointer;
|
font-size: 16px;
|
transition: background-color 0.3s, color 0.3s;
|
}
|
|
.tab-item.active {
|
background-color: #007aff;
|
color: #fff;
|
font-weight: bold;
|
}
|
|
.content {
|
flex: 1;
|
padding: 10px;
|
}
|
|
.tab-content {
|
padding: 10px;
|
}
|
</style>
|